summaryrefslogtreecommitdiffstats
path: root/test/1-config.js
blob: 474ffea018827fdcdbe71f1daa5337d3354bb8e1 (plain)
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
var mock = require('./mock');

describe('Config', function() {

    describe('config.load()', function() {
        it('should not fail if no configuration file', function() {
            return mock.setupDefaultBook()
            .then(function(book) {
                return book.prepareConfig();
            });
        });

        it('should load from a JSON file', function() {
            return mock.setupDefaultBook({
                'book.json': { title: 'Hello World' }
            })
            .then(function(book) {
                return book.prepareConfig()
                .then(function() {
                    book.config.get('title', '').should.equal('Hello World');
                });
            });
        });

        it('should load from a JS file', function() {
            return mock.setupDefaultBook({
                'book.js': 'module.exports = { title: "Hello World" };'
            })
            .then(function(book) {
                return book.prepareConfig()
                .then(function() {
                    book.config.get('title', '').should.equal('Hello World');
                });
            });
        });
    });

});