forked from assemble/assemble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.list.compile.js
46 lines (36 loc) · 1.18 KB
/
app.list.compile.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
'use strict';
require('mocha');
require('should');
var assert = require('assert');
var support = require('./support');
var App = support.resolve();
var List = App.List;
var list;
describe('app.list.compile', function() {
beforeEach(function() {
list = new List();
list.engine('tmpl', require('engine-base'));
});
it('should compile an item:', function() {
var buffer = new Buffer('a b c');
var item = list.addItem('a.tmpl', {contents: buffer})
.compile();
assert(typeof item.fn === 'function');
});
it('should use the compiled function to render:', function() {
var buffer = new Buffer('a <%= title %> c');
var item = list.addItem('a.tmpl', {contents: buffer})
.compile();
assert(item.fn({title: 'z'}));
assert(typeof item.fn({title: 'z'}) === 'string');
assert(item.fn({title: 'z'}) === 'a z c');
});
it('should compile a view by name:', function() {
var buffer = new Buffer('a <%= title %> c');
list.addItem('a.tmpl', {contents: buffer});
var item = list.compile('a.tmpl');
assert(item.fn({title: 'z'}));
assert(typeof item.fn({title: 'z'}) === 'string');
assert(item.fn({title: 'z'}) === 'a z c');
});
});