Skip to main content
Module

x/rambda/source/without.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
import {without} from './without'import {without as withoutRamda} from 'ramda'
test('should return a new list without values in the first argument', () => { const itemsToOmit = ['A', 'B', 'C'] const collection = ['A', 'B', 'C', 'D', 'E', 'F']
expect(without(itemsToOmit, collection)).toEqual(['D', 'E', 'F']) expect(without(itemsToOmit)(collection)).toEqual(['D', 'E', 'F'])})
test('with list of objects', () => { const itemsToOmit = [{a: 1}, {c: 3}] const collection = [{a: 1}, {b: 2}, {c: 3}, {d: 4}] const expected = [{b: 2}, {d: 4}]
expect(without(itemsToOmit, collection)).toEqual(expected) expect(withoutRamda(itemsToOmit, collection)).toEqual(expected)})
test('ramda accepts string as target input while rambda throws', () => { expect(withoutRamda('0:1', ['0', '0:1'])).toEqual([]) expect(() => without('0:1', ['0', '0:1'])).toThrow() expect(without(['0:1'], ['0', '0:1'])).toEqual(['0'])})
test('ramda test', () => { expect(without([1, 2])([1, 2, 1, 3, 4])).toEqual([3, 4])})