Skip to content

Commit 569ce65

Browse files
added test for myLodash
1 parent 51fa4e4 commit 569ce65

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

‎__tests__/utils/myLodash.test.js‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const myLodash = require('../../api/utils/myLodash');
2+
3+
describe('myLodash >', () => {
4+
describe('objectIsEmpty >', () => {
5+
describe('when receives an filled object', () => {
6+
it('should return false', () => {
7+
const objectIsEmpty = myLodash.objectIsEmpty({ lorem: 'ipsum' });
8+
9+
expect(objectIsEmpty).toBeFalsy();
10+
expect.assertions(1);
11+
});
12+
});
13+
14+
describe('when receives an empty object', () => {
15+
it('should return true', () => {
16+
const objectIsEmpty = myLodash.objectIsEmpty({});
17+
18+
expect(objectIsEmpty).toBeTruthy();
19+
expect.assertions(1);
20+
});
21+
});
22+
23+
describe('when receives anything that arent a object', () => {
24+
it('should do nothing', () => {
25+
const objectIsEmpty = myLodash.objectIsEmpty('foobar');
26+
27+
expect(objectIsEmpty).toBeUndefined();
28+
expect.assertions(1);
29+
});
30+
});
31+
});
32+
});

‎api/utils/myLodash.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module.exports.objectIsEmpty = (object) => {
2+
if (typeof object != 'object') return;
23
return Object.keys(object).length === 0
34
}

0 commit comments

Comments
 (0)