mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:57:34 +00:00
LibJS: Run prettier on test-common.js
This commit is contained in:
parent
1b0c862f3a
commit
8694d804c7
1 changed files with 30 additions and 11 deletions
|
@ -63,15 +63,24 @@ class ExpectationError extends Error {
|
||||||
|
|
||||||
toBe(value) {
|
toBe(value) {
|
||||||
this.__doMatcher(() => {
|
this.__doMatcher(() => {
|
||||||
this.__expect(Object.is(this.target, value),
|
this.__expect(
|
||||||
() => ("toBe: expected _" + String(value) + "_, got _" + String(this.target) + "_"));
|
Object.is(this.target, value),
|
||||||
|
() =>
|
||||||
|
"toBe: expected _" + String(value) + "_, got _" + String(this.target) + "_"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Take a precision argument like jest's toBeCloseTo matcher
|
// FIXME: Take a precision argument like jest's toBeCloseTo matcher
|
||||||
toBeCloseTo(value) {
|
toBeCloseTo(value) {
|
||||||
this.__expect(typeof this.target === "number", () => "toBeCloseTo: target not of type number");
|
this.__expect(
|
||||||
this.__expect(typeof value === "number", () => "toBeCloseTo: argument not of type number");
|
typeof this.target === "number",
|
||||||
|
() => "toBeCloseTo: target not of type number"
|
||||||
|
);
|
||||||
|
this.__expect(
|
||||||
|
typeof value === "number",
|
||||||
|
() => "toBeCloseTo: argument not of type number"
|
||||||
|
);
|
||||||
|
|
||||||
this.__doMatcher(() => {
|
this.__doMatcher(() => {
|
||||||
this.__expect(Math.abs(this.target - value) < 0.000001);
|
this.__expect(Math.abs(this.target - value) < 0.000001);
|
||||||
|
@ -79,7 +88,10 @@ class ExpectationError extends Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
toHaveLength(length) {
|
toHaveLength(length) {
|
||||||
this.__expect(typeof this.target.length === "number", () => "toHaveLength: target.length not of type number");
|
this.__expect(
|
||||||
|
typeof this.target.length === "number",
|
||||||
|
() => "toHaveLength: target.length not of type number"
|
||||||
|
);
|
||||||
|
|
||||||
this.__doMatcher(() => {
|
this.__doMatcher(() => {
|
||||||
this.__expect(Object.is(this.target.length, length));
|
this.__expect(Object.is(this.target.length, length));
|
||||||
|
@ -139,13 +151,19 @@ class ExpectationError extends Error {
|
||||||
|
|
||||||
toBeUndefined() {
|
toBeUndefined() {
|
||||||
this.__doMatcher(() => {
|
this.__doMatcher(() => {
|
||||||
this.__expect(this.target === undefined, () => "toBeUndefined: target was not undefined");
|
this.__expect(
|
||||||
|
this.target === undefined,
|
||||||
|
() => "toBeUndefined: target was not undefined"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toBeNaN() {
|
toBeNaN() {
|
||||||
this.__doMatcher(() => {
|
this.__doMatcher(() => {
|
||||||
this.__expect(isNaN(this.target), () => ("toBeNaN: target was _" + String(this.target) + "_, not NaN"));
|
this.__expect(
|
||||||
|
isNaN(this.target),
|
||||||
|
() => "toBeNaN: target was _" + String(this.target) + "_, not NaN"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,13 +406,14 @@ class ExpectationError extends Error {
|
||||||
|
|
||||||
__expect(value, details) {
|
__expect(value, details) {
|
||||||
if (value !== true) {
|
if (value !== true) {
|
||||||
if (details !== undefined)
|
if (details !== undefined) {
|
||||||
throw new ExpectationError(details());
|
throw new ExpectationError(details());
|
||||||
else
|
} else {
|
||||||
throw new ExpectationError();
|
throw new ExpectationError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
expect = value => new Expector(value);
|
expect = value => new Expector(value);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue