forked from nextstrain/auspice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsortedDomain.test.js
67 lines (65 loc) · 1.38 KB
/
sortedDomain.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
64
65
66
67
import { sortedDomain } from "../src/util/sortedDomain";
test("sortedDomain works correctly in normal case", () => {
const stateCount = new Map([
["Italy", 8],
["Lombardy", 9],
["USA", 1],
["Iran", 18],
["Comunitat Valenciana", 1],
["Hubei", 35],
["China", 2],
["Grand Princess", 2],
["Hong Kong", 1],
["South Korea", 1],
["Europe", 1],
["UK", 1]
]);
const domain = stateCount.keys();
const sorted = sortedDomain(domain, "", stateCount);
expect(sorted).toMatchObject([
"Hubei",
"Iran",
"Lombardy",
"Italy",
"China",
"Grand Princess",
"Comunitat Valenciana",
"Europe",
"Hong Kong",
"South Korea",
"UK",
"USA"
]);
});
test("sortedDomain works correctly in special case", () => {
const stateCount = new Map([
["Italy", 8],
["Lombardy", 9],
["USA", 1],
["Iran", 18],
["Comunitat Valenciana", 1],
["Hubei", 35],
["China", 2],
["Grand Princess", 2],
["Hong Kong", 1],
["South Korea", 1],
["Europe", 1],
["UK", 1]
]);
const domain = stateCount.keys();
const sorted = sortedDomain(domain, "clade_membership", stateCount);
expect(sorted).toMatchObject([
"China",
"Comunitat Valenciana",
"Europe",
"Grand Princess",
"Hong Kong",
"Hubei",
"Iran",
"Italy",
"Lombardy",
"South Korea",
"UK",
"USA"
]);
});