Skip to content

Commit

Permalink
LibJS: Run prettier on test-common.js
Browse files Browse the repository at this point in the history
  • Loading branch information
linusg authored and awesomekling committed Nov 12, 2020
1 parent 1b0c862 commit 8694d80
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions Libraries/LibJS/Tests/test-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,35 @@ class ExpectationError extends Error {

toBe(value) {
this.__doMatcher(() => {
this.__expect(Object.is(this.target, value),
() => ("toBe: expected _" + String(value) + "_, got _" + String(this.target) + "_"));
this.__expect(
Object.is(this.target, value),
() =>
"toBe: expected _" + String(value) + "_, got _" + String(this.target) + "_"
);
});
}

// FIXME: Take a precision argument like jest's toBeCloseTo matcher
toBeCloseTo(value) {
this.__expect(typeof this.target === "number", () => "toBeCloseTo: target not of type number");
this.__expect(typeof value === "number", () => "toBeCloseTo: argument not of type number");
this.__expect(
typeof this.target === "number",
() => "toBeCloseTo: target not of type number"
);
this.__expect(
typeof value === "number",
() => "toBeCloseTo: argument not of type number"
);

this.__doMatcher(() => {
this.__expect(Math.abs(this.target - value) < 0.000001);
});
}

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.__expect(Object.is(this.target.length, length));
Expand Down Expand Up @@ -139,13 +151,19 @@ class ExpectationError extends Error {

toBeUndefined() {
this.__doMatcher(() => {
this.__expect(this.target === undefined, () => "toBeUndefined: target was not undefined");
this.__expect(
this.target === undefined,
() => "toBeUndefined: target was not undefined"
);
});
}

toBeNaN() {
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"
);
});
}

Expand Down Expand Up @@ -388,10 +406,11 @@ class ExpectationError extends Error {

__expect(value, details) {
if (value !== true) {
if (details !== undefined)
throw new ExpectationError(details());
else
throw new ExpectationError();
if (details !== undefined) {
throw new ExpectationError(details());
} else {
throw new ExpectationError();
}
}
}
}
Expand Down

0 comments on commit 8694d80

Please sign in to comment.