2023-12-31 00:24:48 +00:00
|
|
|
let
|
2023-12-31 04:27:09 +00:00
|
|
|
html = import ../nixite/html.nix;
|
2023-12-31 00:24:48 +00:00
|
|
|
elems = import ../nixite/elems.nix;
|
|
|
|
site = import ../nixite/site.nix;
|
2024-01-01 08:10:32 +00:00
|
|
|
style = import ../nixite/style.nix;
|
2023-12-31 00:24:48 +00:00
|
|
|
it = import ./it.nix;
|
2023-12-31 21:33:42 +00:00
|
|
|
in with site; [
|
|
|
|
(it "applies a style" {
|
|
|
|
expected = {
|
|
|
|
"index.html" = html.tag "html" { } [
|
|
|
|
(html.tag "head" { } [
|
|
|
|
(elems.title { } "foobar")
|
|
|
|
(elems.Stylesheet "/style.css")
|
|
|
|
])
|
|
|
|
(elems.main { } "something")
|
|
|
|
];
|
|
|
|
blog = {
|
|
|
|
"index.html" = html.tag "html" { } [
|
|
|
|
(html.tag "head" { } [
|
|
|
|
(elems.title { } "foobar")
|
|
|
|
(elems.Stylesheet "/style.css")
|
|
|
|
])
|
|
|
|
(elems.main { } "blogy blog")
|
2023-12-31 04:27:09 +00:00
|
|
|
];
|
2023-12-31 00:24:48 +00:00
|
|
|
};
|
2023-12-31 21:33:42 +00:00
|
|
|
"style.css" = ''
|
|
|
|
this is a stylesheet
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
actual = applyStyle ''
|
|
|
|
this is a stylesheet
|
|
|
|
'' {
|
|
|
|
"index.html" = html.tag "html" { } [
|
|
|
|
(html.tag "head" { } [ (elems.title { } "foobar") ])
|
|
|
|
(elems.main { } "something")
|
|
|
|
];
|
|
|
|
blog = {
|
|
|
|
"index.html" = html.tag "html" { } [
|
|
|
|
(html.tag "head" { } [ (elems.title { } "foobar") ])
|
|
|
|
(elems.main { } "blogy blog")
|
2023-12-31 09:15:25 +00:00
|
|
|
];
|
|
|
|
};
|
2023-12-31 21:33:42 +00:00
|
|
|
};
|
|
|
|
asJSON = true;
|
|
|
|
})
|
2024-01-01 08:10:32 +00:00
|
|
|
|
|
|
|
(it "applies a favicon" {
|
|
|
|
expected = {
|
|
|
|
"index.html" = elems.html { } [
|
|
|
|
(elems.head { } [
|
|
|
|
(elems.title { } "foobar")
|
|
|
|
(elems.link {
|
|
|
|
rel = "shortcut icon";
|
|
|
|
href = ./src/favicon.png;
|
|
|
|
})
|
|
|
|
])
|
|
|
|
(elems.main { } "something")
|
|
|
|
];
|
|
|
|
blog = {
|
|
|
|
"index.html" = elems.html { } [
|
|
|
|
(elems.head { } [
|
|
|
|
(elems.title { } "foobar")
|
|
|
|
(elems.link {
|
|
|
|
rel = "shortcut icon";
|
|
|
|
href = ./src/favicon.png;
|
|
|
|
})
|
|
|
|
])
|
|
|
|
(elems.main { } "something")
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
actual = applyFavicon ./src/favicon.png {
|
|
|
|
"index.html" = elems.html { } [
|
|
|
|
(elems.head { } [ (elems.title { } "foobar") ])
|
|
|
|
(elems.main { } "something")
|
|
|
|
];
|
|
|
|
blog = {
|
|
|
|
"index.html" = elems.html { } [
|
|
|
|
(elems.head { } [ (elems.title { } "foobar") ])
|
|
|
|
(elems.main { } "something")
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
asJSON = true;
|
|
|
|
})
|
|
|
|
|
|
|
|
(it "extracts all styles" {
|
|
|
|
expected = {
|
|
|
|
"p.class" = {color = "blue";};
|
|
|
|
"a.class2" = {color = "green";};
|
|
|
|
};
|
|
|
|
actual = getStyles (let
|
|
|
|
p = style.tag "p" "class" {style = {color = "blue";};};
|
|
|
|
g = style.tag "a" "class2" {style = {color = "green";};};
|
|
|
|
in {
|
|
|
|
"index.html" = p "";
|
|
|
|
blog = {
|
|
|
|
"index.html" = g "";
|
|
|
|
};
|
|
|
|
});
|
|
|
|
removeDunders = true;
|
|
|
|
})
|
|
|
|
|
2023-12-31 21:33:42 +00:00
|
|
|
(it "extracts top level paths" {
|
|
|
|
actual = getPaths {
|
|
|
|
something = "";
|
|
|
|
src = ./src/index.md;
|
|
|
|
};
|
|
|
|
expected = { "index.md" = ./src/index.md; };
|
|
|
|
})
|
|
|
|
(it "extracts lower level paths" {
|
|
|
|
actual = getPaths {
|
|
|
|
something = "yes";
|
|
|
|
a-list = [
|
|
|
|
{ thingy = ./src/index.md; }
|
|
|
|
[ (html.tag "img" { src = ./src/favicon.png; } "") ]
|
|
|
|
];
|
|
|
|
};
|
|
|
|
expected = {
|
|
|
|
"index.md" = ./src/index.md;
|
|
|
|
"favicon.png" = ./src/favicon.png;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
(it "switches paths" {
|
|
|
|
actual = switchPaths {
|
|
|
|
something = "";
|
|
|
|
a-thing = { src = ./src/index.md; };
|
|
|
|
a-list = [{ thingy = ./src/index.md; }];
|
|
|
|
};
|
|
|
|
expected = {
|
|
|
|
something = "";
|
|
|
|
a-thing = { src = "/static/index.md"; };
|
|
|
|
a-list = [{ thingy = "/static/index.md"; }];
|
|
|
|
};
|
|
|
|
})
|
2023-12-31 09:15:25 +00:00
|
|
|
|
2023-12-31 21:33:42 +00:00
|
|
|
(it "extracts paths" {
|
|
|
|
actual = extractPaths {
|
|
|
|
something = "";
|
|
|
|
a-thing = { src = ./src/index.md; };
|
|
|
|
a-list = [{ thingy = ./src/index.md; }];
|
|
|
|
};
|
|
|
|
expected = {
|
|
|
|
something = "";
|
|
|
|
a-thing = { src = "/static/index.md"; };
|
|
|
|
a-list = [{ thingy = "/static/index.md"; }];
|
|
|
|
static = { "index.md" = ./src/index.md; };
|
|
|
|
};
|
|
|
|
})
|
|
|
|
]
|