import Vue from '@vue/compat' import { nextTick } from '@vue/runtime-core' import { CompilerDeprecationTypes } from '../../compiler-core/src' import { toggleDeprecationWarning } from '../../runtime-core/src/compat/compatConfig' import { triggerEvent } from './utils' beforeEach(() => { toggleDeprecationWarning(false) Vue.configureCompat({ MODE: 2 }) }) afterEach(() => { toggleDeprecationWarning(false) Vue.configureCompat({ MODE: 3 }) }) // COMPILER_V_FOR_REF is tested in ./refInfor.spec.ts // COMPILER_FILTERS is tested in ./filters.spec.ts test('COMPILER_IS_ON_ELEMENT', () => { const MyButton = { template: `
` } const vm = new Vue({ template: ``, components: { MyButton } }).$mount() expect(vm.$el.outerHTML).toBe(`
text
`) expect(CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT).toHaveBeenWarned() }) test('COMPILER_IS_ON_ELEMENT (dynamic)', () => { const MyButton = { template: `
` } const vm = new Vue({ template: ``, components: { MyButton } }).$mount() expect(vm.$el.outerHTML).toBe(`
text
`) expect(CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT).toHaveBeenWarned() }) test('COMPILER_V_BIND_SYNC', async () => { const MyButton = { props: ['foo'], template: `` } const vm = new Vue({ data() { return { foo: 0 } }, template: ``, components: { MyButton } }).$mount() expect(vm.$el.textContent).toBe(`0`) triggerEvent(vm.$el, 'click') await nextTick() expect(vm.$el.textContent).toBe(`1`) expect(CompilerDeprecationTypes.COMPILER_V_BIND_SYNC).toHaveBeenWarned() }) test('COMPILER_V_BIND_PROP', () => { const vm = new Vue({ template: `
` }).$mount() expect(vm.$el.id).toBe('foo') expect(CompilerDeprecationTypes.COMPILER_V_BIND_PROP).toHaveBeenWarned() }) test('COMPILER_V_BIND_OBJECT_ORDER', () => { const vm = new Vue({ template: `
` }).$mount() expect(vm.$el.id).toBe('foo') expect(vm.$el.className).toBe('baz') expect( CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER ).toHaveBeenWarned() }) test('COMPILER_V_ON_NATIVE', () => { const spy = jest.fn() const vm = new Vue({ template: ``, components: { child: { template: `