Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
143 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
var tm = require('../lib/templateManager') | ||
, expect = require('chai').expect; | ||
|
||
describe('Template manager', function() { | ||
|
||
it('should render ejs', function(done) { | ||
var opts = { | ||
locals: {item: 'test'}, | ||
filename: 'test.ejs', | ||
source: '<h1><%= item%> <%= engine%></h1>' | ||
} | ||
|
||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('<h1>test .ejs</h1>'); | ||
|
||
done() | ||
}) | ||
}) | ||
|
||
it('should render jade', function(done) { | ||
var opts = { | ||
locals: {item: 'test'}, | ||
filename: 'test.jade', | ||
source: 'h1= item\nh1= engine' | ||
} | ||
|
||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('<h1>test</h1><h1>.jade</h1>'); | ||
|
||
done() | ||
}) | ||
}) | ||
|
||
it('should render swig', function(done) { | ||
var opts = { | ||
locals: {item: 'test'}, | ||
filename: 'test.swig', | ||
source: '<h1>{{ item }} {{ engine }}</h1>' | ||
} | ||
|
||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('<h1>test .swig</h1>'); | ||
|
||
done() | ||
}) | ||
}) | ||
|
||
it('should render handlebars', function(done) { | ||
var opts = { | ||
locals: {item: 'test'}, | ||
filename: 'test.handlebars', | ||
source: '<h1>{{ item }} {{ engine }}</h1>' | ||
} | ||
|
||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('<h1>test .handlebars</h1>'); | ||
|
||
done() | ||
}) | ||
}) | ||
|
||
it('should render less', function(done) { | ||
var opts = { | ||
locals : {}, | ||
filename : 'test.less', | ||
source : '.class{ width: (1 + 1) }' | ||
} | ||
|
||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('.class {\n width: 2;\n}\n'); | ||
|
||
done() | ||
}) | ||
}) | ||
|
||
it('should render stylus', function(done) { | ||
var opts = {locals: {}}; | ||
opts.filename = 'test.stylus'; | ||
opts.source = 'body\n width: 2px\n'; | ||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('body {\n width: 2px;\n}\n'); | ||
done(); | ||
}) | ||
}) | ||
|
||
it('should render styl', function(done) { | ||
var opts = { | ||
locals : {whitespace: true}, | ||
filename : 'test.styl', | ||
source : 'body\n color: blue' | ||
} | ||
|
||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('body {\n color: blue;\n}') | ||
done() | ||
}) | ||
}) | ||
|
||
it('should render sass', function(done) { | ||
var opts = { | ||
locals : {}, | ||
filename : 'test.sass', | ||
source : '$gray: #ccc;body {color: $gray}' | ||
} | ||
|
||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('body {\n color: #ccc; }\n'); | ||
|
||
done() | ||
}) | ||
}) | ||
|
||
it('should render css', function(done) { | ||
var opts = { | ||
locals : {}, | ||
filename : 'test.css', | ||
source : 'body { color: #ccc; }' | ||
} | ||
|
||
tm.render(opts, function(err, res) { | ||
expect(err).to.be.null; | ||
expect(res).to.equal('body { color: #ccc; }'); | ||
|
||
done() | ||
}) | ||
}) | ||
}) |