1- import { assert , assertEquals } from "./asserts.js " ;
1+ import { assert , assertEquals } from "./asserts.ts " ;
22import {
33 AsyncRenderCallback ,
4- CustomElement ,
54 ConstructHOF ,
5+ CustomElement ,
6+ factorizeComponent ,
67 HOF ,
78 LifeCycleCallback ,
89 State ,
910 StateSymbol ,
10- factorizeComponent ,
1111 useAttributes ,
1212 useCallbacks ,
1313 useShadow ,
1414 useTemplate ,
15+ ValidateAttributeCallback ,
1516} from "./component.ts" ;
16- // @deno -types="./testing.d.ts"
17- import { constructComponent , factorizeSpy , test , withDom } from "./testing.js" ;
18- import { deferUntil , deferUntilNextFrame , noop } from "./utilities.js" ;
17+ import { constructComponent , factorizeSpy , test , withDom } from "./testing.ts" ;
18+ import { deferUntil , deferUntilNextFrame , noop } from "./utilities.ts" ;
1919
2020type RenderSpyFunction <
2121 S extends State ,
4444 } ) ;
4545 } ) ;
4646 } ) ,
47- ( ) => "ShadowRoot" in globalThis ,
4847) ;
4948
5049test (
9190 } ) ;
9291 } ) ;
9392 } ) ,
94- ( ) => "ShadowRoot" in globalThis ,
9593) ;
9694
9795test (
@@ -111,15 +109,17 @@ test(
111109 const e = constructComponent < ComponentState > ( Component ) ;
112110 assert ( e . shadowRoot ) ;
113111 } ) ,
114- ( ) => "ShadowRoot " in globalThis ,
112+ ( ) => "DocumentFragment " in globalThis ,
115113) ;
116114
117115test (
118116 "useAttributes" ,
119117 withDom ( ( ) => {
120118 type ComponentState = { value : number } ;
121119 const [ attributeMapSpy , assertAttributeMapSpy ] = factorizeSpy ( Number ) ;
122- const [ validateAttributeSpy , assertValidateAttributeSpy ] = factorizeSpy (
120+ const [ validateAttributeSpy , assertValidateAttributeSpy ] = factorizeSpy <
121+ ValidateAttributeCallback < ComponentState >
122+ > (
123123 ( { name : _name , oldValue, value } ) => ( oldValue !== value && value >= 0 ) ,
124124 ) ;
125125 const [ renderSpy , assertRenderSpy ] = factorizeSpy <
@@ -159,7 +159,6 @@ test(
159159 } ) ;
160160 } ) ;
161161 } ) ,
162- ( ) => "ShadowRoot" in globalThis ,
163162) ;
164163
165164test (
@@ -170,16 +169,15 @@ test(
170169 active : false ,
171170 count : 0 ,
172171 } ;
173- const callback =
174- ( (
175- _e : CustomElement < ComponentState > ,
176- render : AsyncRenderCallback < ComponentState > ,
177- ...xs : [ string , string , string ]
178- ) => {
179- render ( ( _ , { count } ) => ( { active : true , count : ++ count } ) ) (
180- { } as unknown as Event ,
181- ) ;
182- } ) as LifeCycleCallback < ComponentState > ;
172+ const callback = ( (
173+ _e : CustomElement < ComponentState > ,
174+ render : AsyncRenderCallback < ComponentState > ,
175+ ..._xs : [ string , string , string ]
176+ ) => {
177+ render ( ( _ , { count } ) => ( { active : true , count : ++ count } ) ) (
178+ { } as unknown as Event ,
179+ ) ;
180+ } ) as LifeCycleCallback < ComponentState > ;
183181 const [ adoptedCallbackSpy , assertAdoptedCallbackSpy ] = factorizeSpy (
184182 callback ,
185183 ) ;
@@ -210,13 +208,13 @@ test(
210208
211209 const e = constructComponent ( Component ) ;
212210
211+ e . connectedCallback && e . connectedCallback ( ) ;
212+
213213 e . adoptedCallback && e . adoptedCallback ( ) ;
214214
215215 e . attributeChangedCallback &&
216216 e . attributeChangedCallback ( "value" , null , "42" ) ;
217217
218- e . connectedCallback && e . connectedCallback ( ) ;
219-
220218 e . disconnectedCallback && e . disconnectedCallback ( ) ;
221219
222220 return deferUntilNextFrame ( )
@@ -234,7 +232,6 @@ test(
234232 assert ( assertRenderSpy . callCount === 5 ) ;
235233 } ) ;
236234 } ) ,
237- ( ) => "ShadowRoot" in globalThis ,
238235) ;
239236
240237test (
@@ -280,7 +277,10 @@ test(
280277 addButton : ( e ) => e . querySelector ( "button" ) ,
281278 number : ( e ) => e . querySelector ( "span" ) ,
282279 } ,
283- ) ( ( f ) => f ( Component , renderSpy , initialState ) , noop as ConstructHOF < ComponentState > ) ;
280+ ) (
281+ ( f ) => f ( Component , renderSpy , initialState ) ,
282+ noop as ConstructHOF < ComponentState > ,
283+ ) ;
284284
285285 const e = constructComponent < ComponentState > ( Component ) ;
286286
0 commit comments