From 0ff055c81e38867423399361a216961694350507 Mon Sep 17 00:00:00 2001 From: Thorsten Luenborg Date: Fri, 26 Nov 2021 08:52:16 +0100 Subject: [PATCH] test: Add test case --- packages/vue-compat/__tests__/global.spec.ts | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/vue-compat/__tests__/global.spec.ts b/packages/vue-compat/__tests__/global.spec.ts index 86bb4391092..06109a67f64 100644 --- a/packages/vue-compat/__tests__/global.spec.ts +++ b/packages/vue-compat/__tests__/global.spec.ts @@ -285,6 +285,28 @@ describe('GLOBAL_PROTOTYPE', () => { delete Vue.prototype.$test }) + test.only('functions keeps additional properties', () => { + function test(this: any) { + return this.msg + } + test.additionalFn = () => { + return 'additional fn' + } + + Vue.prototype.$test = test + const vm = new Vue({ + data() { + return { + msg: 'test' + } + } + }) as any + expect(typeof vm.$test).toBe('function') + expect(typeof vm.$test.additionalFn).toBe('function') + expect(vm.$test.additionalFn()).toBe('additional fn') + delete Vue.prototype.$test + }) + test('extended prototype', async () => { const Foo = Vue.extend() Foo.prototype.$test = 1