1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | import { Map } from 'immutable'
|
9 | import { tap } from 'ramda'
|
10 | import {
|
11 | createNumberSequence,
|
12 | random,
|
13 | valueOrDefaultValue,
|
14 | thrower,
|
15 | compareIntegers,
|
16 | objectMap,
|
17 | objectWithBooleansFromStrings,
|
18 | objectWithoutUndefinedValues,
|
19 | debugFactory,
|
20 | debug,
|
21 | arrayToObjectEntries,
|
22 | objectFilterKeys,
|
23 | clone,
|
24 | push,
|
25 | pop,
|
26 | unshift,
|
27 | shift,
|
28 | sort,
|
29 | reverse,
|
30 | remove,
|
31 | splice,
|
32 | reducer
|
33 | } from '.'
|
34 |
|
35 | describe('@chantelle/util', () => {
|
36 | test('exports correct types', () => {
|
37 | ;[
|
38 | [debug, 'function'],
|
39 | [debugFactory, 'function'],
|
40 | [createNumberSequence, 'function'],
|
41 | [random, 'function'],
|
42 | [valueOrDefaultValue, 'function'],
|
43 | [thrower, 'function'],
|
44 | [compareIntegers, 'function'],
|
45 | [objectMap, 'function'],
|
46 | [objectWithBooleansFromStrings, 'function'],
|
47 | [objectWithoutUndefinedValues, 'function'],
|
48 | [arrayToObjectEntries, 'function'],
|
49 | [objectFilterKeys, 'function'],
|
50 | [clone, 'function'],
|
51 | [push, 'function'],
|
52 | [pop, 'function'],
|
53 | [unshift, 'function'],
|
54 | [shift, 'function'],
|
55 | [sort, 'function'],
|
56 | [reverse, 'function'],
|
57 | [remove, 'function'],
|
58 | [splice, 'function'],
|
59 | [reducer, 'function']
|
60 | ].map(([exported, type]) => expect(typeof exported).toBe(type))
|
61 | })
|
62 |
|
63 | test('reducer is working', () => {
|
64 | reducer(
|
65 | ['test', true],
|
66 | [
|
67 | 'test',
|
68 | state => tap(test => expect(test).toBe(true), state.get('test'))
|
69 | ],
|
70 | ['blabla', 'bla'],
|
71 | ['test2', state => state.get('test')],
|
72 | [
|
73 | 'test2',
|
74 | state =>
|
75 | tap(
|
76 | test2 => expect(test2).toBe(state.get('test')),
|
77 | state.get('test2')
|
78 | )
|
79 | ]
|
80 | )(Map({ test: true }))
|
81 | })
|
82 | })
|