@@ -279,75 +279,4 @@ describe("Compiler", () => {
279279 done ( ) ;
280280 } ) ;
281281 } ) ;
282- describe ( "Watching" , ( ) => {
283- let compiler ;
284- beforeEach ( ( ) => {
285- compiler = webpack ( {
286- entry : "./c" ,
287- context : path . join ( __dirname , "fixtures" ) ,
288- output : {
289- path : "/" ,
290- pathinfo : true ,
291- }
292- } ) ;
293- } ) ;
294- describe ( "constructor" , ( ) => {
295- it ( "constructs Watching.watchOptions correctly when passed a number, string, or object for watchOptions" , ( done ) => {
296- const Watching1 = compiler . watch ( 1000 , err => err ) ;
297- const Watching2 = compiler . watch ( {
298- aggregateTimeout : 1000
299- } , err => err ) ;
300- const Watching3 = compiler . watch ( "I am a string" , err => err ) ;
301- Watching1 . watchOptions . aggregateTimeout . should . equal ( Watching2 . watchOptions . aggregateTimeout ) ;
302- Watching3 . watchOptions . aggregateTimeout . should . equal ( 200 ) ;
303- done ( ) ;
304- } ) ;
305- it ( "invokes compiler.readRecords" , ( done ) => {
306- compiler . readRecords = sinon . spy ( ) ;
307- compiler . watch ( 1000 , err => err ) ;
308- compiler . readRecords . callCount . should . be . exactly ( 1 ) ;
309- done ( ) ;
310- } ) ;
311- } ) ;
312- describe ( "_done" , ( ) => {
313- it ( "invokes this.handler and turns this.running boolean to false when passed an error" , ( done ) => {
314- const mockHandler = sinon . spy ( ) ;
315- const Watching1 = compiler . watch ( 1000 , mockHandler ) ;
316- Watching1 . running . should . be . exactly ( true ) ;
317- Watching1 . _done ( Watching1 . handler , false ) ;
318- mockHandler . callCount . should . be . exactly ( 1 ) ;
319- Watching1 . running . should . be . exactly ( false ) ;
320- done ( ) ;
321- } ) ;
322- } ) ;
323- describe ( "invalidate" , ( ) => {
324- it ( "pauses this.watcher and sets this.watcher to null if this.watcher is true" , ( done ) => {
325- const mockPause = sinon . spy ( ) ;
326- const Watching1 = compiler . watch ( 1000 , err => err ) ;
327- Watching1 . watcher = {
328- pause : mockPause
329- } ;
330- Watching1 . invalidate ( ) ;
331- mockPause . callCount . should . be . exactly ( 1 ) ;
332- should ( Watching1 . watcher ) . be . exactly ( null ) ;
333- done ( ) ;
334- } ) ;
335- it ( "sets this.invalid to true if this.running is true, else this.invalid = false" , ( done ) => {
336- const Watching1 = compiler . watch ( 1000 , err => err ) ;
337- Watching1 . invalid = false ;
338- const response = Watching1 . invalidate ( ) ;
339- Watching1 . invalid . should . be . exactly ( true ) ;
340- response . should . be . exactly ( false ) ;
341- done ( ) ;
342- } ) ;
343- it ( "invokes this._go() if !this.running" , ( done ) => {
344- const Watching1 = compiler . watch ( 1000 , err => err ) ;
345- Watching1 . running = false ;
346- Watching1 . _go = sinon . spy ( ) ;
347- Watching1 . invalidate ( ) ;
348- Watching1 . _go . callCount . should . be . exactly ( 1 ) ;
349- done ( ) ;
350- } ) ;
351- } ) ;
352- } ) ;
353282} ) ;
0 commit comments