UNPKG

2.09 kBJavaScriptView Raw
1'use strict';
2
3var Path = require('path');
4require('should');
5var SuperTest = require('supertest');
6
7var application_builder = require(Path.resolve(__dirname, '../examples/config/app'));
8var app = application_builder({
9 project_folder: Path.resolve(__dirname, '../examples/config'),
10 alias: 'application-configuration',
11 environment: 'local'
12});
13
14describe('Application configuration', function() {
15 it('should be valid configuration', function() {
16 var config = app.config;
17 var site_config = config.site;
18
19 config.should.be.an.Object();
20
21 config.env.should.be.equal('local');
22 config.environment.should.be.equal('local');
23
24 site_config.local.origin.should.be.equal('https://localhost:8080');
25 site_config.local.url('/some/path').should.be.equal('https://localhost:8080/some/path');
26
27 site_config.global.ssl.key.should.be.equal(Path.resolve(app.project_folder, 'path/to/key'));
28
29 site_config.global.origin.should.be.equal('https://ifnode.com:3000');
30 site_config.global.url('some/path').should.be.equal('https://ifnode.com:3000/some/path');
31
32 config.application.express.should.be.an.Object();
33 config.application.folders.should.be.an.Object();
34
35 config.db.virtual.schema.should.be.equal('virtual');
36 });
37
38 it("should be non-editable configuration", function() {
39 var config = app.config;
40
41 (function() {
42 config.site = {};
43 }).should.throw();
44
45 (function() {
46 config.site.local = {};
47 }).should.throw();
48
49 (function() {
50 config.site.local.origin = 'my custom origin';
51 }).should.throw();
52 });
53
54 it("should load different types of global middleware", function(done) {
55 var app = application_builder({
56 project_folder: Path.resolve(__dirname, '../examples/config'),
57 alias: 'middleware-test',
58 environment: 'middleware-test'
59 });
60
61 app.load();
62
63 SuperTest(app.listener)
64 .get('/')
65 .expect(200, done);
66 });
67});