insomnia/app/templating/__tests__/utils.test.js
Gregory Schier e2c72987e8 Autocomplete for variables and tags (#112)
* Fixed duplication kve bug

* Autocomplete sort of works now

* Even better

* Styled autocomplete dropdown

* Minor tweaks

* Autocomplete looking pretty spiffy

* Bug fixes

* Apply dropdown to all editors

* Fixed key propagation when autocomplete open

* Fixed some modals

* Split up editor less

* Some css improvements

* Move filter help out of editor

* Fixed drag-n-drop

* Perfected autocomplete theme

* "fixed" one-line-editor hint click bug

* Better autocomplete and switch single line input on drag enter

* Don't autocomplete on Tab

* Better tag dnd

* Add constants completion API

* Autocomplete headers

* Fixed tests
2017-03-11 16:31:23 -08:00

42 lines
829 B
JavaScript

import * as utils from '../utils';
describe('getKeys()', () => {
it('flattens complex object', () => {
const obj = {
foo: 'bar',
nested: {a: {b: {}}},
array: [
'hello',
{hi: 'there'},
true,
['x', 'y', 'z']
]
};
const keys = utils.getKeys(obj);
expect(keys).toEqual({
'array[0]': obj.array[0],
'array[1].hi': obj.array[1].hi,
'array[2]': obj.array[2],
'array[3][0]': obj.array[3][0],
'array[3][1]': obj.array[3][1],
'array[3][2]': obj.array[3][2],
'foo': obj.foo
});
});
it('ignores functions', () => {
const obj = {
foo: 'bar',
toString: function () {
// Nothing
}
};
const keys = utils.getKeys(obj);
expect(keys).toEqual({
foo: 'bar'
});
});
});