@@ -101,3 +101,47 @@ describe "HtmlHelper.createElement" <| fun _ ->
101101 let propsContainChildren : bool = extractedProps |> Array.exists ( fun ( k , _ ) -> k = " children" )
102102 expect( propsContainChildren) .toBeFalsy()
103103 expect( extractedProps.Length) .toBe(( props |> Seq.length) - 1 )
104+
105+ test " extract as last" <| fun _ ->
106+ let child = [ Html.span []; Html.div [] ]
107+ let props =
108+ [
109+ " id" , box " my-div"
110+ " data-test" , box true
111+ " style" , box {| color = " red" |}
112+ " onClick" , box ( fun _ -> ())
113+ " tabIndex" , box 0
114+ " className" , box " container"
115+ " children" , box child
116+ ]
117+ let extractedProps , childOption = HtmlHelper.extractByKeyFast " children" props
118+ expect( child) .toBeTruthy()
119+ let key , child =
120+ match childOption with
121+ | Some kvp -> kvp
122+ | None -> failwith " Expected to find 'children' key"
123+ expect( key) .toBe( " children" )
124+ expect( child) .toEqual( child)
125+ let propsContainChildren : bool = extractedProps |> Array.exists ( fun ( k , _ ) -> k = " children" )
126+ expect( propsContainChildren) .toBeFalsy()
127+ expect( extractedProps.Length) .toBe(( props |> Seq.length) - 1 )
128+
129+ test " extract as exactlyOne" <| fun _ ->
130+ let child = [ Html.span []; Html.div [] ]
131+ let props =
132+ [
133+ " children" , box child
134+ ]
135+ let extractedProps , childOption = HtmlHelper.extractByKeyFast " children" props
136+ Browser.Dom.console.log( extractedProps)
137+ Browser.Dom.console.log( childOption)
138+ expect( child) .toBeTruthy()
139+ let key , child =
140+ match childOption with
141+ | Some kvp -> kvp
142+ | None -> failwith " Expected to find 'children' key"
143+ expect( key) .toBe( " children" )
144+ expect( child) .toEqual( child)
145+ let propsContainChildren : bool = extractedProps |> Array.exists ( fun ( k , _ ) -> k = " children" )
146+ expect( propsContainChildren) .toBeFalsy()
147+ expect( extractedProps.Length) .toBe(( props |> Seq.length) - 1 )
0 commit comments