forked from balderdashy/sails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhook.userconfig.test.js
72 lines (54 loc) · 2.07 KB
/
hook.userconfig.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
/**
* Test dependencies
*/
var assert = require('assert');
var httpHelper = require('./helpers/httpHelper.js');
var appHelper = require('./helpers/appHelper');
var util = require('util');
var wrench = require('wrench');
var path = require('path');
var fs = require('fs-extra');
var Sails = require('../../lib/app');
var async = require('async');
describe('hooks :: ', function() {
var sailsprocess;
describe('userconfig hook', function() {
var appName = 'testApp';
before(function(done) {
appHelper.teardown();
this.timeout(5000);
async.series([
function(cb) {fs.outputFile(path.resolve(__dirname,'../../testApp/config/abc.js'), 'module.exports = {"foo":"goo"};', cb);},
function(cb) {fs.outputFile(path.resolve(__dirname,'../../testApp/config/foo/bar.js'), 'module.exports = {"foo":"bar", "abc":123};', cb);},
function(cb) {process.chdir('testApp'); cb();}
], done);
});
after(function() {
process.chdir('../');
appHelper.teardown();
});
describe("with default options", function() {
it("should merge config options regardless of file structure", function(done) {
Sails().load({hooks:{grunt:false}}, function(err, sails) {
if (err) return callback(err);
assert.equal(sails.config.foo, "bar");
assert.equal(sails.config.abc, 123);
assert.equal(typeof(sails.config.bar), "undefined");
return done();
});
});
});
describe("with 'dontFlattenConfig' true", function() {
it("should use filenames in subfolders as keys", function(done) {
Sails().load({hooks:{grunt:false}, dontFlattenConfig: true}, function(err, sails) {
if (err) return callback(err);
assert.equal(sails.config.foo, "goo");
assert.equal(sails.config.bar.foo, "bar");
assert.equal(sails.config.bar.abc, 123);
assert.equal(typeof(sails.config.abc), "undefined");
return done();
});
});
});
});
});