|
3 | 3 | * @module tutils/utils/tests/unit/isObjectCurly |
4 | 4 | */ |
5 | 5 |
|
| 6 | +import INTEGER from '#fixtures/integer' |
| 7 | +import TODAY from '#fixtures/today' |
| 8 | +import VEHICLE from '#fixtures/vehicle' |
6 | 9 | import testSubject from '../is-object-curly' |
7 | 10 |
|
8 | 11 | describe('unit:utils/isObjectCurly', () => { |
9 | | - it('should return false if value is not curly-braced object', () => { |
| 12 | + it('should return false if value is array', () => { |
| 13 | + expect(testSubject([])).to.be.false |
| 14 | + }) |
| 15 | + |
| 16 | + it('should return false if value is function', () => { |
| 17 | + expect(testSubject(vi.fn())).to.be.false |
| 18 | + }) |
| 19 | + |
| 20 | + it('should return false if value is a primitive', () => { |
10 | 21 | // Arrange |
11 | 22 | const cases: Parameters<typeof testSubject>[] = [ |
12 | | - [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], |
| 23 | + [INTEGER], |
| 24 | + [VEHICLE.vin], |
| 25 | + [faker.datatype.boolean()], |
| 26 | + [faker.number.bigInt()], |
13 | 27 | [faker.string.hexadecimal({ length: 24 })], |
14 | | - [vi.fn()] |
| 28 | + [null], |
| 29 | + [undefined] |
15 | 30 | ] |
16 | 31 |
|
17 | 32 | // Act + Expect |
18 | 33 | cases.forEach(([value]) => expect(testSubject(value)).to.be.false) |
19 | 34 | }) |
20 | 35 |
|
21 | | - it('should return true if value is curly-braced object', () => { |
22 | | - // Arrange |
23 | | - const cases: Parameters<typeof testSubject>[] = [ |
24 | | - [faker.date.anytime()], |
25 | | - [{ email: faker.internet.email() }] |
26 | | - ] |
| 36 | + it('should return true if value is instance object', () => { |
| 37 | + expect(testSubject(TODAY)).to.be.true |
| 38 | + }) |
27 | 39 |
|
28 | | - // Act + Expect |
29 | | - cases.forEach(([value]) => expect(testSubject(value)).to.be.true) |
| 40 | + it('should return true if value is plain object', () => { |
| 41 | + expect(testSubject(VEHICLE)).to.be.true |
30 | 42 | }) |
31 | 43 | }) |
0 commit comments