Skip to content

Commit

Permalink
types(test): reject isn't required
Browse files Browse the repository at this point in the history
  • Loading branch information
deot committed Dec 19, 2023
1 parent ef68804 commit ec8b490
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/test/__tests__/scheduler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,18 @@ describe('scheduler.ts', () => {

await scheduler;
});

it('next, mircotask', async () => {
expect.assertions(1);
const scheduler = new Scheduler();
const next = vi.fn(scheduler.next);
Promise.resolve().then(next);

// 这里的_task还是上一个
scheduler.then(() => {
expect(next).toBeCalledTimes(1);
});

await Promise.resolve();
});
});
2 changes: 1 addition & 1 deletion packages/test/src/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class Scheduler<T = any> {
return this;
};

then(resolve: Func<T>, reject: Func<T>) {
then(resolve: Func<T>, reject?: Func<T>) {
return this._task.then(resolve, reject);
}

Expand Down

0 comments on commit ec8b490

Please sign in to comment.