@@ -2293,9 +2293,13 @@ Actual: ${stringify(fullActual)}`);
2293
2293
}
2294
2294
2295
2295
public verifyCurrentFileContent ( text : string ) {
2296
- const actual = this . getFileContent ( this . activeFile . fileName ) ;
2296
+ this . verifyFileContent ( this . activeFile . fileName , text ) ;
2297
+ }
2298
+
2299
+ private verifyFileContent ( fileName : string , text : string ) {
2300
+ const actual = this . getFileContent ( fileName ) ;
2297
2301
if ( actual !== text ) {
2298
- throw new Error ( `verifyCurrentFileContent failed:\n${ showTextDiff ( text , actual ) } ` ) ;
2302
+ throw new Error ( `verifyFileContent failed:\n${ showTextDiff ( text , actual ) } ` ) ;
2299
2303
}
2300
2304
}
2301
2305
@@ -2483,7 +2487,7 @@ Actual: ${stringify(fullActual)}`);
2483
2487
2484
2488
this . applyCodeActions ( details . codeActions ) ;
2485
2489
2486
- this . verifyNewContent ( options ) ;
2490
+ this . verifyNewContent ( options , ts . flatMap ( details . codeActions , a => a . changes . map ( c => c . fileName ) ) ) ;
2487
2491
}
2488
2492
2489
2493
public verifyRangeIs ( expectedText : string , includeWhiteSpace ?: boolean ) {
@@ -2570,13 +2574,25 @@ Actual: ${stringify(fullActual)}`);
2570
2574
this . applyEdits ( change . fileName , change . textChanges , /*isFormattingEdit*/ false ) ;
2571
2575
}
2572
2576
2573
- this . verifyNewContent ( options ) ;
2577
+ this . verifyNewContent ( options , action . changes . map ( c => c . fileName ) ) ;
2574
2578
}
2575
2579
2576
- private verifyNewContent ( options : FourSlashInterface . NewContentOptions ) {
2580
+ private verifyNewContent ( options : FourSlashInterface . NewContentOptions , changedFiles : ReadonlyArray < string > ) {
2581
+ const assertedChangedFiles = ! options . newFileContent || typeof options . newFileContent === "string"
2582
+ ? [ this . activeFile . fileName ]
2583
+ : ts . getOwnKeys ( options . newFileContent ) ;
2584
+ assert . deepEqual ( assertedChangedFiles , changedFiles ) ;
2585
+
2577
2586
if ( options . newFileContent !== undefined ) {
2578
2587
assert ( ! options . newRangeContent ) ;
2579
- this . verifyCurrentFileContent ( options . newFileContent ) ;
2588
+ if ( typeof options . newFileContent === "string" ) {
2589
+ this . verifyCurrentFileContent ( options . newFileContent ) ;
2590
+ }
2591
+ else {
2592
+ for ( const fileName in options . newFileContent ) {
2593
+ this . verifyFileContent ( fileName , options . newFileContent [ fileName ] ) ;
2594
+ }
2595
+ }
2580
2596
}
2581
2597
else {
2582
2598
this . verifyRangeIs ( options . newRangeContent , /*includeWhitespace*/ true ) ;
@@ -4781,7 +4797,7 @@ namespace FourSlashInterface {
4781
4797
4782
4798
export interface NewContentOptions {
4783
4799
// Exactly one of these should be defined.
4784
- newFileContent ?: string ;
4800
+ newFileContent ?: string | { readonly [ filename : string ] : string } ;
4785
4801
newRangeContent ?: string ;
4786
4802
}
4787
4803
0 commit comments