-
Notifications
You must be signed in to change notification settings - Fork 20
/
repeatable_task_list.spec.ts
48 lines (39 loc) · 1.21 KB
/
repeatable_task_list.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { useIVI, useMockFn } from "ivi-jest";
const ivi = useIVI();
describe("RepeatableTaskList", () => {
const t = useMockFn((fn) => fn.mockReturnValue(true));
const f = useMockFn((fn) => fn.mockReturnValue(false));
test("run one task", () => {
ivi.runRepeatableTasks([f]);
expect(f).toHaveBeenCalledTimes(1);
});
test("run two tasks", () => {
ivi.runRepeatableTasks([f, f]);
expect(f).toHaveBeenCalledTimes(2);
});
test("run one task twice", () => {
const tasks = [f];
ivi.runRepeatableTasks(tasks);
ivi.runRepeatableTasks(tasks);
expect(f).toHaveBeenCalledTimes(2);
});
test("run two tasks twice", () => {
const tasks = [f, f];
ivi.runRepeatableTasks(tasks);
ivi.runRepeatableTasks(tasks);
expect(f).toHaveBeenCalledTimes(4);
});
test("run one one-time task twice", () => {
const tasks = [t];
ivi.runRepeatableTasks(tasks);
ivi.runRepeatableTasks(tasks);
expect(t).toHaveBeenCalledTimes(1);
});
test("run one one-time and one simple task twice", () => {
const tasks = [t, f];
ivi.runRepeatableTasks(tasks);
ivi.runRepeatableTasks(tasks);
expect(t).toHaveBeenCalledTimes(1);
expect(f).toHaveBeenCalledTimes(2);
});
});