2018-05-22 17:13:56 +00:00
|
|
|
import {getDeep} from 'src/utils/wrappers'
|
2018-05-14 17:52:52 +00:00
|
|
|
|
|
|
|
describe('utils.wrappers', () => {
|
|
|
|
describe('get', () => {
|
|
|
|
it('gets a nested value', () => {
|
|
|
|
const example = {a: {b: 'hello'}}
|
|
|
|
|
2018-05-22 17:13:56 +00:00
|
|
|
expect(getDeep(example, 'a.b', 'default')).toEqual('hello')
|
2018-05-14 17:52:52 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('gets the default value when key is empty', () => {
|
|
|
|
const example = {a: {b: 'hello'}}
|
|
|
|
|
2018-05-22 17:13:56 +00:00
|
|
|
expect(getDeep(example, 'a.c', 'default')).toEqual('default')
|
2018-05-14 17:52:52 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|