-
Notifications
You must be signed in to change notification settings - Fork 189
/
union-test.js
24 lines (19 loc) · 1005 Bytes
/
union-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
import {union} from "../src/index.js";
import {assertSetEqual} from "./asserts.js";
it("union(values) returns a set of values", () => {
assertSetEqual(union([1, 2, 3, 2, 1]), [1, 2, 3]);
});
it("union(values, other) returns a set of values", () => {
assertSetEqual(union([1, 2], [2, 3, 1]), [1, 2, 3]);
});
it("union(...values) returns a set of values", () => {
assertSetEqual(union([1], [2], [2, 3], [1]), [1, 2, 3]);
});
it("union(...values) accepts iterables", () => {
assertSetEqual(union(new Set([1, 2, 3])), [1, 2, 3]);
assertSetEqual(union(Uint8Array.of(1, 2, 3)), [1, 2, 3]);
});
it("union(...values) performs interning", () => {
assertSetEqual(union([new Date("2021-01-01"), new Date("2021-01-01"), new Date("2021-01-02")]), [new Date("2021-01-01"), new Date("2021-01-02")]);
assertSetEqual(union([new Date("2021-01-01"), new Date("2021-01-03")], [new Date("2021-01-01"), new Date("2021-01-02")]), [new Date("2021-01-01"), new Date("2021-01-02"), new Date("2021-01-03")]);
});