feat(Assertion): Add toBeTypeOf assertion method
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartexpect',
|
||||
version: '1.4.0',
|
||||
version: '1.5.0',
|
||||
description: 'A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.'
|
||||
}
|
||||
|
@ -209,6 +209,20 @@ export class Assertion {
|
||||
});
|
||||
}
|
||||
|
||||
public toBeTypeOf(expectedType: string) {
|
||||
return this.runCheck(() => {
|
||||
const actualType = typeof this.getObjectToTestReference();
|
||||
if (actualType !== expectedType) {
|
||||
throw new Error(
|
||||
this.failMessage ||
|
||||
`Assertion failed: ${this.baseReference} with drill down ${
|
||||
this.propertyDrillDown
|
||||
} is not of type ${expectedType}, but typeof ${actualType}`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public toHaveProperty(propertyArg: string, equalsArg?: any) {
|
||||
return this.runCheck(() => {
|
||||
const obj = this.getObjectToTestReference();
|
||||
|
Reference in New Issue
Block a user