Skip to main content
Module

x/rambda/difference.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
import { difference } from './difference'
test('difference', () => { const a = [ 1, 2, 3, 4 ] const b = [ 3, 4, 5, 6 ] expect(difference(a)(b)).toEqual([ 1, 2 ])
expect(difference([], [])).toEqual([])})
test('difference with objects', () => { const a = [ { id : 1 }, { id : 2 }, { id : 3 }, { id : 4 } ] const b = [ { id : 3 }, { id : 4 }, { id : 5 }, { id : 6 } ] expect(difference(a, b)).toEqual([ { id : 1 }, { id : 2 } ])})
test('no duplicates in first list', () => { const M2 = [ 1, 2, 3, 4, 1, 2, 3, 4 ] const N2 = [ 3, 3, 4, 4, 5, 5, 6, 6 ] expect(difference(M2, N2)).toEqual([ 1, 2 ])})
test('should use R.equals', () => { expect(difference([ NaN ], [ NaN ]).length).toEqual(0)})