From b894ea76374530102e4c192f0a5920474b303db6 Mon Sep 17 00:00:00 2001 From: Jeff Sagal Date: Fri, 11 Mar 2016 11:07:18 -0800 Subject: [PATCH] =?UTF-8?q?also=20run=20assertions=20on=20labels,=20fix=20?= =?UTF-8?q?=E2=80=98resets=20the=20selected=20values=20when=20the=20option?= =?UTF-8?q?s=20property=20changes=E2=80=99=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/unit/Select.spec.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/unit/Select.spec.js b/test/unit/Select.spec.js index 1733e16..430433f 100644 --- a/test/unit/Select.spec.js +++ b/test/unit/Select.spec.js @@ -43,6 +43,7 @@ describe('Select.vue', () => { }).$mount() expect( vm.$children[0].$get('value').value ).toEqual( 'foo' ) + expect( vm.$children[0].$get('value').label ).toEqual( 'This is Foo' ) }) it('can accept an array of objects and pre-selected values (multiple)', () => { @@ -56,9 +57,13 @@ describe('Select.vue', () => { }).$mount() var values = vm.$children[0].$get('value') + var labels = [] + + labels = values.map( value => value.label ) values = values.map( value => value.value ) expect( values ).toEqual( ['foo', 'bar'] ) + expect( labels ).toEqual( ['This is Foo', 'This is Bar'] ) }) it('can determine if the value prop is empty', () => { @@ -84,9 +89,9 @@ describe('Select.vue', () => { expect(select.isValueEmpty).toEqual(true) }) - it('resets the selected values when the options property changes', () => { + it('resets the selected values when the options property changes', (done) => { const vm = new Vue({ - template: '
', + template: '
', components: { vSelect }, data: { value: ['one'], @@ -95,7 +100,11 @@ describe('Select.vue', () => { }).$mount() vm.$children[0].options = ['four','five','six'] - expect(vm.$children[0].$get('value')).toEqual([]) + + Vue.nextTick(() => { + expect(vm.$children[0].$get('value')).toEqual([]) + done() + }) }) it('can retain values present in a new array of options', () => {