Skip to content

Commit 3f9aebf

Browse files
rahulcsafontcu
authored andcommitted
docs: Add example for 'listeners' mount option
1 parent 089a6ca commit 3f9aebf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/api/options.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,23 @@ Please see [Other options](#other-options).
270270

271271
Set the component instance's `$listeners` object.
272272

273+
Example:
274+
275+
```js
276+
const Component = {
277+
template: '<button v-on:click="$emit(\'click\')"></button>'
278+
}
279+
const onClick = jest.fn()
280+
const wrapper = mount(Component, {
281+
listeners: {
282+
click: onClick
283+
}
284+
})
285+
286+
wrapper.trigger('click')
287+
expect(onClick).toHaveBeenCalled()
288+
```
289+
273290
## parentComponent
274291

275292
- type: `Object`

0 commit comments

Comments
 (0)