nixite/testing/builder.test.nix

48 lines
1.1 KiB
Nix
Raw Permalink Normal View History

2024-01-04 05:23:06 +00:00
{
describe,
it,
...
}: let
builder = import ../nixite/builder.nix;
in
with builder; [
(describe "buildSiteTo" [
(it "copies all the files" {
actual = buildSiteTo "." {
page = "this is a page";
subdir = {
page = "this page is in a subdir";
link = ./src;
};
};
expected = ''
cp /nix/store/crirfz0n6f8dgl1si3x7pwyw7fqm0r8l-page ./page
mkdir -p ./subdir
cp -r /nix/store/q95cn7ccixzi9w22aic4bl0ykk40ka7v-src ./subdir/link
cp /nix/store/ic6fyy8wg8r4338a3m5kinmg11igxsyj-page ./subdir/page
'';
})
(it "throws with a list for a page" {
actual = buildSiteTo "." {page = [];};
throws = true;
})
(it "throws with null for a page" {
actual = buildSiteTo "." {page = null;};
throws = true;
})
(it "throws with a bool for a page" {
actual = buildSiteTo "." {page = true;};
throws = true;
})
(it "throws with a number for a page" {
actual = buildSiteTo "." {page = 5;};
throws = true;
})
])
]