@@ -45,7 +45,9 @@ describe('browserify preprocessor', function () {
4545
4646 sandbox . stub ( fs , 'ensureDirAsync' ) . resolves ( )
4747
48- this . config = { }
48+ this . config = {
49+ isTextTerminal : true ,
50+ }
4951 this . userOptions = { }
5052 this . filePath = 'path/to/file.js'
5153 this . outputPath = 'output/output.js'
@@ -62,7 +64,7 @@ describe('browserify preprocessor', function () {
6264
6365 describe ( 'exported function' , function ( ) {
6466 it ( 'receives user options and returns a preprocessor function' , function ( ) {
65- expect ( preprocessor ( this . userOptions ) ) . to . be . a ( 'function' )
67+ expect ( preprocessor ( this . config , this . userOptions ) ) . to . be . a ( 'function' )
6668 } )
6769 } )
6870
@@ -86,7 +88,7 @@ describe('browserify preprocessor', function () {
8688 browserify . reset ( )
8789 browserify . returns ( this . bundlerApi )
8890
89- const run = preprocessor ( this . userOptions )
91+ const run = preprocessor ( this . config , this . userOptions )
9092 return run ( this . filePath , this . util )
9193 . then ( ( ) => {
9294 return run ( this . filePath , this . util )
@@ -104,7 +106,7 @@ describe('browserify preprocessor', function () {
104106
105107 it ( 'specifies default extensions if none provided' , function ( ) {
106108 return this . run ( ) . then ( ( ) => {
107- expect ( browserify . lastCall . args [ 0 ] . extensions ) . to . eql ( [ '.js' ] )
109+ expect ( browserify . lastCall . args [ 0 ] . extensions ) . to . eql ( [ '.js' , '.jsx' , '.coffee' , '.cjsx' ] )
108110 } )
109111 } )
110112
@@ -122,9 +124,25 @@ describe('browserify preprocessor', function () {
122124 } )
123125 } )
124126
125- it ( 'includes watchifyOptions if provided' , function ( ) {
127+ it ( 'use default watchOptions if not provided' , function ( ) {
128+ this . config . isTextTerminal = false
129+ return this . run ( ) . then ( ( ) => {
130+ expect ( this . bundlerApi . plugin ) . to . be . calledWith ( watchify , {
131+ ignoreWatch : [
132+ '**/.git/**' ,
133+ '**/.nyc_output/**' ,
134+ '**/.sass-cache/**' ,
135+ '**/bower_components/**' ,
136+ '**/coverage/**' ,
137+ '**/node_modules/**' ,
138+ ] ,
139+ } )
140+ } )
141+ } )
142+
143+ it ( 'includes watchOptions if provided' , function ( ) {
126144 this . config . isTextTerminal = false
127- this . userOptions . watchifyOptions = { ignoreWatch : [ 'node_modules' ] }
145+ this . userOptions . watchOptions = { ignoreWatch : [ 'node_modules' ] }
128146 return this . run ( ) . then ( ( ) => {
129147 expect ( this . bundlerApi . plugin ) . to . be . calledWith ( watchify , {
130148 ignoreWatch : [ 'node_modules' ] ,
@@ -133,7 +151,6 @@ describe('browserify preprocessor', function () {
133151 } )
134152
135153 it ( 'does not watch when isTextTerminal is true' , function ( ) {
136- this . config . isTextTerminal = true
137154 return this . run ( ) . then ( ( ) => {
138155 expect ( this . bundlerApi . plugin ) . not . to . be . called
139156 } )
@@ -210,7 +227,6 @@ describe('browserify preprocessor', function () {
210227 } )
211228
212229 it ( 'does not close bundler when isTextTerminal is true and onClose callback is called' , function ( ) {
213- this . config . isTextTerminal = true
214230 return this . run ( ) . then ( ( ) => {
215231 this . util . onClose . lastCall . args [ 0 ] ( )
216232 expect ( this . bundlerApi . close ) . not . to . be . called
0 commit comments