|
| 1 | +import { expect } from 'chai'; |
| 2 | +import forEach from 'mocha-each'; |
| 3 | + |
| 4 | +import { isEmpty, isObject } from './'; |
| 5 | + |
| 6 | +describe('utils', () => { |
| 7 | + |
| 8 | + describe('.isEmpty', () => { |
| 9 | + describe('returns true', () => { |
| 10 | + it('when given an empty object', () => { |
| 11 | + expect(isEmpty({})).to.be.true; |
| 12 | + }); |
| 13 | + |
| 14 | + it('when given an empty array', () => { |
| 15 | + expect(isEmpty([])).to.be.true; |
| 16 | + }); |
| 17 | + }); |
| 18 | + |
| 19 | + describe('returns false', () => { |
| 20 | + it('when given an empty object', () => { |
| 21 | + expect(isEmpty({ a: 1 })).to.be.false; |
| 22 | + }); |
| 23 | + |
| 24 | + it('when given an empty array', () => { |
| 25 | + expect(isEmpty([1])).to.be.false; |
| 26 | + }); |
| 27 | + }); |
| 28 | + }); |
| 29 | + |
| 30 | + describe('.isObject', () => { |
| 31 | + it('returns true when value is an object', () => { |
| 32 | + expect(isObject({})).to.be.true; |
| 33 | + }); |
| 34 | + |
| 35 | + it('returns true when value is an array', () => { |
| 36 | + expect(isObject([])).to.be.true; |
| 37 | + }); |
| 38 | + |
| 39 | + forEach([ |
| 40 | + ['int', 1], |
| 41 | + ['string', 'a'], |
| 42 | + ['boolean', true], |
| 43 | + ['null', null], |
| 44 | + ['undefined', undefined], |
| 45 | + ['function', () => ({})], |
| 46 | + ]).it('returns false when value is of type: %s', (type, value) => { |
| 47 | + expect(isObject(value)).to.be.false; |
| 48 | + }); |
| 49 | + }); |
| 50 | +}); |
0 commit comments