This repository was archived by the owner on Jun 27, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments