Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 374f514

Browse files
committed
Add set utility tests
1 parent 27af329 commit 374f514

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

test/sets-test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright 2021 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import {setHasDiff} from "../src/utils/sets";
18+
19+
describe('sets', () => {
20+
describe('setHasDiff', () => {
21+
it('should flag true on A length > B length', () => {
22+
const a = new Set([1, 2, 3, 4]);
23+
const b = new Set([1, 2, 3]);
24+
const result = setHasDiff(a, b);
25+
expect(result).toBe(true);
26+
});
27+
28+
it('should flag true on A length < B length', () => {
29+
const a = new Set([1, 2, 3]);
30+
const b = new Set([1, 2, 3, 4]);
31+
const result = setHasDiff(a, b);
32+
expect(result).toBe(true);
33+
});
34+
35+
it('should flag true on element differences', () => {
36+
const a = new Set([1, 2, 3]);
37+
const b = new Set([4, 5, 6]);
38+
const result = setHasDiff(a, b);
39+
expect(result).toBe(true);
40+
});
41+
42+
it('should flag false if same but order different', () => {
43+
const a = new Set([1, 2, 3]);
44+
const b = new Set([3, 1, 2]);
45+
const result = setHasDiff(a, b);
46+
expect(result).toBe(false);
47+
});
48+
49+
it('should flag false if same', () => {
50+
const a = new Set([1, 2, 3]);
51+
const b = new Set([1, 2, 3]);
52+
const result = setHasDiff(a, b);
53+
expect(result).toBe(false);
54+
});
55+
});
56+
});

0 commit comments

Comments
 (0)