-
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.
Merge pull request #22 from MapColonies/fix-null-value-freeze
fix: support null valued config attributes
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
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
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,43 @@ | ||
import 'jest-extended'; | ||
import { deepFreeze } from '../src/utils/helpers'; | ||
|
||
describe('helpers', () => { | ||
describe('#deepFreeze', () => { | ||
it('should return frozen object', () => { | ||
const data = { | ||
name: 'I am parent', | ||
child: { | ||
name: 'I am child', | ||
}, | ||
}; | ||
|
||
deepFreeze(data); | ||
expect(data).toBeFrozen(); | ||
}); | ||
|
||
it('should freeze the input object that include null valued property without error', () => { | ||
const data = { | ||
name: null, | ||
child: { | ||
name: 'i am child', | ||
}, | ||
}; | ||
|
||
deepFreeze(data); | ||
expect(data).toBeFrozen(); | ||
}); | ||
|
||
it('should freeze the input object include nested property', () => { | ||
const data = { | ||
name: 'I am parent', | ||
child: { | ||
name: 'I am child', | ||
}, | ||
}; | ||
|
||
deepFreeze(data); | ||
const child = data.child; | ||
expect(child).toBeFrozen(); | ||
}); | ||
}); | ||
}); |