|
1 | 1 | const { expect } = require('chai'); |
2 | 2 |
|
3 | | -const { set } = require('../../lib/helpers'); |
| 3 | +const { set, toCamelCase, toSnakeCase, toKebabCase } = require('../../lib/helpers'); |
4 | 4 |
|
5 | 5 | describe('Helpers', () => { |
6 | | - it('should do nothing if it is not an object', () => { |
7 | | - const object = 1; |
8 | | - set(object, 'exist', true); |
9 | | - expect(object).to.equal(1); |
10 | | - }); |
| 6 | + describe('set', () => { |
| 7 | + it('should do nothing if it is not an object', () => { |
| 8 | + const object = 1; |
| 9 | + set(object, 'exist', true); |
| 10 | + expect(object).to.equal(1); |
| 11 | + }); |
11 | 12 |
|
12 | | - it('should set a value by path', () => { |
13 | | - const object = { exist: {} }; |
14 | | - set(object, 'exist', true); |
15 | | - set(object, 'a[0].b.c', 4); |
16 | | - set(object, ['x', '0', 'y', 'z'], 5); |
17 | | - expect(object).to.deep.equal({ |
18 | | - exist: true, |
19 | | - a: [ |
20 | | - { |
21 | | - b: { |
22 | | - c: 4, |
| 13 | + it('should set a value by path', () => { |
| 14 | + const object = { exist: {} }; |
| 15 | + set(object, 'exist', true); |
| 16 | + set(object, 'a[0].b.c', 4); |
| 17 | + set(object, ['x', '0', 'y', 'z'], 5); |
| 18 | + expect(object).to.deep.equal({ |
| 19 | + exist: true, |
| 20 | + a: [ |
| 21 | + { |
| 22 | + b: { |
| 23 | + c: 4, |
| 24 | + }, |
23 | 25 | }, |
24 | | - }, |
25 | | - ], |
26 | | - x: [ |
27 | | - { |
28 | | - y: { |
29 | | - z: 5, |
| 26 | + ], |
| 27 | + x: [ |
| 28 | + { |
| 29 | + y: { |
| 30 | + z: 5, |
| 31 | + }, |
30 | 32 | }, |
31 | | - }, |
32 | | - ], |
| 33 | + ], |
| 34 | + }); |
| 35 | + }); |
| 36 | + }); |
| 37 | + |
| 38 | + describe('toCamelCase', () => { |
| 39 | + it('should not choke on non-alpha characters', () => { |
| 40 | + expect(toCamelCase('*')).to.equal('*'); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + describe('toSnakeCase', () => { |
| 45 | + it('should not choke on non-alphanumeric characters', () => { |
| 46 | + expect(toSnakeCase('*')).to.equal('*'); |
| 47 | + }); |
| 48 | + }); |
| 49 | + |
| 50 | + describe('toKebabCase', () => { |
| 51 | + it('should not choke on non-alphanumeric characters', () => { |
| 52 | + expect(toKebabCase('*')).to.equal('*'); |
33 | 53 | }); |
34 | 54 | }); |
35 | 55 | }); |
0 commit comments