feature: support more than html for SSI
This commit is contained in:
parent
02c10aaa72
commit
b3e5a4e1b4
4 changed files with 190 additions and 4 deletions
|
@ -71,3 +71,153 @@ Deno.test({
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: 'get html file with markdown included',
|
||||
permissions: {
|
||||
env: true,
|
||||
read: true,
|
||||
write: true,
|
||||
net: true
|
||||
},
|
||||
fn: async () => {
|
||||
let test_server_info: EPHEMERAL_SERVER | null = null;
|
||||
const cwd = Deno.cwd();
|
||||
|
||||
try {
|
||||
Deno.chdir('./tests/www');
|
||||
test_server_info = await get_ephemeral_listen_server();
|
||||
|
||||
const response = await fetch(`http://${test_server_info.hostname}:${test_server_info.port}/includes/with_markdown.html`);
|
||||
|
||||
const body = await response.text();
|
||||
|
||||
asserts.assert(response.ok);
|
||||
asserts.assert(body);
|
||||
asserts.assertMatch(body, /\<html\>.*?\<h1\>This is Markdown\<\/h1\>.*?\<\/html\>/is);
|
||||
} finally {
|
||||
Deno.chdir(cwd);
|
||||
if (test_server_info) {
|
||||
await test_server_info?.server?.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: 'get html file with text included',
|
||||
permissions: {
|
||||
env: true,
|
||||
read: true,
|
||||
write: true,
|
||||
net: true
|
||||
},
|
||||
fn: async () => {
|
||||
let test_server_info: EPHEMERAL_SERVER | null = null;
|
||||
const cwd = Deno.cwd();
|
||||
|
||||
try {
|
||||
Deno.chdir('./tests/www');
|
||||
test_server_info = await get_ephemeral_listen_server();
|
||||
|
||||
const response = await fetch(`http://${test_server_info.hostname}:${test_server_info.port}/includes/with_text.html`);
|
||||
|
||||
const body = await response.text();
|
||||
|
||||
asserts.assert(response.ok);
|
||||
asserts.assert(body);
|
||||
asserts.assertMatch(body, /\<html\>.*?Just some random text in a random text file\..*?\<\/html\>/is);
|
||||
} finally {
|
||||
Deno.chdir(cwd);
|
||||
if (test_server_info) {
|
||||
await test_server_info?.server?.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: 'get html file with lots of includes',
|
||||
permissions: {
|
||||
env: true,
|
||||
read: true,
|
||||
write: true,
|
||||
net: true
|
||||
},
|
||||
fn: async () => {
|
||||
let test_server_info: EPHEMERAL_SERVER | null = null;
|
||||
const cwd = Deno.cwd();
|
||||
|
||||
try {
|
||||
Deno.chdir('./tests/www');
|
||||
test_server_info = await get_ephemeral_listen_server();
|
||||
|
||||
const response = await fetch(
|
||||
`http://${test_server_info.hostname}:${test_server_info.port}/includes/with_lots_of_includes.html`
|
||||
);
|
||||
|
||||
const body = await response.text();
|
||||
|
||||
asserts.assert(response.ok);
|
||||
asserts.assert(body);
|
||||
asserts.assertEquals(
|
||||
body,
|
||||
`<html>
|
||||
<body>
|
||||
<p>Hello. Markdown should follow:</p>
|
||||
|
||||
<h1>This is Markdown</h1>
|
||||
<br>
|
||||
Welcome to it.
|
||||
<br>
|
||||
<h2>This is a level 2 heading</h2>
|
||||
<br>
|
||||
Can you read this?
|
||||
<br>
|
||||
<h3>Let's go deeper, level 3 heading</h3>
|
||||
<br>
|
||||
<ul>
|
||||
<li> this</li>
|
||||
<br>
|
||||
<li> is</li>
|
||||
<br>
|
||||
<li> a</li>
|
||||
<br>
|
||||
<li> list?</li>
|
||||
<br>
|
||||
</ul>
|
||||
<br>
|
||||
<h3>How about a table?</h3>
|
||||
<br>
|
||||
| column 1 | column 2 |
|
||||
| -------- | -------- |
|
||||
| hi | hey |
|
||||
| hoy | hah |
|
||||
<br>
|
||||
<h2>Ok, that seems sufficient?</h2>
|
||||
<br>
|
||||
Hardly, but we'll get back to this.
|
||||
|
||||
Just some random text in a random text file.
|
||||
|
||||
<div>Include #1</div>
|
||||
|
||||
<div>Include #2!</div>
|
||||
|
||||
|
||||
<div>Include #3</div>
|
||||
|
||||
|
||||
<p>Goodbye. The include should be above.</p>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
);
|
||||
} finally {
|
||||
Deno.chdir(cwd);
|
||||
if (test_server_info) {
|
||||
await test_server_info?.server?.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue