chore: update * pin prettier version & format code
This commit is contained in:
parent
5d05f87768
commit
53d4062e52
18 changed files with 93 additions and 78 deletions
|
|
@ -10,7 +10,7 @@ class ExpectError extends Error {
|
|||
super(
|
||||
`${reason}\n` +
|
||||
`\texpected: ${displayValue(expected)}\n` +
|
||||
`\tactual : ${displayValue(actual)}`
|
||||
`\tactual : ${displayValue(actual)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ export class Expect<T> {
|
|||
throw new ExpectError(
|
||||
`value does not equal expected`,
|
||||
expected,
|
||||
this.value
|
||||
this.value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ export class StringExpect extends Expect<string> {
|
|||
throw new ExpectError(
|
||||
`value does not match expected pattern`,
|
||||
pattern,
|
||||
this.value
|
||||
this.value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ export class StringExpect extends Expect<string> {
|
|||
throw new ExpectError(
|
||||
`value does not start with expected prefix`,
|
||||
prefix,
|
||||
this.value
|
||||
this.value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ export class StringExpect extends Expect<string> {
|
|||
throw new ExpectError(
|
||||
`value does not end with expected suffix`,
|
||||
suffix,
|
||||
this.value
|
||||
this.value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -138,14 +138,14 @@ export class FunctionExpect<T> extends Expect<() => T> {
|
|||
throw new ExpectError(
|
||||
`function threw non-Error value`,
|
||||
pattern,
|
||||
error
|
||||
error,
|
||||
);
|
||||
}
|
||||
if (!matches(error.message, pattern)) {
|
||||
throw new ExpectError(
|
||||
`thrown Error's message does not match pattern`,
|
||||
pattern,
|
||||
error.message
|
||||
error.message,
|
||||
);
|
||||
}
|
||||
return;
|
||||
|
|
@ -153,7 +153,7 @@ export class FunctionExpect<T> extends Expect<() => T> {
|
|||
throw new ExpectError(
|
||||
`function did not throw expected error`,
|
||||
pattern,
|
||||
null
|
||||
null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ const runTest = async (test: Test): Promise<TestResult> => {
|
|||
error instanceof Error
|
||||
? error
|
||||
: new Error(
|
||||
`threw non-error object: ${displayValue(error)}`
|
||||
`threw non-error object: ${displayValue(error)}`,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ export interface TestSuiteContext {
|
|||
*/
|
||||
export const testSuite = (
|
||||
suiteName: string,
|
||||
def: (ctx: TestSuiteContext) => void
|
||||
def: (ctx: TestSuiteContext) => void,
|
||||
): void => {
|
||||
const tests: Test[] = [];
|
||||
const test = (name: string, runTest: () => void | Promise<void>): void => {
|
||||
|
|
@ -104,14 +104,14 @@ export const testSuite = (
|
|||
if (testResult.result === "fail") {
|
||||
console.error(
|
||||
`[TEST FAILURE] "${suiteName}": "${testResult.testName}": ` +
|
||||
`${testResult.error.stack}\n`
|
||||
`${testResult.error.stack}\n`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
passed += 1;
|
||||
}
|
||||
console.info(
|
||||
`[TEST] suite "${suiteName}": ${passed} of ${tests.length} succeeded\n\n`
|
||||
`[TEST] suite "${suiteName}": ${passed} of ${tests.length} succeeded\n\n`,
|
||||
);
|
||||
if (passed < tests.length) {
|
||||
process.exitCode = 1;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ const areArraysEqual = <T>(a: T[], b: T[]): boolean => {
|
|||
|
||||
const areObjectsEqual = <T extends Record<string, unknown>>(
|
||||
a: T,
|
||||
b: T
|
||||
b: T,
|
||||
): boolean => {
|
||||
const aKeys = Object.keys(a) as Array<keyof T>;
|
||||
const bKeys = Object.keys(b) as Array<keyof T>;
|
||||
|
|
@ -67,7 +67,7 @@ export const areEqual = <T>(a: T, b: T): boolean => {
|
|||
if (typeof a === "object" && typeof b === "object") {
|
||||
return areObjectsEqual(
|
||||
a as Record<string, unknown>,
|
||||
b as Record<string, unknown>
|
||||
b as Record<string, unknown>,
|
||||
);
|
||||
}
|
||||
return a === b;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue