UNPKG

@brightlayer-ui/react-native-components

Version:

Reusable React Native components for Brightlayer UI applications

28 lines (27 loc) 1.04 kB
import { interleave, groupBy } from './Utils.js'; describe('utils', () => { describe('interleave', () => { it('returns an empty array if passed an empty array', () => { const output = interleave([], () => ' '); expect(output).toEqual([]); }); it('interleaves the separator into the array', () => { const output = interleave([1, 2, 3], () => ' '); expect(output).toEqual([1, ' ', 2, ' ', 3]); }); }); describe('groupBy', () => { const getFirstLetter = (str) => str.slice(0, 1); it('returns an empty object when given an empty array', () => { const groups = groupBy(getFirstLetter, []); expect(groups).toEqual({}); }); it('creates mappings of label to array matching it', () => { const groups = groupBy(getFirstLetter, ['abc', 'aaa', 'bcd']); expect(groups).toEqual({ a: ['abc', 'aaa'], b: ['bcd'], }); }); }); });