svelte-i18n/test/cli/includes.test.ts

18 lines
430 B
TypeScript
Raw Normal View History

2020-01-21 14:07:27 +01:00
import { deepGet } from '../../src/cli/includes/deepGet'
2020-01-15 17:47:02 +01:00
describe('deep object handling', () => {
test('gets a deep property', () => {
const obj = {
a: { b: { c: { d: ['foo', 'bar'] } } },
}
2020-01-21 14:07:27 +01:00
expect(deepGet(obj, 'a.b.c.d.1')).toBe('bar')
2020-01-15 17:47:02 +01:00
})
test('returns undefined for if some property not found', () => {
const obj = {
a: { b: 1 },
}
2020-01-21 14:07:27 +01:00
expect(deepGet(obj, 'c.b')).toBe(undefined)
2020-01-15 17:47:02 +01:00
})
})