fix(assertion-matchers): Refactor matcher implementations to consistently use customAssertion for improved consistency and clarity.
This commit is contained in:
@ -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`
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user