@@ -120,3 +120,56 @@ test("$event action variable in middle of args", (t) => {
120120 const action = component . actionQueue [ 0 ] ;
121121 t . is ( action . payload . name , "test(\"4\", 1)" )
122122} ) ;
123+
124+ test ( "$event action loading attr" , ( t ) => {
125+ const html = `
126+ <div unicorn:id="5jypjiyb" unicorn:name="text-inputs" unicorn:checksum="GXzew3Km">
127+ <button unicorn:click='test()' u:loading.attr="disabled"></button>
128+ </div>` ;
129+ const component = getComponent ( html )
130+
131+ t . is ( component . attachedEventTypes . length , 1 ) ;
132+ t . is ( component . actionEvents . click . length , 1 ) ;
133+
134+ const { el} = component . actionEvents . click [ 0 ] . element ;
135+ t . true ( typeof el . attributes . disabled === "undefined" ) ;
136+
137+ el . click ( )
138+ t . false ( typeof el . attributes . disabled === "undefined" ) ;
139+ } ) ;
140+
141+ test ( "$event action loading class" , ( t ) => {
142+ const html = `
143+ <div unicorn:id="5jypjiyb" unicorn:name="text-inputs" unicorn:checksum="GXzew3Km">
144+ <button unicorn:click='test()' u:loading.class="loading"></button>
145+ </div>` ;
146+ const component = getComponent ( html )
147+
148+ t . is ( component . attachedEventTypes . length , 1 ) ;
149+ t . is ( component . actionEvents . click . length , 1 ) ;
150+
151+ const { el} = component . actionEvents . click [ 0 ] . element ;
152+ t . is ( el . classList . length , 0 ) ;
153+
154+ el . click ( )
155+ t . is ( el . classList . length , 1 ) ;
156+ t . is ( el . classList [ 0 ] , "loading" ) ;
157+ } ) ;
158+
159+ test ( "$event action loading remove class" , ( t ) => {
160+ const html = `
161+ <div unicorn:id="5jypjiyb" unicorn:name="text-inputs" unicorn:checksum="GXzew3Km">
162+ <button unicorn:click='test()' u:loading.class.remove="unloading" class="unloading"></button>
163+ </div>` ;
164+ const component = getComponent ( html )
165+
166+ t . is ( component . attachedEventTypes . length , 1 ) ;
167+ t . is ( component . actionEvents . click . length , 1 ) ;
168+
169+ const { el} = component . actionEvents . click [ 0 ] . element ;
170+ t . is ( el . classList . length , 1 ) ;
171+ t . is ( el . classList [ 0 ] , "unloading" ) ;
172+
173+ el . click ( )
174+ t . is ( el . classList . length , 0 ) ;
175+ } ) ;
0 commit comments