mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 21:07:52 -05:00
Add test that getEditsForFileRename respects UserPreferences (#25745)
* Add test that getEditsForFileRename respects UserPreferences * Test quotePreference
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 };
|
||||
|
||||
26
tests/cases/fourslash/getEditsForFileRename_preferences.ts
Normal file
26
tests/cases/fourslash/getEditsForFileRename_preferences.ts
Normal 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",
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user