@@ -42,36 +42,72 @@ let modelTests =
4242 " Html element with no properties and no children"
4343 |> Expect.equal actual expected
4444
45+ testCase " Custom Html element - empty" <| fun _ ->
46+ let actual = Html.custom " test" [] [] |> HtmlElement.ToString
47+ let expected = " <test></test>"
48+ " Custom Html element with no properties and no children"
49+ |> Expect.equal actual expected
50+
4551 testCase " Html element - one property" <| fun _ ->
4652 let actual = Html.a [ Href " index.html" ] [] |> HtmlElement.ToString
4753 let expected = " <a href=\" index.html\" ></a>"
4854 " Html element with one property and no children"
4955 |> Expect.equal actual expected
5056
57+ testCase " Custom Html element - one property" <| fun _ ->
58+ let actual = Html.custom " test" [ Href " index.html" ] [] |> HtmlElement.ToString
59+ let expected = " <test href=\" index.html\" ></test>"
60+ " Custom Html element with one property and no children"
61+ |> Expect.equal actual expected
62+
5163 testCase " Html element - multiple properties" <| fun _ ->
5264 let actual = Html.a [ Href " index.html" ; Hidden true ] [] |> HtmlElement.ToString
5365 let expected = " <a href=\" index.html\" hidden=\" true\" ></a>"
5466 " Html element with multiple properties and no children"
5567 |> Expect.equal actual expected
5668
69+ testCase " Custom Html element - multiple property" <| fun _ ->
70+ let actual = Html.custom " test" [ Href " index.html" ; Hidden true ] [] |> HtmlElement.ToString
71+ let expected = " <test href=\" index.html\" hidden=\" true\" ></test>"
72+ " Custom Html element with multiple properties and no children"
73+ |> Expect.equal actual expected
74+
5775 testCase " Html element - one child" <| fun _ ->
5876 let actual = Html.a [] [ Html.span [] [] ] |> HtmlElement.ToString
5977 let expected = " <a>\n <span></span>\n </a>"
6078 " Html element with no properties and one child"
6179 |> Expect.equal actual expected
6280
81+ testCase " Custom Html element - one child" <| fun _ ->
82+ let actual = Html.custom " test" [] [ Html.span [] [] ] |> HtmlElement.ToString
83+ let expected = " <test>\n <span></span>\n </test>"
84+ " Custom Html element with no properties and one child"
85+ |> Expect.equal actual expected
86+
6387 testCase " Html element - multiple children" <| fun _ ->
6488 let actual = Html.a [] [ Html.span [] []; Html.div [] [] ] |> HtmlElement.ToString
6589 let expected = " <a>\n <span></span>\n <div></div>\n </a>"
6690 " Html element with no properties and multiple children"
6791 |> Expect.equal actual expected
6892
93+ testCase " Custom Html element - multiple children" <| fun _ ->
94+ let actual = Html.custom " test" [] [ Html.span [] []; Html.div [] [] ] |> HtmlElement.ToString
95+ let expected = " <test>\n <span></span>\n <div></div>\n </test>"
96+ " Custom Html element with no properties and multiple children"
97+ |> Expect.equal actual expected
98+
6999 testCase " Html element - multiple properites and children" <| fun _ ->
70100 let actual = Html.a [ Href " index.html" ; Hidden true ] [ Html.span [] []; Html.div [] [] ] |> HtmlElement.ToString
71101 let expected = " <a href=\" index.html\" hidden=\" true\" >\n <span></span>\n <div></div>\n </a>"
72102 " Html element with multiple properties and multiple children"
73103 |> Expect.equal actual expected
74104
105+ testCase " Custom Html element - multiple properites and children" <| fun _ ->
106+ let actual = Html.custom " test" [ Href " index.html" ; Hidden true ] [ Html.span [] []; Html.div [] [] ] |> HtmlElement.ToString
107+ let expected = " <test href=\" index.html\" hidden=\" true\" >\n <span></span>\n <div></div>\n </test>"
108+ " Custom Html element with multiple properties and multiple children"
109+ |> Expect.equal actual expected
110+
75111 testCase " Html element - void element as child" <| fun _ ->
76112 let actual = Html.div [ ] [ Html.br [ ] ] |> HtmlElement.ToString
77113 let expected = " <div>\n <br/>\n </div>"
@@ -84,6 +120,18 @@ let modelTests =
84120 " Html element with one void element as child"
85121 |> Expect.equal actual expected
86122
123+ testCase " Custom Html element - mutliple properties and children (void and normal element)" <| fun _ ->
124+ let actual = Html.custom " test" [ HtmlProperties.Style [ Display " block" ] ] [ Html.br [ ]; Html.p [ ] [ ]; Html.img [ Src " https://dummyimage.com/128x128/" ] ] |> HtmlElement.ToString
125+ let expected = " <test style=\" display: block;\" >\n <br/>\n <p></p>\n <img src=\" https://dummyimage.com/128x128/\" />\n </test>"
126+ " Custom Html element with one void element as child"
127+ |> Expect.equal actual expected
128+
129+ testCase " Custom Html element - as child with property and child" <| fun _ ->
130+ let actual = Html.div [] [ Html.custom " test" [ HtmlProperties.Style [ Display " block" ] ] [ Html.span [] [] ] ] |> HtmlElement.ToString
131+ let expected = " <div>\n <test style=\" display: block;\" >\n <span></span>\n </test>\n </div>"
132+ " Custom Html element with one void element as child"
133+ |> Expect.equal actual expected
134+
87135 testCase " Html void element - empty" <| fun _ ->
88136 let actual = Html.br [ ] |> HtmlElement.ToString
89137 let expected = " <br/>"
0 commit comments