-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.test.js
48 lines (32 loc) · 879 Bytes
/
main.test.js
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 sinon from "sinon";
import { suite } from "uvu";
import { bulkThreadAction } from "./main.js";
const { assert, fake, stub } = sinon;
const query = "test";
const search = stub();
const threadAction = fake();
const act = () => bulkThreadAction(query, threadAction);
global.GmailApp = {
search,
};
const BTA = suite("bulkThreadAction");
BTA.after.each(() => {
threadAction.resetHistory();
});
BTA("Takes no action when there are no threads", () => {
search.returns([]);
act();
assert.notCalled(threadAction);
});
BTA("Does not chunk <= 100 threads", () => {
const fakeThreads = Array(100).fill(0);
search.returns(fakeThreads);
act();
assert.calledOnceWithExactly(threadAction, fakeThreads);
});
BTA("Properly chunks > 100 threads", () => {
search.returns(Array(1000).fill(0));
act();
assert.callCount(threadAction, 10);
});
BTA.run();