|
|
@@ -51,4 +51,55 @@ describe('Directive v-model component', () => {
|
|
|
vm.$destroy()
|
|
|
}).then(done)
|
|
|
})
|
|
|
+
|
|
|
+ it('modifier: .lazy', () => {
|
|
|
+ const vm = new Vue({
|
|
|
+ template: `<div><my-input ref="input" v-model.lazy="text"></my-input></div>`,
|
|
|
+ data: { text: 'foo' },
|
|
|
+ components: {
|
|
|
+ 'my-input': {
|
|
|
+ template: '<input>'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).$mount()
|
|
|
+ expect(vm.text).toBe('foo')
|
|
|
+ vm.$refs.input.$emit('input', 'bar')
|
|
|
+ expect(vm.text).toBe('foo')
|
|
|
+ vm.$refs.input.$emit('change', 'bar')
|
|
|
+ expect(vm.text).toBe('bar')
|
|
|
+ })
|
|
|
+
|
|
|
+ it('modifier: .number', () => {
|
|
|
+ const vm = new Vue({
|
|
|
+ template: `<div><my-input ref="input" v-model.number="text"></my-input></div>`,
|
|
|
+ data: { text: 'foo' },
|
|
|
+ components: {
|
|
|
+ 'my-input': {
|
|
|
+ template: '<input>'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).$mount()
|
|
|
+ expect(vm.text).toBe('foo')
|
|
|
+ vm.$refs.input.$emit('input', 'bar')
|
|
|
+ expect(vm.text).toBe('bar')
|
|
|
+ vm.$refs.input.$emit('input', '123')
|
|
|
+ expect(vm.text).toBe(123)
|
|
|
+ })
|
|
|
+
|
|
|
+ it('modifier: .trim', () => {
|
|
|
+ const vm = new Vue({
|
|
|
+ template: `<div><my-input ref="input" v-model.trim="text"></my-input></div>`,
|
|
|
+ data: { text: 'foo' },
|
|
|
+ components: {
|
|
|
+ 'my-input': {
|
|
|
+ template: '<input>'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).$mount()
|
|
|
+ expect(vm.text).toBe('foo')
|
|
|
+ vm.$refs.input.$emit('input', ' bar ')
|
|
|
+ expect(vm.text).toBe('bar')
|
|
|
+ vm.$refs.input.$emit('input', ' foo o ')
|
|
|
+ expect(vm.text).toBe('foo o')
|
|
|
+ })
|
|
|
})
|