nixite/testing/elems.test.nix

85 lines
2.3 KiB
Nix
Raw Normal View History

2023-12-31 00:24:48 +00:00
let
elems = import ../nixite/elems.nix;
html = import ../nixite/html.nix;
it = import ./it.nix;
in
with elems; [
(it "makes a p tag" {
2023-12-31 06:59:23 +00:00
expected = html.tag "p" {class = ["p"];} "foobar";
actual = p {} "foobar";
asString = true;
2023-12-31 00:24:48 +00:00
})
2023-12-31 01:14:45 +00:00
(it "makes a div tag" {
2023-12-31 06:59:23 +00:00
expected = html.tag "div" {class = ["div"];} "foobar";
actual = div {} "foobar";
asString = true;
2023-12-31 01:14:45 +00:00
})
(it "makes a section tag" {
2023-12-31 06:59:23 +00:00
expected = html.tag "section" {class = ["section"];} "foobar";
actual = section {} "foobar";
asString = true;
2023-12-31 01:14:45 +00:00
})
(it "makes a span tag" {
2023-12-31 06:59:23 +00:00
expected = html.tag "span" {class = ["span"];} "foobar";
actual = span {} "foobar";
asString = true;
2023-12-31 01:14:45 +00:00
})
2023-12-31 00:24:48 +00:00
(it "makes a main tag" {
2023-12-31 06:59:23 +00:00
expected = html.tag "main" {class = ["main"];} ["yeet"];
actual = main {} ["yeet"];
asString = true;
2023-12-31 00:24:48 +00:00
})
(it "makes an h1 tag" {
expected = html.tag "h1" {} "foobar";
actual = h 1 "foobar";
asString = true;
2023-12-31 00:24:48 +00:00
})
(it "makes an h2 tag" {
expected = html.tag "h2" {} "foobar";
actual = h 2 "foobar";
asString = true;
2023-12-31 00:24:48 +00:00
})
(it "makes a title tag" {
2023-12-31 06:59:23 +00:00
expected = html.tag "title" {class = [];} "foobar";
actual = title {} "foobar";
asString = true;
2023-12-31 00:24:48 +00:00
})
(it "makes an a tag" {
expected = html.tag "a" {href = "https://example.com";} "example";
actual = link "https://example.com" "example";
asString = true;
2023-12-31 00:24:48 +00:00
})
(it "makes a stylesheet link" {
expected = html.tag "link" {
href = "/style";
rel = "stylesheet";
} "";
actual = stylesheet "/style";
asString = true;
2023-12-31 00:24:48 +00:00
})
(it "makes a list" {
expected = (html.tag "ul" {
2023-12-31 06:59:23 +00:00
__ = "";
class = ["list"];
} [
(html.tag "li" {} "foo")
(html.tag "li" {} "bar")
(html.tag "li" {} "baz")
]);
actual = (list {} ["foo" "bar" "baz"]);
asString = true;
2023-12-31 00:24:48 +00:00
})
(it "makes an html doc" {
expected = (html.tag "html" {
__child = "";
2023-12-31 06:59:23 +00:00
class = [];
lang = "en";
} [
(html.tag "head" {} ["foo"])
(html.tag "body" {} "bar")
]);
actual = (doc {} [["foo"] "bar"]);
asString = true;
2023-12-31 00:24:48 +00:00
})
]