forked from muttoni/fcl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend-ping.test.js
49 lines (37 loc) · 1.11 KB
/
send-ping.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
49
import {AccessAPI} from "@onflow/protobuf"
import {sendPing} from "./send-ping.js"
import {build} from "../build/build.js"
import {ping} from "../build/build-ping.js"
import {resolve} from "../resolve/resolve.js"
const jsonToUInt8Array = (json) => {
var str = JSON.stringify(json, null, 0);
var ret = new Uint8Array(str.length);
for (var i = 0; i < str.length; i++) {
ret[i] = str.charCodeAt(i);
}
return ret
};
describe("Ping", () => {
test("Ping", async () => {
const unaryMock = jest.fn();
unaryMock.mockReturnValue({});
await sendPing(
await resolve(
await build([
ping(),
])
),
{
unary: unaryMock,
node: "localhost:3000"
}
)
expect(unaryMock.mock.calls.length).toEqual(1)
const unaryMockArgs = unaryMock.mock.calls[0]
expect(unaryMockArgs.length).toEqual(3)
const unaryType = unaryMock.mock.calls[0][1]
expect(unaryType).toEqual(AccessAPI.Ping)
const unaryMockRequest = unaryMock.mock.calls[0][2]
expect(unaryMockRequest).not.toBeUndefined()
})
})