Created
March 1, 2016 08:21
-
-
Save jemgold/3428dc082651127b4139 to your computer and use it in GitHub Desktop.
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
import expect from 'expect'; | |
import { flatten, unflatten } from 'src/flatten'; | |
describe('Flatten', () => { | |
it('flattens an object, prefixed by original keys', () => { | |
const input = { | |
foo: { | |
bar: 'baz', | |
qux: 'zip', | |
}, | |
bar: { | |
bar: 'baz', | |
qux: 'zip', | |
}, | |
}; | |
const expected = { | |
foo_bar: 'baz', | |
foo_qux: 'zip', | |
bar_bar: 'baz', | |
bar_qux: 'zip', | |
}; | |
expect(flatten(input)).toEqual(expected); | |
}); | |
}); | |
describe('Unflatten', () => { | |
it('Unflattens an object, prefixed by original keys', () => { | |
const input = { | |
foo_bar: 'baz', | |
foo_qux: 'zip', | |
bar_bar: 'baz', | |
bar_qux: 'zip', | |
}; | |
const expected = { | |
foo: { | |
bar: 'baz', | |
qux: 'zip', | |
}, | |
bar: { | |
bar: 'baz', | |
qux: 'zip', | |
}, | |
}; | |
expect(unflatten(input)).toEqual(expected); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment