Warning, /firebird/firebird-ng/src/app/utils/list.utils.spec.ts is written in an unsupported language. File is not indexed.
0001 import { filterIntersectingItems, removeIntersectingItemsInPlace } from './list.utils';
0002
0003 describe('List Utilities', () => {
0004
0005 describe('filterIntersectingItems', () => {
0006 it('should filter out items from list1 that are present in list2', () => {
0007 const list1 = [1, 2, 3, 4, 5];
0008 const list2 = [3, 4, 5, 6, 7];
0009 const result = filterIntersectingItems(list1, list2);
0010 expect(result).toEqual([1, 2]);
0011 expect(list1).toEqual([1, 2, 3, 4, 5]); // Ensure list1 is not modified
0012 });
0013
0014 it('should return an empty array if all items in list1 are in list2', () => {
0015 const list1 = [1, 2, 3];
0016 const list2 = [1, 2, 3];
0017 const result = filterIntersectingItems(list1, list2);
0018 expect(result).toEqual([]);
0019 });
0020
0021 it('should return the original list1 if no items in list1 are in list2', () => {
0022 const list1 = [1, 2, 3];
0023 const list2 = [4, 5, 6];
0024 const result = filterIntersectingItems(list1, list2);
0025 expect(result).toEqual([1, 2, 3]);
0026 });
0027 });
0028
0029 describe('removeIntersectingItemsInPlace', () => {
0030 it('should remove items from list1 that are present in list2 in place', () => {
0031 const list1 = [1, 2, 3, 4, 5];
0032 const list2 = [3, 4, 5, 6, 7];
0033 removeIntersectingItemsInPlace(list1, list2);
0034 expect(list1).toEqual([1, 2]);
0035 });
0036
0037 it('should remove all items from list1 if they are all in list2', () => {
0038 const list1 = [1, 2, 3];
0039 const list2 = [1, 2, 3];
0040 removeIntersectingItemsInPlace(list1, list2);
0041 expect(list1).toEqual([]);
0042 });
0043
0044 it('should not modify list1 if no items in list1 are in list2', () => {
0045 const list1 = [1, 2, 3];
0046 const list2 = [4, 5, 6];
0047 removeIntersectingItemsInPlace(list1, list2);
0048 expect(list1).toEqual([1, 2, 3]);
0049 });
0050 });
0051
0052 });