nixite/testing/elems.test.nix

69 lines
1.8 KiB
Nix

let
elems = import ../nixite/elems.nix;
html = import ../nixite/html.nix;
it = import ./it.nix;
in
with elems; [
(it "makes a p tag" {
expected = html.tag "p" {} "foobar";
actual = p {} "foobar";
})
(it "makes a div tag" {
expected = html.tag "div" {} "foobar";
actual = div {} "foobar";
})
(it "makes a section tag" {
expected = html.tag "section" {} "foobar";
actual = section {} "foobar";
})
(it "makes a span tag" {
expected = html.tag "span" {} "foobar";
actual = span {} "foobar";
})
(it "makes a main tag" {
expected = html.tag "main" {} ["yeet"];
actual = main {} ["yeet"];
})
(it "makes an h1 tag" {
expected = html.tag "h1" {} "foobar";
actual = h 1 "foobar";
})
(it "makes an h2 tag" {
expected = html.tag "h2" {} "foobar";
actual = h 2 "foobar";
})
(it "makes a title tag" {
expected = html.tag "title" {} "foobar";
actual = title {} "foobar";
})
(it "makes an a tag" {
expected = html.tag "a" {href = "https://example.com";} "example";
actual = link "https://example.com" "example";
})
(it "makes a stylesheet link" {
expected = html.tag "link" {
href = "/style";
rel = "stylesheet";
} "";
actual = stylesheet "/style";
})
(it "makes a list" {
expected = toString (html.tag "ul" {} [
(html.tag "li" {} "foo")
(html.tag "li" {} "bar")
(html.tag "li" {} "baz")
]);
actual = toString (list {} ["foo" "bar" "baz"]);
})
(it "makes an html doc" {
expected = toString (html.tag "html" {
__child = "";
lang = "en";
} [
(html.tag "head" {} ["foo"])
(html.tag "body" {} "bar")
]);
actual = toString (doc {} [["foo"] "bar"]);
})
]