1 | var Config = require('../lib/config');
|
2 |
|
3 | describe('config', function() {
|
4 | it('should fail if no modules are defined', function() {
|
5 | (function() {
|
6 | Config.create({});
|
7 | }).should.throw(/No modules object defined/);
|
8 | });
|
9 |
|
10 | it('should serialize config', function() {
|
11 | var config = Config.create({
|
12 | application: {
|
13 | module: 'foo',
|
14 | name: 'Name!'
|
15 | },
|
16 | modules: {
|
17 | foo: {
|
18 | scripts: [
|
19 | "foo",
|
20 | {template: "bar"}
|
21 | ]
|
22 | }
|
23 | }
|
24 | });
|
25 |
|
26 | config.serialize().should.eql({
|
27 | application: {
|
28 | module: 'foo',
|
29 | name: 'Name!'
|
30 | },
|
31 | modules: {
|
32 | foo: {
|
33 | scripts: [
|
34 | "foo",
|
35 | {template: "bar"}
|
36 | ]
|
37 | }
|
38 | },
|
39 | packages: {
|
40 | web: {
|
41 | name: ''
|
42 | }
|
43 | }
|
44 | });
|
45 | });
|
46 |
|
47 | describe('application module', function() {
|
48 | var config = Config.create({
|
49 | application: {
|
50 | module: 'foo',
|
51 | name: 'Name!'
|
52 | },
|
53 | modules: {}
|
54 | });
|
55 |
|
56 | it('should identify the app module', function() {
|
57 | config.isAppModule('foo').should.be.true;
|
58 | config.isAppModule({name: 'foo'}).should.be.true;
|
59 |
|
60 | config.isAppModule('bar').should.be.false;
|
61 | config.isAppModule({name: 'bar'}).should.be.false;
|
62 | });
|
63 | it('should provide the scoped module name', function() {
|
64 | config.scopedAppModuleName('foo').should.equal('module.exports');
|
65 | config.scopedAppModuleName({name: 'foo'}).should.equal('module.exports');
|
66 |
|
67 | config.scopedAppModuleName('bar').should.equal('Name!');
|
68 | config.scopedAppModuleName({name: 'bar'}).should.equal('Name!');
|
69 | });
|
70 | });
|
71 | });
|