-
Notifications
You must be signed in to change notification settings - Fork 2
/
CopyrightReplaceCommand.test.ts
37 lines (33 loc) · 1.74 KB
/
CopyrightReplaceCommand.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { rr0DefaultCopyright } from "./RR0DefaultCopyright.js"
import { rr0TestUtil } from "./test/RR0TestUtil.js"
import { SsiEchoVarReplaceCommand } from "ssg-api"
import { describe, expect, test } from "@javarome/testscript"
describe("CopyrightReplaceCommand", () => {
test("default copyright with no handler", async () => {
const command = new SsiEchoVarReplaceCommand("copyright", [])
const context = rr0TestUtil.newHtmlContext("time/1/9/5/4/index.html",
`This is published by <!--#echo var="copyright" -->!`)
context.file.meta.copyright = undefined
await command.execute(context)
expect(context.file.meta.copyright).toBeUndefined()
expect(context.file.contents).toBe(`This is published by <!--#echo var="copyright" -->!`)
})
test("default copyright with handler", async () => {
const command = new SsiEchoVarReplaceCommand("copyright", [rr0DefaultCopyright])
const context = rr0TestUtil.newHtmlContext("time/1/9/5/4/index.html",
`This is published by <!--#echo var="copyright" -->!`)
context.file.meta.copyright = undefined
await command.execute(context)
expect(context.file.meta.copyright).toBeUndefined()
expect(context.file.contents).toBe(`This is published by <a href="/GFDL.html">RR0</a>!`)
})
test("copyright with default handler", async () => {
const command = new SsiEchoVarReplaceCommand("copyright", [rr0DefaultCopyright])
const context = rr0TestUtil.newHtmlContext("time/1/9/5/4/10/index.html",
`This is published by <!--#echo var="copyright" -->!`)
context.file.meta.copyright = "Some editor"
await command.execute(context)
expect(context.file.meta.copyright).toBe("Some editor")
expect(context.file.contents).toBe("This is published by Some editor!")
})
})