@@ -8,8 +8,11 @@ var ForkTsCheckerWebpackPlugin = require('../../lib/index');
8
8
9
9
describe ( '[INTEGRATION] index' , function ( ) {
10
10
this . timeout ( 30000 ) ;
11
+ var plugin ;
11
12
12
13
function createCompiler ( options ) {
14
+ plugin = new ForkTsCheckerWebpackPlugin ( Object . assign ( { } , options , { silent : true } ) ) ;
15
+
13
16
return webpack ( {
14
17
context : path . resolve ( __dirname , './project' ) ,
15
18
entry : './src/index.ts' ,
@@ -29,11 +32,20 @@ describe('[INTEGRATION] index', function () {
29
32
]
30
33
} ,
31
34
plugins : [
32
- new ForkTsCheckerWebpackPlugin ( Object . assign ( { } , options , { silent : true } ) )
35
+ plugin
33
36
]
34
37
} ) ;
35
38
}
36
39
40
+ /**
41
+ * Implicitly check whether killService was called by checking that
42
+ * the service property was set to undefined.
43
+ * @returns [boolean] true if killService was called
44
+ */
45
+ function killServiceWasCalled ( ) {
46
+ return plugin . service === undefined ;
47
+ }
48
+
37
49
it ( 'should allow to pass no options' , function ( ) {
38
50
expect ( function ( ) {
39
51
new ForkTsCheckerWebpackPlugin ( ) ;
@@ -108,6 +120,18 @@ describe('[INTEGRATION] index', function () {
108
120
} ) ;
109
121
} ) ;
110
122
123
+ it ( 'kills the service when the watch is done' , function ( done ) {
124
+ var compiler = createCompiler ( ) ;
125
+ var watching = compiler . watch ( { } , function ( ) { } ) ;
126
+
127
+ compiler . plugin ( 'fork-ts-checker-done' , function ( ) {
128
+ watching . close ( function ( ) {
129
+ expect ( killServiceWasCalled ( ) ) . to . be . true ;
130
+ done ( ) ;
131
+ } ) ;
132
+ } ) ;
133
+ } ) ;
134
+
111
135
it ( 'should throw error if config container wrong tsconfig.json path' , function ( ) {
112
136
expect ( function ( ) {
113
137
createCompiler ( {
0 commit comments