-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcommit.test.ts
More file actions
32 lines (25 loc) · 975 Bytes
/
commit.test.ts
File metadata and controls
32 lines (25 loc) · 975 Bytes
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
import { Identifiers } from "@mainsail/constants";
import { Application } from "@mainsail/kernel";
import { describe } from "@mainsail/test-runner";
import { CommitHandler } from "./commit";
describe<{
app: Application;
handler: CommitHandler;
stateStore: any;
logger: any;
}>("CommitHandler", ({ assert, beforeEach, it, spy }) => {
beforeEach((context) => {
context.stateStore = { setBlockNumber: () => {} };
context.logger = { error: () => {} };
context.app = new Application();
context.app.bind(Identifiers.State.Store).toConstantValue(context.stateStore);
context.app.bind(Identifiers.Services.Log.Service).toConstantValue(context.logger);
context.handler = context.app.resolve(CommitHandler);
});
it("sets the block number on the state store", async ({ handler, stateStore }) => {
const setBlockNumber = spy(stateStore, "setBlockNumber");
await handler.handle(123);
setBlockNumber.calledOnce();
setBlockNumber.calledWith(123);
});
});