1 import {ArrayUtil} from './array';
3 describe('ArrayUtil', () => {
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]];
12 it('Compare matching arrays', () => {
13 expect(ArrayUtil.equals(arr1, arr2)).toBe(true);
16 it('Compare non-matching arrays', () => {
17 expect(ArrayUtil.equals(arr1, arr3)).toBe(false);
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);
25 it('Compare non-matching arrays with comparator', () => {
26 expect(ArrayUtil.equals(arr5, arr6, ArrayUtil.equals)).toBe(false);