]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: test case for #3300, #3301
authorEvan You <yyx990803@gmail.com>
Thu, 25 Feb 2021 14:07:49 +0000 (09:07 -0500)
committerEvan You <yyx990803@gmail.com>
Thu, 25 Feb 2021 14:07:49 +0000 (09:07 -0500)
packages/runtime-core/__tests__/apiOptions.spec.ts

index 3130041027277556c6ece0e724e7bba5539871e6..41ce25fdfae6d4d78fec242005b67cdadd238551 100644 (file)
@@ -78,6 +78,8 @@ describe('api: options', () => {
   test('methods', async () => {
     const Comp = defineComponent({
       data() {
+        // #3300 method on ctx should be overwritable
+        this.incBy = this.incBy.bind(this, 2)
         return {
           foo: 1
         }
@@ -85,13 +87,17 @@ describe('api: options', () => {
       methods: {
         inc() {
           this.foo++
+        },
+        incBy(n = 0) {
+          this.foo += n
         }
       },
       render() {
         return h(
           'div',
           {
-            onClick: this.inc
+            onClick: this.inc,
+            onFoo: this.incBy
           },
           this.foo
         )
@@ -104,6 +110,10 @@ describe('api: options', () => {
     triggerEvent(root.children[0] as TestElement, 'click')
     await nextTick()
     expect(serializeInner(root)).toBe(`<div>2</div>`)
+
+    triggerEvent(root.children[0] as TestElement, 'foo')
+    await nextTick()
+    expect(serializeInner(root)).toBe(`<div>4</div>`)
   })
 
   test('component’s own methods have higher priority than global properties', async () => {