]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/share/util/array.spec.ts
LP1837478 Angular Catalog Recent Searches & Templates
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / share / util / array.spec.ts
1 import {ArrayUtil} from './array';
2
3 describe('ArrayUtil', () => {
4
5     const arr1 = [1, '2', true, undefined, null];
6     const arr2 = [1, '2', true, undefined, null];
7     const arr3 = [1, '2', true, undefined, null, 'foo'];
8     const arr4 = [[1, 2, 3], [4, 3, 2]];
9     const arr5 = [[1, 2, 3], [4, 3, 2]];
10     const arr6 = [[1, 2, 3], [1, 2, 3]];
11
12     it('Compare matching arrays', () => {
13         expect(ArrayUtil.equals(arr1, arr2)).toBe(true);
14     });
15
16     it('Compare non-matching arrays', () => {
17         expect(ArrayUtil.equals(arr1, arr3)).toBe(false);
18     });
19
20     // Using ArrayUtil.equals as a comparator -- testception!
21     it('Compare matching arrays with comparator', () => {
22         expect(ArrayUtil.equals(arr4, arr5, ArrayUtil.equals)).toBe(true);
23     });
24
25     it('Compare non-matching arrays with comparator', () => {
26         expect(ArrayUtil.equals(arr5, arr6, ArrayUtil.equals)).toBe(false);
27     });
28
29 });