-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
90 lines (78 loc) · 2.18 KB
/
test.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'use strict';
require('mocha');
var assert = require('assert');
var defaults = require('./');
var verb = require('verb');
var app;
describe('verb-defaults', function() {
beforeEach(function() {
app = verb();
});
describe('plugin', function() {
it('should only register the plugin once', function(cb) {
var count = 0;
app.on('plugin', function(name) {
if (name === 'verb-defaults') {
count++;
}
});
app.use(defaults);
app.use(defaults);
app.use(defaults);
assert.equal(count, 1);
cb();
});
});
describe('defaults', function() {
it('should add defaults', function() {
app.use(defaults);
assert(app.engines.hasOwnProperty('.*'));
});
});
describe('generator', function() {
it('should extend a generator', function(cb) {
app.use(defaults);
app.generator('foo', function(foo) {
assert(foo.engines.hasOwnProperty('.*'));
cb();
});
});
it('should extend from a generator to a sub-generator', function(cb) {
app.generator('foo', function(foo) {
foo.use(defaults);
assert(foo.engines.hasOwnProperty('.*'));
foo.generator('bar', function(bar) {
assert(bar.engines.hasOwnProperty('.*'));
cb();
});
});
});
it('should extend from a sub-generator', function(cb) {
app.generator('foo', function(foo) {
foo.generator('bar', function(bar) {
bar.use(defaults);
assert(bar.engines.hasOwnProperty('.*'));
cb();
});
});
});
it('should extend to a nested sub-generator', function(cb) {
app.use(defaults);
app.generator('foo', function(foo) {
foo.engine('aaa', function() {});
foo.use(function fn() {
this.engine('bbb', function() {});
return fn;
});
foo.generator('bar', function(bar) {
bar.generator('baz', function(baz) {
assert(baz.engines.hasOwnProperty('.*'));
assert(!baz.engines.hasOwnProperty('.aaa'));
assert(baz.engines.hasOwnProperty('.bbb'));
cb();
});
});
});
});
});
});