-
Notifications
You must be signed in to change notification settings - Fork 240
/
async_partial.js
58 lines (46 loc) · 1.23 KB
/
async_partial.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
(function() {
'use strict';
require('../../lib/geddy');
var assert = require('assert')
, Partial = require('../../lib/template/partial').Partial
, tests;
// TODO: how to actually inject template code?
geddy.templateRegistry = {
'app/views/foo/baz': {
file: 'app/views/foo/baz.html.ejs'
, ext: '.ejs'
, baseName: 'baz'
, baseNamePath: 'app/views/foo/baz'
}
, 'app/views/foo/bar': {
file: 'app/views/foo/bar.html.ejs'
, ext: '.ejs'
, baseName: 'bar'
, baseNamePath: 'app/views/foo/bar'
}
};
geddy.viewHelpers.callbackHelper = function() {
return function(cb) {
cb(null, 'callback helper result');
};
};
geddy.viewHelpers.promiseHelper = function() {
return new Promise(function (resolve, reject) {
resolve('promise helper result');
});
};
tests = {
'callback helper': function () {
var p = new Partial('foo/bar', {})
, data = p.getTemplateData();
assert.ok(data);
}
, 'promise helper': function () {
var pParent = new Partial('app/views/foo/baz', {})
var pSub = new Partial('bar', {}, pParent)
, data = pSub.getTemplateData();
assert.ok(data);
}
};
module.exports = tests;
}());