-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmock-data.test.js
63 lines (53 loc) · 1.41 KB
/
mock-data.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { MockData } from "../src";
test("import MockData", () => {
expect.anything(MockData);
});
test("Arrays.range", () => {
const mockA = MockData.range(50);
expect(MockData.range(50).length).toBe(50);
expect(MockData.range(1).length).toBe(1);
expect(MockData.range(500).length).toBe(500);
expect(mockA[0]).toBe(0);
expect(mockA[50]).toBeUndefined();
});
test("Arrays.packData", () => {
const spaceTypes = [
"Office",
"Meeting",
"Support",
"Creative",
"Circulation",
];
const mock = MockData.packData(200);
const spaces = mock.map((m) => m.spaceType);
// check dataset size
expect(mock.length).toBe(200);
// check space types
spaceTypes.map((s) => {
expect(spaces).toContain(s);
});
// check radius and id
spaceTypes.map((s) => {
expect(s.r).not.toBeNaN();
expect(s.i).not.toBeNaN();
});
});
test("Arrays.networkData", () => {
const mock = MockData.networkData(200);
const { nodes } = mock;
// check dataset size
expect(mock.nodes.length).toBe(200);
expect(mock.links.length).toBe(199);
// check node size
mock.nodes.map((n) => {
expect(n.size).not.toBeNaN();
});
// check link size, source, and target
mock.links.map((l) => {
expect(l.size).not.toBeNaN();
expect(l.source).not.toBeNaN();
expect(l.source).toBeLessThan(nodes.length);
expect(l.target).not.toBeNaN();
expect(l.target).toBeLessThan(nodes.length);
});
});