fix(assertion-matchers): Refactor matcher implementations to consistently use customAssertion for improved consistency and clarity.

This commit is contained in:
2025-04-28 19:58:32 +00:00
parent 4eac4544a5
commit 91a3dc43d3
11 changed files with 265 additions and 43 deletions

View File

@ -7,22 +7,37 @@ export class TypeMatchers {
constructor(private assertion: Assertion<any>) {}
toBeTypeofString() {
return this.assertion.toBeTypeofString();
return this.assertion.customAssertion(
(v) => typeof v === 'string',
`Expected type to be 'string'`
);
}
toBeTypeofNumber() {
return this.assertion.toBeTypeofNumber();
return this.assertion.customAssertion(
(v) => typeof v === 'number',
`Expected type to be 'number'`
);
}
toBeTypeofBoolean() {
return this.assertion.toBeTypeofBoolean();
return this.assertion.customAssertion(
(v) => typeof v === 'boolean',
`Expected type to be 'boolean'`
);
}
toBeTypeOf(typeName: string) {
return this.assertion.toBeTypeOf(typeName);
return this.assertion.customAssertion(
(v) => typeof v === typeName,
`Expected type to be '${typeName}'`
);
}
toBeDefined() {
return this.assertion.toBeDefined();
return this.assertion.customAssertion(
(v) => v !== undefined,
`Expected value to be defined`
);
}
}