make tests pass
This commit is contained in:
parent
29f79c67d8
commit
77f70490df
9 changed files with 60 additions and 44 deletions
|
@ -5,23 +5,23 @@ let
|
|||
in
|
||||
with elems; [
|
||||
(it "makes a p tag" {
|
||||
expected = html.tag "p" {} "foobar";
|
||||
expected = html.tag "p" {class = ["p"];} "foobar";
|
||||
actual = p {} "foobar";
|
||||
})
|
||||
(it "makes a div tag" {
|
||||
expected = html.tag "div" {} "foobar";
|
||||
expected = html.tag "div" {class = ["div"];} "foobar";
|
||||
actual = div {} "foobar";
|
||||
})
|
||||
(it "makes a section tag" {
|
||||
expected = html.tag "section" {} "foobar";
|
||||
expected = html.tag "section" {class = ["section"];} "foobar";
|
||||
actual = section {} "foobar";
|
||||
})
|
||||
(it "makes a span tag" {
|
||||
expected = html.tag "span" {} "foobar";
|
||||
expected = html.tag "span" {class = ["span"];} "foobar";
|
||||
actual = span {} "foobar";
|
||||
})
|
||||
(it "makes a main tag" {
|
||||
expected = html.tag "main" {} ["yeet"];
|
||||
expected = html.tag "main" {class = ["main"];} ["yeet"];
|
||||
actual = main {} ["yeet"];
|
||||
})
|
||||
(it "makes an h1 tag" {
|
||||
|
@ -33,7 +33,7 @@ in
|
|||
actual = h 2 "foobar";
|
||||
})
|
||||
(it "makes a title tag" {
|
||||
expected = html.tag "title" {} "foobar";
|
||||
expected = html.tag "title" {class = [];} "foobar";
|
||||
actual = title {} "foobar";
|
||||
})
|
||||
(it "makes an a tag" {
|
||||
|
@ -48,16 +48,20 @@ in
|
|||
actual = stylesheet "/style";
|
||||
})
|
||||
(it "makes a list" {
|
||||
expected = toString (html.tag "ul" {} [
|
||||
(html.tag "li" {} "foo")
|
||||
(html.tag "li" {} "bar")
|
||||
(html.tag "li" {} "baz")
|
||||
]);
|
||||
expected = toString (html.tag "ul" {
|
||||
__ = "";
|
||||
class = ["list"];
|
||||
} [
|
||||
(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 = "";
|
||||
class = [];
|
||||
lang = "en";
|
||||
} [
|
||||
(html.tag "head" {} ["foo"])
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
path:
|
||||
toString (map (v: ''
|
||||
echo '${builtins.baseNameOf path} :: ${v}'
|
||||
'')
|
||||
(import path))
|
||||
''
|
||||
echo
|
||||
echo 'TEST: ${builtins.baseNameOf path}'
|
||||
echo
|
||||
''
|
||||
+ builtins.concatStringsSep "\n" (import path)
|
||||
|
|
|
@ -3,9 +3,11 @@ msg: {
|
|||
expected,
|
||||
}:
|
||||
if actual == expected
|
||||
then msg
|
||||
else
|
||||
throw
|
||||
(builtins.toJSON {
|
||||
inherit actual expected msg;
|
||||
})
|
||||
then ''
|
||||
echo 'it ${msg}'
|
||||
''
|
||||
else ''
|
||||
echo 'FAILED: ${msg}'
|
||||
echo '${builtins.toJSON expected}'
|
||||
echo '${builtins.toJSON actual}'
|
||||
''
|
||||
|
|
|
@ -4,13 +4,13 @@ let
|
|||
it = import ./it.nix;
|
||||
in
|
||||
with md; [
|
||||
(assert heading "# heading 1" == ["#" "heading 1"]; "gets heading 1")
|
||||
(assert heading "## subheading" == ["##" "subheading"]; "gets heading 2")
|
||||
(assert heading "some paragraph" == null; "paragraph is heading 0")
|
||||
(assert heading "# heading 1" == ["#" "heading 1"]; "echo gets heading 1")
|
||||
(assert heading "## subheading" == ["##" "subheading"]; "echo gets heading 2")
|
||||
(assert heading "some paragraph" == null; "echo paragraph is heading 0")
|
||||
|
||||
(assert mdBlock "# heading 1" == elems.h 1 "heading 1"; "makes h1 tag")
|
||||
(assert mdBlock "## subheading" == elems.h 2 "subheading"; "makes h2 tag")
|
||||
(assert mdBlock "some paragraph" == elems.p {} "some paragraph"; "makes p tag")
|
||||
(assert mdBlock "# heading 1" == elems.h 1 "heading 1"; "echo makes h1 tag")
|
||||
(assert mdBlock "## subheading" == elems.h 2 "subheading"; "echo makes h2 tag")
|
||||
(assert mdBlock "some paragraph" == elems.p {} "some paragraph"; "echo makes p tag")
|
||||
|
||||
(it "processes md block" {
|
||||
actual = readMd ''
|
||||
|
|
|
@ -28,11 +28,11 @@ let
|
|||
} {});
|
||||
in [
|
||||
(it "makes a p component" {
|
||||
expected = html.tag "p" {} "yes";
|
||||
expected = html.tag "p" {class = ["p"];} "yes";
|
||||
actual = my.p {} "yes";
|
||||
})
|
||||
(it "does not error without attrs" {
|
||||
expected = html.tag "p" {} "yes";
|
||||
expected = html.tag "p" {class = ["p"];} "yes";
|
||||
actual = my.p "yes";
|
||||
})
|
||||
(it "makes a component" {
|
||||
|
@ -51,10 +51,13 @@ in [
|
|||
actual = my.foobar {} "foobar";
|
||||
})
|
||||
(it "does custom behavour" {
|
||||
expected = toString (html.tag "ul" {} [
|
||||
(html.tag "li" {} "1")
|
||||
(html.tag "li" {} "2")
|
||||
]);
|
||||
expected = toString (html.tag "ul" {
|
||||
__ = "";
|
||||
class = ["list"];
|
||||
} [
|
||||
(html.tag "li" {} "1")
|
||||
(html.tag "li" {} "2")
|
||||
]);
|
||||
actual = toString (my.list {} ["1" "2"]);
|
||||
})
|
||||
(it "combines attrs" {
|
||||
|
@ -66,7 +69,7 @@ in [
|
|||
})
|
||||
(it "makes a style" {
|
||||
expected = ''
|
||||
p {
|
||||
p.p {
|
||||
some-style: some value;
|
||||
}
|
||||
div.something {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue