-
Notifications
You must be signed in to change notification settings - Fork 101
/
templates.js
145 lines (127 loc) · 4.2 KB
/
templates.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
var should = require('should')
var polymer = require('../')
describe("templates", function(){
var root = __dirname + "/fixtures/templates"
var poly = polymer.root(root)
describe(".ejs", function(){
it("should render ejs file", function(done){
poly.render("bio.ejs", function(error, body){
should.not.exist(error)
should.exist(body)
body.should.include("<h1>Hello EJS</h1>")
done()
})
})
it("should minify beyond preprocessor", function(done){
poly.render("bio.ejs", function(error, body){
should.not.exist(error)
body.should.not.include("\n\n")
done()
})
})
})
describe(".md", function(){
it("should render markdown file", function(done){
poly.render("stuff.md", function(error, body){
should.not.exist(error)
should.exist(body)
body.should.include("<h1>hello markdown</h1>")
body.should.include("<p>")
body.should.include('<code class="language-json">')
body.should.not.include('<code class="lang-json">')
done()
})
})
it("should minify beyond preprocessor", function(done){
poly.render("stuff.md", function(error, body){
should.not.exist(error)
body.should.not.include("\n\n")
done()
})
})
it("should render markdown file encoded in UTF-8 with BOM", function(done){
poly.render("bom.md", function(error, body){
should.not.exist(error)
should.exist(body)
body.should.include("<h1>file with bom marker</h1>")
done()
})
})
it("should render table", function(done){
poly.render("table.md", function(error, body){
should.not.exist(error)
body.should.include("<h2>Hello Table</h2>")
body.should.include("<table>")
body.should.include("<thead>")
body.should.include("<tbody>")
done()
})
})
})
describe(".jade", function(){
it("should not give deprecated !!! warning", function(done){
poly.render("deprecated/jade/index.jade", function(error, body){
should.exist(error)
should.not.exist(body)
done()
})
})
it("should have jade partial layout and include working", function(done){
poly.render("index.jade", function(error, body){
should.not.exist(error)
should.exist(body)
body.should.include("<h1>Sintaxi</h1>")
body.should.include("<h2>Hello World</h2>")
body.should.include("<h3>Brock Whitten</h3>")
body.should.include("<h4>Vancouver</h4>")
done()
})
})
// it("should support filters", function(done){
// poly.render("filters.jade", function(error, body){
// should.not.exist(error)
// body.should.include('<h1>hello markdown</h1>')
// done()
// })
// })
it("should minify beyond preprocessor", function(done){
poly.render("index.jade", function(error, body){
should.not.exist(error)
body.should.not.include("\n\n")
done()
})
})
it("should pass in partials from the global object", function(done){
poly.render("index.jade", function(error, body){
should.not.exist(error)
should.exist(body)
body.should.include("<h1>Sintaxi</h1>")
body.should.include("<h2>Hello World</h2>")
body.should.include("<h3>Brock Whitten</h3>")
body.should.include("<h4>Vancouver</h4>")
done()
})
})
it("should return errors if error found", function(done){
poly.render("invalid.jade", function(error, body){
should.not.exist(body)
should.exist(error)
error.should.have.property("name")
error.should.have.property("message")
error.should.have.property("stack")
done()
})
})
it("should extend from a file with absolute path", function(done){
poly.render("extend.jade", function(error, body){
should.not.exist(error)
should.exist(body)
body.should.include("<h1>Sintaxi</h1>")
body.should.include("<h2>Hello World</h2>")
body.should.include("<h3>Brock Whitten</h3>")
body.should.include("<h4>Vancouver</h4>")
done()
})
})
})
})