forked from janl/mustache.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext_test.js
More file actions
47 lines (46 loc) · 1.75 KB
/
context_test.js
File metadata and controls
47 lines (46 loc) · 1.75 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
47
var assert = require("assert"),
vows = require("vows"),
Context = require("./../mustache").Context;
vows.describe("Mustache.Context").addBatch({
"A Context": {
topic: function () {
var view = { name: 'parent', message: 'hi', a: { b: 'b' } };
var context = new Context(view);
return context;
},
"should be able to lookup properties of its own view": function (context) {
assert.equal(context.lookup("name"), "parent");
},
"should be able to lookup nested properties of its own view": function (context) {
assert.equal(context.lookup("a.b"), "b");
},
"when pushed": {
topic: function (context) {
var view = { name: 'child', c: { d: 'd' } };
return context.push(view);
},
"should return the child context": function (context) {
assert.equal(context.view.name, "child");
assert.equal(context.parent.view.name, "parent");
},
"should be able to lookup properties of its own view": function (context) {
assert.equal(context.lookup("name"), "child");
},
"should be able to lookup properties of the parent context's view": function (context) {
assert.equal(context.lookup("message"), "hi");
},
"should be able to lookup nested properties of its own view": function (context) {
assert.equal(context.lookup("c.d"), "d");
},
"should be able to lookup nested properties of its parent view": function (context) {
assert.equal(context.lookup("a.b"), "b");
}
} // when pushed
}, // A Context
"make": {
"should return the same object when given a Context": function () {
var context = new Context;
assert.strictEqual(Context.make(context), context);
}
}
}).export(module);