links work

This commit is contained in:
tristan 2024-01-01 11:12:37 +00:00
parent 9fc7817e0e
commit 8e97ebe2ce
4 changed files with 111 additions and 42 deletions

View file

@ -1,5 +1,6 @@
msg:
{ actual, expected, asString ? false, asJSON ? false, removeDunders ? false, safeToPrint ? true }:
{ actual, expected, asString ? false, asJSON ? false, removeDunders ? false
, safeToPrint ? true }:
let
preProcess = v:
if removeDunders then
@ -17,9 +18,8 @@ let
in if (a == e) then ''
echo 'it ${msg}'
'' else
builtins.trace actual
builtins.trace expected
''
echo FAILED ${msg}
echo '${if safeToPrint then builtins.toJSON actual else ""}'
''
builtins.trace "FAILED ${msg}" builtins.trace
(if safeToPrint then builtins.toJSON actual else actual) builtins.trace
(if safeToPrint then builtins.toJSON expected else expected) ''
echo FAILED ${msg}
''

View file

@ -147,14 +147,14 @@ in with site; [
};
})
(it "switches functions" (let
coolPage = _: {
type = "page";
(it "switches links" (let
coolPage = {
type = "link";
name = "cool-page";
content = "";
};
in {
actual = switchFunctions {
actual = switchLinks {
something = "";
a-thing = { src = coolPage; };
a-list = [{ thingy = coolPage; }];
@ -166,19 +166,19 @@ in with site; [
};
}))
(it "gets functions" (let
coolPage = _: {
type = "page";
(it "gets links" (let
coolPage = {
type = "link";
name = "cool-page";
content = "cool content";
};
otherPage = _: {
type = "page";
otherPage = {
type = "link";
name = "page2";
content = "stuff";
};
in {
actual = getFunctions {
actual = getLinks {
something = "yes";
a-list =
[ { thingy = coolPage; } [ (elems.img { src = otherPage; } "") ] ];
@ -189,20 +189,20 @@ in with site; [
};
}))
(it "extracts functions" (let
coolPage = _: {
type = "page";
(it "extracts links" (let
coolPage = {
type = "link";
name = "cool-page";
content = "cool content";
};
otherPage = _: {
type = "page";
otherPage = {
type = "link";
name = "page2";
content = "stuff";
};
in {
actual = extractFunctions {
actual = extractLinks {
something = "";
a-thing = { src = coolPage; };
a-list = [{ thingy = otherPage; }];
@ -235,4 +235,59 @@ in with site; [
'';
}))
(it "prepares the site" ({
actual = prepare { favicon = ./src/favicon.png; } {
"index.html" = elems.html { } [
(elems.head { } [ (elems.title { } "foobar") ])
(elems.main { } [
(elems.a {
href = {
type = "link";
name = "a-page";
content = "this is another page";
};
} "A Page")
])
];
blog = {
"index.html" = elems.html { } [
(elems.head { } [ (elems.title { } "foobar") ])
(elems.main { } "something")
];
};
};
expected = {
"index.html" = elems.html { } [
(elems.head { } [
(elems.title { } "foobar")
(elems.link {
rel = "shortcut icon";
href = "/static/favicon.png";
})
(elems.Stylesheet "/style.css")
])
(elems.main { } [ (elems.a { href = "/static/a-page"; } "A Page") ])
];
blog = {
"index.html" = elems.html { } [
(elems.head { } [
(elems.title { } "foobar")
(elems.link {
rel = "shortcut icon";
href = "/static/favicon.png";
})
(elems.Stylesheet "/style.css")
])
(elems.main { } "something")
];
};
static = {
"favicon.png" = ./src/favicon.png;
"a-page" = "this is another page";
};
"style.css" = "";
};
asJSON = true;
}))
]