Skip to content

Commit

Permalink
test: test case for #3300, #3301
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 25, 2021
1 parent e3568ba commit 75964ab
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/runtime-core/__tests__/apiOptions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,26 @@ 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
}
},
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
)
Expand All @@ -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 () => {
Expand Down

0 comments on commit 75964ab

Please sign in to comment.