Skip to content

Commit

Permalink
test(size): add size function tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hamilton committed Jul 4, 2019
1 parent 47d9a95 commit 68abe16
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/__tests__/size.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import size from '../size';

describe('size', () => {
test('should return a number', () => {
expect(typeof size({})).toBe('number');
});

test('should return the size of the object (number of keys)', () => {
const objA = {
a: 1,
b: 2,
};
const objB = {
a: 1,
b: 2,
c: 3,
};

expect(size(objA)).toBe(2);
expect(size(objB)).toBe(3);
});

test('should throw TypeError for invalid arguments', () => {
const invalidObj: unknown = 'testing';

expect(() => size(invalidObj as OObject))
.toThrow(new TypeError('Expected Object, got string testing'));
});
});

0 comments on commit 68abe16

Please # to comment.