mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-10 15:25:54 -06:00
Fixes for new mocha types (#22799)
* Fixes for new mocha types * fix lint
This commit is contained in:
parent
459df020dc
commit
c67fa9d6bd
1178
package-lock.json
generated
1178
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -384,7 +384,7 @@ namespace Harness.Parallel.Host {
|
||||
};
|
||||
}
|
||||
|
||||
describe = ts.noop as any; // Disable unit tests
|
||||
(global as any).describe = ts.noop as any; // Disable unit tests
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -25,10 +25,10 @@ namespace Harness.Parallel.Worker {
|
||||
(global as any).before = undefined;
|
||||
(global as any).after = undefined;
|
||||
(global as any).beforeEach = undefined;
|
||||
describe = ((name, callback) => {
|
||||
(global as any).describe = ((name, callback) => {
|
||||
testList.push({ name, callback, kind: "suite" });
|
||||
}) as Mocha.IContextDefinition;
|
||||
it = ((name, callback) => {
|
||||
(global as any).it = ((name, callback) => {
|
||||
if (!testList) {
|
||||
throw new Error("Tests must occur within a describe block");
|
||||
}
|
||||
@ -251,7 +251,7 @@ namespace Harness.Parallel.Worker {
|
||||
});
|
||||
if (!runUnitTests) {
|
||||
// ensure unit tests do not get run
|
||||
describe = ts.noop as any;
|
||||
(global as any).describe = ts.noop;
|
||||
}
|
||||
else {
|
||||
initialized = true;
|
||||
|
||||
@ -242,7 +242,7 @@ function beginTests() {
|
||||
|
||||
if (!runUnitTests) {
|
||||
// patch `describe` to skip unit tests
|
||||
describe = ts.noop as any;
|
||||
(global as any).describe = ts.noop;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,41 +16,43 @@ namespace ts {
|
||||
const printsCorrectly = makePrintsCorrectly("printsFileCorrectly");
|
||||
// Avoid eagerly creating the sourceFile so that `createSourceFile` doesn't run unless one of these tests is run.
|
||||
let sourceFile: SourceFile;
|
||||
before(() => sourceFile = createSourceFile("source.ts", `
|
||||
interface A<T> {
|
||||
// comment1
|
||||
readonly prop?: T;
|
||||
before(() => {
|
||||
sourceFile = createSourceFile("source.ts", `
|
||||
interface A<T> {
|
||||
// comment1
|
||||
readonly prop?: T;
|
||||
|
||||
// comment2
|
||||
method(): void;
|
||||
// comment2
|
||||
method(): void;
|
||||
|
||||
// comment3
|
||||
new <T>(): A<T>;
|
||||
// comment3
|
||||
new <T>(): A<T>;
|
||||
|
||||
// comment4
|
||||
<T>(): A<T>;
|
||||
}
|
||||
// comment4
|
||||
<T>(): A<T>;
|
||||
}
|
||||
|
||||
// comment5
|
||||
type B = number | string | object;
|
||||
type C = A<number> & { x: string; }; // comment6
|
||||
// comment5
|
||||
type B = number | string | object;
|
||||
type C = A<number> & { x: string; }; // comment6
|
||||
|
||||
// comment7
|
||||
enum E1 {
|
||||
// comment8
|
||||
first
|
||||
}
|
||||
// comment7
|
||||
enum E1 {
|
||||
// comment8
|
||||
first
|
||||
}
|
||||
|
||||
const enum E2 {
|
||||
second
|
||||
}
|
||||
const enum E2 {
|
||||
second
|
||||
}
|
||||
|
||||
// comment9
|
||||
console.log(1 + 2);
|
||||
// comment9
|
||||
console.log(1 + 2);
|
||||
|
||||
// comment10
|
||||
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }
|
||||
`, ScriptTarget.ES2015));
|
||||
// comment10
|
||||
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }
|
||||
`, ScriptTarget.ES2015);
|
||||
});
|
||||
printsCorrectly("default", {}, printer => printer.printFile(sourceFile));
|
||||
printsCorrectly("removeComments", { removeComments: true }, printer => printer.printFile(sourceFile));
|
||||
|
||||
@ -65,20 +67,22 @@ namespace ts {
|
||||
describe("printBundle", () => {
|
||||
const printsCorrectly = makePrintsCorrectly("printsBundleCorrectly");
|
||||
let bundle: Bundle;
|
||||
before(() => bundle = createBundle([
|
||||
createSourceFile("a.ts", `
|
||||
/*! [a.ts] */
|
||||
before(() => {
|
||||
bundle = createBundle([
|
||||
createSourceFile("a.ts", `
|
||||
/*! [a.ts] */
|
||||
|
||||
// comment0
|
||||
const a = 1;
|
||||
`, ScriptTarget.ES2015),
|
||||
createSourceFile("b.ts", `
|
||||
/*! [b.ts] */
|
||||
// comment0
|
||||
const a = 1;
|
||||
`, ScriptTarget.ES2015),
|
||||
createSourceFile("b.ts", `
|
||||
/*! [b.ts] */
|
||||
|
||||
// comment1
|
||||
const b = 2;
|
||||
`, ScriptTarget.ES2015)
|
||||
]));
|
||||
// comment1
|
||||
const b = 2;
|
||||
`, ScriptTarget.ES2015)
|
||||
]);
|
||||
});
|
||||
printsCorrectly("default", {}, printer => printer.printBundle(bundle));
|
||||
printsCorrectly("removeComments", { removeComments: true }, printer => printer.printBundle(bundle));
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user