Add test that getEditsForFileRename respects UserPreferences (#25745)

* Add test that getEditsForFileRename respects UserPreferences

* Test quotePreference
This commit is contained in:
Andy
2018-07-17 17:05:35 -07:00
committed by GitHub
parent 854462d383
commit d92c26db69
3 changed files with 33 additions and 5 deletions

View File

@@ -3365,9 +3365,9 @@ Actual: ${stringify(fullActual)}`);
this.cancellationToken.resetCancelled();
}
public getEditsForFileRename({ oldPath, newPath, newFileContents }: FourSlashInterface.GetEditsForFileRenameOptions): void {
public getEditsForFileRename({ oldPath, newPath, newFileContents, preferences }: FourSlashInterface.GetEditsForFileRenameOptions): void {
const test = (fileContents: { readonly [fileName: string]: string }, description: string): void => {
const changes = this.languageService.getEditsForFileRename(oldPath, newPath, this.formatCodeSettings, ts.emptyOptions);
const changes = this.languageService.getEditsForFileRename(oldPath, newPath, this.formatCodeSettings, preferences);
this.testNewFileContents(changes, fileContents, description);
};
@@ -4890,6 +4890,7 @@ namespace FourSlashInterface {
readonly oldPath: string;
readonly newPath: string;
readonly newFileContents: { readonly [fileName: string]: string };
readonly preferences?: ts.UserPreferences;
}
export interface MoveToNewFileOptions {

View File

@@ -336,9 +336,10 @@ declare namespace FourSlashInterface {
ProjectInfo(expected: string[]): void;
allRangesAppearInImplementationList(markerName: string): void;
getEditsForFileRename(options: {
oldPath: string;
newPath: string;
newFileContents: { [fileName: string]: string };
readonly oldPath: string;
readonly newPath: string;
readonly newFileContents: { readonly [fileName: string]: string };
readonly preferences?: UserPreferences;
}): void;
moveToNewFile(options: {
readonly newFileContents: { readonly [fileName: string]: string };

View File

@@ -0,0 +1,26 @@
/// <reference path='fourslash.ts' />
// @Filename: /dir/a.ts
////export const a = 0;
// @Filename: /dir/b.ts
////import {} from "dir/a";
////import {} from 'dir/a';
// @Filename: /tsconfig.json
////{ "compilerOptions": { "baseUrl": "." } }
verify.getEditsForFileRename({
oldPath: "/dir/a.ts",
newPath: "/dir/a1.ts",
newFileContents: {
"/dir/b.ts":
`import {} from "dir/a1";
import {} from 'dir/a1';`,
},
preferences: {
importModuleSpecifierPreference: "non-relative",
// No effect because we are changing existing imports, which already have quotes
quotePreference: "single",
},
});