feat: allow layout and _app overrides (#1611)

This commit is contained in:
Marvin Hagemeister
2023-08-09 16:35:53 +00:00
committed by GitHub
parent 81ae7b8427
commit 7ebaf0404d
13 changed files with 277 additions and 20 deletions
+47 -1
View File
@@ -1,5 +1,10 @@
import { assert } from "./deps.ts";
import { assertSelector, fetchHtml, withFresh } from "./test_utils.ts";
import {
assertNotSelector,
assertSelector,
fetchHtml,
withFresh,
} from "./test_utils.ts";
Deno.test("apply root _layout and _app", async () => {
await withFresh(
@@ -103,3 +108,44 @@ Deno.test({
);
},
});
Deno.test("disable _app layout", async () => {
await withFresh(
"./tests/fixture_layouts/main.ts",
async (address) => {
const doc = await fetchHtml(`${address}/override/no_app`);
assertNotSelector(doc, "body body");
assertSelector(doc, "body > .override-layout >.no-app");
},
);
});
Deno.test("override layouts", async () => {
await withFresh(
"./tests/fixture_layouts/main.ts",
async (address) => {
const doc = await fetchHtml(`${address}/override`);
assertSelector(doc, "body > .app > .override-layout > .override-page");
},
);
});
Deno.test("route overrides layout", async () => {
await withFresh(
"./tests/fixture_layouts/main.ts",
async (address) => {
const doc = await fetchHtml(`${address}/override/no_layout`);
assertSelector(doc, "body > .app > .no-layouts");
},
);
});
Deno.test("route overrides layout", async () => {
await withFresh(
"./tests/fixture_layouts/main.ts",
async (address) => {
const doc = await fetchHtml(`${address}/override/no_layout_no_app`);
assertSelector(doc, "body > .no-app-no-layouts");
},
);
});