-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathinclude.js
More file actions
120 lines (107 loc) · 3.67 KB
/
include.js
File metadata and controls
120 lines (107 loc) · 3.67 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*!
* Consign include tests.
* Autoload your scripts.
*
* @author Jarrad Seers <jarrad@seers.me>
* @license MIT
*/
// Module dependencies.
var path = require('path');
module.exports = function(consign, assert) {
// Test setup.
var cwd = 'test/test-app'
, verbose = false
;
it('Should include a single file', function() {
var instance = consign({verbose: verbose}).include('test/test-app/controllers/one.js')
, file = path.resolve('test/test-app/controllers/one.js')
;
assert.deepEqual([file], instance._files);
});
it('Should include all test files in the test app', function() {
var instance = consign({verbose: verbose}).include('test/test-app')
, files = [
'test/test-app/config/dev-config.json',
'test/test-app/controllers/one.js',
'test/test-app/controllers/three.js',
'test/test-app/controllers/two.js',
'test/test-app/models/one.js',
'test/test-app/models/three.js',
'test/test-app/models/two.js'
].map(function(file) {
return path.resolve(file);
})
;
assert.deepEqual(files, instance._files);
});
it('Using CWD test/test-app, should load all test files', function() {
var instance = consign({cwd: cwd, verbose: verbose}).include('models').then('controllers')
, files = [
'models/one.js',
'models/three.js',
'models/two.js',
'controllers/one.js',
'controllers/three.js',
'controllers/two.js'
].map(function(file) {
return path.resolve(path.join(cwd, file));
})
;
assert.deepEqual(files, instance._files);
});
it('Should include all test files in the test app, loading models first', function() {
var instance = consign({verbose: verbose}).include('test/test-app/models').then('test/test-app')
, files = [
'test/test-app/models/one.js',
'test/test-app/models/three.js',
'test/test-app/models/two.js',
'test/test-app/config/dev-config.json',
'test/test-app/controllers/one.js',
'test/test-app/controllers/three.js',
'test/test-app/controllers/two.js'
].map(function(file) {
return path.resolve(file);
})
;
assert.deepEqual(files, instance._files);
});
it('Should include test files loaded in via comma separated string', function() {
var instance = consign({cwd: cwd, verbose: verbose}).include('models, controllers')
, files = [
'models/one.js',
'models/three.js',
'models/two.js',
'controllers/one.js',
'controllers/three.js',
'controllers/two.js'
].map(function(file) {
return path.resolve(path.join(cwd, file));
})
;
assert.deepEqual(files, instance._files);
});
it('Should include controller files in specific file order loaded in via comma separated string', function() {
var instance = consign({cwd: cwd, verbose: verbose}).include('controllers/one.js, controllers/two.js, controllers/three.js')
, files = [
'controllers/one.js',
'controllers/two.js',
'controllers/three.js'
].map(function(file) {
return path.resolve(path.join(cwd, file));
})
;
assert.deepEqual(files, instance._files);
});
it('Should include model files in specific file order loaded in via comma separated string', function() {
var instance = consign({cwd: cwd, verbose: verbose}).include('models/one.js, models/two.js, models')
, files = [
'models/one.js',
'models/two.js',
'models/three.js'
].map(function(file) {
return path.resolve(path.join(cwd, file));
})
;
assert.deepEqual(files, instance._files);
});
};