@@ -2,7 +2,8 @@ import ComponentWithEvents from '~resources/components/component-with-events.vue
2
2
import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue'
3
3
import {
4
4
describeWithShallowAndMount ,
5
- scopedSlotsSupported
5
+ scopedSlotsSupported ,
6
+ isRunningPhantomJS
6
7
} from '~resources/utils'
7
8
import Vue from 'vue'
8
9
import { itDoNotRunIf } from 'conditional-specs'
@@ -92,7 +93,9 @@ describeWithShallowAndMount('trigger', mountingMethod => {
92
93
propsData : { clickHandler }
93
94
} )
94
95
const button = wrapper . find ( '.left-click' )
95
- button . trigger ( 'mousedown' )
96
+ button . trigger ( 'mousedown' , {
97
+ button : 1
98
+ } )
96
99
button . trigger ( 'mousedown' , {
97
100
button : 0
98
101
} )
@@ -180,4 +183,35 @@ describeWithShallowAndMount('trigger', mountingMethod => {
180
183
. with . property ( 'message' , message )
181
184
} )
182
185
} )
186
+
187
+ itDoNotRunIf (
188
+ isRunningPhantomJS ,
189
+ 'trigger should create events with correct interface' , ( ) => {
190
+ let lastEvent
191
+ const TestComponent = {
192
+ template : `
193
+ <div @click="updateLastEvent" />
194
+ ` ,
195
+ methods : {
196
+ updateLastEvent ( event ) {
197
+ lastEvent = event
198
+ }
199
+ }
200
+ }
201
+
202
+ const wrapper = mountingMethod ( TestComponent )
203
+
204
+ wrapper . trigger ( 'click' )
205
+ expect ( lastEvent ) . to . be . an . instanceof ( window . MouseEvent )
206
+ } )
207
+
208
+ it ( 'falls back to supported event if not supported by browser' , ( ) => {
209
+ const TestComponent = {
210
+ template : '<div />'
211
+ }
212
+
213
+ const wrapper = mountingMethod ( TestComponent )
214
+
215
+ wrapper . trigger ( 'gamepadconnected' )
216
+ } )
183
217
} )
0 commit comments