This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.test.ts
85 lines (77 loc) · 2.95 KB
/
node.test.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import assert from "assert";
import { Sleeper } from "./commons.js";
import { getMewClient } from "./my-client.js";
const sleeper = new Sleeper();
describe('Get some info📄', function () {
describe('Get node info🏘', function () {
it('should get info of node not_a_robot🤖', async function () {
const client = await getMewClient();
const result = await client?.getNodeInfo('not_a_robot');
if (result?.data) {
assert.notEqual(result.data.id, undefined);
} else {
assert.fail();
}
});
it('should get info of node 212863117974745088🐱', async function () {
await sleeper.sleep();
const client = await getMewClient();
const result = await client?.getNodeInfo('212863117974745088');
if (result?.data) {
assert.notEqual(result.data.id, undefined);
} else {
assert.fail();
}
});
it('should get a not found error💢', async function () {
await sleeper.sleep();
const client = await getMewClient();
const result = await client?.getNodeInfo('somenodethatnotexistsatall');
if (result?.error) {
assert.notEqual(result.error.name, undefined);
} else {
assert.fail();
}
});
});
describe('Get node members🤺', function() {
let prev: string | undefined;
let next: string | undefined;
it('should get a page of node members👯', async function () {
await sleeper.sleep();
const client = await getMewClient();
const result = await client?.getNodeMembers('not_a_robot');
if (result?.data) {
prev = result.data.prev_cursor;
next = result.data.next_cursor;
assert.notEqual(result.data.entries, undefined);
} else {
assert.fail();
}
});
it('should get next page of node members👉', async function () {
if (!next)
assert.fail();
await sleeper.sleep();
const client = await getMewClient();
const result = await client?.getNodeMembers('not_a_robot', next);
if (result?.data) {
assert.notEqual(result.data.entries, undefined);
} else {
assert.fail();
}
});
it('should get previous page of node members👈', async function () {
if (!next)
assert.fail();
await sleeper.sleep();
const client = await getMewClient();
const result = await client?.getNodeMembers('not_a_robot', undefined, prev);
if (result?.data) {
assert.notEqual(result.data.entries, undefined);
} else {
assert.fail();
}
});
});
});