@@ -2,7 +2,8 @@ import ComponentWithEvents from '~resources/components/component-with-events.vue
22import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue'
33import {
44 describeWithShallowAndMount ,
5- scopedSlotsSupported
5+ scopedSlotsSupported ,
6+ isRunningPhantomJS
67} from '~resources/utils'
78import Vue from 'vue'
89import { itDoNotRunIf } from 'conditional-specs'
@@ -92,7 +93,9 @@ describeWithShallowAndMount('trigger', mountingMethod => {
9293 propsData : { clickHandler }
9394 } )
9495 const button = wrapper . find ( '.left-click' )
95- button . trigger ( 'mousedown' )
96+ button . trigger ( 'mousedown' , {
97+ button : 1
98+ } )
9699 button . trigger ( 'mousedown' , {
97100 button : 0
98101 } )
@@ -180,4 +183,35 @@ describeWithShallowAndMount('trigger', mountingMethod => {
180183 . with . property ( 'message' , message )
181184 } )
182185 } )
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+ } )
183217} )
0 commit comments