Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit d0469f2

Browse files
committed
Added serve command test
1 parent e1e4d59 commit d0469f2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/serve.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const proxyquire = require('proxyquire');
2+
const tap = require('tap');
3+
const _ = require('lodash');
4+
const resolveConfig = require('../bin/resolve_config');
5+
const browserSyncMock = require('./mocks/browsersync.mock.js');
6+
const wrapAsync = require('../bin/utils').wrapAsync;
7+
8+
// Require serve but mock patternlab so that we only test the module behavior
9+
const serve = proxyquire('../bin/serve', {'browser-sync': browserSyncMock});
10+
11+
tap.test('Serve ->', t => wrapAsync(function*() {
12+
const config = yield resolveConfig('./test/fixtures/patternlab-config.json');
13+
config.paths.source.root = undefined;
14+
t.throws(() => { serve(); }, {}, 'throws when config is empty');
15+
t.throws(() => { serve(123); }, {}, 'throws when config is not of type object');
16+
t.throws(() => {
17+
_.unset(config, 'paths.source.root');
18+
serve(config);
19+
}, {}, 'throws when no source root dir is set on config');
20+
t.throws(() => {
21+
_.unset(config, 'paths.public.root');
22+
serve(config);
23+
}, {}, 'throws when no public root dir is set on config');
24+
t.end();
25+
}));

0 commit comments

Comments
 (0)