feat(assertion): Add toBeDefined assertion method
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartexpect',
|
||||
version: '1.0.21',
|
||||
description: 'manage expectations in code'
|
||||
version: '1.1.0',
|
||||
description: 'A testing library to manage expectations in code, offering both synchronous and asynchronous assertion methods.'
|
||||
}
|
||||
|
@ -71,6 +71,22 @@ export class Assertion {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the given object is defined
|
||||
*/
|
||||
public toBeDefined() {
|
||||
return this.runCheck(() => {
|
||||
if (this.getObjectToTestReference() === undefined) {
|
||||
throw new Error(
|
||||
`${this.baseReference} with drill down ${this.propertyDrillDown} is not defined`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* checks if the given object is not defined
|
||||
*/
|
||||
public toBeTypeofString() {
|
||||
return this.runCheck(() => {
|
||||
if (typeof this.getObjectToTestReference() !== 'string') {
|
||||
|
Reference in New Issue
Block a user