@@ -7,9 +7,6 @@ const tmp = require('tmp');
77
88const originalCwd = process . cwd ( ) ;
99
10- const inputFile = path . join ( originalCwd , '__testfixtures__/final-boss.input.js' ) ;
11- const outputFile = path . join ( originalCwd , '__testfixtures__/final-boss.output.js' ) ;
12-
1310let tmpPath ;
1411
1512function run ( ) {
@@ -95,6 +92,9 @@ describe('bin acceptance', function() {
9592
9693 describe ( 'with valid file' , function ( ) {
9794 let tmpFile ;
95+ const inputFile = path . join ( originalCwd , '__testfixtures__/final-boss.input.js' ) ;
96+ const outputFile = path . join ( originalCwd , '__testfixtures__/final-boss.output.js' ) ;
97+
9898
9999 beforeEach ( function ( ) {
100100 fs . ensureDirSync ( path . join ( tmpPath , 'app' ) ) ;
@@ -120,5 +120,37 @@ describe('bin acceptance', function() {
120120 } ) ;
121121 } ) ;
122122 } ) ;
123+
124+ describe ( 'with invalid file' , function ( ) {
125+ const inputFile = path . join ( originalCwd , '__testfixtures__/leave-unmatched-destructuring.input.js' ) ;
126+
127+ beforeEach ( function ( ) {
128+ fs . ensureDirSync ( path . join ( tmpPath , 'app' ) ) ;
129+
130+ let tmpFile = path . join ( tmpPath , 'app/leave-unmatched-destructuring.input.js' ) ;
131+
132+ fs . copySync (
133+ inputFile ,
134+ tmpFile
135+ ) ;
136+ } ) ;
137+
138+ it ( 'reports errors' , function ( ) {
139+ return run ( ) . then ( result => {
140+ let exitCode = result . exitCode ;
141+ let stdout = result . stdout ;
142+
143+ expect ( exitCode ) . toEqual ( 0 ) ;
144+
145+ expect ( stdout ) . toMatch ( 'Done! Some files could not be upgraded automatically. See MODULE_REPORT.md.\n' ) ;
146+
147+ let expectedOutput = fs . readFileSync ( path . join ( __dirname , 'expected' , 'MODULE_REPORT.md' ) , 'utf8' )
148+ . replace ( / \/ / , path . sep ) ;
149+ let actualOutput = fs . readFileSync ( path . join ( tmpPath , 'MODULE_REPORT.md' ) , 'utf8' ) ;
150+
151+ expect ( actualOutput ) . toEqual ( expectedOutput ) ;
152+ } ) ;
153+ } ) ;
154+ } ) ;
123155 } ) ;
124156} ) ;
0 commit comments