@@ -5,33 +5,46 @@ test("click", (t) => {
55 const html = "<button unicorn:click='test()'></button>" ;
66 const element = getElement ( html ) ;
77
8- t . is ( element . action . name , "test()" ) ;
9- t . is ( element . action . eventType , "click" ) ;
8+ const action = element . actions [ 0 ] ;
9+ t . is ( action . name , "test()" ) ;
10+ t . is ( action . eventType , "click" ) ;
1011} ) ;
1112
1213test ( "keydown.enter" , ( t ) => {
1314 const html = "<input unicorn:keydown.enter='test()'></input>" ;
1415 const element = getElement ( html ) ;
1516
16- t . is ( element . action . name , "test()" ) ;
17- t . is ( element . action . eventType , "keydown" ) ;
18- t . is ( element . action . key , "enter" ) ;
17+ const action = element . actions [ 0 ] ;
18+ t . is ( action . name , "test()" ) ;
19+ t . is ( action . eventType , "keydown" ) ;
20+ t . is ( action . key , "enter" ) ;
1921} ) ;
2022
2123test ( "click.prevent" , ( t ) => {
2224 const html = "<a href='#' unicorn:click.prevent='test()'>Test()</a>" ;
2325 const element = getElement ( html ) ;
2426
25- t . true ( element . action . isPrevent ) ;
26- t . is ( element . action . eventType , "click" ) ;
27- t . is ( element . action . key , undefined ) ;
27+ const action = element . actions [ 0 ] ;
28+ t . true ( action . isPrevent ) ;
29+ t . is ( action . eventType , "click" ) ;
30+ t . is ( action . key , undefined ) ;
2831} ) ;
2932
3033test ( "click.stop" , ( t ) => {
3134 const html = "<a href='#' unicorn:click.stop='test()'>Test()</a>" ;
3235 const element = getElement ( html ) ;
3336
34- t . true ( element . action . isStop ) ;
35- t . is ( element . action . eventType , "click" ) ;
36- t . is ( element . action . key , undefined ) ;
37+ const action = element . actions [ 0 ] ;
38+ t . true ( action . isStop ) ;
39+ t . is ( action . eventType , "click" ) ;
40+ t . is ( action . key , undefined ) ;
41+ } ) ;
42+
43+ test ( "multiple actions" , ( t ) => {
44+ const html = "<input unicorn:keyup.enter='add' unicorn:keydown.escape='clear'></input>" ;
45+ const element = getElement ( html ) ;
46+
47+ t . true ( element . actions . length === 2 ) ;
48+ t . true ( element . actions [ 0 ] . eventType === "keyup" ) ;
49+ t . true ( element . actions [ 1 ] . eventType === "keydown" ) ;
3750} ) ;
0 commit comments