Skip to content

Commit

Permalink
feat: add test demo
Browse files Browse the repository at this point in the history
  • Loading branch information
imddc committed Aug 13, 2024
1 parent 9a383c7 commit 4a585eb
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/helper/repeatExecute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import { describe, it, expect } from 'vitest';
import repeatExecute from './repeatExecute.js';

describe('repeatExecute', () => {
it('should work well', () => {
const result = repeatExecute(() => {
console.log(1);
}, 5);
expect(typeof result).toMatchInlineSnapshot(`"object"`);
});

it('在延时时间内多次调用确保只执行一次', (done) => {});
it('should work well', async () => {
let sum = 0;
await repeatExecute(
() => {
sum += 1;
},
5,
300
);

it('首次执行立即执行', (done) => {});
expect(sum).toBe(5);
});
});

0 comments on commit 4a585eb

Please sign in to comment.