@@ -249,9 +249,10 @@ describe('TextBuffer IO', () => {
249249
250250 describe ( '.save' , ( ) => {
251251 let filePath
252+ let tempDir
252253
253254 beforeEach ( ( ) => {
254- const tempDir = temp . mkdirSync ( )
255+ tempDir = temp . mkdirSync ( )
255256 filePath = path . join ( tempDir , 'temp.txt' )
256257 fs . writeFileSync ( filePath , '' )
257258 buffer = new TextBuffer ( )
@@ -430,6 +431,17 @@ describe('TextBuffer IO', () => {
430431 done ( )
431432 } , buffer . fileChangeDelay ) )
432433 } )
434+
435+ it ( 'passes setPath to the custom File object' , ( done ) => {
436+ const newPath = path . join ( tempDir , 'temp2.txt' )
437+ fs . writeFileSync ( newPath , '' )
438+ buffer . setPath ( newPath )
439+ buffer . setText ( 'test' )
440+ buffer . save ( ) . then ( ( ) => {
441+ expect ( fs . readFileSync ( newPath , 'utf8' ) ) . toEqual ( 'TEST' )
442+ done ( )
443+ } )
444+ } )
433445 } )
434446
435447 describe ( 'when a permission error occurs' , ( ) => {
@@ -1153,6 +1165,10 @@ class ReverseCaseFile {
11531165 return this . path
11541166 }
11551167
1168+ setPath ( path ) {
1169+ this . path = path
1170+ }
1171+
11561172 createReadStream ( ) {
11571173 return fs . createReadStream ( this . path ) . pipe ( new Transform ( {
11581174 transform ( chunk , encoding , callback ) {
0 commit comments