Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Exelord committed Jan 21, 2023
1 parent 8e2417d commit dcc4536
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export class Job<T, Args extends unknown[]> {
}
)
.finally(() => {
debugger;
if (task.isFulfilled || task.isRejected) {
this.#reactiveState.lastSettled = task;
}
Expand All @@ -133,8 +132,10 @@ export function createJob<T, Args extends unknown[]>(
options: JobOptions = {}
): Job<T, Args> {
const job = new Job(taskFn, options);

onCleanup(() => {
job.cancelAll();
});

return job;
}
4 changes: 2 additions & 2 deletions tests/vitest/job.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe("job", () => {
});

test("cancels all tasks on cleanup", async () => {
createRoot(async (cleanup) => {
await createRoot(async (cleanup) => {
const job = createJob(async (signal) => {
await work(signal, new Promise(() => {}));
});
Expand All @@ -112,7 +112,7 @@ describe("job", () => {

cleanup();

await Promise.resolve();
await new Promise(process.nextTick);

expect(job.isPending).toBe(false);
});
Expand Down

0 comments on commit dcc4536

Please sign in to comment.