Skip to content

Commit

Permalink
test(inflate): add tests for inflate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hamilton committed Dec 5, 2018
1 parent d8182fa commit b309ae0
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/inflate.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import inflate from '../src/inflate';

describe('inflate', () => {
test('should return an empty object if the one specified isn\'t an object', () => {
const inflated = inflate('test');

expect(typeof inflated).toBe('object');
});

test('should return an empty object if the one specified is empty', () => {
const inflated = inflate({});

expect(typeof inflated).toBe('object');
});

test('should return an object with no changes if no dot notation keys are present', () => {
const a = {
a: 1,
};

const inflated = inflate(a);

expect(inflated.a).toBe(1);
});

test('should return an object with dot notation keys inflated to objects', () => {
const a = {
'a.b': {
c: 1,
},
};

const inflated = inflate(a);

expect(inflated.a.b.c).toBe(1);
});

test('should return an object with all dot notation keys inflated to objects', () => {
const a = {
'a.b': {
c: 1,
},
'd.e': {
f: 1,
},
};

const inflated = inflate(a);

expect(inflated.a.b.c + inflated.d.e.f).toBe(2);
});
});

0 comments on commit b309ae0

Please # to comment.