UNPKG

@yoroi/common

Version:

The Common package of Yoroi SDK

51 lines (50 loc) 1.67 kB
"use strict"; var _arrays = require("./arrays"); describe('Array Utils', () => { describe('difference', () => { it('should return the difference of two arrays', () => { const a = [1, 2, 3, 4, 5]; const b = [2, 4, 6, 7]; const result = (0, _arrays.difference)(a, b); expect(result).toEqual([1, 3, 5]); }); it('should return an empty array when all elements are common', () => { const a = [1, 2, 3]; const b = [1, 2, 3]; const result = (0, _arrays.difference)(a, b); expect(result).toEqual([]); }); it('should return the first array when the second array is empty', () => { const a = [1, 2, 3]; const b = []; const result = (0, _arrays.difference)(a, b); expect(result).toEqual(a); }); }); describe('intersection', () => { it('should return the intersection of two arrays', () => { const a = [1, 2, 3, 4, 5]; const b = [2, 4, 6]; const result = (0, _arrays.intersection)(a, b); expect(result).toEqual([2, 4]); }); it('should return an empty array when there is no common element', () => { const a = [1, 3, 5]; const b = [2, 4, 6]; const result = (0, _arrays.intersection)(a, b); expect(result).toEqual([]); }); it('should return an empty array when one or both arrays are empty', () => { const a = []; const b = [2, 4, 6]; const result = (0, _arrays.intersection)(a, b); expect(result).toEqual([]); }); }); describe('predicates', () => { it('first', () => { expect((0, _arrays.first)()).toBe(true); }); }); }); //# sourceMappingURL=arrays.test.js.map