import Vue from 'vue' describe('Directive v-model radio', () => { it('should work', done => { const vm = new Vue({ data: { test: '1' }, template: `
` }).$mount() document.body.appendChild(vm.$el) expect(vm.$el.children[0].checked).toBe(true) expect(vm.$el.children[1].checked).toBe(false) vm.test = '2' waitForUpdate(() => { expect(vm.$el.children[0].checked).toBe(false) expect(vm.$el.children[1].checked).toBe(true) vm.$el.children[0].click() expect(vm.$el.children[0].checked).toBe(true) expect(vm.$el.children[1].checked).toBe(false) expect(vm.test).toBe('1') }).then(() => { document.body.removeChild(vm.$el) }).then(done) }) it('should respect value bindings', done => { const vm = new Vue({ data: { test: 1 }, template: `
` }).$mount() document.body.appendChild(vm.$el) expect(vm.$el.children[0].checked).toBe(true) expect(vm.$el.children[1].checked).toBe(false) vm.test = 2 waitForUpdate(() => { expect(vm.$el.children[0].checked).toBe(false) expect(vm.$el.children[1].checked).toBe(true) vm.$el.children[0].click() expect(vm.$el.children[0].checked).toBe(true) expect(vm.$el.children[1].checked).toBe(false) expect(vm.test).toBe(1) }).then(() => { document.body.removeChild(vm.$el) }).then(done) }) it('warn inline checked', () => { const vm = new Vue({ template: ``, data: { test: '2' } }).$mount() expect(vm.$el.checked).toBe(false) expect('inline checked attributes will be ignored when using v-model').toHaveBeenWarned() }) })