Skip to content

Commit

Permalink
Add unit test for sorted domain
Browse files Browse the repository at this point in the history
  • Loading branch information
douglowder committed Mar 24, 2020
1 parent 436e0df commit 43da507
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions test/sortedDomain.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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"
]);
});

0 comments on commit 43da507

Please sign in to comment.