Skip to content

Commit 6862c44

Browse files
Use jest mock to ensure a given func is called once
1 parent 0d4046b commit 6862c44

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

packages/npm-packages/ruby-wasm-wasi/test/js_from_rb.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,12 @@ describe("Manipulation of JS from Ruby", () => {
9898
end
9999
end
100100
`);
101-
proc.call(
102-
"call",
103-
vm.wrap({
104-
take_block: (arg1: string, block: (_: any) => void) => {
105-
expect(arg1).toBe("x");
106-
block("y");
107-
},
108-
})
109-
);
101+
const takeBlock = jest.fn((arg1: string, block: (_: any) => void) => {
102+
expect(arg1).toBe("x");
103+
block("y");
104+
});
105+
proc.call("call", vm.wrap({ take_block: takeBlock }));
106+
expect(takeBlock).toBeCalled();
110107
const y = vm.eval(`$y`);
111108
expect(y.toString()).toBe("y");
112109
});

0 commit comments

Comments
 (0)