Skip to content

Commit 435a12e

Browse files
author
Andy
authored
Remove some duplicate code in convertToAsyncFunction unit tests (#26527)
1 parent 926bdee commit 435a12e

File tree

2 files changed

+2
-34
lines changed

2 files changed

+2
-34
lines changed

src/testRunner/unittests/convertToAsyncFunction.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -319,38 +319,6 @@ interface String { charAt: any; }
319319
interface Array<T> {}`
320320
};
321321

322-
const newLineCharacter = "\n";
323-
const formatOptions: FormatCodeSettings = {
324-
indentSize: 4,
325-
tabSize: 4,
326-
newLineCharacter,
327-
convertTabsToSpaces: true,
328-
indentStyle: IndentStyle.Smart,
329-
insertSpaceAfterConstructor: false,
330-
insertSpaceAfterCommaDelimiter: true,
331-
insertSpaceAfterSemicolonInForStatements: true,
332-
insertSpaceBeforeAndAfterBinaryOperators: true,
333-
insertSpaceAfterKeywordsInControlFlowStatements: true,
334-
insertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
335-
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
336-
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
337-
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,
338-
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
339-
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false,
340-
insertSpaceBeforeFunctionParenthesis: false,
341-
placeOpenBraceOnNewLineForFunctions: false,
342-
placeOpenBraceOnNewLineForControlBlocks: false,
343-
};
344-
345-
const notImplementedHost: LanguageServiceHost = {
346-
getCompilationSettings: notImplemented,
347-
getScriptFileNames: notImplemented,
348-
getScriptVersion: notImplemented,
349-
getScriptSnapshot: notImplemented,
350-
getDefaultLibFileName: notImplemented,
351-
getCurrentDirectory: notImplemented,
352-
};
353-
354322
function testConvertToAsyncFunction(caption: string, text: string, baselineFolder: string, description: DiagnosticMessage, includeLib?: boolean) {
355323
const t = getTest(text);
356324
const selectionRange = t.ranges.get("selection")!;
@@ -389,7 +357,7 @@ interface Array<T> {}`
389357
cancellationToken: { throwIfCancellationRequested: noop, isCancellationRequested: returnFalse },
390358
preferences: emptyOptions,
391359
host: notImplementedHost,
392-
formatContext: formatting.getFormatContext(formatOptions)
360+
formatContext: formatting.getFormatContext(testFormatOptions)
393361
};
394362

395363
const diagnostics = languageService.getSuggestionDiagnostics(f.path);

src/testRunner/unittests/extractTestHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace ts {
8686
placeOpenBraceOnNewLineForControlBlocks: false,
8787
};
8888

89-
const notImplementedHost: LanguageServiceHost = {
89+
export const notImplementedHost: LanguageServiceHost = {
9090
getCompilationSettings: notImplemented,
9191
getScriptFileNames: notImplemented,
9292
getScriptVersion: notImplemented,

0 commit comments

Comments
 (0)