forked from pattern-lab/patternlab-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.test.js
More file actions
45 lines (43 loc) · 1.05 KB
/
build.test.js
File metadata and controls
45 lines (43 loc) · 1.05 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
const patternlab = require('@pattern-lab/core');
const proxyquire = require('proxyquire');
const tap = require('tap');
const patternLabMock = require('./mocks/patternlab.mock.js');
const config = patternlab.getDefaultConfig();
// Require build and mock patternlab.build() so that we only test the build module behavior
const build = proxyquire('../bin/build', {
'@pattern-lab/core': patternLabMock,
});
const opts = { patternsOnly: true };
tap.test('Build ->', t => {
t.throws(
() => {
build();
},
{},
'throws when config is empty'
);
t.throws(
() => {
build(123);
},
{},
'throws when config is not of type object'
);
t.throws(
() => {
build(undefined, opts);
},
{},
'--patterns-only throws when config is empty'
);
t.throws(
() => {
build(undefined, opts);
},
{},
'--patterns-only throws when config is not of type object'
);
t.type(build(config), 'boolean', 'returns a bool');
t.type(build(config, opts), 'boolean', '--patterns-only returns a bool');
t.end();
});