feat(assertion): Add toBeDefined assertion method

This commit is contained in:
Philipp Kunz 2024-08-17 07:27:32 +02:00
parent 537545766c
commit 9ef1e5120e
5 changed files with 3920 additions and 2742 deletions

40
changelog.md Normal file
View File

@ -0,0 +1,40 @@
# Changelog
## 2024-08-17 - 1.1.0 - feat(assertion)
Add toBeDefined assertion method
- Added the toBeDefined method to the Assertion class for checking if an object is defined
## 2024-05-29 - 1.0.21 - General Updates
General updates and maintenance.
- Updated description
- Updated tsconfig
- Updated npmextra.json: githost
## 2023-08-12 - 1.0.20 to 1.0.21 - General Fixes
General fixes and update.
- Fixed core updates (multiple instances)
- 1.0.21 release
## 2023-07-10 - 1.0.15 - Organization Update
- Switched to new org scheme
## 2023-06-22 - 1.0.14 to 1.0.19 - General Updates
General fixes and updates.
- Fixed core updates (multiple instances)
- 1.0.18 to 1.0.16 releases
## 2022-02-02 - 1.0.8 to 1.0.13 - General Fixes
General fixes and update.
- Fixed core updates (multiple instances)
- 1.0.14 release
## 2022-01-20 - 1.0.1 to 1.0.7 - Initial Releases
Initial core updates and fixes.
- Fixed core updates (multiple instances)
- 1.0.7 release

View File

@ -18,12 +18,12 @@
"@gitzone/tsbundle": "^2.0.8",
"@gitzone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.0.12",
"@types/node": "^20.4.10"
"@push.rocks/tapbundle": "^5.0.23",
"@types/node": "^22.4.0"
},
"dependencies": {
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartpromise": "^4.0.2",
"@push.rocks/smartpromise": "^4.0.4",
"fast-deep-equal": "^3.1.3"
},
"browserslist": [

File diff suppressed because it is too large Load Diff

View File

@ -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.'
}

View File

@ -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') {