From 21ea0178c5dc61633aec217e95bd517540047feb Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 1 Mar 2019 13:23:02 -0800 Subject: [PATCH] Refactor the tests --- src/testRunner/unittests/tsbuild/outFile.ts | 640 ++++++++++---------- 1 file changed, 327 insertions(+), 313 deletions(-) diff --git a/src/testRunner/unittests/tsbuild/outFile.ts b/src/testRunner/unittests/tsbuild/outFile.ts index 819f0e5d73d..e4c4e0cc639 100644 --- a/src/testRunner/unittests/tsbuild/outFile.ts +++ b/src/testRunner/unittests/tsbuild/outFile.ts @@ -442,241 +442,250 @@ namespace ts { describe("Prepend output with .tsbuildinfo", () => { // Prologues - function enableStrict(fs: vfs.FileSystem, path: string) { - replaceText(fs, path, `"strict": false`, `"strict": true`); - } + describe("Prologues", () => { + function enableStrict(fs: vfs.FileSystem, path: string) { + replaceText(fs, path, `"strict": false`, `"strict": true`); + } - // Verify initial + incremental edits - verifyOutFileScenario({ - scenario: "strict in all projects", - modifyFs: fs => { - enableStrict(fs, sources[project.first][source.config]); - enableStrict(fs, sources[project.second][source.config]); - enableStrict(fs, sources[project.third][source.config]); - }, - modifyAgainFs: fs => addPrologue(fs, relSources[project.first][source.ts][part.one], `"myPrologue"`) - }); + // Verify initial + incremental edits + verifyOutFileScenario({ + scenario: "strict in all projects", + modifyFs: fs => { + enableStrict(fs, sources[project.first][source.config]); + enableStrict(fs, sources[project.second][source.config]); + enableStrict(fs, sources[project.third][source.config]); + }, + modifyAgainFs: fs => addPrologue(fs, relSources[project.first][source.ts][part.one], `"myPrologue"`) + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "strict in one dependency", - modifyFs: fs => enableStrict(fs, sources[project.second][source.config]), - modifyAgainFs: fs => addPrologue(fs, "src/first/first_PART1.ts", `"myPrologue"`), - ignoreDtsChanged: true, - baselineOnly: true - }); + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "strict in one dependency", + modifyFs: fs => enableStrict(fs, sources[project.second][source.config]), + modifyAgainFs: fs => addPrologue(fs, "src/first/first_PART1.ts", `"myPrologue"`), + ignoreDtsChanged: true, + baselineOnly: true + }); - function addPrologue(fs: vfs.FileSystem, path: string, prologue: string) { - prependText(fs, path, `${prologue} + function addPrologue(fs: vfs.FileSystem, path: string, prologue: string) { + prependText(fs, path, `${prologue} `); - } + } - // Verify initial + incremental edits - sourcemap verification - verifyOutFileScenario({ - scenario: "multiple prologues in all projects", - modifyFs: fs => { - enableStrict(fs, sources[project.first][source.config]); - addPrologue(fs, sources[project.first][source.ts][part.one], `"myPrologue"`); - enableStrict(fs, sources[project.second][source.config]); - addPrologue(fs, sources[project.second][source.ts][part.one], `"myPrologue"`); - addPrologue(fs, sources[project.second][source.ts][part.two], `"myPrologue2";`); - enableStrict(fs, sources[project.third][source.config]); - addPrologue(fs, sources[project.third][source.ts][part.one], `"myPrologue";`); - addPrologue(fs, sources[project.third][source.ts][part.one], `"myPrologue3";`); - }, - modifyAgainFs: fs => addPrologue(fs, relSources[project.first][source.ts][part.one], `"myPrologue5"`) - }); + // Verify initial + incremental edits - sourcemap verification + verifyOutFileScenario({ + scenario: "multiple prologues in all projects", + modifyFs: fs => { + enableStrict(fs, sources[project.first][source.config]); + addPrologue(fs, sources[project.first][source.ts][part.one], `"myPrologue"`); + enableStrict(fs, sources[project.second][source.config]); + addPrologue(fs, sources[project.second][source.ts][part.one], `"myPrologue"`); + addPrologue(fs, sources[project.second][source.ts][part.two], `"myPrologue2";`); + enableStrict(fs, sources[project.third][source.config]); + addPrologue(fs, sources[project.third][source.ts][part.one], `"myPrologue";`); + addPrologue(fs, sources[project.third][source.ts][part.one], `"myPrologue3";`); + }, + modifyAgainFs: fs => addPrologue(fs, relSources[project.first][source.ts][part.one], `"myPrologue5"`) + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "multiple prologues in different projects", - modifyFs: fs => { - enableStrict(fs, sources[project.first][source.config]); - addPrologue(fs, sources[project.second][source.ts][part.one], `"myPrologue"`); - addPrologue(fs, sources[project.second][source.ts][part.two], `"myPrologue2";`); - enableStrict(fs, sources[project.third][source.config]); - }, - modifyAgainFs: fs => addPrologue(fs, sources[project.first][source.ts][part.one], `"myPrologue5"`), - ignoreDtsChanged: true, - baselineOnly: true + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "multiple prologues in different projects", + modifyFs: fs => { + enableStrict(fs, sources[project.first][source.config]); + addPrologue(fs, sources[project.second][source.ts][part.one], `"myPrologue"`); + addPrologue(fs, sources[project.second][source.ts][part.two], `"myPrologue2";`); + enableStrict(fs, sources[project.third][source.config]); + }, + modifyAgainFs: fs => addPrologue(fs, sources[project.first][source.ts][part.one], `"myPrologue5"`), + ignoreDtsChanged: true, + baselineOnly: true + }); }); // Shebang - function addShebang(fs: vfs.FileSystem, project: string, file: string) { - prependText(fs, `src/${project}/${file}.ts`, `#!someshebang ${project} ${file} + describe("Shebang", () => { + function addShebang(fs: vfs.FileSystem, project: string, file: string) { + prependText(fs, `src/${project}/${file}.ts`, `#!someshebang ${project} ${file} `); - } + } - // changes declaration because its emitted in .d.ts file - // Verify initial + incremental edits - verifyOutFileScenario({ - scenario: "shebang in all projects", - modifyFs: fs => { - addShebang(fs, "first", "first_PART1"); - addShebang(fs, "first", "first_part2"); - addShebang(fs, "second", "second_part1"); - addShebang(fs, "third", "third_part1"); - }, - }); + // changes declaration because its emitted in .d.ts file + // Verify initial + incremental edits + verifyOutFileScenario({ + scenario: "shebang in all projects", + modifyFs: fs => { + addShebang(fs, "first", "first_PART1"); + addShebang(fs, "first", "first_part2"); + addShebang(fs, "second", "second_part1"); + addShebang(fs, "third", "third_part1"); + }, + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "shebang in only one dependency project", - modifyFs: fs => addShebang(fs, "second", "second_part1"), - ignoreDtsChanged: true, - baselineOnly: true + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "shebang in only one dependency project", + modifyFs: fs => addShebang(fs, "second", "second_part1"), + ignoreDtsChanged: true, + baselineOnly: true + }); }); // emitHelpers - function restContent(project: string, file: string) { - return `function for${project}${file}Rest() { + describe("emitHelpers", () => { + function restContent(project: string, file: string) { + return `function for${project}${file}Rest() { const { b, ...rest } = { a: 10, b: 30, yy: 30 }; }`; - } + } - function nonrestContent(project: string, file: string) { - return `function for${project}${file}Rest() { }`; - } + function nonrestContent(project: string, file: string) { + return `function for${project}${file}Rest() { }`; + } - function addRest(fs: vfs.FileSystem, project: string, file: string) { - appendText(fs, `src/${project}/${file}.ts`, restContent(project, file)); - } + function addRest(fs: vfs.FileSystem, project: string, file: string) { + appendText(fs, `src/${project}/${file}.ts`, restContent(project, file)); + } - function removeRest(fs: vfs.FileSystem, project: string, file: string) { - replaceText(fs, `src/${project}/${file}.ts`, restContent(project, file), nonrestContent(project, file)); - } + function removeRest(fs: vfs.FileSystem, project: string, file: string) { + replaceText(fs, `src/${project}/${file}.ts`, restContent(project, file), nonrestContent(project, file)); + } - function addStubFoo(fs: vfs.FileSystem, project: string, file: string) { - appendText(fs, `src/${project}/${file}.ts`, nonrestContent(project, file)); - } + function addStubFoo(fs: vfs.FileSystem, project: string, file: string) { + appendText(fs, `src/${project}/${file}.ts`, nonrestContent(project, file)); + } - function changeStubToRest(fs: vfs.FileSystem, project: string, file: string) { - replaceText(fs, `src/${project}/${file}.ts`, nonrestContent(project, file), restContent(project, file)); - } + function changeStubToRest(fs: vfs.FileSystem, project: string, file: string) { + replaceText(fs, `src/${project}/${file}.ts`, nonrestContent(project, file), restContent(project, file)); + } - // Verify initial + incremental edits - verifyOutFileScenario({ - scenario: "emitHelpers in all projects", - modifyFs: fs => { - addRest(fs, "first", "first_PART1"); - addRest(fs, "second", "second_part1"); - addRest(fs, "third", "third_part1"); - }, - modifyAgainFs: fs => removeRest(fs, "first", "first_PART1") - }); + // Verify initial + incremental edits + verifyOutFileScenario({ + scenario: "emitHelpers in all projects", + modifyFs: fs => { + addRest(fs, "first", "first_PART1"); + addRest(fs, "second", "second_part1"); + addRest(fs, "third", "third_part1"); + }, + modifyAgainFs: fs => removeRest(fs, "first", "first_PART1") + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "emitHelpers in only one dependency project", - modifyFs: fs => { - addStubFoo(fs, "first", "first_PART1"); - addRest(fs, "second", "second_part1"); - }, - modifyAgainFs: fs => changeStubToRest(fs, "first", "first_PART1"), - ignoreDtsChanged: true, - baselineOnly: true - }); + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "emitHelpers in only one dependency project", + modifyFs: fs => { + addStubFoo(fs, "first", "first_PART1"); + addRest(fs, "second", "second_part1"); + }, + modifyAgainFs: fs => changeStubToRest(fs, "first", "first_PART1"), + ignoreDtsChanged: true, + baselineOnly: true + }); - function addSpread(fs: vfs.FileSystem, project: string, file: string) { - const path = `src/${project}/${file}.ts`; - const content = fs.readFileSync(path, "utf8"); - fs.writeFileSync(path, `${content} + function addSpread(fs: vfs.FileSystem, project: string, file: string) { + const path = `src/${project}/${file}.ts`; + const content = fs.readFileSync(path, "utf8"); + fs.writeFileSync(path, `${content} function ${project}${file}Spread(...b: number[]) { } ${project}${file}Spread(...[10, 20, 30]);`); - replaceText(fs, `src/${project}/tsconfig.json`, `"strict": false,`, `"strict": false, + replaceText(fs, `src/${project}/tsconfig.json`, `"strict": false,`, `"strict": false, "downlevelIteration": true,`); - } + } - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "multiple emitHelpers in all projects", - modifyFs: fs => { - addRest(fs, "first", "first_PART1"); - addSpread(fs, "first", "first_part3"); - addRest(fs, "second", "second_part1"); - addSpread(fs, "second", "second_part2"); - addRest(fs, "third", "third_part1"); - addSpread(fs, "third", "third_part1"); - }, - modifyAgainFs: fs => removeRest(fs, "first", "first_PART1"), - ignoreDtsChanged: true, - baselineOnly: true - }); + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "multiple emitHelpers in all projects", + modifyFs: fs => { + addRest(fs, "first", "first_PART1"); + addSpread(fs, "first", "first_part3"); + addRest(fs, "second", "second_part1"); + addSpread(fs, "second", "second_part2"); + addRest(fs, "third", "third_part1"); + addSpread(fs, "third", "third_part1"); + }, + modifyAgainFs: fs => removeRest(fs, "first", "first_PART1"), + ignoreDtsChanged: true, + baselineOnly: true + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "multiple emitHelpers in different projects", - modifyFs: fs => { - addRest(fs, "first", "first_PART1"); - addSpread(fs, "second", "second_part1"); - addRest(fs, "third", "third_part1"); - }, - modifyAgainFs: fs => removeRest(fs, "first", "first_PART1"), - ignoreDtsChanged: true, - baselineOnly: true + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "multiple emitHelpers in different projects", + modifyFs: fs => { + addRest(fs, "first", "first_PART1"); + addSpread(fs, "second", "second_part1"); + addRest(fs, "third", "third_part1"); + }, + modifyAgainFs: fs => removeRest(fs, "first", "first_PART1"), + ignoreDtsChanged: true, + baselineOnly: true + }); }); // triple slash refs - // changes declaration because its emitted in .d.ts file - function getTripleSlashRef(project: string) { - return `/src/${project}/tripleRef.d.ts`; - } + describe("triple slash refs", () => { + // changes declaration because its emitted in .d.ts file + function getTripleSlashRef(project: string) { + return `/src/${project}/tripleRef.d.ts`; + } - function addTripleSlashRef(fs: vfs.FileSystem, project: string, file: string) { - fs.writeFileSync(getTripleSlashRef(project), `declare class ${project}${file} { }`); - prependText(fs, `src/${project}/${file}.ts`, `/// + function addTripleSlashRef(fs: vfs.FileSystem, project: string, file: string) { + fs.writeFileSync(getTripleSlashRef(project), `declare class ${project}${file} { }`); + prependText(fs, `src/${project}/${file}.ts`, `/// const ${file}Const = new ${project}${file}(); `); - } - - // Verify initial + incremental edits - verifyOutFileScenario({ - scenario: "triple slash refs in all projects", - modifyFs: fs => { - addTripleSlashRef(fs, "first", "first_part2"); - addTripleSlashRef(fs, "second", "second_part1"); - addTripleSlashRef(fs, "third", "third_part1"); - }, - additionalSourceFiles: [ - getTripleSlashRef("first"), getTripleSlashRef("second"), getTripleSlashRef("third") - ] - }); - - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "triple slash refs in one project", - modifyFs: fs => addTripleSlashRef(fs, "second", "second_part1"), - additionalSourceFiles: [ - getTripleSlashRef("second") - ], - ignoreDtsChanged: true, - baselineOnly: true - }); - - function disableRemoveComments(fs: vfs.FileSystem, file: string) { - replaceText(fs, file, `"removeComments": true`, `"removeComments": false`); - } - - function diableRemoveCommentsInAll(fs: vfs.FileSystem) { - disableRemoveComments(fs, sources[project.first][source.config]); - disableRemoveComments(fs, sources[project.second][source.config]); - disableRemoveComments(fs, sources[project.third][source.config]); - } - - function stripInternalOfThird(fs: vfs.FileSystem) { - replaceText(fs, sources[project.third][source.config], `"declaration": true,`, `"declaration": true, -"stripInternal": true`); - } - - function stripInternalScenario(fs: vfs.FileSystem, removeCommentsDisabled?: boolean, jsDocStyle?: boolean) { - const internal = jsDocStyle ? `/**@internal*/` : `/*@internal*/`; - if (removeCommentsDisabled) { - diableRemoveCommentsInAll(fs); } - stripInternalOfThird(fs); - replaceText(fs, sources[project.first][source.ts][part.one], "interface", `${internal} interface`); - appendText(fs, sources[project.second][source.ts][part.one], ` + + // Verify initial + incremental edits + verifyOutFileScenario({ + scenario: "triple slash refs in all projects", + modifyFs: fs => { + addTripleSlashRef(fs, "first", "first_part2"); + addTripleSlashRef(fs, "second", "second_part1"); + addTripleSlashRef(fs, "third", "third_part1"); + }, + additionalSourceFiles: [ + getTripleSlashRef("first"), getTripleSlashRef("second"), getTripleSlashRef("third") + ] + }); + + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "triple slash refs in one project", + modifyFs: fs => addTripleSlashRef(fs, "second", "second_part1"), + additionalSourceFiles: [ + getTripleSlashRef("second") + ], + ignoreDtsChanged: true, + baselineOnly: true + }); + }); + + describe("stripInternal", () => { + function disableRemoveComments(fs: vfs.FileSystem, file: string) { + replaceText(fs, file, `"removeComments": true`, `"removeComments": false`); + } + + function diableRemoveCommentsInAll(fs: vfs.FileSystem) { + disableRemoveComments(fs, sources[project.first][source.config]); + disableRemoveComments(fs, sources[project.second][source.config]); + disableRemoveComments(fs, sources[project.third][source.config]); + } + + function stripInternalOfThird(fs: vfs.FileSystem) { + replaceText(fs, sources[project.third][source.config], `"declaration": true,`, `"declaration": true, +"stripInternal": true`); + } + + function stripInternalScenario(fs: vfs.FileSystem, removeCommentsDisabled?: boolean, jsDocStyle?: boolean) { + const internal = jsDocStyle ? `/**@internal*/` : `/*@internal*/`; + if (removeCommentsDisabled) { + diableRemoveCommentsInAll(fs); + } + stripInternalOfThird(fs); + replaceText(fs, sources[project.first][source.ts][part.one], "interface", `${internal} interface`); + appendText(fs, sources[project.second][source.ts][part.one], ` class normalC { ${internal} constructor() { } ${internal} prop: string; @@ -702,107 +711,97 @@ ${internal} import internalImport = internalNamespace.someClass; ${internal} type internalType = internalC; ${internal} const internalConst = 10; ${internal} enum internalEnum { a, b, c }`); - } + } - // Verify initial + incremental edits - verifyOutFileScenario({ - scenario: "stripInternal", - modifyFs: stripInternalScenario, - modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), - }); + // Verify initial + incremental edits + verifyOutFileScenario({ + scenario: "stripInternal", + modifyFs: stripInternalScenario, + modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "stripInternal with comments emit enabled", - modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true), - modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), - ignoreDtsChanged: true, - baselineOnly: true - }); + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "stripInternal with comments emit enabled", + modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true), + modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), + ignoreDtsChanged: true, + baselineOnly: true + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "stripInternal jsdoc style comment", - modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true), - modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface"), - ignoreDtsChanged: true, - baselineOnly: true - }); + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "stripInternal jsdoc style comment", + modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true), + modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface"), + ignoreDtsChanged: true, + baselineOnly: true + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "stripInternal jsdoc style with comments emit enabled", - modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true, /*jsDocStyle*/ true), - ignoreDtsChanged: true, - baselineOnly: true - }); + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "stripInternal jsdoc style with comments emit enabled", + modifyFs: fs => stripInternalScenario(fs, /*removeCommentsDisabled*/ true, /*jsDocStyle*/ true), + ignoreDtsChanged: true, + baselineOnly: true + }); - function makeOneTwoThreeDependOrder(fs: vfs.FileSystem) { - replaceText(fs, sources[project.second][source.config], "[", `[ + describe("with three levels of project dependency", () => { + function makeOneTwoThreeDependOrder(fs: vfs.FileSystem) { + replaceText(fs, sources[project.second][source.config], "[", `[ { "path": "../first", "prepend": true }`); - replaceText(fs, sources[project.third][source.config], `{ "path": "../first", "prepend": true },`, ""); - } + replaceText(fs, sources[project.third][source.config], `{ "path": "../first", "prepend": true },`, ""); + } - function stripInternalWithDependentOrder(fs: vfs.FileSystem, removeCommentsDisabled?: boolean, jsDocStyle?: boolean) { - stripInternalScenario(fs, removeCommentsDisabled, jsDocStyle); - makeOneTwoThreeDependOrder(fs); - } + function stripInternalWithDependentOrder(fs: vfs.FileSystem, removeCommentsDisabled?: boolean, jsDocStyle?: boolean) { + stripInternalScenario(fs, removeCommentsDisabled, jsDocStyle); + makeOneTwoThreeDependOrder(fs); + } - // Verify initial + incremental edits - verifyOutFileScenario({ - scenario: "stripInternal when one-two-three are prepended in order", - modifyFs: stripInternalWithDependentOrder, - modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), - dependOrdered: true, - }); + // Verify initial + incremental edits + verifyOutFileScenario({ + scenario: "stripInternal when one-two-three are prepended in order", + modifyFs: stripInternalWithDependentOrder, + modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), + dependOrdered: true, + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "stripInternal with comments emit enabled when one-two-three are prepended in order", - modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true), - modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), - dependOrdered: true, - ignoreDtsChanged: true, - baselineOnly: true - }); + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "stripInternal with comments emit enabled when one-two-three are prepended in order", + modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true), + modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/*@internal*/ interface`, "interface"), + dependOrdered: true, + ignoreDtsChanged: true, + baselineOnly: true + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "stripInternal jsdoc style comment when one-two-three are prepended in order", - modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true), - modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface"), - dependOrdered: true, - ignoreDtsChanged: true, - baselineOnly: true - }); + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "stripInternal jsdoc style comment when one-two-three are prepended in order", + modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ false, /*jsDocStyle*/ true), + modifyAgainFs: fs => replaceText(fs, sources[project.first][source.ts][part.one], `/**@internal*/ interface`, "interface"), + dependOrdered: true, + ignoreDtsChanged: true, + baselineOnly: true + }); - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "stripInternal jsdoc style with comments emit enabled when one-two-three are prepended in order", - modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true, /*jsDocStyle*/ true), - dependOrdered: true, - ignoreDtsChanged: true, - baselineOnly: true - }); + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "stripInternal jsdoc style with comments emit enabled when one-two-three are prepended in order", + modifyFs: fs => stripInternalWithDependentOrder(fs, /*removeCommentsDisabled*/ true, /*jsDocStyle*/ true), + dependOrdered: true, + ignoreDtsChanged: true, + baselineOnly: true + }); + }); - function makeThirdEmptySourceFile(fs: vfs.FileSystem) { - fs.writeFileSync(sources[project.third][source.ts][part.one], "", "utf8"); - } - - // Verify ignore dtsChanged - verifyOutFileScenario({ - scenario: "when source files are empty in the own file", - modifyFs: makeThirdEmptySourceFile, - ignoreDtsChanged: true, - baselineOnly: true - }); - - // only baseline - verifyOutFileScenario({ - scenario: "stripInternal baseline when internal is inside another internal", - modifyFs: fs => { - stripInternalOfThird(fs); - prependText(fs, sources[project.first][source.ts][part.one], `namespace ts { + // only baseline + verifyOutFileScenario({ + scenario: "stripInternal baseline when internal is inside another internal", + modifyFs: fs => { + stripInternalOfThird(fs); + prependText(fs, sources[project.first][source.ts][part.one], `namespace ts { /* @internal */ /** * Subset of properties from SourceFile that are used in multiple utility functions @@ -830,18 +829,18 @@ ${internal} enum internalEnum { a, b, c }`); someProp: string; } }`); - }, - ignoreDtsChanged: true, - ignoreDtsUnchanged: true, - baselineOnly: true - }); + }, + ignoreDtsChanged: true, + ignoreDtsUnchanged: true, + baselineOnly: true + }); - // only baseline - verifyOutFileScenario({ - scenario: "stripInternal when few members of enum are internal", - modifyFs: fs => { - stripInternalOfThird(fs); - prependText(fs, sources[project.first][source.ts][part.one], `enum TokenFlags { + // only baseline + verifyOutFileScenario({ + scenario: "stripInternal when few members of enum are internal", + modifyFs: fs => { + stripInternalOfThird(fs); + prependText(fs, sources[project.first][source.ts][part.one], `enum TokenFlags { None = 0, /* @internal */ PrecedingLineBreak = 1 << 0, @@ -864,24 +863,39 @@ ${internal} enum internalEnum { a, b, c }`); NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinaryOrOctalSpecifier | ContainsSeparator } `); - }, - ignoreDtsChanged: true, - ignoreDtsUnchanged: true, - baselineOnly: true + }, + ignoreDtsChanged: true, + ignoreDtsUnchanged: true, + baselineOnly: true + }); }); - // only baseline - verifyOutFileScenario({ - scenario: "declarationMap and sourceMap disabled", - modifyFs: fs => { - makeThirdEmptySourceFile(fs); - replaceText(fs, sources[project.third][source.config], `"composite": true,`, ""); - replaceText(fs, sources[project.third][source.config], `"sourceMap": true,`, ""); - replaceText(fs, sources[project.third][source.config], `"declarationMap": true,`, ""); - }, - ignoreDtsChanged: true, - ignoreDtsUnchanged: true, - baselineOnly: true + describe("empty source files", () => { + function makeThirdEmptySourceFile(fs: vfs.FileSystem) { + fs.writeFileSync(sources[project.third][source.ts][part.one], "", "utf8"); + } + + // Verify ignore dtsChanged + verifyOutFileScenario({ + scenario: "when source files are empty in the own file", + modifyFs: makeThirdEmptySourceFile, + ignoreDtsChanged: true, + baselineOnly: true + }); + + // only baseline + verifyOutFileScenario({ + scenario: "declarationMap and sourceMap disabled", + modifyFs: fs => { + makeThirdEmptySourceFile(fs); + replaceText(fs, sources[project.third][source.config], `"composite": true,`, ""); + replaceText(fs, sources[project.third][source.config], `"sourceMap": true,`, ""); + replaceText(fs, sources[project.third][source.config], `"declarationMap": true,`, ""); + }, + ignoreDtsChanged: true, + ignoreDtsUnchanged: true, + baselineOnly: true + }); }); }); });