-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtests.lua
More file actions
27 lines (23 loc) · 929 Bytes
/
tests.lua
File metadata and controls
27 lines (23 loc) · 929 Bytes
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
require 'busted.runner'()
describe("template module", function()
local template = require('template')
describe("template processing", function()
it("processes simple template", function()
local func = template.compile("Hello, <%= name %>!")
local output = {}
template.print(func, { name = "World" }, function(s) table.insert(output, s) end)
assert.equal("Hello, World!", table.concat(output, ""))
end)
it("processes conditional template", function()
local func = template.compile("<? if name then ?>Hello, <%= name %>!<? else ?>Guest<? end ?>")
local output = {}
template.print(func, { name = "World" }, function(s) table.insert(output, s) end)
assert.equal("Hello, World!", table.concat(output, ""))
end)
it("errors on invalid template", function()
assert.has_error(function()
template.compile("<%= ) %>")
end)
end)
end)
end)