mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
Update build for node 6 to allow private package
This commit is contained in:
@@ -114,7 +114,7 @@ export class Arg {
|
||||
public static includes(value: string): string & string[] & Arg;
|
||||
public static includes<T>(value: T): T[] & Arg;
|
||||
public static includes<T>(value: T): Arg {
|
||||
return new Arg(value_ => Array.isArray(value_) ? value_.includes(value) : typeof value_ === "string" && value_.includes("" + value), `contains ${value}`);
|
||||
return new Arg(value_ => Array.isArray(value_) ? value_.indexOf(value) >= 0 : typeof value_ === "string" && value_.includes("" + value), `contains ${value}`);
|
||||
}
|
||||
|
||||
public static array<T>(values: (T | T & Arg)[]): T[] & Arg {
|
||||
|
||||
@@ -174,7 +174,7 @@ export class Mock<T extends object> {
|
||||
if (times === undefined) {
|
||||
times = Times.atLeastOnce();
|
||||
}
|
||||
this._handler.verify(callback, times);
|
||||
this._handler.verify(callback, times, message);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ class Recording {
|
||||
public match(trap: string, name: PropertyKey | undefined, thisArg: any, argArray: any, newTarget: any) {
|
||||
return this.trap === trap
|
||||
&& this.name === name
|
||||
&& Arg.validate(this.thisCondition, thisArg)
|
||||
&& this.matchThisArg(thisArg)
|
||||
&& Arg.validateAll(this.argConditions, argArray)
|
||||
&& Arg.validate(this.newTargetCondition, newTarget);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import "./sourceMapSupport";
|
||||
import { Mock } from "../mock";
|
||||
import { Inject } from "../inject";
|
||||
import { Arg } from "../arg";
|
||||
import { Times } from "../times";
|
||||
import { recordError } from "./utils";
|
||||
@@ -107,7 +106,7 @@ describe("mock", () => {
|
||||
// arrange
|
||||
const target = { a: 1 };
|
||||
const error = new Error("error");
|
||||
const mock = new Mock(target, { set a(value: number) { throw error; } });
|
||||
const mock = new Mock(target, { set a(_: number) { throw error; } });
|
||||
|
||||
// act
|
||||
const e = recordError(() => mock.proxy.a = 2);
|
||||
@@ -218,7 +217,7 @@ describe("mock", () => {
|
||||
});
|
||||
it("function", () => {
|
||||
// arrange
|
||||
const mock = new Mock<(x: number) => number>(x => 0);
|
||||
const mock = new Mock<(x: number) => number>(_ => 0);
|
||||
mock.setup(_ => _(Arg.number()), { return: 2 });
|
||||
|
||||
// act
|
||||
@@ -248,7 +247,7 @@ describe("mock", () => {
|
||||
// arrange
|
||||
const target = { a: 1 };
|
||||
const mock = new Mock(target);
|
||||
const result = mock.proxy.a;
|
||||
mock.proxy.a;
|
||||
|
||||
// act
|
||||
const e = recordError(() => mock.verify(_ => _.a, Times.once()));
|
||||
@@ -298,7 +297,7 @@ describe("mock", () => {
|
||||
// arrange
|
||||
const target = { a() { return 1; } };
|
||||
const mock = new Mock(target);
|
||||
const result = mock.proxy.a();
|
||||
mock.proxy.a();
|
||||
|
||||
// act
|
||||
const e = recordError(() => mock.verify(_ => _.a(), Times.once()));
|
||||
@@ -321,7 +320,7 @@ describe("mock", () => {
|
||||
it("called passes", () => {
|
||||
// arrange
|
||||
const mock = Mock.function();
|
||||
const result = mock.proxy();
|
||||
mock.proxy();
|
||||
|
||||
// act
|
||||
const e = recordError(() => mock.verify(_ => _(), Times.once()));
|
||||
@@ -335,7 +334,7 @@ describe("mock", () => {
|
||||
// arrange
|
||||
const target = { a: 1 };
|
||||
const mock = new Mock(target, { get a() { return 2 } });
|
||||
const result = mock.proxy.a;
|
||||
mock.proxy.a;
|
||||
|
||||
// act
|
||||
const e = recordError(() => mock.verify(_ => _.a, Times.once()));
|
||||
@@ -351,7 +350,7 @@ describe("mock", () => {
|
||||
return x + 2;
|
||||
}
|
||||
});
|
||||
const result = mock.proxy.a(3);
|
||||
mock.proxy.a(3);
|
||||
|
||||
// act
|
||||
const e = recordError(() => mock.verify(_ => _.a(Arg.number()), Times.once()));
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es2017",
|
||||
"target": "es2015",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"types": ["mocha"],
|
||||
"newLine": "LF",
|
||||
"outDir": "dist"
|
||||
|
||||
Reference in New Issue
Block a user