config-defaults.spec.js
1.47 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
/* global it, describe, beforeEach, afterEach */
'use strict';
var assert = require('assert');
var mockery = require('mockery');
var sinon = require('sinon');
describe('config-defaults', () => {
var fallbackMock;
var loggerMock;
beforeEach(() => {
mockery.enable({ useCleanCache: true });
fallbackMock = sinon.stub();
mockery.registerMock('connect-history-api-fallback', fallbackMock);
loggerMock = sinon.stub();
mockery.registerMock('connect-logger', loggerMock);
mockery.registerAllowable('../lib/config-defaults');
});
afterEach(() => {
mockery.deregisterAll();
mockery.disable();
});
it('should provide defaults', () => {
fallbackMock.returns('fallback-middleware');
loggerMock.returns('logger-middleware');
var configDefaults = require('../lib/config-defaults');
assert.strictEqual(configDefaults.injectChanges, false,
'includes NG2 styleUrls workaround');
assert.ok(configDefaults.files.length,
'includes files array');
assert.strictEqual(configDefaults.watchOptions.ignored, 'node_modules',
'ignores node_modules from watchlist');
assert.ok(configDefaults.server.baseDir,
'includes basedir');
assert.deepEqual(
configDefaults.server.middleware,
['logger-middleware', 'fallback-middleware'],
'includes middleware'
);
assert.ok(loggerMock.called, 'logger middleware initialized');
assert.ok(fallbackMock.called, 'fallback middleware initialized');
});
});