|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 |
| -describe( 'Object reduction tools:', () => { |
4 |
| - // Ensure parity with the relevant signature & functionality of lodash.reduce |
5 |
| - [ |
6 |
| - { |
7 |
| - name: 'lodash.reduce (for API parity verification)', |
8 |
| - fn: require( 'lodash.reduce' ), |
9 |
| - }, { |
10 |
| - name: 'objectReduce utility', |
11 |
| - fn: require( '../../../../lib/util/object-reduce' ), |
12 |
| - }, |
13 |
| - ].forEach( ( test ) => { |
| 3 | +const objectReduce = require( '../../../../lib/util/object-reduce' ); |
14 | 4 |
|
15 |
| - describe( test.name, () => { |
16 |
| - const objectReduce = test.fn; |
| 5 | +describe( 'objectReduce utility', () => { |
17 | 6 |
|
18 |
| - it( 'is defined', () => { |
19 |
| - expect( objectReduce ).toBeDefined(); |
20 |
| - } ); |
21 |
| - |
22 |
| - it( 'is a function', () => { |
23 |
| - expect( typeof objectReduce ).toBe( 'function' ); |
24 |
| - } ); |
25 |
| - |
26 |
| - it( 'resolves to the provided initial value if called on an empty object', () => { |
27 |
| - expect( objectReduce( {}, () => {}, 'Sasquatch' ) ).toBe( 'Sasquatch' ); |
28 |
| - } ); |
| 7 | + it( 'is defined', () => { |
| 8 | + expect( objectReduce ).toBeDefined(); |
| 9 | + } ); |
29 | 10 |
|
30 |
| - it( 'can be used to reduce over an object', () => { |
31 |
| - const result = objectReduce( { |
32 |
| - key1: 'val1', |
33 |
| - key2: 'val2', |
34 |
| - key3: 'val3', |
35 |
| - }, ( memo, val, key ) => memo + val + key, 'result:' ); |
36 |
| - expect( result ).toBe( 'result:val1key1val2key2val3key3' ); |
37 |
| - } ); |
| 11 | + it( 'is a function', () => { |
| 12 | + expect( typeof objectReduce ).toBe( 'function' ); |
| 13 | + } ); |
38 | 14 |
|
39 |
| - } ); |
| 15 | + it( 'resolves to the provided initial value if called on an empty object', () => { |
| 16 | + expect( objectReduce( {}, () => {}, 'Sasquatch' ) ).toBe( 'Sasquatch' ); |
| 17 | + } ); |
40 | 18 |
|
| 19 | + it( 'can be used to reduce over an object', () => { |
| 20 | + const result = objectReduce( { |
| 21 | + key1: 'val1', |
| 22 | + key2: 'val2', |
| 23 | + key3: 'val3', |
| 24 | + }, ( memo, val, key ) => memo + val + key, 'result:' ); |
| 25 | + expect( result ).toBe( 'result:val1key1val2key2val3key3' ); |
41 | 26 | } );
|
42 | 27 |
|
43 | 28 | } );
|
0 commit comments