File tree 1 file changed +31
-0
lines changed
questions/232-key-modifiers
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { mount } from "@vue/test-utils"
2
+ import { describe , it , expect , vi } from "vitest"
3
+
4
+ import App from "./App.vue"
5
+
6
+ describe ( "key modifiers" , ( ) => {
7
+ it ( "should work" , async ( ) => {
8
+ let printLog = ""
9
+ console . log = vi . fn (
10
+ ( log : string ) => {
11
+ printLog = log ?. toString ( ) ?. trim ( )
12
+ } )
13
+ const wrapper = mount ( App )
14
+ const buttons = wrapper . findAll ( "button" )
15
+
16
+ await buttons [ 0 ] . trigger ( 'click' )
17
+ expect ( printLog ) . toMatchInlineSnapshot ( '""' )
18
+ await buttons [ 0 ] . trigger ( 'click.alt' )
19
+ expect ( printLog ) . toMatchInlineSnapshot ( '"onClick1"' )
20
+ await buttons [ 0 ] . trigger ( 'click.shift' )
21
+ expect ( printLog ) . toMatchInlineSnapshot ( '"onClick1"' )
22
+
23
+ await buttons [ 1 ] . trigger ( 'click' )
24
+ expect ( printLog ) . toMatchInlineSnapshot ( '"onClick1"' )
25
+ await buttons [ 1 ] . trigger ( 'click.shift' )
26
+ expect ( printLog ) . toMatchInlineSnapshot ( '"onCtrlClick"' )
27
+
28
+ await buttons [ 2 ] . trigger ( 'click' )
29
+ expect ( printLog ) . toMatchInlineSnapshot ( '"onClick2"' )
30
+ } )
31
+ } )
You can’t perform that action at this time.
0 commit comments