@@ -3,38 +3,65 @@ const cssStandardsRewired = rewire('../lib')
3
3
const cssStandards = require ( '../lib' )
4
4
const test = require ( 'ava' )
5
5
6
- test ( 'basic ' , ( t ) => {
7
- cssStandardsRewired . __set__ ( 'postcssImport' , ( opts ) => {
8
- t . truthy ( opts . root === 'test' )
9
- t . truthy ( opts . path [ 0 ] === 'test/test1 ' )
10
- t . truthy ( opts . path [ 1 ] === 'test/test2' )
11
- } )
6
+ test ( 'passes parser opt correctly ' , ( t ) => {
7
+ const out = cssStandards ( { parser : 'test' } )
8
+ const out2 = cssStandards ( { parser : false } )
9
+ t . is ( out . parser , 'test' )
10
+ t . is ( out2 . parser , undefined )
11
+ } )
12
12
13
- cssStandardsRewired . __set__ ( 'cssnext' , ( opts ) => {
14
- t . truthy ( opts . features === 'test' )
15
- t . truthy ( opts . browsers === 'test' )
16
- t . truthy ( opts . warnForDuplicates === 'test' )
13
+ test ( 'passes import opts correctly' , ( t ) => {
14
+ const undo = cssStandardsRewired . __set__ ( 'postcssImport' , ( opts ) => {
15
+ t . is ( opts . root , 'test' )
16
+ t . is ( opts . path [ 0 ] , 'test' )
17
17
} )
18
+ cssStandardsRewired ( { root : 'test' , path : 'test' } )
19
+ undo ( )
20
+ } )
18
21
19
- cssStandardsRewired . __set__ ( 'rucksack' , ( opts ) => {
20
- t . truthy ( opts === 'test' )
22
+ test ( 'passes cssnext opts correctly' , ( t ) => {
23
+ const undo = cssStandardsRewired . __set__ ( 'cssnext' , ( opts ) => {
24
+ t . is ( opts . browsers , 'test' )
25
+ t . is ( opts . features , 'test' )
26
+ t . is ( opts . warnForDuplicates , 'test' )
21
27
} )
22
-
23
- const out1 = cssStandardsRewired ( {
24
- parser : false ,
25
- path : [ 'test/test1' , 'test/test2' ] ,
26
- features : 'test' ,
28
+ cssStandardsRewired ( {
27
29
browsers : 'test' ,
28
- warnForDuplicates : 'test' ,
29
- rucksack : 'test' ,
30
- root : 'test'
30
+ features : 'test' ,
31
+ warnForDuplicates : 'test'
32
+ } )
33
+ undo ( )
34
+ } )
35
+
36
+ test ( 'passes rucksack opts correctly' , ( t ) => {
37
+ const undo = cssStandardsRewired . __set__ ( 'rucksack' , ( opts ) => {
38
+ t . is ( opts , 'test' )
31
39
} )
40
+ cssStandardsRewired ( { rucksack : 'test' } )
41
+ undo ( )
42
+ } )
32
43
33
- t . truthy ( out1 . plugins . length === 3 )
34
- t . falsy ( out1 . parser )
44
+ test ( 'default plugins working' , ( t ) => {
45
+ const out = cssStandards ( )
46
+ t . is ( out . plugins . length , 3 )
47
+ } )
35
48
36
- const out2 = cssStandards ( { minify : true } )
49
+ test ( 'minify option working' , ( t ) => {
50
+ const out = cssStandards ( { minify : true } )
51
+ t . is ( out . plugins . length , 4 )
52
+ t . is ( out . plugins [ out . plugins . length - 1 ] . postcssPlugin , 'cssnano' )
53
+ } )
54
+
55
+ test ( 'appendPlugins option' , ( t ) => {
56
+ const out = cssStandards ( { appendPlugins : [ 'test' ] } )
57
+ const out2 = cssStandards ( { appendPlugins : 'test' } )
58
+ t . truthy ( out . plugins [ out . plugins . length - 1 ] === 'test' )
59
+ t . truthy ( out2 . plugins [ out . plugins . length - 1 ] === 'test' )
60
+ } )
37
61
38
- t . truthy ( out2 . parser )
39
- t . truthy ( out2 . plugins . length === 4 )
62
+ test ( 'prependPlugins option' , ( t ) => {
63
+ const out = cssStandards ( { prependPlugins : [ 'test' ] } )
64
+ const out2 = cssStandards ( { prependPlugins : 'test' } )
65
+ t . truthy ( out . plugins [ 0 ] === 'test' )
66
+ t . truthy ( out2 . plugins [ 0 ] === 'test' )
40
67
} )
0 commit comments