forked from sindresorhus/gulp-template
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathtest.js
More file actions
46 lines (36 loc) · 1.07 KB
/
test.js
File metadata and controls
46 lines (36 loc) · 1.07 KB
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
'use strict';
var assert = require('assert');
var gutil = require('gulp-util');
var template = require('./index.js');
it('should compile Handlebars templates', function (cb) {
var data = {
people: ['foo', 'bar']
};
var options = {
templates: 'test/templates',
data: 'test/data',
partials: 'test/partials',
helpers: 'test/helpers'
};
var stream = template(data, options);
stream.on('data', function (data) {
assert.equal(data.contents.toString(), '<header/><li>foo</li><li>bar</li> baz');
cb();
});
stream.write(new gutil.File({
path: 'test/test.handlebars',
contents: new Buffer('{{> header}}{{#each people}}<li>{{.}}</li>{{/each}} {{toLower message}}')
}));
stream.end();
});
it('should compile Handlebars templates with no helpers or partials', function (cb) {
var stream = template( {people: ['foo', 'bar']});
stream.on('data', function (data) {
assert.equal(data.contents.toString(), '<li>foo</li><li>bar</li>');
cb();
});
stream.write(new gutil.File({
contents: new Buffer('{{#each people}}<li>{{.}}</li>{{/each}}')
}));
stream.end();
});