mirror of https://github.com/vuejs/vue.git
				
				
				
			test: jasmine.createSpy -> vi.fn
This commit is contained in:
		
							parent
							
								
									8e672c4251
								
							
						
					
					
						commit
						52627b95ce
					
				|  | @ -106,8 +106,8 @@ function createAssertions (runInNewContext) { | |||
| 
 | ||||
|   it('render with cache (get/set)', done => { | ||||
|     const cache = {} | ||||
|     const get = jasmine.createSpy('get') | ||||
|     const set = jasmine.createSpy('set') | ||||
|     const get = vi.fn() | ||||
|     const set = vi.fn() | ||||
|     const options = { | ||||
|       runInNewContext, | ||||
|       cache: { | ||||
|  | @ -138,8 +138,8 @@ function createAssertions (runInNewContext) { | |||
|         renderer.renderToString((err, res) => { | ||||
|           expect(err).toBeNull() | ||||
|           expect(res).toBe(expected) | ||||
|           expect(get.calls.count()).toBe(2) | ||||
|           expect(set.calls.count()).toBe(1) | ||||
|           expect(get.mock.calls.length).toBe(2) | ||||
|           expect(set.mock.calls.length).toBe(1) | ||||
|           done() | ||||
|         }) | ||||
|       }) | ||||
|  | @ -148,9 +148,9 @@ function createAssertions (runInNewContext) { | |||
| 
 | ||||
|   it('render with cache (get/set/has)', done => { | ||||
|     const cache = {} | ||||
|     const has = jasmine.createSpy('has') | ||||
|     const get = jasmine.createSpy('get') | ||||
|     const set = jasmine.createSpy('set') | ||||
|     const has = vi.fn() | ||||
|     const get = vi.fn() | ||||
|     const set = vi.fn() | ||||
|     const options = { | ||||
|       runInNewContext, | ||||
|       cache: { | ||||
|  | @ -185,9 +185,9 @@ function createAssertions (runInNewContext) { | |||
|         renderer.renderToString((err, res) => { | ||||
|           expect(err).toBeNull() | ||||
|           expect(res).toBe(expected) | ||||
|           expect(has.calls.count()).toBe(2) | ||||
|           expect(get.calls.count()).toBe(1) | ||||
|           expect(set.calls.count()).toBe(1) | ||||
|           expect(has.mock.calls.length).toBe(2) | ||||
|           expect(get.mock.calls.length).toBe(1) | ||||
|           expect(set.mock.calls.length).toBe(1) | ||||
|           done() | ||||
|         }) | ||||
|       }) | ||||
|  | @ -210,10 +210,10 @@ function createAssertions (runInNewContext) { | |||
|       renderer.renderToString(context1, (err, res) => { | ||||
|         expect(err).toBeNull() | ||||
|         expect(res).toBe(expected) | ||||
|         expect(cache.set.calls.count()).toBe(3) // 3 nested components cached
 | ||||
|         expect(cache.set.mock.calls.length).toBe(3) // 3 nested components cached
 | ||||
|         const cached = cache.get(key) | ||||
|         expect(cached.html).toBe(expected) | ||||
|         expect(cache.get.calls.count()).toBe(1) | ||||
|         expect(cache.get.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|         // assert component usage registration for nested children
 | ||||
|         expect(context1.registered).toEqual(['app', 'child', 'grandchild']) | ||||
|  | @ -221,8 +221,8 @@ function createAssertions (runInNewContext) { | |||
|         renderer.renderToString(context2, (err, res) => { | ||||
|           expect(err).toBeNull() | ||||
|           expect(res).toBe(expected) | ||||
|           expect(cache.set.calls.count()).toBe(3) // no new cache sets
 | ||||
|           expect(cache.get.calls.count()).toBe(2) // 1 get for root
 | ||||
|           expect(cache.set.mock.calls.length).toBe(3) // no new cache sets
 | ||||
|           expect(cache.get.mock.calls.length).toBe(2) // 1 get for root
 | ||||
| 
 | ||||
|           expect(context2.registered).toEqual(['app', 'child', 'grandchild']) | ||||
|           done() | ||||
|  | @ -233,8 +233,8 @@ function createAssertions (runInNewContext) { | |||
| 
 | ||||
|   it('render with cache (opt-out)', done => { | ||||
|     const cache = {} | ||||
|     const get = jasmine.createSpy('get') | ||||
|     const set = jasmine.createSpy('set') | ||||
|     const get = vi.fn() | ||||
|     const set = vi.fn() | ||||
|     const options = { | ||||
|       runInNewContext, | ||||
|       cache: { | ||||
|  |  | |||
|  | @ -9,19 +9,19 @@ describe('Component keep-alive', () => { | |||
|   beforeEach(() => { | ||||
|     one = { | ||||
|       template: '<div>one</div>', | ||||
|       created: jasmine.createSpy('one created'), | ||||
|       mounted: jasmine.createSpy('one mounted'), | ||||
|       activated: jasmine.createSpy('one activated'), | ||||
|       deactivated: jasmine.createSpy('one deactivated'), | ||||
|       destroyed: jasmine.createSpy('one destroyed') | ||||
|       created: vi.fn(), | ||||
|       mounted: vi.fn(), | ||||
|       activated: vi.fn(), | ||||
|       deactivated: vi.fn(), | ||||
|       destroyed: vi.fn() | ||||
|     } | ||||
|     two = { | ||||
|       template: '<div>two</div>', | ||||
|       created: jasmine.createSpy('two created'), | ||||
|       mounted: jasmine.createSpy('two mounted'), | ||||
|       activated: jasmine.createSpy('two activated'), | ||||
|       deactivated: jasmine.createSpy('two deactivated'), | ||||
|       destroyed: jasmine.createSpy('two destroyed') | ||||
|       created: vi.fn(), | ||||
|       mounted: vi.fn(), | ||||
|       activated: vi.fn(), | ||||
|       deactivated: vi.fn(), | ||||
|       destroyed: vi.fn() | ||||
|     } | ||||
|     components = { | ||||
|       one, | ||||
|  | @ -33,11 +33,11 @@ describe('Component keep-alive', () => { | |||
| 
 | ||||
|   function assertHookCalls (component, callCounts) { | ||||
|     expect([ | ||||
|       component.created.calls.count(), | ||||
|       component.mounted.calls.count(), | ||||
|       component.activated.calls.count(), | ||||
|       component.deactivated.calls.count(), | ||||
|       component.destroyed.calls.count() | ||||
|       component.created.mock.calls.length, | ||||
|       component.mounted.mock.calls.length, | ||||
|       component.activated.mock.calls.length, | ||||
|       component.deactivated.mock.calls.length, | ||||
|       component.destroyed.mock.calls.length | ||||
|     ]).toEqual(callCounts) | ||||
|   } | ||||
| 
 | ||||
|  | @ -507,21 +507,21 @@ describe('Component keep-alive', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('max', done => { | ||||
|     const spyA = jasmine.createSpy() | ||||
|     const spyB = jasmine.createSpy() | ||||
|     const spyC = jasmine.createSpy() | ||||
|     const spyAD = jasmine.createSpy() | ||||
|     const spyBD = jasmine.createSpy() | ||||
|     const spyCD = jasmine.createSpy() | ||||
|     const spyA = vi.fn() | ||||
|     const spyB = vi.fn() | ||||
|     const spyC = vi.fn() | ||||
|     const spyAD = vi.fn() | ||||
|     const spyBD = vi.fn() | ||||
|     const spyCD = vi.fn() | ||||
| 
 | ||||
|     function assertCount (calls) { | ||||
|       expect([ | ||||
|         spyA.calls.count(), | ||||
|         spyAD.calls.count(), | ||||
|         spyB.calls.count(), | ||||
|         spyBD.calls.count(), | ||||
|         spyC.calls.count(), | ||||
|         spyCD.calls.count() | ||||
|         spyA.mock.calls.length, | ||||
|         spyAD.mock.calls.length, | ||||
|         spyB.mock.calls.length, | ||||
|         spyBD.mock.calls.length, | ||||
|         spyC.mock.calls.length, | ||||
|         spyCD.mock.calls.length | ||||
|       ]).toEqual(calls) | ||||
|     } | ||||
| 
 | ||||
|  | @ -573,21 +573,21 @@ describe('Component keep-alive', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('max=1', done => { | ||||
|     const spyA = jasmine.createSpy() | ||||
|     const spyB = jasmine.createSpy() | ||||
|     const spyC = jasmine.createSpy() | ||||
|     const spyAD = jasmine.createSpy() | ||||
|     const spyBD = jasmine.createSpy() | ||||
|     const spyCD = jasmine.createSpy() | ||||
|     const spyA = vi.fn() | ||||
|     const spyB = vi.fn() | ||||
|     const spyC = vi.fn() | ||||
|     const spyAD = vi.fn() | ||||
|     const spyBD = vi.fn() | ||||
|     const spyCD = vi.fn() | ||||
| 
 | ||||
|     function assertCount (calls) { | ||||
|       expect([ | ||||
|         spyA.calls.count(), | ||||
|         spyAD.calls.count(), | ||||
|         spyB.calls.count(), | ||||
|         spyBD.calls.count(), | ||||
|         spyC.calls.count(), | ||||
|         spyCD.calls.count() | ||||
|         spyA.mock.calls.length, | ||||
|         spyAD.mock.calls.length, | ||||
|         spyB.mock.calls.length, | ||||
|         spyBD.mock.calls.length, | ||||
|         spyC.mock.calls.length, | ||||
|         spyCD.mock.calls.length | ||||
|       ]).toEqual(calls) | ||||
|     } | ||||
| 
 | ||||
|  | @ -651,12 +651,12 @@ describe('Component keep-alive', () => { | |||
|     const Foo = { | ||||
|       name: 'foo', | ||||
|       template: `<div>foo</div>`, | ||||
|       created: jasmine.createSpy('foo') | ||||
|       created: vi.fn() | ||||
|     } | ||||
| 
 | ||||
|     const Bar = { | ||||
|       template: `<div>bar</div>`, | ||||
|       created: jasmine.createSpy('bar') | ||||
|       created: vi.fn() | ||||
|     } | ||||
| 
 | ||||
|     const Child = { | ||||
|  | @ -679,8 +679,8 @@ describe('Component keep-alive', () => { | |||
|     }).$mount() | ||||
| 
 | ||||
|     function assert (foo, bar) { | ||||
|       expect(Foo.created.calls.count()).toBe(foo) | ||||
|       expect(Bar.created.calls.count()).toBe(bar) | ||||
|       expect(Foo.created.mock.calls.length).toBe(foo) | ||||
|       expect(Bar.created.mock.calls.length).toBe(bar) | ||||
|     } | ||||
| 
 | ||||
|     expect(vm.$el.textContent).toBe('foo') | ||||
|  | @ -703,12 +703,12 @@ describe('Component keep-alive', () => { | |||
|   it('should cache anonymous components if include is not specified', done => { | ||||
|     const Foo = { | ||||
|       template: `<div>foo</div>`, | ||||
|       created: jasmine.createSpy('foo') | ||||
|       created: vi.fn() | ||||
|     } | ||||
| 
 | ||||
|     const Bar = { | ||||
|       template: `<div>bar</div>`, | ||||
|       created: jasmine.createSpy('bar') | ||||
|       created: vi.fn() | ||||
|     } | ||||
| 
 | ||||
|     const Child = { | ||||
|  | @ -731,8 +731,8 @@ describe('Component keep-alive', () => { | |||
|     }).$mount() | ||||
| 
 | ||||
|     function assert (foo, bar) { | ||||
|       expect(Foo.created.calls.count()).toBe(foo) | ||||
|       expect(Bar.created.calls.count()).toBe(bar) | ||||
|       expect(Foo.created.mock.calls.length).toBe(foo) | ||||
|       expect(Bar.created.mock.calls.length).toBe(bar) | ||||
|     } | ||||
| 
 | ||||
|     expect(vm.$el.textContent).toBe('foo') | ||||
|  | @ -756,7 +756,7 @@ describe('Component keep-alive', () => { | |||
|   it('should not destroy active instance when pruning cache', done => { | ||||
|     const Foo = { | ||||
|       template: `<div>foo</div>`, | ||||
|       destroyed: jasmine.createSpy('destroyed') | ||||
|       destroyed: vi.fn() | ||||
|     } | ||||
|     const vm = new Vue({ | ||||
|       template: ` | ||||
|  | @ -1167,7 +1167,7 @@ describe('Component keep-alive', () => { | |||
|     }) | ||||
| 
 | ||||
|     it('async components with transition-mode out-in', done => { | ||||
|       const barResolve = jasmine.createSpy('bar resolved') | ||||
|       const barResolve = vi.fn() | ||||
|       let next | ||||
|       const foo = (resolve) => { | ||||
|         setTimeout(() => { | ||||
|  | @ -1231,7 +1231,7 @@ describe('Component keep-alive', () => { | |||
|         }).thenWaitFor(_next => { next = _next }).then(() => { | ||||
|           // foo afterLeave get called
 | ||||
|           // and bar has already been resolved before afterLeave get called
 | ||||
|           expect(barResolve.calls.count()).toBe(1) | ||||
|           expect(barResolve.mock.calls.length).toBe(1) | ||||
|           expect(vm.$el.innerHTML).toBe('<!---->') | ||||
|         }).thenWaitFor(nextFrame).then(() => { | ||||
|           expect(vm.$el.innerHTML).toBe( | ||||
|  |  | |||
|  | @ -899,8 +899,8 @@ describe('Component scoped slot', () => { | |||
| 
 | ||||
|   // 2.6 scoped slot perf optimization
 | ||||
|   it('should have accurate tracking for scoped slots', done => { | ||||
|     const parentUpdate = jasmine.createSpy() | ||||
|     const childUpdate = jasmine.createSpy() | ||||
|     const parentUpdate = vi.fn() | ||||
|     const childUpdate = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       template: ` | ||||
|         <div>{{ parentCount }}<foo #default>{{ childCount }}</foo></div> | ||||
|  | @ -923,15 +923,15 @@ describe('Component scoped slot', () => { | |||
|     waitForUpdate(() => { | ||||
|       expect(vm.$el.innerHTML).toMatch(`1<div>0</div>`) | ||||
|       // should only trigger parent update
 | ||||
|       expect(parentUpdate.calls.count()).toBe(1) | ||||
|       expect(childUpdate.calls.count()).toBe(0) | ||||
|       expect(parentUpdate.mock.calls.length).toBe(1) | ||||
|       expect(childUpdate.mock.calls.length).toBe(0) | ||||
| 
 | ||||
|       vm.childCount++ | ||||
|     }).then(() => { | ||||
|       expect(vm.$el.innerHTML).toMatch(`1<div>1</div>`) | ||||
|       // should only trigger child update
 | ||||
|       expect(parentUpdate.calls.count()).toBe(1) | ||||
|       expect(childUpdate.calls.count()).toBe(1) | ||||
|       expect(parentUpdate.mock.calls.length).toBe(1) | ||||
|       expect(childUpdate.mock.calls.length).toBe(1) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -972,7 +972,7 @@ describe('Component scoped slot', () => { | |||
|   // regression #9396
 | ||||
|   it('should not force update child with no slot content', done => { | ||||
|     const Child = { | ||||
|       updated: jasmine.createSpy(), | ||||
|       updated: vi.fn(), | ||||
|       template: `<div></div>` | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -131,7 +131,7 @@ describe('Component slot', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('fallback content should not be evaluated when the parent is providing it', () => { | ||||
|     const test = jasmine.createSpy('test') | ||||
|     const test = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       template: '<test>slot default</test>', | ||||
|       components: { | ||||
|  | @ -567,7 +567,7 @@ describe('Component slot', () => { | |||
| 
 | ||||
|   // #3518
 | ||||
|   it('events should not break when slot is toggled by v-if', done => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       template: `<test><div class="click" @click="test">hi</div></test>`, | ||||
|       methods: { | ||||
|  |  | |||
|  | @ -360,7 +360,7 @@ describe('Component', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('catch component render error and preserve previous vnode', done => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     Vue.config.errorHandler = spy | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|  |  | |||
|  | @ -88,7 +88,7 @@ found in | |||
|     const vm = new Vue() | ||||
| 
 | ||||
|     it('calls warnHandler if warnHandler is set', () => { | ||||
|       Vue.config.warnHandler = jasmine.createSpy() | ||||
|       Vue.config.warnHandler = vi.fn() | ||||
| 
 | ||||
|       warn(msg, vm) | ||||
| 
 | ||||
|  |  | |||
|  | @ -627,7 +627,7 @@ describe('Directive v-for', () => { | |||
| 
 | ||||
|   it('should warn component v-for without keys', () => { | ||||
|     const warn = console.warn | ||||
|     console.warn = jasmine.createSpy() | ||||
|     console.warn = vi.fn() | ||||
|     new Vue({ | ||||
|       template: `<div><test v-for="i in 3"></test></div>`, | ||||
|       components: { | ||||
|  |  | |||
|  | @ -243,8 +243,8 @@ describe('Directive v-if', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should maintain stable list to avoid unnecessary patches', done => { | ||||
|     const created = jasmine.createSpy() | ||||
|     const destroyed = jasmine.createSpy() | ||||
|     const created = vi.fn() | ||||
|     const destroyed = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         ok: true | ||||
|  | @ -266,10 +266,10 @@ describe('Directive v-if', () => { | |||
|       } | ||||
|     }).$mount() | ||||
| 
 | ||||
|     expect(created.calls.count()).toBe(1) | ||||
|     expect(created.mock.calls.length).toBe(1) | ||||
|     vm.ok = false | ||||
|     waitForUpdate(() => { | ||||
|       expect(created.calls.count()).toBe(1) | ||||
|       expect(created.mock.calls.length).toBe(1) | ||||
|       expect(destroyed).not.toHaveBeenCalled() | ||||
|     }).then(done) | ||||
|   }) | ||||
|  |  | |||
|  | @ -72,7 +72,7 @@ describe('Directive v-model component', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should support customization via model option', done => { | ||||
|     const spy = jasmine.createSpy('update') | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         msg: 'hello' | ||||
|  |  | |||
|  | @ -86,7 +86,7 @@ describe('Directive v-model radio', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('multiple radios ', (done) => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         selections: ['a', '1'], | ||||
|  |  | |||
|  | @ -207,7 +207,7 @@ describe('Directive v-model select', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should work with select which has no default selected options', (done) => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         id: 4, | ||||
|  | @ -228,7 +228,7 @@ describe('Directive v-model select', () => { | |||
|     document.body.appendChild(vm.$el) | ||||
|     vm.testChange = 10 | ||||
|     waitForUpdate(() => { | ||||
|       expect(spy.calls.count()).toBe(0) | ||||
|       expect(spy.mock.calls.length).toBe(0) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -296,7 +296,7 @@ describe('Directive v-model select', () => { | |||
|   } | ||||
| 
 | ||||
|   it('should work with multiple binding', (done) => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         isMultiple: true, | ||||
|  | @ -352,7 +352,7 @@ describe('Directive v-model select', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('multiple selects', (done) => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         selections: ['', ''], | ||||
|  | @ -520,7 +520,7 @@ describe('Directive v-model select', () => { | |||
| 
 | ||||
|   // #6193
 | ||||
|   it('should not trigger change event when matching option can be found for each value', done => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         options: ['1'] | ||||
|  |  | |||
|  | @ -136,7 +136,7 @@ describe('Directive v-model text', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('multiple inputs', (done) => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         selections: [[1, 2, 3], [4, 5]], | ||||
|  | @ -230,7 +230,7 @@ describe('Directive v-model text', () => { | |||
| 
 | ||||
|   // #3468
 | ||||
|   it('should have higher priority than user v-on events', () => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         a: 'a' | ||||
|  | @ -317,7 +317,7 @@ describe('Directive v-model text', () => { | |||
| 
 | ||||
|   if (!isAndroid) { | ||||
|     it('does not trigger extra input events with single compositionend', () => { | ||||
|       const spy = jasmine.createSpy() | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         data: { | ||||
|           a: 'a' | ||||
|  | @ -329,16 +329,16 @@ describe('Directive v-model text', () => { | |||
|           } | ||||
|         } | ||||
|       }).$mount() | ||||
|       expect(spy.calls.count()).toBe(0) | ||||
|       expect(spy.mock.calls.length).toBe(0) | ||||
|       vm.$el.value = 'b' | ||||
|       triggerEvent(vm.$el, 'input') | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       triggerEvent(vm.$el, 'compositionend') | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|     }) | ||||
| 
 | ||||
|     it('triggers extra input on compositionstart + end', () => { | ||||
|       const spy = jasmine.createSpy() | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         data: { | ||||
|           a: 'a' | ||||
|  | @ -350,13 +350,13 @@ describe('Directive v-model text', () => { | |||
|           } | ||||
|         } | ||||
|       }).$mount() | ||||
|       expect(spy.calls.count()).toBe(0) | ||||
|       expect(spy.mock.calls.length).toBe(0) | ||||
|       vm.$el.value = 'b' | ||||
|       triggerEvent(vm.$el, 'input') | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       triggerEvent(vm.$el, 'compositionstart') | ||||
|       triggerEvent(vm.$el, 'compositionend') | ||||
|       expect(spy.calls.count()).toBe(2) | ||||
|       expect(spy.mock.calls.length).toBe(2) | ||||
|     }) | ||||
| 
 | ||||
|     // #4392
 | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ describe('Directive v-on', () => { | |||
| 
 | ||||
|   beforeEach(() => { | ||||
|     vm = null | ||||
|     spy = jasmine.createSpy() | ||||
|     spy = vi.fn() | ||||
|     el = document.createElement('div') | ||||
|     document.body.appendChild(el) | ||||
|   }) | ||||
|  | @ -24,7 +24,7 @@ describe('Directive v-on', () => { | |||
|       methods: { foo: spy } | ||||
|     }) | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|     const args = spy.calls.allArgs() | ||||
|     const event = args[0] && args[0][0] || {} | ||||
|  | @ -38,7 +38,7 @@ describe('Directive v-on', () => { | |||
|       methods: { foo: spy } | ||||
|     }) | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|     const args = spy.calls.allArgs() | ||||
|     const firstArgs = args[0] | ||||
|  | @ -50,7 +50,7 @@ describe('Directive v-on', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should support inline function expression', () => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|       template: `<div class="test" @click="function (e) { log(e.target.className) }"></div>`, | ||||
|  | @ -69,7 +69,7 @@ describe('Directive v-on', () => { | |||
|       methods: { foo: spy } | ||||
|     }) | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('should support stop propagation', () => { | ||||
|  | @ -130,9 +130,9 @@ describe('Directive v-on', () => { | |||
|       methods: { foo: spy } | ||||
|     }) | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) // should no longer trigger
 | ||||
|     expect(spy.mock.calls.length).toBe(1) // should no longer trigger
 | ||||
|   }) | ||||
| 
 | ||||
|   // #4655
 | ||||
|  | @ -148,14 +148,14 @@ describe('Directive v-on', () => { | |||
|       methods: { foo: spy } | ||||
|     }) | ||||
|     triggerEvent(vm.$refs.one, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     triggerEvent(vm.$refs.one, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     triggerEvent(vm.$refs.two, 'click') | ||||
|     expect(spy.calls.count()).toBe(2) | ||||
|     expect(spy.mock.calls.length).toBe(2) | ||||
|     triggerEvent(vm.$refs.one, 'click') | ||||
|     triggerEvent(vm.$refs.two, 'click') | ||||
|     expect(spy.calls.count()).toBe(2) | ||||
|     expect(spy.mock.calls.length).toBe(2) | ||||
|   }) | ||||
| 
 | ||||
|   it('should support capture and once', () => { | ||||
|  | @ -190,7 +190,7 @@ describe('Directive v-on', () => { | |||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spy).toHaveBeenCalled() | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('should support keyCode', () => { | ||||
|  | @ -233,24 +233,24 @@ describe('Directive v-on', () => { | |||
|     }) | ||||
| 
 | ||||
|     triggerEvent(vm.$refs.ctrl, 'keyup') | ||||
|     expect(spy.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(0) | ||||
|     triggerEvent(vm.$refs.ctrl, 'keyup', e => { e.ctrlKey = true }) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|     triggerEvent(vm.$refs.shift, 'keyup') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     triggerEvent(vm.$refs.shift, 'keyup', e => { e.shiftKey = true }) | ||||
|     expect(spy.calls.count()).toBe(2) | ||||
|     expect(spy.mock.calls.length).toBe(2) | ||||
| 
 | ||||
|     triggerEvent(vm.$refs.alt, 'keyup') | ||||
|     expect(spy.calls.count()).toBe(2) | ||||
|     expect(spy.mock.calls.length).toBe(2) | ||||
|     triggerEvent(vm.$refs.alt, 'keyup', e => { e.altKey = true }) | ||||
|     expect(spy.calls.count()).toBe(3) | ||||
|     expect(spy.mock.calls.length).toBe(3) | ||||
| 
 | ||||
|     triggerEvent(vm.$refs.meta, 'keyup') | ||||
|     expect(spy.calls.count()).toBe(3) | ||||
|     expect(spy.mock.calls.length).toBe(3) | ||||
|     triggerEvent(vm.$refs.meta, 'keyup', e => { e.metaKey = true }) | ||||
|     expect(spy.calls.count()).toBe(4) | ||||
|     expect(spy.mock.calls.length).toBe(4) | ||||
|   }) | ||||
| 
 | ||||
|   it('should support exact modifier', () => { | ||||
|  | @ -265,19 +265,19 @@ describe('Directive v-on', () => { | |||
|     }) | ||||
| 
 | ||||
|     triggerEvent(vm.$refs.ctrl, 'keyup') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|     triggerEvent(vm.$refs.ctrl, 'keyup', e => { | ||||
|       e.ctrlKey = true | ||||
|     }) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|     // should not trigger if has other system modifiers
 | ||||
|     triggerEvent(vm.$refs.ctrl, 'keyup', e => { | ||||
|       e.ctrlKey = true | ||||
|       e.altKey = true | ||||
|     }) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('should support system modifiers with exact', () => { | ||||
|  | @ -292,19 +292,19 @@ describe('Directive v-on', () => { | |||
|     }) | ||||
| 
 | ||||
|     triggerEvent(vm.$refs.ctrl, 'keyup') | ||||
|     expect(spy.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(0) | ||||
| 
 | ||||
|     triggerEvent(vm.$refs.ctrl, 'keyup', e => { | ||||
|       e.ctrlKey = true | ||||
|     }) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|     // should not trigger if has other system modifiers
 | ||||
|     triggerEvent(vm.$refs.ctrl, 'keyup', e => { | ||||
|       e.ctrlKey = true | ||||
|       e.altKey = true | ||||
|     }) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('should support number keyCode', () => { | ||||
|  | @ -323,9 +323,9 @@ describe('Directive v-on', () => { | |||
|     const left = 0 | ||||
|     const middle = 1 | ||||
|     const right = 2 | ||||
|     const spyLeft = jasmine.createSpy() | ||||
|     const spyMiddle = jasmine.createSpy() | ||||
|     const spyRight = jasmine.createSpy() | ||||
|     const spyLeft = vi.fn() | ||||
|     const spyMiddle = vi.fn() | ||||
|     const spyRight = vi.fn() | ||||
| 
 | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|  | @ -378,17 +378,17 @@ describe('Directive v-on', () => { | |||
|     }) | ||||
| 
 | ||||
|     triggerEvent(vm.$refs.enter, 'keyup', e => { e.key = 'Enter' }) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     triggerEvent(vm.$refs.space, 'keyup', e => { e.key = ' ' }) | ||||
|     expect(spy.calls.count()).toBe(2) | ||||
|     expect(spy.mock.calls.length).toBe(2) | ||||
|     triggerEvent(vm.$refs.esc, 'keyup', e => { e.key = 'Escape' }) | ||||
|     expect(spy.calls.count()).toBe(3) | ||||
|     expect(spy.mock.calls.length).toBe(3) | ||||
|     triggerEvent(vm.$refs.left, 'keyup', e => { e.key = 'ArrowLeft' }) | ||||
|     expect(spy.calls.count()).toBe(4) | ||||
|     expect(spy.mock.calls.length).toBe(4) | ||||
|     triggerEvent(vm.$refs.delete, 'keyup', e => { e.key = 'Backspace' }) | ||||
|     expect(spy.calls.count()).toBe(5) | ||||
|     expect(spy.mock.calls.length).toBe(5) | ||||
|     triggerEvent(vm.$refs.delete, 'keyup', e => { e.key = 'Delete' }) | ||||
|     expect(spy.calls.count()).toBe(6) | ||||
|     expect(spy.mock.calls.length).toBe(6) | ||||
|   }) | ||||
| 
 | ||||
|   it('should support custom keyCode', () => { | ||||
|  | @ -471,7 +471,7 @@ describe('Directive v-on', () => { | |||
| 
 | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(`The .native modifier for v-on is only valid on components but it was used on <button>.`).toHaveBeenWarned() | ||||
|     expect(spy.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(0) | ||||
|   }) | ||||
| 
 | ||||
|   it('should not throw a warning if native modifier is used on a dynamic component', () => { | ||||
|  | @ -500,13 +500,13 @@ describe('Directive v-on', () => { | |||
|       } | ||||
|     }) | ||||
|     vm.$children[0].$emit('custom') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     vm.$children[0].$emit('custom') | ||||
|     expect(spy.calls.count()).toBe(1) // should not be called again
 | ||||
|     expect(spy.mock.calls.length).toBe(1) // should not be called again
 | ||||
|   }) | ||||
| 
 | ||||
|   it('remove listener', done => { | ||||
|     const spy2 = jasmine.createSpy('remove listener') | ||||
|     const spy2 = vi.fn() | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|       methods: { foo: spy, bar: spy2 }, | ||||
|  | @ -520,19 +520,19 @@ describe('Directive v-on', () => { | |||
|       } | ||||
|     }) | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy2.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     expect(spy2.mock.calls.length).toBe(0) | ||||
|     vm.ok = false | ||||
|     waitForUpdate(() => { | ||||
|       triggerEvent(vm.$el, 'click') | ||||
|       expect(spy.calls.count()).toBe(1) // should no longer trigger
 | ||||
|       expect(spy.mock.calls.length).toBe(1) // should no longer trigger
 | ||||
|       triggerEvent(vm.$el, 'input') | ||||
|       expect(spy2.calls.count()).toBe(1) | ||||
|       expect(spy2.mock.calls.length).toBe(1) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|   it('remove capturing listener', done => { | ||||
|     const spy2 = jasmine.createSpy('remove listener') | ||||
|     const spy2 = vi.fn() | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|       methods: { foo: spy, bar: spy2, stopped (ev) { ev.stopPropagation() } }, | ||||
|  | @ -546,19 +546,19 @@ describe('Directive v-on', () => { | |||
|       } | ||||
|     }) | ||||
|     triggerEvent(vm.$el.firstChild, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy2.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     expect(spy2.mock.calls.length).toBe(0) | ||||
|     vm.ok = false | ||||
|     waitForUpdate(() => { | ||||
|       triggerEvent(vm.$el.firstChild, 'click') | ||||
|       expect(spy.calls.count()).toBe(1) // should no longer trigger
 | ||||
|       expect(spy.mock.calls.length).toBe(1) // should no longer trigger
 | ||||
|       triggerEvent(vm.$el, 'mouseOver') | ||||
|       expect(spy2.calls.count()).toBe(1) | ||||
|       expect(spy2.mock.calls.length).toBe(1) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|   it('remove once listener', done => { | ||||
|     const spy2 = jasmine.createSpy('remove listener') | ||||
|     const spy2 = vi.fn() | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|       methods: { foo: spy, bar: spy2 }, | ||||
|  | @ -572,21 +572,21 @@ describe('Directive v-on', () => { | |||
|       } | ||||
|     }) | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) // should no longer trigger
 | ||||
|     expect(spy2.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(1) // should no longer trigger
 | ||||
|     expect(spy2.mock.calls.length).toBe(0) | ||||
|     vm.ok = false | ||||
|     waitForUpdate(() => { | ||||
|       triggerEvent(vm.$el, 'click') | ||||
|       expect(spy.calls.count()).toBe(1) // should no longer trigger
 | ||||
|       expect(spy.mock.calls.length).toBe(1) // should no longer trigger
 | ||||
|       triggerEvent(vm.$el, 'input') | ||||
|       expect(spy2.calls.count()).toBe(1) | ||||
|       expect(spy2.mock.calls.length).toBe(1) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|   it('remove capturing and once listener', done => { | ||||
|     const spy2 = jasmine.createSpy('remove listener') | ||||
|     const spy2 = vi.fn() | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|       methods: { foo: spy, bar: spy2, stopped (ev) { ev.stopPropagation() } }, | ||||
|  | @ -600,21 +600,21 @@ describe('Directive v-on', () => { | |||
|       } | ||||
|     }) | ||||
|     triggerEvent(vm.$el.firstChild, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     triggerEvent(vm.$el.firstChild, 'click') | ||||
|     expect(spy.calls.count()).toBe(1) // should no longer trigger
 | ||||
|     expect(spy2.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(1) // should no longer trigger
 | ||||
|     expect(spy2.mock.calls.length).toBe(0) | ||||
|     vm.ok = false | ||||
|     waitForUpdate(() => { | ||||
|       triggerEvent(vm.$el.firstChild, 'click') | ||||
|       expect(spy.calls.count()).toBe(1) // should no longer trigger
 | ||||
|       expect(spy.mock.calls.length).toBe(1) // should no longer trigger
 | ||||
|       triggerEvent(vm.$el, 'mouseOver') | ||||
|       expect(spy2.calls.count()).toBe(1) | ||||
|       expect(spy2.mock.calls.length).toBe(1) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|   it('remove listener on child component', done => { | ||||
|     const spy2 = jasmine.createSpy('remove listener') | ||||
|     const spy2 = vi.fn() | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|       methods: { foo: spy, bar: spy2 }, | ||||
|  | @ -633,14 +633,14 @@ describe('Directive v-on', () => { | |||
|       } | ||||
|     }) | ||||
|     vm.$children[0].$emit('foo') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy2.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     expect(spy2.mock.calls.length).toBe(0) | ||||
|     vm.ok = false | ||||
|     waitForUpdate(() => { | ||||
|       vm.$children[0].$emit('foo') | ||||
|       expect(spy.calls.count()).toBe(1) // should no longer trigger
 | ||||
|       expect(spy.mock.calls.length).toBe(1) // should no longer trigger
 | ||||
|       vm.$children[0].$emit('bar') | ||||
|       expect(spy2.calls.count()).toBe(1) | ||||
|       expect(spy2.mock.calls.length).toBe(1) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -658,10 +658,10 @@ describe('Directive v-on', () => { | |||
| 
 | ||||
|   // Github Issue #5046
 | ||||
|   it('should support keyboard modifier for direction keys', () => { | ||||
|     const spyLeft = jasmine.createSpy() | ||||
|     const spyRight = jasmine.createSpy() | ||||
|     const spyUp = jasmine.createSpy() | ||||
|     const spyDown = jasmine.createSpy() | ||||
|     const spyLeft = vi.fn() | ||||
|     const spyRight = vi.fn() | ||||
|     const spyUp = vi.fn() | ||||
|     const spyDown = vi.fn() | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|       template: ` | ||||
|  | @ -691,10 +691,10 @@ describe('Directive v-on', () => { | |||
|     triggerEvent(vm.$refs.down, 'keydown', e => { e.keyCode = 40 }) | ||||
|     triggerEvent(vm.$refs.down, 'keydown', e => { e.keyCode = 39 }) | ||||
| 
 | ||||
|     expect(spyLeft.calls.count()).toBe(1) | ||||
|     expect(spyRight.calls.count()).toBe(1) | ||||
|     expect(spyUp.calls.count()).toBe(1) | ||||
|     expect(spyDown.calls.count()).toBe(1) | ||||
|     expect(spyLeft.mock.calls.length).toBe(1) | ||||
|     expect(spyRight.mock.calls.length).toBe(1) | ||||
|     expect(spyUp.mock.calls.length).toBe(1) | ||||
|     expect(spyDown.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   // This test case should only run when the test browser supports passive.
 | ||||
|  | @ -751,7 +751,7 @@ describe('Directive v-on', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should transform click.right to contextmenu', () => { | ||||
|     const spy = jasmine.createSpy('click.right') | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       template: `<div @click.right="foo"></div>`, | ||||
|       methods: { foo: spy } | ||||
|  | @ -762,7 +762,7 @@ describe('Directive v-on', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should transform click.middle to mouseup', () => { | ||||
|     const spy = jasmine.createSpy('click.middle') | ||||
|     const spy = vi.fn() | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|       template: `<div @click.middle="foo"></div>`, | ||||
|  | @ -775,8 +775,8 @@ describe('Directive v-on', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('object syntax (no argument)', () => { | ||||
|     const click = jasmine.createSpy('click') | ||||
|     const mouseup = jasmine.createSpy('mouseup') | ||||
|     const click = vi.fn() | ||||
|     const mouseup = vi.fn() | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|       template: `<button v-on="listeners">foo</button>`, | ||||
|  | @ -789,18 +789,18 @@ describe('Directive v-on', () => { | |||
|     }) | ||||
| 
 | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(mouseup.calls.count()).toBe(0) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|     expect(mouseup.mock.calls.length).toBe(0) | ||||
| 
 | ||||
|     triggerEvent(vm.$el, 'mouseup') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(mouseup.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|     expect(mouseup.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('object syntax (no argument, mixed with normal listeners)', () => { | ||||
|     const click1 = jasmine.createSpy('click1') | ||||
|     const click2 = jasmine.createSpy('click2') | ||||
|     const mouseup = jasmine.createSpy('mouseup') | ||||
|     const click1 = vi.fn() | ||||
|     const click2 = vi.fn() | ||||
|     const mouseup = vi.fn() | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|       template: `<button v-on="listeners" @click="click2">foo</button>`, | ||||
|  | @ -816,20 +816,20 @@ describe('Directive v-on', () => { | |||
|     }) | ||||
| 
 | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(click1.calls.count()).toBe(1) | ||||
|     expect(click2.calls.count()).toBe(1) | ||||
|     expect(mouseup.calls.count()).toBe(0) | ||||
|     expect(click1.mock.calls.length).toBe(1) | ||||
|     expect(click2.mock.calls.length).toBe(1) | ||||
|     expect(mouseup.mock.calls.length).toBe(0) | ||||
| 
 | ||||
|     triggerEvent(vm.$el, 'mouseup') | ||||
|     expect(click1.calls.count()).toBe(1) | ||||
|     expect(click2.calls.count()).toBe(1) | ||||
|     expect(mouseup.calls.count()).toBe(1) | ||||
|     expect(click1.mock.calls.length).toBe(1) | ||||
|     expect(click2.mock.calls.length).toBe(1) | ||||
|     expect(mouseup.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('object syntax (usage in HOC, mixed with native listeners)', () => { | ||||
|     const click = jasmine.createSpy('click') | ||||
|     const mouseup = jasmine.createSpy('mouseup') | ||||
|     const mousedown = jasmine.createSpy('mousedown') | ||||
|     const click = vi.fn() | ||||
|     const mouseup = vi.fn() | ||||
|     const mousedown = vi.fn() | ||||
| 
 | ||||
|     vm = new Vue({ | ||||
|       el, | ||||
|  | @ -855,19 +855,19 @@ describe('Directive v-on', () => { | |||
|     }) | ||||
| 
 | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(mouseup.calls.count()).toBe(0) | ||||
|     expect(mousedown.calls.count()).toBe(0) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|     expect(mouseup.mock.calls.length).toBe(0) | ||||
|     expect(mousedown.mock.calls.length).toBe(0) | ||||
| 
 | ||||
|     triggerEvent(vm.$el, 'mouseup') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(mouseup.calls.count()).toBe(1) | ||||
|     expect(mousedown.calls.count()).toBe(0) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|     expect(mouseup.mock.calls.length).toBe(1) | ||||
|     expect(mousedown.mock.calls.length).toBe(0) | ||||
| 
 | ||||
|     triggerEvent(vm.$el, 'mousedown') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(mouseup.calls.count()).toBe(1) | ||||
|     expect(mousedown.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|     expect(mouseup.mock.calls.length).toBe(1) | ||||
|     expect(mousedown.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   // #6805 (v-on="object" bind order problem)
 | ||||
|  | @ -948,7 +948,7 @@ describe('Directive v-on', () => { | |||
|     vm.ok = false | ||||
|     waitForUpdate(() => { | ||||
|       triggerEvent(vm.$el.childNodes[0], 'click') | ||||
|       expect(spy.calls.count()).toBe(0) | ||||
|       expect(spy.mock.calls.length).toBe(0) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -984,12 +984,12 @@ describe('Directive v-on', () => { | |||
|     }) | ||||
|     // simulating autocomplete event (Event object with type keyup but without keyCode)
 | ||||
|     triggerEvent(vm.$el, 'keyup') | ||||
|     expect(spy.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(0) | ||||
|   }) | ||||
| 
 | ||||
|   describe('dynamic arguments', () => { | ||||
|     it('basic', done => { | ||||
|       const spy = jasmine.createSpy() | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: `<div v-on:[key]="spy"></div>`, | ||||
|         data: { | ||||
|  | @ -1000,25 +1000,25 @@ describe('Directive v-on', () => { | |||
|         } | ||||
|       }).$mount() | ||||
|       triggerEvent(vm.$el, 'click') | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       vm.key = 'mouseup' | ||||
|       waitForUpdate(() => { | ||||
|         triggerEvent(vm.$el, 'click') | ||||
|         expect(spy.calls.count()).toBe(1) | ||||
|         expect(spy.mock.calls.length).toBe(1) | ||||
|         triggerEvent(vm.$el, 'mouseup') | ||||
|         expect(spy.calls.count()).toBe(2) | ||||
|         expect(spy.mock.calls.length).toBe(2) | ||||
|         // explicit null value
 | ||||
|         vm.key = null | ||||
|       }).then(() => { | ||||
|         triggerEvent(vm.$el, 'click') | ||||
|         expect(spy.calls.count()).toBe(2) | ||||
|         expect(spy.mock.calls.length).toBe(2) | ||||
|         triggerEvent(vm.$el, 'mouseup') | ||||
|         expect(spy.calls.count()).toBe(2) | ||||
|         expect(spy.mock.calls.length).toBe(2) | ||||
|       }).then(done) | ||||
|     }) | ||||
| 
 | ||||
|     it('shorthand', done => { | ||||
|       const spy = jasmine.createSpy() | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: `<div @[key]="spy"></div>`, | ||||
|         data: { | ||||
|  | @ -1029,18 +1029,18 @@ describe('Directive v-on', () => { | |||
|         } | ||||
|       }).$mount() | ||||
|       triggerEvent(vm.$el, 'click') | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       vm.key = 'mouseup' | ||||
|       waitForUpdate(() => { | ||||
|         triggerEvent(vm.$el, 'click') | ||||
|         expect(spy.calls.count()).toBe(1) | ||||
|         expect(spy.mock.calls.length).toBe(1) | ||||
|         triggerEvent(vm.$el, 'mouseup') | ||||
|         expect(spy.calls.count()).toBe(2) | ||||
|         expect(spy.mock.calls.length).toBe(2) | ||||
|       }).then(done) | ||||
|     }) | ||||
| 
 | ||||
|     it('with .middle modifier', () => { | ||||
|       const spy = jasmine.createSpy() | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: `<div @[key].middle="spy"></div>`, | ||||
|         data: { | ||||
|  | @ -1057,7 +1057,7 @@ describe('Directive v-on', () => { | |||
|     }) | ||||
| 
 | ||||
|     it('with .right modifier', () => { | ||||
|       const spy = jasmine.createSpy() | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: `<div @[key].right="spy"></div>`, | ||||
|         data: { | ||||
|  | @ -1098,9 +1098,9 @@ describe('Directive v-on', () => { | |||
|         methods: { foo: spy } | ||||
|       }).$mount() | ||||
|       triggerEvent(vm.$el, 'click') | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       triggerEvent(vm.$el, 'click') | ||||
|       expect(spy.calls.count()).toBe(1) // should no longer trigger
 | ||||
|       expect(spy.mock.calls.length).toBe(1) // should no longer trigger
 | ||||
|     }) | ||||
|   }) | ||||
| }) | ||||
|  |  | |||
|  | @ -149,7 +149,7 @@ describe('Error handling', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('config.errorHandler should capture render errors', done => { | ||||
|     const spy = Vue.config.errorHandler = jasmine.createSpy('errorHandler') | ||||
|     const spy = Vue.config.errorHandler = vi.fn() | ||||
|     const vm = createTestInstance(components.render) | ||||
| 
 | ||||
|     const args = spy.calls.argsFor(0) | ||||
|  | @ -165,7 +165,7 @@ describe('Error handling', () => { | |||
|   it('should capture and recover from nextTick errors', done => { | ||||
|     const err1 = new Error('nextTick') | ||||
|     const err2 = new Error('nextTick2') | ||||
|     const spy = Vue.config.errorHandler = jasmine.createSpy('errorHandler') | ||||
|     const spy = Vue.config.errorHandler = vi.fn() | ||||
|     Vue.nextTick(() => { throw err1 }) | ||||
|     Vue.nextTick(() => { | ||||
|       expect(spy).toHaveBeenCalledWith(err1, undefined, 'nextTick') | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ describe('Global config', () => { | |||
| 
 | ||||
|   describe('optionMergeStrategies', () => { | ||||
|     it('should allow defining custom option merging strategies', () => { | ||||
|       const spy = jasmine.createSpy('option merging') | ||||
|       const spy = vi.fn() | ||||
|       Vue.config.optionMergeStrategies.__test__ = (parent, child, vm) => { | ||||
|         spy(parent, child, vm) | ||||
|         return child + 1 | ||||
|  | @ -33,13 +33,13 @@ describe('Global config', () => { | |||
|       const Test = Vue.extend({ | ||||
|         __test__: 1 | ||||
|       }) | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       expect(spy).toHaveBeenCalledWith(undefined, 1, undefined) | ||||
|       expect(Test.options.__test__).toBe(2) | ||||
|       const test = new Test({ | ||||
|         __test__: 2 | ||||
|       }) | ||||
|       expect(spy.calls.count()).toBe(2) | ||||
|       expect(spy.mock.calls.length).toBe(2) | ||||
|       expect(spy).toHaveBeenCalledWith(2, 2, test) | ||||
|       expect(test.$options.__test__).toBe(3) | ||||
|     }) | ||||
|  | @ -58,7 +58,7 @@ describe('Global config', () => { | |||
| 
 | ||||
|   describe('async', () => { | ||||
|     it('does not update synchronously when true', () => { | ||||
|       const spy = jasmine.createSpy() | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: `<div :class="value"></div>`, | ||||
|         updated: spy, | ||||
|  | @ -69,7 +69,7 @@ describe('Global config', () => { | |||
|     }) | ||||
| 
 | ||||
|     it('updates synchronously when false', () => { | ||||
|       const spy = jasmine.createSpy() | ||||
|       const spy = vi.fn() | ||||
|       Vue.config.async = false | ||||
|       const vm = new Vue({ | ||||
|         template: `<div :class="value"></div>`, | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ describe('Global API: mixin', () => { | |||
|   afterEach(() => { Vue.options = options }) | ||||
| 
 | ||||
|   it('should work', () => { | ||||
|     const spy = jasmine.createSpy('global mixin') | ||||
|     const spy = vi.fn() | ||||
|     Vue.mixin({ | ||||
|       created () { | ||||
|         spy(this.$options.myOption) | ||||
|  | @ -87,7 +87,7 @@ describe('Global API: mixin', () => { | |||
| 
 | ||||
|   // #4976
 | ||||
|   it('should not drop late-attached custom options on existing constructors', () => { | ||||
|     const baseSpy = jasmine.createSpy('base') | ||||
|     const baseSpy = vi.fn() | ||||
|     const Base = Vue.extend({ | ||||
|       beforeCreate: baseSpy | ||||
|     }) | ||||
|  | @ -100,11 +100,11 @@ describe('Global API: mixin', () => { | |||
|       $style: () => 123 | ||||
|     } | ||||
| 
 | ||||
|     const spy = jasmine.createSpy('late attached') | ||||
|     const spy = vi.fn() | ||||
|     Test.options.beforeCreate = Test.options.beforeCreate.concat(spy) | ||||
| 
 | ||||
|     // Update super constructor's options
 | ||||
|     const mixinSpy = jasmine.createSpy('mixin') | ||||
|     const mixinSpy = vi.fn() | ||||
|     Vue.mixin({ | ||||
|       beforeCreate: mixinSpy | ||||
|     }) | ||||
|  | @ -114,9 +114,9 @@ describe('Global API: mixin', () => { | |||
|       template: '<div>{{ $style }}</div>' | ||||
|     }).$mount() | ||||
| 
 | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(baseSpy.calls.count()).toBe(1) | ||||
|     expect(mixinSpy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     expect(baseSpy.mock.calls.length).toBe(1) | ||||
|     expect(mixinSpy.mock.calls.length).toBe(1) | ||||
|     expect(vm.$el.textContent).toBe('123') | ||||
|     expect(vm.$style).toBe(123) | ||||
| 
 | ||||
|  | @ -127,7 +127,7 @@ describe('Global API: mixin', () => { | |||
| 
 | ||||
|   // vue-class-component#83
 | ||||
|   it('should work for a constructor mixin', () => { | ||||
|     const spy = jasmine.createSpy('global mixin') | ||||
|     const spy = vi.fn() | ||||
|     const Mixin = Vue.extend({ | ||||
|       created () { | ||||
|         spy(this.$options.myOption) | ||||
|  | @ -144,13 +144,13 @@ describe('Global API: mixin', () => { | |||
| 
 | ||||
|   // vue-class-component#87
 | ||||
|   it('should not drop original lifecycle hooks', () => { | ||||
|     const base = jasmine.createSpy('base') | ||||
|     const base = vi.fn() | ||||
| 
 | ||||
|     const Base = Vue.extend({ | ||||
|       beforeCreate: base | ||||
|     }) | ||||
| 
 | ||||
|     const injected = jasmine.createSpy('injected') | ||||
|     const injected = vi.fn() | ||||
| 
 | ||||
|     // inject a function
 | ||||
|     Base.options.beforeCreate = Base.options.beforeCreate.concat(injected) | ||||
|  | @ -170,7 +170,7 @@ describe('Global API: mixin', () => { | |||
| 
 | ||||
|   // #9198
 | ||||
|   it('should not mix global mixin lifecycle hook twice', () => { | ||||
|     const spy = jasmine.createSpy('global mixed in lifecycle hook') | ||||
|     const spy = vi.fn() | ||||
|     Vue.mixin({ | ||||
|       created: spy | ||||
|     }) | ||||
|  | @ -192,6 +192,6 @@ describe('Global API: mixin', () => { | |||
|     const vm = new Child() | ||||
| 
 | ||||
|     expect(typeof vm.$options.methods.a).toBe('function') | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| }) | ||||
|  |  | |||
|  | @ -21,7 +21,7 @@ describe('Instance methods data', () => { | |||
|   describe('$watch', () => { | ||||
|     let vm, spy | ||||
|     beforeEach(() => { | ||||
|       spy = jasmine.createSpy('watch') | ||||
|       spy = vi.fn() | ||||
|       vm = new Vue({ | ||||
|         data: { | ||||
|           a: { | ||||
|  | @ -41,18 +41,18 @@ describe('Instance methods data', () => { | |||
|       vm.$watch('a.b', spy) | ||||
|       vm.a.b = 2 | ||||
|       waitForUpdate(() => { | ||||
|         expect(spy.calls.count()).toBe(1) | ||||
|         expect(spy.mock.calls.length).toBe(1) | ||||
|         expect(spy).toHaveBeenCalledWith(2, 1) | ||||
|         vm.a = { b: 3 } | ||||
|       }).then(() => { | ||||
|         expect(spy.calls.count()).toBe(2) | ||||
|         expect(spy.mock.calls.length).toBe(2) | ||||
|         expect(spy).toHaveBeenCalledWith(3, 2) | ||||
|       }).then(done) | ||||
|     }) | ||||
| 
 | ||||
|     it('immediate', () => { | ||||
|       vm.$watch('a.b', spy, { immediate: true }) | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       expect(spy).toHaveBeenCalledWith(1) | ||||
|     }) | ||||
| 
 | ||||
|  | @ -61,7 +61,7 @@ describe('Instance methods data', () => { | |||
|       unwatch() | ||||
|       vm.a.b = 2 | ||||
|       waitForUpdate(() => { | ||||
|         expect(spy.calls.count()).toBe(0) | ||||
|         expect(spy.mock.calls.length).toBe(0) | ||||
|       }).then(done) | ||||
|     }) | ||||
| 
 | ||||
|  | @ -107,7 +107,7 @@ describe('Instance methods data', () => { | |||
|         handler: 'foo', | ||||
|         immediate: true | ||||
|       }) | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       expect(spy).toHaveBeenCalledWith(1) | ||||
|     }) | ||||
| 
 | ||||
|  | @ -116,7 +116,7 @@ describe('Instance methods data', () => { | |||
|         handler: 'foo', | ||||
|         immediate: true | ||||
|       }) | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       expect(spy).toHaveBeenCalledWith('ok') | ||||
|     }) | ||||
| 
 | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ describe('Instance methods events', () => { | |||
|   beforeEach(() => { | ||||
|     // @ts-expect-error
 | ||||
|     const vm = new Vue() | ||||
|     spy = jasmine.createSpy('emitter') | ||||
|     spy = vi.fn() | ||||
|   }) | ||||
| 
 | ||||
|   it('$on', () => { | ||||
|  | @ -15,7 +15,7 @@ describe('Instance methods events', () => { | |||
|       spy.apply(this, arguments) | ||||
|     }) | ||||
|     vm.$emit('test', 1, 2, 3, 4) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     expect(spy).toHaveBeenCalledWith(1, 2, 3, 4) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -25,10 +25,10 @@ describe('Instance methods events', () => { | |||
|       spy.apply(this, arguments) | ||||
|     }) | ||||
|     vm.$emit('test1', 1, 2, 3, 4) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     expect(spy).toHaveBeenCalledWith(1, 2, 3, 4) | ||||
|     vm.$emit('test2', 5, 6, 7, 8) | ||||
|     expect(spy.calls.count()).toBe(2) | ||||
|     expect(spy.mock.calls.length).toBe(2) | ||||
|     expect(spy).toHaveBeenCalledWith(5, 6, 7, 8) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -39,7 +39,7 @@ describe('Instance methods events', () => { | |||
|     vm.$emit('test2') | ||||
|     expect(spy).not.toHaveBeenCalled() | ||||
|     vm.$emit('test3', 1, 2, 3, 4) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('$off multi event without callback', () => { | ||||
|  | @ -53,7 +53,7 @@ describe('Instance methods events', () => { | |||
|     vm.$once('test', spy) | ||||
|     vm.$emit('test', 1, 2, 3) | ||||
|     vm.$emit('test', 2, 3, 4) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     expect(spy).toHaveBeenCalledWith(1, 2, 3) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -80,18 +80,18 @@ describe('Instance methods events', () => { | |||
|     vm.$off('test1') // test off something that's already off
 | ||||
|     vm.$emit('test1', 1) | ||||
|     vm.$emit('test2', 2) | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     expect(spy).toHaveBeenCalledWith(2) | ||||
|   }) | ||||
| 
 | ||||
|   it('$off event + fn', () => { | ||||
|     const spy2 = jasmine.createSpy('emitter') | ||||
|     const spy2 = vi.fn() | ||||
|     vm.$on('test', spy) | ||||
|     vm.$on('test', spy2) | ||||
|     vm.$off('test', spy) | ||||
|     vm.$emit('test', 1, 2, 3) | ||||
|     expect(spy).not.toHaveBeenCalled() | ||||
|     expect(spy2.calls.count()).toBe(1) | ||||
|     expect(spy2.mock.calls.length).toBe(1) | ||||
|     expect(spy2).toHaveBeenCalledWith(1, 2, 3) | ||||
|   }) | ||||
| }) | ||||
|  |  | |||
|  | @ -57,7 +57,7 @@ describe('Instance methods lifecycle', () => { | |||
|     it('Dep.target should be undefined during invocation of child immediate watcher', done => { | ||||
|       let calls = 0 | ||||
|       const childData = { a: 1 } | ||||
|       const parentUpdate = jasmine.createSpy() | ||||
|       const parentUpdate = vi.fn() | ||||
|       new Vue({ | ||||
|         template: '<div><my-component></my-component></div>', | ||||
|         updated: parentUpdate, | ||||
|  | @ -117,13 +117,13 @@ describe('Instance methods lifecycle', () => { | |||
|     }) | ||||
| 
 | ||||
|     it('avoid duplicate calls', () => { | ||||
|       const spy = jasmine.createSpy('destroy') | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         beforeDestroy: spy | ||||
|       }) | ||||
|       vm.$destroy() | ||||
|       vm.$destroy() | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|  |  | |||
|  | @ -168,8 +168,8 @@ describe('Instance properties', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('$listeners', done => { | ||||
|     const spyA = jasmine.createSpy('A') | ||||
|     const spyB = jasmine.createSpy('B') | ||||
|     const spyA = vi.fn() | ||||
|     const spyB = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       template: `<foo @click="foo"/>`, | ||||
|       data: { foo: spyA }, | ||||
|  | @ -184,14 +184,14 @@ describe('Instance properties', () => { | |||
|     document.body.appendChild(vm.$el) | ||||
| 
 | ||||
|     triggerEvent(vm.$el, 'click') | ||||
|     expect(spyA.calls.count()).toBe(1) | ||||
|     expect(spyB.calls.count()).toBe(0) | ||||
|     expect(spyA.mock.calls.length).toBe(1) | ||||
|     expect(spyB.mock.calls.length).toBe(0) | ||||
| 
 | ||||
|     vm.foo = spyB | ||||
|     waitForUpdate(() => { | ||||
|       triggerEvent(vm.$el, 'click') | ||||
|       expect(spyA.calls.count()).toBe(1) | ||||
|       expect(spyB.calls.count()).toBe(1) | ||||
|       expect(spyA.mock.calls.length).toBe(1) | ||||
|       expect(spyB.mock.calls.length).toBe(1) | ||||
|       document.body.removeChild(vm.$el) | ||||
|     }).then(done) | ||||
|   }) | ||||
|  |  | |||
|  | @ -91,7 +91,7 @@ describe('Options computed', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('watching computed', done => { | ||||
|     const spy = jasmine.createSpy('watch computed') | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         a: 1 | ||||
|  | @ -108,7 +108,7 @@ describe('Options computed', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('caching', () => { | ||||
|     const spy = jasmine.createSpy('cached computed') | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         a: 1 | ||||
|  | @ -120,15 +120,15 @@ describe('Options computed', () => { | |||
|         } | ||||
|       } | ||||
|     }) | ||||
|     expect(spy.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(0) | ||||
|     vm.b | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     vm.b | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('cache: false', () => { | ||||
|     const spy = jasmine.createSpy('cached computed') | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         a: 1 | ||||
|  | @ -143,11 +143,11 @@ describe('Options computed', () => { | |||
|         } | ||||
|       } | ||||
|     }) | ||||
|     expect(spy.calls.count()).toBe(0) | ||||
|     expect(spy.mock.calls.length).toBe(0) | ||||
|     vm.b | ||||
|     expect(spy.calls.count()).toBe(1) | ||||
|     expect(spy.mock.calls.length).toBe(1) | ||||
|     vm.b | ||||
|     expect(spy.calls.count()).toBe(2) | ||||
|     expect(spy.mock.calls.length).toBe(2) | ||||
|   }) | ||||
| 
 | ||||
|   it('as component', done => { | ||||
|  |  | |||
|  | @ -2,11 +2,11 @@ import Vue from 'vue' | |||
| 
 | ||||
| describe('Options directives', () => { | ||||
|   it('basic usage', done => { | ||||
|     const bindSpy = jasmine.createSpy('bind') | ||||
|     const insertedSpy = jasmine.createSpy('inserted') | ||||
|     const updateSpy = jasmine.createSpy('update') | ||||
|     const componentUpdatedSpy = jasmine.createSpy('componentUpdated') | ||||
|     const unbindSpy = jasmine.createSpy('unbind') | ||||
|     const bindSpy = vi.fn() | ||||
|     const insertedSpy = vi.fn() | ||||
|     const updateSpy = vi.fn() | ||||
|     const componentUpdatedSpy = vi.fn() | ||||
|     const unbindSpy = vi.fn() | ||||
| 
 | ||||
|     const assertContext = (el, binding, vnode) => { | ||||
|       expect(vnode.context).toBe(vm) | ||||
|  | @ -75,7 +75,7 @@ describe('Options directives', () => { | |||
|       expect(unbindSpy).not.toHaveBeenCalled() | ||||
|       vm.msg = 'bye' | ||||
|     }).then(() => { | ||||
|       expect(componentUpdatedSpy.calls.count()).toBe(2) | ||||
|       expect(componentUpdatedSpy.mock.calls.length).toBe(2) | ||||
|       vm.ok = false | ||||
|     }).then(() => { | ||||
|       expect(unbindSpy).toHaveBeenCalled() | ||||
|  | @ -83,7 +83,7 @@ describe('Options directives', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('function shorthand', done => { | ||||
|     const spy = jasmine.createSpy('directive') | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       template: '<div v-test:arg.hello="a"></div>', | ||||
|       data: { a: 'foo' }, | ||||
|  | @ -105,7 +105,7 @@ describe('Options directives', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('function shorthand (global)', done => { | ||||
|     const spy = jasmine.createSpy('directive') | ||||
|     const spy = vi.fn() | ||||
|     Vue.directive('test', function (el, binding, vnode) { | ||||
|       expect(vnode.context).toBe(vm) | ||||
|       expect(binding.arg).toBe('arg') | ||||
|  | @ -153,7 +153,7 @@ describe('Options directives', () => { | |||
| 
 | ||||
|   it('should properly handle same node with different directive sets', done => { | ||||
|     const spies = {} | ||||
|     const createSpy = name => (spies[name] = jasmine.createSpy(name)) | ||||
|     const createSpy = name => (spies[name] = vi.fn()) | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         ok: true, | ||||
|  | @ -183,41 +183,41 @@ describe('Options directives', () => { | |||
|       } | ||||
|     }).$mount() | ||||
| 
 | ||||
|     expect(spies.bind1.calls.count()).toBe(2) | ||||
|     expect(spies.inserted1.calls.count()).toBe(2) | ||||
|     expect(spies.bind2.calls.count()).toBe(0) | ||||
|     expect(spies.inserted2.calls.count()).toBe(0) | ||||
|     expect(spies.bind1.mock.calls.length).toBe(2) | ||||
|     expect(spies.inserted1.mock.calls.length).toBe(2) | ||||
|     expect(spies.bind2.mock.calls.length).toBe(0) | ||||
|     expect(spies.inserted2.mock.calls.length).toBe(0) | ||||
| 
 | ||||
|     vm.ok = false | ||||
|     waitForUpdate(() => { | ||||
|       // v-test with modifier should be updated
 | ||||
|       expect(spies.update1.calls.count()).toBe(1) | ||||
|       expect(spies.componentUpdated1.calls.count()).toBe(1) | ||||
|       expect(spies.update1.mock.calls.length).toBe(1) | ||||
|       expect(spies.componentUpdated1.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|       // v-test without modifier should be unbound
 | ||||
|       expect(spies.unbind1.calls.count()).toBe(1) | ||||
|       expect(spies.unbind1.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|       // v-test2 should be bound
 | ||||
|       expect(spies.bind2.calls.count()).toBe(1) | ||||
|       expect(spies.inserted2.calls.count()).toBe(1) | ||||
|       expect(spies.bind2.mock.calls.length).toBe(1) | ||||
|       expect(spies.inserted2.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|       vm.ok = true | ||||
|     }).then(() => { | ||||
|       // v-test without modifier should be bound again
 | ||||
|       expect(spies.bind1.calls.count()).toBe(3) | ||||
|       expect(spies.inserted1.calls.count()).toBe(3) | ||||
|       expect(spies.bind1.mock.calls.length).toBe(3) | ||||
|       expect(spies.inserted1.mock.calls.length).toBe(3) | ||||
| 
 | ||||
|       // v-test2 should be unbound
 | ||||
|       expect(spies.unbind2.calls.count()).toBe(1) | ||||
|       expect(spies.unbind2.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|       // v-test with modifier should be updated again
 | ||||
|       expect(spies.update1.calls.count()).toBe(2) | ||||
|       expect(spies.componentUpdated1.calls.count()).toBe(2) | ||||
|       expect(spies.update1.mock.calls.length).toBe(2) | ||||
|       expect(spies.componentUpdated1.mock.calls.length).toBe(2) | ||||
| 
 | ||||
|       vm.val = 234 | ||||
|     }).then(() => { | ||||
|       expect(spies.update1.calls.count()).toBe(4) | ||||
|       expect(spies.componentUpdated1.calls.count()).toBe(4) | ||||
|       expect(spies.update1.mock.calls.length).toBe(4) | ||||
|       expect(spies.componentUpdated1.mock.calls.length).toBe(4) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -231,9 +231,9 @@ describe('Options directives', () => { | |||
|   // #6513
 | ||||
|   it('should invoke unbind & inserted on inner component root element change', done => { | ||||
|     const dir = { | ||||
|       bind: jasmine.createSpy('bind'), | ||||
|       inserted: jasmine.createSpy('inserted'), | ||||
|       unbind: jasmine.createSpy('unbind') | ||||
|       bind: vi.fn(), | ||||
|       inserted: vi.fn(), | ||||
|       unbind: vi.fn() | ||||
|     } | ||||
| 
 | ||||
|     const Child = { | ||||
|  | @ -248,20 +248,20 @@ describe('Options directives', () => { | |||
|     }).$mount() | ||||
| 
 | ||||
|     const oldEl = vm.$el | ||||
|     expect(dir.bind.calls.count()).toBe(1) | ||||
|     expect(dir.bind.mock.calls.length).toBe(1) | ||||
|     expect(dir.bind.calls.argsFor(0)[0]).toBe(oldEl) | ||||
|     expect(dir.inserted.calls.count()).toBe(1) | ||||
|     expect(dir.inserted.mock.calls.length).toBe(1) | ||||
|     expect(dir.inserted.calls.argsFor(0)[0]).toBe(oldEl) | ||||
|     expect(dir.unbind).not.toHaveBeenCalled() | ||||
| 
 | ||||
|     vm.$refs.child.ok = false | ||||
|     waitForUpdate(() => { | ||||
|       expect(vm.$el.tagName).toBe('SPAN') | ||||
|       expect(dir.bind.calls.count()).toBe(2) | ||||
|       expect(dir.bind.mock.calls.length).toBe(2) | ||||
|       expect(dir.bind.calls.argsFor(1)[0]).toBe(vm.$el) | ||||
|       expect(dir.inserted.calls.count()).toBe(2) | ||||
|       expect(dir.inserted.mock.calls.length).toBe(2) | ||||
|       expect(dir.inserted.calls.argsFor(1)[0]).toBe(vm.$el) | ||||
|       expect(dir.unbind.calls.count()).toBe(1) | ||||
|       expect(dir.unbind.mock.calls.length).toBe(1) | ||||
|       expect(dir.unbind.calls.argsFor(0)[0]).toBe(oldEl) | ||||
|     }).then(done) | ||||
|   }) | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ describe('Options errorCaptured', () => { | |||
|   let globalSpy | ||||
| 
 | ||||
|   beforeEach(() => { | ||||
|     globalSpy = Vue.config.errorHandler = jasmine.createSpy() | ||||
|     globalSpy = Vue.config.errorHandler = vi.fn() | ||||
|   }) | ||||
| 
 | ||||
|   afterEach(() => { | ||||
|  | @ -12,7 +12,7 @@ describe('Options errorCaptured', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should capture error from child component', () => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
| 
 | ||||
|     let child | ||||
|     let err | ||||
|  | @ -68,7 +68,7 @@ describe('Options errorCaptured', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should not propagate to global handler when returning true', () => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
| 
 | ||||
|     let child | ||||
|     let err | ||||
|  | @ -249,7 +249,7 @@ describe('Options errorCaptured', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should capture error from watcher', done => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
| 
 | ||||
|     let child | ||||
|     let err | ||||
|  | @ -285,7 +285,7 @@ describe('Options errorCaptured', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should capture promise error from watcher', done => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
| 
 | ||||
|     let child | ||||
|     let err | ||||
|  | @ -323,7 +323,7 @@ describe('Options errorCaptured', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should capture error from immediate watcher', done => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
| 
 | ||||
|     let child | ||||
|     let err | ||||
|  | @ -360,7 +360,7 @@ describe('Options errorCaptured', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should capture promise error from immediate watcher', done => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
| 
 | ||||
|     let child | ||||
|     let err | ||||
|  |  | |||
|  | @ -52,7 +52,7 @@ describe('Options extends', () => { | |||
|     it('should work with global mixins + Object.prototype.watch', done => { | ||||
|       Vue.mixin({}) | ||||
| 
 | ||||
|       const spy = jasmine.createSpy('watch') | ||||
|       const spy = vi.fn() | ||||
|       const A = Vue.extend({ | ||||
|         data: function () { | ||||
|           return { a: 1 } | ||||
|  |  | |||
|  | @ -51,8 +51,8 @@ describe('Options functional', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should expose data.on as listeners', () => { | ||||
|     const foo = jasmine.createSpy('foo') | ||||
|     const bar = jasmine.createSpy('bar') | ||||
|     const foo = vi.fn() | ||||
|     const bar = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       template: '<div><wrap @click="foo" @test="bar"/></div>', | ||||
|       methods: { foo, bar }, | ||||
|  | @ -134,7 +134,7 @@ describe('Options functional', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should let vnode raw data pass through', done => { | ||||
|     const onValid = jasmine.createSpy('valid') | ||||
|     const onValid = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { msg: 'hello' }, | ||||
|       template: `<div>
 | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import Vue from 'vue' | |||
| describe('Options lifecycle hooks', () => { | ||||
|   let spy | ||||
|   beforeEach(() => { | ||||
|     spy = jasmine.createSpy('hook') | ||||
|     spy = vi.fn() | ||||
|   }) | ||||
| 
 | ||||
|   describe('beforeCreate', () => { | ||||
|  | @ -156,8 +156,8 @@ describe('Options lifecycle hooks', () => { | |||
| 
 | ||||
|     // #8076
 | ||||
|     it('should not be called after destroy', done => { | ||||
|       const beforeUpdate = jasmine.createSpy('beforeUpdate') | ||||
|       const destroyed = jasmine.createSpy('destroyed') | ||||
|       const beforeUpdate = vi.fn() | ||||
|       const destroyed = vi.fn() | ||||
| 
 | ||||
|       Vue.component('todo', { | ||||
|         template: '<div>{{todo.done}}</div>', | ||||
|  | @ -240,8 +240,8 @@ describe('Options lifecycle hooks', () => { | |||
| 
 | ||||
|     // #8076
 | ||||
|     it('should not be called after destroy', done => { | ||||
|       const updated = jasmine.createSpy('updated') | ||||
|       const destroyed = jasmine.createSpy('destroyed') | ||||
|       const updated = vi.fn() | ||||
|       const destroyed = vi.fn() | ||||
| 
 | ||||
|       Vue.component('todo', { | ||||
|         template: '<div>{{todo.done}}</div>', | ||||
|  | @ -290,7 +290,7 @@ describe('Options lifecycle hooks', () => { | |||
|       vm.$destroy() | ||||
|       vm.$destroy() | ||||
|       expect(spy).toHaveBeenCalled() | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -308,14 +308,14 @@ describe('Options lifecycle hooks', () => { | |||
|       vm.$destroy() | ||||
|       vm.$destroy() | ||||
|       expect(spy).toHaveBeenCalled() | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|   it('should emit hook events', () => { | ||||
|     const created = jasmine.createSpy() | ||||
|     const mounted = jasmine.createSpy() | ||||
|     const destroyed = jasmine.createSpy() | ||||
|     const created = vi.fn() | ||||
|     const mounted = vi.fn() | ||||
|     const destroyed = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       render () {}, | ||||
|       beforeCreate () { | ||||
|  |  | |||
|  | @ -111,8 +111,8 @@ describe('Options mixins', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should accept further extended constructors as mixins', () => { | ||||
|     const spy1 = jasmine.createSpy('mixinA') | ||||
|     const spy2 = jasmine.createSpy('mixinB') | ||||
|     const spy1 = vi.fn() | ||||
|     const spy2 = vi.fn() | ||||
| 
 | ||||
|     const mixinA = Vue.extend({ | ||||
|       created: spy1, | ||||
|  |  | |||
|  | @ -169,56 +169,56 @@ describe('Options props', () => { | |||
| 
 | ||||
|     it('string', () => { | ||||
|       makeInstance('hello', String) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(123, String) | ||||
|       expect('Expected String with value "123", got Number with value 123').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('number', () => { | ||||
|       makeInstance(123, Number) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance('123', Number) | ||||
|       expect('Expected Number with value 123, got String with value "123"').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('number & boolean', () => { | ||||
|       makeInstance(123, Number) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(false, Number) | ||||
|       expect('Expected Number, got Boolean with value false').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('string & boolean', () => { | ||||
|       makeInstance('hello', String) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(true, String) | ||||
|       expect('Expected String, got Boolean with value true').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('boolean', () => { | ||||
|       makeInstance(true, Boolean) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance('123', Boolean) | ||||
|       expect('Expected Boolean, got String with value "123"').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('function', () => { | ||||
|       makeInstance(() => {}, Function) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(123, Function) | ||||
|       expect('Expected Function, got Number with value 123').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('object', () => { | ||||
|       makeInstance({}, Object) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance([], Object) | ||||
|       expect('Expected Object, got Array').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('array', () => { | ||||
|       makeInstance([], Array) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance({}, Array) | ||||
|       expect('Expected Array, got Object').toHaveBeenWarned() | ||||
|     }) | ||||
|  | @ -226,18 +226,18 @@ describe('Options props', () => { | |||
|     it('primitive wrapper objects', () => { | ||||
|       /* eslint-disable no-new-wrappers */ | ||||
|       makeInstance(new String('s'), String) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(new Number(1), Number) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(new Boolean(true), Boolean) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       /* eslint-enable no-new-wrappers */ | ||||
|     }) | ||||
| 
 | ||||
|     if (hasSymbol) { | ||||
|       it('symbol', () => { | ||||
|         makeInstance(Symbol('foo'), Symbol) | ||||
|         expect(console.error.calls.count()).toBe(0) | ||||
|         expect(console.error.mock.calls.length).toBe(0) | ||||
|         makeInstance({}, Symbol) | ||||
|         expect('Expected Symbol, got Object').toHaveBeenWarned() | ||||
|       }) | ||||
|  | @ -252,12 +252,12 @@ describe('Options props', () => { | |||
|         expect('Expected String, Number, got Symbol').toHaveBeenWarned() | ||||
|       }) | ||||
|     } | ||||
| 	 | ||||
| 
 | ||||
|     if (typeof BigInt !== 'undefined') { | ||||
|       /* global BigInt */ | ||||
|       it('bigint', () => { | ||||
|         makeInstance(BigInt(100), BigInt) | ||||
|         expect(console.error.calls.count()).toBe(0) | ||||
|         expect(console.error.mock.calls.length).toBe(0) | ||||
|         makeInstance({}, BigInt) | ||||
|         expect('Expected BigInt, got Object').toHaveBeenWarned() | ||||
|       }) | ||||
|  | @ -266,28 +266,28 @@ describe('Options props', () => { | |||
|     it('custom constructor', () => { | ||||
|       function Class () {} | ||||
|       makeInstance(new Class(), Class) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance({}, Class) | ||||
|       expect('type check failed').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('multiple types', () => { | ||||
|       makeInstance([], [Array, Number, Boolean]) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance({}, [Array, Number, Boolean]) | ||||
|       expect('Expected Array, Number, Boolean, got Object').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('custom validator', () => { | ||||
|       makeInstance(123, null, v => v === 123) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(123, null, v => v === 234) | ||||
|       expect('custom validator check failed').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('type check + custom validator', () => { | ||||
|       makeInstance(123, Number, v => v === 123) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(123, Number, v => v === 234) | ||||
|       expect('custom validator check failed').toHaveBeenWarned() | ||||
|       makeInstance(123, String, v => v === 123) | ||||
|  | @ -296,7 +296,7 @@ describe('Options props', () => { | |||
| 
 | ||||
|     it('multiple types + custom validator', () => { | ||||
|       makeInstance(123, [Number, String, Boolean], v => v === 123) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(123, [Number, String, Boolean], v => v === 234) | ||||
|       expect('custom validator check failed').toHaveBeenWarned() | ||||
|       makeInstance(123, [String, Boolean], v => v === 123) | ||||
|  | @ -305,31 +305,31 @@ describe('Options props', () => { | |||
| 
 | ||||
|     it('optional with type + null/undefined', () => { | ||||
|       makeInstance(undefined, String) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(null, String) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|     }) | ||||
| 
 | ||||
|     it('required with type + null/undefined', () => { | ||||
|       makeInstance(undefined, String, null, true) | ||||
|       expect(console.error.calls.count()).toBe(1) | ||||
|       expect(console.error.mock.calls.length).toBe(1) | ||||
|       expect('Expected String').toHaveBeenWarned() | ||||
|       makeInstance(null, Boolean, null, true) | ||||
|       expect(console.error.calls.count()).toBe(2) | ||||
|       expect(console.error.mock.calls.length).toBe(2) | ||||
|       expect('Expected Boolean').toHaveBeenWarned() | ||||
|     }) | ||||
| 
 | ||||
|     it('optional prop of any type (type: true or prop: true)', () => { | ||||
|       makeInstance(1, true) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance('any', true) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance({}, true) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(undefined, true) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|       makeInstance(null, true) | ||||
|       expect(console.error.calls.count()).toBe(0) | ||||
|       expect(console.error.mock.calls.length).toBe(0) | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -468,12 +468,12 @@ describe('Options props', () => { | |||
|         } | ||||
|       } | ||||
|     }).$mount() | ||||
|     expect(console.error.calls.count()).toBe(0) | ||||
|     expect(console.error.mock.calls.length).toBe(0) | ||||
|   }) | ||||
| 
 | ||||
|   // #3453
 | ||||
|   it('should not fire watcher on object/array props when parent re-renders', done => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         arr: [] | ||||
|  | @ -497,7 +497,7 @@ describe('Options props', () => { | |||
| 
 | ||||
|   // #4090
 | ||||
|   it('should not trigger watcher on default value', done => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       template: `<test :value="a" :test="b"></test>`, | ||||
|       data: { | ||||
|  | @ -526,14 +526,14 @@ describe('Options props', () => { | |||
|       expect(spy).not.toHaveBeenCalled() | ||||
|       vm.b = {} | ||||
|     }).then(() => { | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|     }).then(() => { | ||||
|       vm.b = undefined | ||||
|     }).then(() => { | ||||
|       expect(spy.calls.count()).toBe(2) | ||||
|       expect(spy.mock.calls.length).toBe(2) | ||||
|       vm.a++ | ||||
|     }).then(() => { | ||||
|       expect(spy.calls.count()).toBe(2) | ||||
|       expect(spy.mock.calls.length).toBe(2) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  |  | |||
|  | @ -27,7 +27,7 @@ describe('Options renderError', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('should pass on errors in renderError to global handler', () => { | ||||
|     const spy = Vue.config.errorHandler = jasmine.createSpy() | ||||
|     const spy = Vue.config.errorHandler = vi.fn() | ||||
|     const err = new Error('renderError') | ||||
|     const vm = new Vue({ | ||||
|       render () { | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ import { finished } from 'stream'; | |||
| describe('Options watch', () => { | ||||
|   let spy | ||||
|   beforeEach(() => { | ||||
|     spy = jasmine.createSpy('watch') | ||||
|     spy = vi.fn() | ||||
|   }) | ||||
| 
 | ||||
|   testObjectOption('watch') | ||||
|  | @ -48,7 +48,7 @@ describe('Options watch', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('multiple cbs (after option merge)', done => { | ||||
|     const spy1 = jasmine.createSpy('watch') | ||||
|     const spy1 = vi.fn() | ||||
|     const Test = Vue.extend({ | ||||
|       watch: { | ||||
|         a: spy1 | ||||
|  | @ -107,8 +107,8 @@ describe('Options watch', () => { | |||
|   }) | ||||
| 
 | ||||
|   it('correctly merges multiple extends', done => { | ||||
|     const spy2 = jasmine.createSpy('A') | ||||
|     const spy3 = jasmine.createSpy('B') | ||||
|     const spy2 = vi.fn() | ||||
|     const spy3 = vi.fn() | ||||
|     const A = Vue.extend({ | ||||
|       data: function () { | ||||
|         return { | ||||
|  |  | |||
|  | @ -177,9 +177,9 @@ if (!isIE9) { | |||
| 
 | ||||
|     it('events', done => { | ||||
|       let next | ||||
|       const beforeEnterSpy = jasmine.createSpy() | ||||
|       const afterEnterSpy = jasmine.createSpy() | ||||
|       const afterLeaveSpy = jasmine.createSpy() | ||||
|       const beforeEnterSpy = vi.fn() | ||||
|       const afterEnterSpy = vi.fn() | ||||
|       const afterLeaveSpy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: ` | ||||
|           <div> | ||||
|  | @ -219,7 +219,7 @@ if (!isIE9) { | |||
|             `<div class="test v-enter v-enter-active">d</div>` + | ||||
|           `</span>` | ||||
|         ) | ||||
|         expect(beforeEnterSpy.calls.count()).toBe(1) | ||||
|         expect(beforeEnterSpy.mock.calls.length).toBe(1) | ||||
|       }).thenWaitFor(_next => { next = _next }).then(() => { | ||||
|         expect(vm.$el.innerHTML).toBe( | ||||
|           `<span>` + | ||||
|  | @ -229,7 +229,7 @@ if (!isIE9) { | |||
|             `<div class="test">d</div>` + | ||||
|           `</span>` | ||||
|         ) | ||||
|         expect(afterEnterSpy.calls.count()).toBe(1) | ||||
|         expect(afterEnterSpy.mock.calls.length).toBe(1) | ||||
|         vm.items.shift() | ||||
|       }).thenWaitFor(_next => { next = _next }).then(() => { | ||||
|         expect(vm.$el.innerHTML).toBe( | ||||
|  | @ -239,7 +239,7 @@ if (!isIE9) { | |||
|             `<div class="test">d</div>` + | ||||
|           `</span>` | ||||
|         ) | ||||
|         expect(afterLeaveSpy.calls.count()).toBe(1) | ||||
|         expect(afterLeaveSpy.mock.calls.length).toBe(1) | ||||
|       }).then(done) | ||||
|     }) | ||||
| 
 | ||||
|  |  | |||
|  | @ -137,8 +137,8 @@ if (!isIE9) { | |||
|     }) | ||||
| 
 | ||||
|     it('inline transition object', done => { | ||||
|       const enter = jasmine.createSpy('enter') | ||||
|       const leave = jasmine.createSpy('leave') | ||||
|       const enter = vi.fn() | ||||
|       const leave = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         render (h) { | ||||
|           return h('div', null, [ | ||||
|  | @ -184,12 +184,12 @@ if (!isIE9) { | |||
|     }) | ||||
| 
 | ||||
|     it('transition events', done => { | ||||
|       const onLeaveSpy = jasmine.createSpy('leave') | ||||
|       const onEnterSpy = jasmine.createSpy('enter') | ||||
|       const beforeLeaveSpy = jasmine.createSpy('beforeLeave') | ||||
|       const beforeEnterSpy = jasmine.createSpy('beforeEnter') | ||||
|       const afterLeaveSpy = jasmine.createSpy('afterLeave') | ||||
|       const afterEnterSpy = jasmine.createSpy('afterEnter') | ||||
|       const onLeaveSpy = vi.fn() | ||||
|       const onEnterSpy = vi.fn() | ||||
|       const beforeLeaveSpy = vi.fn() | ||||
|       const beforeEnterSpy = vi.fn() | ||||
|       const afterLeaveSpy = vi.fn() | ||||
|       const afterEnterSpy = vi.fn() | ||||
| 
 | ||||
|       const vm = new Vue({ | ||||
|         template: ` | ||||
|  | @ -259,12 +259,12 @@ if (!isIE9) { | |||
|     }) | ||||
| 
 | ||||
|     it('transition events (v-show)', done => { | ||||
|       const onLeaveSpy = jasmine.createSpy('leave') | ||||
|       const onEnterSpy = jasmine.createSpy('enter') | ||||
|       const beforeLeaveSpy = jasmine.createSpy('beforeLeave') | ||||
|       const beforeEnterSpy = jasmine.createSpy('beforeEnter') | ||||
|       const afterLeaveSpy = jasmine.createSpy('afterLeave') | ||||
|       const afterEnterSpy = jasmine.createSpy('afterEnter') | ||||
|       const onLeaveSpy = vi.fn() | ||||
|       const onEnterSpy = vi.fn() | ||||
|       const beforeLeaveSpy = vi.fn() | ||||
|       const beforeEnterSpy = vi.fn() | ||||
|       const afterLeaveSpy = vi.fn() | ||||
|       const afterEnterSpy = vi.fn() | ||||
| 
 | ||||
|       const vm = new Vue({ | ||||
|         template: ` | ||||
|  | @ -386,8 +386,8 @@ if (!isIE9) { | |||
|     }) | ||||
| 
 | ||||
|     it('css: false', done => { | ||||
|       const enterSpy = jasmine.createSpy('enter') | ||||
|       const leaveSpy = jasmine.createSpy('leave') | ||||
|       const enterSpy = vi.fn() | ||||
|       const leaveSpy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: ` | ||||
|           <div> | ||||
|  | @ -415,8 +415,8 @@ if (!isIE9) { | |||
|     }) | ||||
| 
 | ||||
|     it('no transition detected', done => { | ||||
|       const enterSpy = jasmine.createSpy('enter') | ||||
|       const leaveSpy = jasmine.createSpy('leave') | ||||
|       const enterSpy = vi.fn() | ||||
|       const leaveSpy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: '<div><transition name="nope" @enter="enter" @leave="leave"><div v-if="ok">foo</div></transition></div>', | ||||
|         data: { ok: true }, | ||||
|  | @ -442,7 +442,7 @@ if (!isIE9) { | |||
|     }) | ||||
| 
 | ||||
|     it('enterCancelled', done => { | ||||
|       const spy = jasmine.createSpy('enterCancelled') | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: ` | ||||
|           <div> | ||||
|  | @ -476,7 +476,7 @@ if (!isIE9) { | |||
|     }) | ||||
| 
 | ||||
|     it('should remove stale leaving elements', done => { | ||||
|       const spy = jasmine.createSpy('afterLeave') | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: ` | ||||
|           <div> | ||||
|  | @ -579,7 +579,7 @@ if (!isIE9) { | |||
|     }) | ||||
| 
 | ||||
|     it('leaveCancelled (v-show only)', done => { | ||||
|       const spy = jasmine.createSpy('leaveCancelled') | ||||
|       const spy = vi.fn() | ||||
|       const vm = new Vue({ | ||||
|         template: ` | ||||
|           <div> | ||||
|  |  | |||
|  | @ -622,7 +622,7 @@ describe('codegen', () => { | |||
|       `with(this){return _c("myComponent",{tag:"div"})}` | ||||
|     ) | ||||
|     expect('Inline-template components must have exactly one child element.').toHaveBeenWarned() | ||||
|     expect(console.error.calls.count()).toBe(3) | ||||
|     expect(console.error.mock.calls.length).toBe(3) | ||||
|   }) | ||||
| 
 | ||||
|   it('generate static trees inside v-for', () => { | ||||
|  |  | |||
|  | @ -676,8 +676,8 @@ describe('parser', () => { | |||
| 
 | ||||
|   it('pre/post transforms', () => { | ||||
|     const options = extend({}, baseOptions) | ||||
|     const spy1 = jasmine.createSpy('preTransform') | ||||
|     const spy2 = jasmine.createSpy('postTransform') | ||||
|     const spy1 = vi.fn() | ||||
|     const spy2 = vi.fn() | ||||
|     options.modules = options.modules.concat([{ | ||||
|       preTransformNode (el) { | ||||
|         spy1(el.tag) | ||||
|  |  | |||
|  | @ -187,7 +187,7 @@ describe('Observer', () => { | |||
|         this.deps.push(dep) | ||||
|         dep.addSub(this) | ||||
|       }, | ||||
|       update: jasmine.createSpy() | ||||
|       update: vi.fn() | ||||
|     } | ||||
|     // collect dep
 | ||||
|     Dep.target = watcher | ||||
|  | @ -195,10 +195,10 @@ describe('Observer', () => { | |||
|     Dep.target = null | ||||
|     expect(watcher.deps.length).toBe(3) // obj.a + a + a.b
 | ||||
|     obj.a.b = 3 | ||||
|     expect(watcher.update.calls.count()).toBe(1) | ||||
|     expect(watcher.update.mock.calls.length).toBe(1) | ||||
|     // swap object
 | ||||
|     obj.a = { b: 4 } | ||||
|     expect(watcher.update.calls.count()).toBe(2) | ||||
|     expect(watcher.update.mock.calls.length).toBe(2) | ||||
|     watcher.deps = [] | ||||
| 
 | ||||
|     Dep.target = watcher | ||||
|  | @ -208,10 +208,10 @@ describe('Observer', () => { | |||
|     expect(watcher.deps.length).toBe(4) | ||||
|     // set on the swapped object
 | ||||
|     obj.a.b = 5 | ||||
|     expect(watcher.update.calls.count()).toBe(3) | ||||
|     expect(watcher.update.mock.calls.length).toBe(3) | ||||
|     // should not trigger on NaN -> NaN set
 | ||||
|     obj.c = NaN | ||||
|     expect(watcher.update.calls.count()).toBe(3) | ||||
|     expect(watcher.update.mock.calls.length).toBe(3) | ||||
|   }) | ||||
| 
 | ||||
|   it('observing object prop change on defined property', () => { | ||||
|  | @ -242,22 +242,22 @@ describe('Observer', () => { | |||
|     spyOn(dep1, 'notify') | ||||
|     setProp(obj1, 'b', 2) | ||||
|     expect(obj1.b).toBe(2) | ||||
|     expect(dep1.notify.calls.count()).toBe(1) | ||||
|     expect(dep1.notify.mock.calls.length).toBe(1) | ||||
|     delProp(obj1, 'a') | ||||
|     expect(hasOwn(obj1, 'a')).toBe(false) | ||||
|     expect(dep1.notify.calls.count()).toBe(2) | ||||
|     expect(dep1.notify.mock.calls.length).toBe(2) | ||||
|     // set existing key, should be a plain set and not
 | ||||
|     // trigger own ob's notify
 | ||||
|     setProp(obj1, 'b', 3) | ||||
|     expect(obj1.b).toBe(3) | ||||
|     expect(dep1.notify.calls.count()).toBe(2) | ||||
|     expect(dep1.notify.mock.calls.length).toBe(2) | ||||
|     // set non-existing key
 | ||||
|     setProp(obj1, 'c', 1) | ||||
|     expect(obj1.c).toBe(1) | ||||
|     expect(dep1.notify.calls.count()).toBe(3) | ||||
|     expect(dep1.notify.mock.calls.length).toBe(3) | ||||
|     // should ignore deleting non-existing key
 | ||||
|     delProp(obj1, 'a') | ||||
|     expect(dep1.notify.calls.count()).toBe(3) | ||||
|     expect(dep1.notify.mock.calls.length).toBe(3) | ||||
|     // should work on non-observed objects
 | ||||
|     const obj2 = { a: 1 } | ||||
|     delProp(obj2, 'a') | ||||
|  | @ -270,10 +270,10 @@ describe('Observer', () => { | |||
|     spyOn(dep3, 'notify') | ||||
|     setProp(obj3, 'b', 2) | ||||
|     expect(obj3.b).toBe(2) | ||||
|     expect(dep3.notify.calls.count()).toBe(1) | ||||
|     expect(dep3.notify.mock.calls.length).toBe(1) | ||||
|     delProp(obj3, 'a') | ||||
|     expect(hasOwn(obj3, 'a')).toBe(false) | ||||
|     expect(dep3.notify.calls.count()).toBe(2) | ||||
|     expect(dep3.notify.mock.calls.length).toBe(2) | ||||
|     // set and delete non-numeric key on array
 | ||||
|     const arr2 = ['a'] | ||||
|     const ob2 = observe(arr2) | ||||
|  | @ -281,10 +281,10 @@ describe('Observer', () => { | |||
|     spyOn(dep2, 'notify') | ||||
|     setProp(arr2, 'b', 2) | ||||
|     expect(arr2.b).toBe(2) | ||||
|     expect(dep2.notify.calls.count()).toBe(1) | ||||
|     expect(dep2.notify.mock.calls.length).toBe(1) | ||||
|     delProp(arr2, 'b') | ||||
|     expect(hasOwn(arr2, 'b')).toBe(false) | ||||
|     expect(dep2.notify.calls.count()).toBe(2) | ||||
|     expect(dep2.notify.mock.calls.length).toBe(2) | ||||
|   }) | ||||
| 
 | ||||
|   it('warning set/delete on a Vue instance', done => { | ||||
|  | @ -339,7 +339,7 @@ describe('Observer', () => { | |||
|     arr.splice(0, 0, objs[2]) | ||||
|     arr.sort() | ||||
|     arr.reverse() | ||||
|     expect(dep.notify.calls.count()).toBe(7) | ||||
|     expect(dep.notify.mock.calls.length).toBe(7) | ||||
|     // inserted elements should be observed
 | ||||
|     objs.forEach(obj => { | ||||
|       expect(obj.__ob__ instanceof Observer).toBe(true) | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ function queueWatcher (watcher) { | |||
| describe('Scheduler', () => { | ||||
|   let spy | ||||
|   beforeEach(() => { | ||||
|     spy = jasmine.createSpy('scheduler') | ||||
|     spy = vi.fn() | ||||
|   }) | ||||
| 
 | ||||
|   it('queueWatcher', done => { | ||||
|  | @ -20,7 +20,7 @@ describe('Scheduler', () => { | |||
|       run: spy | ||||
|     }) | ||||
|     waitForUpdate(() => { | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -34,7 +34,7 @@ describe('Scheduler', () => { | |||
|       run: spy | ||||
|     }) | ||||
|     waitForUpdate(() => { | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -49,7 +49,7 @@ describe('Scheduler', () => { | |||
|       run () { queueWatcher(job) } | ||||
|     }) | ||||
|     waitForUpdate(() => { | ||||
|       expect(spy.calls.count()).toBe(2) | ||||
|       expect(spy.mock.calls.length).toBe(2) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ describe('Watcher', () => { | |||
|         msg: 'yo' | ||||
|       } | ||||
|     }).$mount() | ||||
|     spy = jasmine.createSpy('watcher') | ||||
|     spy = vi.fn() | ||||
|   }) | ||||
| 
 | ||||
|   it('path', done => { | ||||
|  | @ -44,7 +44,7 @@ describe('Watcher', () => { | |||
|     waitForUpdate(() => { | ||||
|       expect(watcher1.value).toBe(123) | ||||
|       expect(watcher2.value).toBeUndefined() | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       expect(spy).toHaveBeenCalledWith(123, undefined) | ||||
|     }).then(done) | ||||
|   }) | ||||
|  | @ -85,11 +85,11 @@ describe('Watcher', () => { | |||
|       vm.b = { c: [{ a: 1 }] } | ||||
|     }).then(() => { | ||||
|       expect(spy).toHaveBeenCalledWith(vm.b, oldB) | ||||
|       expect(spy.calls.count()).toBe(2) | ||||
|       expect(spy.mock.calls.length).toBe(2) | ||||
|       vm.b.c[0].a = 2 | ||||
|     }).then(() => { | ||||
|       expect(spy).toHaveBeenCalledWith(vm.b, vm.b) | ||||
|       expect(spy.calls.count()).toBe(3) | ||||
|       expect(spy.mock.calls.length).toBe(3) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -110,11 +110,11 @@ describe('Watcher', () => { | |||
|     Vue.set(vm.b, '_', vm.b) | ||||
|     waitForUpdate(() => { | ||||
|       expect(spy).toHaveBeenCalledWith(vm.b, vm.b) | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       vm.b._.c = 1 | ||||
|     }).then(() => { | ||||
|       expect(spy).toHaveBeenCalledWith(vm.b, vm.b) | ||||
|       expect(spy.calls.count()).toBe(2) | ||||
|       expect(spy.mock.calls.length).toBe(2) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  | @ -123,10 +123,10 @@ describe('Watcher', () => { | |||
|     Vue.set(vm.b, 'e', 123) | ||||
|     waitForUpdate(() => { | ||||
|       expect(spy).toHaveBeenCalledWith(vm.b, vm.b) | ||||
|       expect(spy.calls.count()).toBe(1) | ||||
|       expect(spy.mock.calls.length).toBe(1) | ||||
|       Vue.delete(vm.b, 'e') | ||||
|     }).then(() => { | ||||
|       expect(spy.calls.count()).toBe(2) | ||||
|       expect(spy.mock.calls.length).toBe(2) | ||||
|     }).then(done) | ||||
|   }) | ||||
| 
 | ||||
|  |  | |||
|  | @ -5,8 +5,8 @@ describe('invokeWithErrorHandling', () => { | |||
|   if (typeof Promise !== 'undefined') { | ||||
|     it('should errorHandler call once when nested calls return rejected promise', done => { | ||||
|       const originalHandler = Vue.config.errorHandler | ||||
|       const handler = Vue.config.errorHandler = jasmine.createSpy() | ||||
|       const userCatch = jasmine.createSpy() | ||||
|       const handler = Vue.config.errorHandler = vi.fn() | ||||
|       const userCatch = vi.fn() | ||||
|       const err = new Error('fake error') | ||||
| 
 | ||||
|       invokeWithErrorHandling(() => { | ||||
|  | @ -15,7 +15,7 @@ describe('invokeWithErrorHandling', () => { | |||
|         }) | ||||
|       }).catch(userCatch).then(() => { | ||||
|         Vue.config.errorHandler = originalHandler | ||||
|         expect(handler.calls.count()).toBe(1) | ||||
|         expect(handler.mock.calls.length).toBe(1) | ||||
|         expect(userCatch).toHaveBeenCalledWith(err) | ||||
|         done() | ||||
|       }) | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ describe('nextTick', () => { | |||
|     }) | ||||
| 
 | ||||
|     it('returned Promise should resolve correctly vs callback', done => { | ||||
|       const spy = jasmine.createSpy() | ||||
|       const spy = vi.fn() | ||||
|       nextTick(spy) | ||||
|       nextTick().then(() => { | ||||
|         expect(spy).toHaveBeenCalled() | ||||
|  |  | |||
|  | @ -5,9 +5,9 @@ import VNode from 'core/vdom/vnode' | |||
| describe('vdom directive module', () => { | ||||
|   it('should work', () => { | ||||
|     const directive1 = { | ||||
|       bind: jasmine.createSpy('bind'), | ||||
|       update: jasmine.createSpy('update'), | ||||
|       unbind: jasmine.createSpy('unbind') | ||||
|       bind: vi.fn(), | ||||
|       update: vi.fn(), | ||||
|       unbind: vi.fn() | ||||
|     } | ||||
|     const vm = new Vue({ directives: { directive1 }}) | ||||
|     // create
 | ||||
|  |  | |||
|  | @ -3,17 +3,17 @@ import VNode from 'core/vdom/vnode' | |||
| 
 | ||||
| describe('vdom events module', () => { | ||||
|   it('should attach event handler to element', () => { | ||||
|     const click = jasmine.createSpy() | ||||
|     const click = vi.fn() | ||||
|     const vnode = new VNode('a', { on: { click }}) | ||||
| 
 | ||||
|     const elm = patch(null, vnode) | ||||
|     document.body.appendChild(elm) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('should not duplicate the same listener', () => { | ||||
|     const click = jasmine.createSpy() | ||||
|     const click = vi.fn() | ||||
|     const vnode1 = new VNode('a', { on: { click }}) | ||||
|     const vnode2 = new VNode('a', { on: { click }}) | ||||
| 
 | ||||
|  | @ -21,90 +21,90 @@ describe('vdom events module', () => { | |||
|     patch(vnode1, vnode2) | ||||
|     document.body.appendChild(elm) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('should update different listener', () => { | ||||
|     const click = jasmine.createSpy() | ||||
|     const click2 = jasmine.createSpy() | ||||
|     const click = vi.fn() | ||||
|     const click2 = vi.fn() | ||||
|     const vnode1 = new VNode('a', { on: { click }}) | ||||
|     const vnode2 = new VNode('a', { on: { click: click2 }}) | ||||
| 
 | ||||
|     const elm = patch(null, vnode1) | ||||
|     document.body.appendChild(elm) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(click2.calls.count()).toBe(0) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|     expect(click2.mock.calls.length).toBe(0) | ||||
| 
 | ||||
|     patch(vnode1, vnode2) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(click2.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|     expect(click2.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('should attach Array of multiple handlers', () => { | ||||
|     const click = jasmine.createSpy() | ||||
|     const click = vi.fn() | ||||
|     const vnode = new VNode('a', { on: { click: [click, click] }}) | ||||
| 
 | ||||
|     const elm = patch(null, vnode) | ||||
|     document.body.appendChild(elm) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(2) | ||||
|     expect(click.mock.calls.length).toBe(2) | ||||
|   }) | ||||
| 
 | ||||
|   it('should update Array of multiple handlers', () => { | ||||
|     const click = jasmine.createSpy() | ||||
|     const click2 = jasmine.createSpy() | ||||
|     const click = vi.fn() | ||||
|     const click2 = vi.fn() | ||||
|     const vnode1 = new VNode('a', { on: { click: [click, click2] }}) | ||||
|     const vnode2 = new VNode('a', { on: { click: [click] }}) | ||||
| 
 | ||||
|     const elm = patch(null, vnode1) | ||||
|     document.body.appendChild(elm) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(click2.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|     expect(click2.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|     patch(vnode1, vnode2) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(2) | ||||
|     expect(click2.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(2) | ||||
|     expect(click2.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('should remove handlers that are no longer present', () => { | ||||
|     const click = jasmine.createSpy() | ||||
|     const click = vi.fn() | ||||
|     const vnode1 = new VNode('a', { on: { click }}) | ||||
|     const vnode2 = new VNode('a', {}) | ||||
| 
 | ||||
|     const elm = patch(null, vnode1) | ||||
|     document.body.appendChild(elm) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|     patch(vnode1, vnode2) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| 
 | ||||
|   it('should remove Array handlers that are no longer present', () => { | ||||
|     const click = jasmine.createSpy() | ||||
|     const click = vi.fn() | ||||
|     const vnode1 = new VNode('a', { on: { click: [click, click] }}) | ||||
|     const vnode2 = new VNode('a', {}) | ||||
| 
 | ||||
|     const elm = patch(null, vnode1) | ||||
|     document.body.appendChild(elm) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(2) | ||||
|     expect(click.mock.calls.length).toBe(2) | ||||
| 
 | ||||
|     patch(vnode1, vnode2) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(2) | ||||
|     expect(click.mock.calls.length).toBe(2) | ||||
|   }) | ||||
| 
 | ||||
|   // #4650
 | ||||
|   it('should handle single -> array or array -> single handler changes', () => { | ||||
|     const click = jasmine.createSpy() | ||||
|     const click2 = jasmine.createSpy() | ||||
|     const click3 = jasmine.createSpy() | ||||
|     const click = vi.fn() | ||||
|     const click2 = vi.fn() | ||||
|     const click3 = vi.fn() | ||||
|     const vnode0 = new VNode('a', { on: { click: click }}) | ||||
|     const vnode1 = new VNode('a', { on: { click: [click, click2] }}) | ||||
|     const vnode2 = new VNode('a', { on: { click: click }}) | ||||
|  | @ -113,23 +113,23 @@ describe('vdom events module', () => { | |||
|     const elm = patch(null, vnode0) | ||||
|     document.body.appendChild(elm) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(1) | ||||
|     expect(click2.calls.count()).toBe(0) | ||||
|     expect(click.mock.calls.length).toBe(1) | ||||
|     expect(click2.mock.calls.length).toBe(0) | ||||
| 
 | ||||
|     patch(vnode0, vnode1) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(2) | ||||
|     expect(click2.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(2) | ||||
|     expect(click2.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|     patch(vnode1, vnode2) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(3) | ||||
|     expect(click2.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(3) | ||||
|     expect(click2.mock.calls.length).toBe(1) | ||||
| 
 | ||||
|     patch(vnode2, vnode3) | ||||
|     global.triggerEvent(elm, 'click') | ||||
|     expect(click.calls.count()).toBe(3) | ||||
|     expect(click2.calls.count()).toBe(2) | ||||
|     expect(click3.calls.count()).toBe(1) | ||||
|     expect(click.mock.calls.length).toBe(3) | ||||
|     expect(click2.mock.calls.length).toBe(2) | ||||
|     expect(click3.mock.calls.length).toBe(1) | ||||
|   }) | ||||
| }) | ||||
|  |  | |||
|  | @ -270,7 +270,7 @@ describe('vdom patch: edge cases', () => { | |||
| 
 | ||||
|   // #6803
 | ||||
|   it('backwards compat with checkbox code generated before 2.4', () => { | ||||
|     const spy = jasmine.createSpy() | ||||
|     const spy = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { | ||||
|         label: 'foobar', | ||||
|  | @ -339,7 +339,7 @@ describe('vdom patch: edge cases', () => { | |||
| 
 | ||||
|   // #7294
 | ||||
|   it('should cleanup component inline events on patch when no events are present', done => { | ||||
|     const log = jasmine.createSpy() | ||||
|     const log = vi.fn() | ||||
|     const vm = new Vue({ | ||||
|       data: { ok: true }, | ||||
|       template: ` | ||||
|  | @ -393,7 +393,7 @@ describe('vdom patch: edge cases', () => { | |||
| 
 | ||||
|     // sometimes we do need to tap into these internal hooks (e.g. in vue-router)
 | ||||
|     // so make sure it does work
 | ||||
|     const inlineHookSpy = jasmine.createSpy('inlineInit') | ||||
|     const inlineHookSpy = vi.fn() | ||||
| 
 | ||||
|     const vm = new Vue({ | ||||
|       render (h) { | ||||
|  | @ -409,7 +409,7 @@ describe('vdom patch: edge cases', () => { | |||
|     }).$mount() | ||||
| 
 | ||||
|     expect(vm.$el.textContent).toBe('FooBar') | ||||
|     expect(inlineHookSpy.calls.count()).toBe(2) | ||||
|     expect(inlineHookSpy.mock.calls.length).toBe(2) | ||||
|   }) | ||||
| 
 | ||||
|   // #9549
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue