-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(inflate): add tests for inflate function
- Loading branch information
Sean Hamilton
committed
Dec 5, 2018
1 parent
d8182fa
commit b309ae0
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |