Skip to content

Commit dc4f54f

Browse files
committed
ci: improves tests
1 parent daea0e1 commit dc4f54f

File tree

6 files changed

+40
-5
lines changed

6 files changed

+40
-5
lines changed

test/Errors.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Renderer } from "../index.js"
2+
import should from "should"
3+
4+
const keikan = new Renderer();
5+
6+
describe("Errors", () => {
7+
it("should handle incomplete view", async () => {
8+
const view = await keikan.compilePath(import.meta.dirname + "/views/incomplete");
9+
10+
view().should.equal("<h3>Hello <error>Invalid block</error>");
11+
});
12+
});

test/Features.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Renderer } from "../index.js"
2+
import should from "should"
3+
4+
const keikan = new Renderer();
5+
6+
describe("Features", () => {
7+
it("<% include %> can be used to load another view", async () => {
8+
const view = await keikan.compilePath(import.meta.dirname + "/views/has-include");
9+
10+
view({ name: "world" }).should.equal("<h3>Hello world\n</h3>");
11+
});
12+
13+
it("<%= %>, <%- %> and <%# %>", async () => {
14+
const view = await keikan.compilePath(import.meta.dirname + "/views/escaping");
15+
16+
view().should.equal("<ul><li>This is a &quot;quoted&quot; string</li><li>This is not a \"quoted\" string</li><li></li></ul>");
17+
});
18+
});

test/Renderer.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ describe("Renderer", () => {
3535

3636
view({ name: "world" }).should.equal("<h3>Hello world</h3>");
3737
});
38-
});
3938

40-
describe("Features", () => {
41-
it("<% include %> can be used to load another view", async () => {
42-
const view = await keikan.compilePath(import.meta.dirname + "/views/complex");
39+
it("compilePath will use process cwd when base is explicitly passed as null", async () => {
40+
const view = await keikan.compilePath("test/views/simple", null);
4341

44-
view({ name: "world" }).should.equal("<h3>Hello world\n</h3>");
42+
view({ name: "world" }).should.equal("<h3>Hello world</h3>");
4543
});
4644
});

test/views/escaping.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ul>
2+
<li><%= "This is a \"quoted\" string" %></li>
3+
<li><%- "This is not a \"quoted\" string" %></li>
4+
<li><%# "This is a comment" %></li>
5+
</ul>
File renamed without changes.

test/views/incomplete.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h3>
2+
Hello <%= name

0 commit comments

Comments
 (0)