forked from assemble/assemble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.use.js
62 lines (55 loc) · 1.28 KB
/
view.use.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
59
60
61
62
'use strict';
require('mocha');
require('should');
var assert = require('assert');
var support = require('./support');
var App = support.resolve();
var View = App.View;
var view;
describe('view.use', function() {
beforeEach(function() {
view = new View();
});
it('should expose the instance to `use`:', function(cb) {
view.use(function(inst) {
assert(inst instanceof View);
cb();
});
});
it('should be chainable:', function(cb) {
view.use(function(inst) {
assert(inst instanceof View);
})
.use(function(inst) {
assert(inst instanceof View);
})
.use(function(inst) {
assert(inst instanceof View);
cb();
});
});
it('should expose the view to a plugin:', function() {
view.use(function(view) {
assert(view instanceof View);
view.foo = function(str) {
return str + ' ' + 'bar';
};
});
assert(view.foo('foo') === 'foo bar');
});
it('should be chainable:', function() {
view
.use(function(view) {
view.a = 'aaa';
})
.use(function(view) {
view.b = 'bbb';
})
.use(function(view) {
view.c = 'ccc';
});
assert(view.a === 'aaa');
assert(view.b === 'bbb');
assert(view.c === 'ccc');
});
});