-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.root.test.js
More file actions
61 lines (47 loc) · 1.76 KB
/
Copy pathmodule.root.test.js
File metadata and controls
61 lines (47 loc) · 1.76 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
var keystone = require('../');
var demand = require('must');
var path = require('path');
var getExpressApp = require('./helpers/getExpressApp');
describe('Keystone "module root" setting', function () {
before(function() {
getExpressApp();
});
describe('default', function() {
it('should be set to the path where keystone was required', function() {
demand(keystone.get('module root')).to.be(__dirname);
});
it('should be used by keystone.getPath()', function() {
var viewsPath = 'relative/path/to/views'
keystone.set('views', viewsPath);
demand(keystone.getPath('views')).to.be(path.resolve(__dirname, viewsPath));
});
});
describe('custom with relative path', function() {
var customPath = '../..';
before(function() {
keystone.set('module root', customPath);
});
it('should return the custom configured path', function() {
demand(keystone.get('module root')).to.be(path.resolve(__dirname, customPath));
});
it('should be used by keystone.getPath() to resolve relative paths', function() {
var viewsPath = 'relative/path/to/views'
keystone.set('views', viewsPath);
demand(keystone.getPath('views')).to.be(path.resolve(__dirname, customPath, viewsPath));
});
});
describe('custom with absolute path', function() {
var customPath = path.resolve(__dirname, '../..');
before(function() {
keystone.set('module root', customPath);
});
it('should return the custom configured path', function() {
demand(keystone.get('module root')).to.be(customPath);
});
it('should be used by keystone.getPath() to resolve relative paths', function() {
var viewsPath = 'relative/path/to/views'
keystone.set('views', viewsPath);
demand(keystone.getPath('views')).to.be(path.resolve(customPath, viewsPath));
});
});
});