From f0b59c1c5d940fbd7570581dbb1e6ad7d5790ec8 Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 13 Sep 2019 12:48:37 -0700 Subject: [PATCH] add tests --- tests/unit/OptionKey.spec.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/unit/OptionKey.spec.js diff --git a/tests/unit/OptionKey.spec.js b/tests/unit/OptionKey.spec.js new file mode 100644 index 0000000..c1417f0 --- /dev/null +++ b/tests/unit/OptionKey.spec.js @@ -0,0 +1,25 @@ +import Select from '../../src/components/Select.vue'; + +describe('Serializing Option Keys', () => { + + const getOptionKey = Select.props.getOptionKey.default; + + it('can serialize strings to a key', () => { + expect(getOptionKey('vue')).toBe('"vue"'); + }); + + it('can serialize integers to a key', () => { + expect(getOptionKey(1)).toBe('1'); + }); + + it('can serialize objects to a key', () => { + expect(getOptionKey({label: 'vue'})).toBe('{"label":"vue"}'); + }); + + it('will use an ID property if the object contains one', () => { + expect(getOptionKey({id: 1})).toBe(1); + expect(getOptionKey({id: 'one'})).toBe('one'); + expect(getOptionKey({id: {im: 'a nested object'}})) + .toEqual({im: 'a nested object'}); + }); +});