@@ -9,72 +9,114 @@ describe('[UNIT] ForkTsCheckerWebpackPlugin', function() {
9
9
mockRequire . stopAll ( ) ;
10
10
} ) ;
11
11
12
- it ( 'should throw if typescript not present' , function ( ) {
13
- mockRequire ( 'typescript' , undefined ) ;
14
- var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
15
-
16
- expect ( function ( ) {
17
- new ForkTsCheckerWebpackPlugin ( ) ;
18
- } ) . to . throw (
19
- Error ,
20
- 'When you use this plugin you must install `typescript`.'
21
- ) ;
22
- } ) ;
12
+ describe ( 'typescript' , ( ) => {
13
+ it ( 'should throw if typescript not present' , function ( ) {
14
+ mockRequire ( 'typescript' , undefined ) ;
15
+ var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
23
16
24
- it ( 'should not throw if typescript version >= 2.1.0' , function ( ) {
25
- mockRequire ( 'typescript' , { version : '2.1.0' } ) ;
26
- var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
17
+ expect ( function ( ) {
18
+ new ForkTsCheckerWebpackPlugin ( ) ;
19
+ } ) . to . throw (
20
+ Error ,
21
+ 'When you use this plugin you must install `typescript`.'
22
+ ) ;
23
+ } ) ;
27
24
28
- expect ( function ( ) {
29
- new ForkTsCheckerWebpackPlugin ( ) ;
30
- } ) . to . not . throw ( ) ;
31
- } ) ;
25
+ it ( 'should not throw if typescript version >= 2.1.0' , function ( ) {
26
+ mockRequire ( 'typescript' , { version : '2.1.0' } ) ;
27
+ var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
32
28
33
- it ( 'should throw if typescript version < 2.1.0' , function ( ) {
34
- mockRequire ( 'typescript' , { version : '2.0.8' } ) ;
35
- var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
29
+ expect ( function ( ) {
30
+ new ForkTsCheckerWebpackPlugin ( ) ;
31
+ } ) . to . not . throw ( ) ;
32
+ } ) ;
36
33
37
- expect ( function ( ) {
38
- new ForkTsCheckerWebpackPlugin ( ) ;
39
- } ) . to . throw (
40
- Error ,
41
- 'Cannot use current typescript version of 2.0.8, the minimum required version is 2.1.0'
42
- ) ;
43
- } ) ;
34
+ it ( 'should throw if typescript version < 2.1.0' , function ( ) {
35
+ mockRequire ( 'typescript' , { version : '2.0.8' } ) ;
36
+ var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
44
37
45
- it ( 'should throw if tslint not present' , function ( ) {
46
- mockRequire ( 'typescript' , { version : '2.1.0' } ) ;
47
- mockRequire ( 'tslint' , undefined ) ;
48
- var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
49
-
50
- expect ( function ( ) {
51
- new ForkTsCheckerWebpackPlugin ( { tslint : true } ) ;
52
- } ) . to . throw (
53
- Error ,
54
- 'When you use `tslint` option, make sure to install `tslint`.'
55
- ) ;
38
+ expect ( function ( ) {
39
+ new ForkTsCheckerWebpackPlugin ( ) ;
40
+ } ) . to . throw (
41
+ Error ,
42
+ 'Cannot use current typescript version of 2.0.8, the minimum required version is 2.1.0'
43
+ ) ;
44
+ } ) ;
56
45
} ) ;
57
46
58
- it ( 'should not throw if tslint version >= 4.0.0' , function ( ) {
59
- mockRequire ( 'typescript' , { version : '2.1.0' } ) ;
60
- mockRequire ( 'tslint' , { Linter : { VERSION : '4.0.0' } } ) ;
61
- var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
47
+ describe ( 'tslint' , ( ) => {
48
+ it ( 'should throw if tslint not present' , function ( ) {
49
+ mockRequire ( 'typescript' , { version : '2.1.0' } ) ;
50
+ mockRequire ( 'tslint' , undefined ) ;
51
+ var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
52
+
53
+ expect ( function ( ) {
54
+ new ForkTsCheckerWebpackPlugin ( { tslint : true } ) ;
55
+ } ) . to . throw (
56
+ Error ,
57
+ 'When you use `tslint` option, make sure to install `tslint`.'
58
+ ) ;
59
+ } ) ;
60
+
61
+ it ( 'should not throw if tslint version >= 4.0.0' , function ( ) {
62
+ mockRequire ( 'typescript' , { version : '2.1.0' } ) ;
63
+ mockRequire ( 'tslint' , { Linter : { VERSION : '4.0.0' } } ) ;
64
+ var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
65
+
66
+ expect ( function ( ) {
67
+ new ForkTsCheckerWebpackPlugin ( { tslint : true } ) ;
68
+ } ) . to . not . throw ( ) ;
69
+ } ) ;
70
+
71
+ it ( 'should throw if tslint version < 4.0.0' , function ( ) {
72
+ mockRequire ( 'typescript' , { version : '2.1.0' } ) ;
73
+ mockRequire ( 'tslint' , { Linter : { VERSION : '3.15.1' } } ) ;
74
+ var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
62
75
63
- expect ( function ( ) {
64
- new ForkTsCheckerWebpackPlugin ( { tslint : true } ) ;
65
- } ) . to . not . throw ( ) ;
76
+ expect ( function ( ) {
77
+ new ForkTsCheckerWebpackPlugin ( { tslint : true } ) ;
78
+ } ) . to . throw (
79
+ Error ,
80
+ 'Cannot use current tslint version of 3.15.1, the minimum required version is 4.0.0'
81
+ ) ;
82
+ } ) ;
66
83
} ) ;
67
84
68
- it ( 'should throw if tslint version < 4.0.0' , function ( ) {
69
- mockRequire ( 'typescript' , { version : '2.1.0' } ) ;
70
- mockRequire ( 'tslint' , { Linter : { VERSION : '3.15.1' } } ) ;
71
- var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
72
-
73
- expect ( function ( ) {
74
- new ForkTsCheckerWebpackPlugin ( { tslint : true } ) ;
75
- } ) . to . throw (
76
- Error ,
77
- 'Cannot use current tslint version of 3.15.1, the minimum required version is 4.0.0'
78
- ) ;
85
+ describe ( 'useTypescriptIncrementalApi' , ( ) => {
86
+ it ( 'should be true if useTypescriptIncrementalApi: true supplied' , function ( ) {
87
+ mockRequire ( 'typescript' , { version : '2.1.0' } ) ;
88
+ var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
89
+
90
+ expect (
91
+ new ForkTsCheckerWebpackPlugin ( { useTypescriptIncrementalApi : true } )
92
+ . useTypescriptIncrementalApi
93
+ ) . to . be . true ;
94
+ } ) ;
95
+
96
+ it ( 'should be true if useTypescriptIncrementalApi: false supplied' , function ( ) {
97
+ mockRequire ( 'typescript' , { version : '3.0.0' } ) ;
98
+ var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
99
+
100
+ expect (
101
+ new ForkTsCheckerWebpackPlugin ( { useTypescriptIncrementalApi : false } )
102
+ . useTypescriptIncrementalApi
103
+ ) . to . be . false ;
104
+ } ) ;
105
+
106
+ it ( 'should be false if useTypescriptIncrementalApi not supplied and typescript version < 3.0.0' , function ( ) {
107
+ mockRequire ( 'typescript' , { version : '2.1.0' } ) ;
108
+ var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
109
+
110
+ expect ( new ForkTsCheckerWebpackPlugin ( ) . useTypescriptIncrementalApi ) . to . be
111
+ . false ;
112
+ } ) ;
113
+
114
+ it ( 'should be true if useTypescriptIncrementalApi not supplied and typescript version >= 3.0.0' , function ( ) {
115
+ mockRequire ( 'typescript' , { version : '3.0.0' } ) ;
116
+ var ForkTsCheckerWebpackPlugin = mockRequire . reRequire ( '../../lib/index' ) ;
117
+
118
+ expect ( new ForkTsCheckerWebpackPlugin ( ) . useTypescriptIncrementalApi ) . to . be
119
+ . true ;
120
+ } ) ;
79
121
} ) ;
80
122
} ) ;
0 commit comments