Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
8a8b6cb517 | |||
c3d9b5621c | |||
e5c47a68dc | |||
3cf4a6566b | |||
113e5f48cb | |||
8a2d34e88a | |||
035138a437 | |||
e0a774852e | |||
465e579298 | |||
f5f6e40fff | |||
9d065a54e6 | |||
ee0a797424 | |||
a234069cc8 | |||
534c1e4215 | |||
931a713ae7 | |||
d1be0d8ce2 | |||
3e5121171a |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
|
||||||
|
- name: Run npm prepare
|
||||||
|
run: npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm publish
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
pnpm install -g @gitzone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
141
.gitlab-ci.yml
141
.gitlab-ci.yml
@ -1,141 +0,0 @@
|
|||||||
# gitzone ci_default
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .npmci_cache/
|
|
||||||
key: '$CI_BUILD_STAGE'
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- npm install -g @shipzone/npmci
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --production --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
auditDevDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=dev
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testStable:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
allow_failure: true
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g tslint typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command tsdoc
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
@ -3,10 +3,10 @@
|
|||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartexpect",
|
"gitrepo": "smartexpect",
|
||||||
"description": "manage expectations in code",
|
"description": "manage expectations in code",
|
||||||
"npmPackagename": "@pushrocks/smartexpect",
|
"npmPackagename": "@push.rocks/smartexpect",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "push.rocks"
|
"projectDomain": "push.rocks"
|
||||||
}
|
}
|
||||||
|
27557
package-lock.json
generated
27557
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@ -1,28 +1,29 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartexpect",
|
"name": "@push.rocks/smartexpect",
|
||||||
"version": "1.0.13",
|
"version": "1.0.21",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "manage expectations in code",
|
"description": "manage expectations in code",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsbundle": "^1.0.89",
|
"@gitzone/tsbundle": "^2.0.8",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tsrun": "^1.2.44",
|
||||||
"@pushrocks/tapbundle": "^4.0.0",
|
"@gitzone/tstest": "^1.0.77",
|
||||||
"@types/node": "^17.0.14",
|
"@push.rocks/tapbundle": "^5.0.12",
|
||||||
"tslint": "^6.1.3",
|
"@types/node": "^20.4.10"
|
||||||
"tslint-config-prettier": "^1.15.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@pushrocks/smartpromise": "^3.1.6",
|
"@push.rocks/smartpromise": "^4.0.2",
|
||||||
"fast-deep-equal": "^3.1.3"
|
"fast-deep-equal": "^3.1.3"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
|
4978
pnpm-lock.yaml
generated
Normal file
4978
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
readme.md
30
readme.md
@ -1,27 +1,26 @@
|
|||||||
# @pushrocks/smartexpect
|
# @push.rocks/smartexpect
|
||||||
manage expectations in code
|
manage expectations in code
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartexpect)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartexpect)
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartexpect)
|
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartexpect)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartexpect)
|
* [github.com (source mirror)](https://github.com/push.rocks/smartexpect)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartexpect/)
|
* [docs (typedoc)](https://push.rocks.gitlab.io/smartexpect/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
Status Category | Status Badge
|
Status Category | Status Badge
|
||||||
-- | --
|
-- | --
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
npm | [](https://lossless.cloud)
|
npm | [](https://lossless.cloud)
|
||||||
Snyk | [](https://lossless.cloud)
|
Snyk | [](https://lossless.cloud)
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
Code Style | [](https://lossless.cloud)
|
Code Style | [](https://lossless.cloud)
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ We are always happy for code contributions. If you are not the code contributing
|
|||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
## Legal
|
||||||
|
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
||||||
|
19
test/test.ts
19
test/test.ts
@ -1,5 +1,5 @@
|
|||||||
import { tap } from '@pushrocks/tapbundle';
|
import { tap } from '@push.rocks/tapbundle';
|
||||||
import * as smartexpect from '../ts/index';
|
import * as smartexpect from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('sync tests', async () => {
|
tap.test('sync tests', async () => {
|
||||||
smartexpect.expect('hello').toBeTypeofString();
|
smartexpect.expect('hello').toBeTypeofString();
|
||||||
@ -20,11 +20,16 @@ tap.test('async tests', async (toolsArg) => {
|
|||||||
tap.test('should check equality', async () => {
|
tap.test('should check equality', async () => {
|
||||||
smartexpect.expect('hithere').toEqual('hithere');
|
smartexpect.expect('hithere').toEqual('hithere');
|
||||||
smartexpect.expect('hithere').not.toEqual('hithere2');
|
smartexpect.expect('hithere').not.toEqual('hithere2');
|
||||||
})
|
});
|
||||||
|
|
||||||
|
tap.test('should check for regexp matching', async () => {
|
||||||
|
smartexpect.expect('hithere').toMatch(/hi/);
|
||||||
|
smartexpect.expect('hithere').not.toMatch(/ho/);
|
||||||
|
});
|
||||||
|
|
||||||
tap.test('should correctly state property presence', async () => {
|
tap.test('should correctly state property presence', async () => {
|
||||||
const testObject = {
|
const testObject = {
|
||||||
aprop: 'hello'
|
aprop: 'hello',
|
||||||
};
|
};
|
||||||
|
|
||||||
smartexpect.expect(testObject).toHaveProperty('aprop');
|
smartexpect.expect(testObject).toHaveProperty('aprop');
|
||||||
@ -34,14 +39,14 @@ tap.test('should correctly state property presence', async () => {
|
|||||||
tap.test('should be greater than', async () => {
|
tap.test('should be greater than', async () => {
|
||||||
smartexpect.expect(4).toBeGreaterThan(3);
|
smartexpect.expect(4).toBeGreaterThan(3);
|
||||||
smartexpect.expect(4).toBeLessThan(5);
|
smartexpect.expect(4).toBeLessThan(5);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.test('should correctly determine toContain', async () => {
|
tap.test('should correctly determine toContain', async () => {
|
||||||
const hello = {
|
const hello = {
|
||||||
socool: 'yes'
|
socool: 'yes',
|
||||||
};
|
};
|
||||||
const testArray = [hello];
|
const testArray = [hello];
|
||||||
smartexpect.expect(testArray).toContain(hello);
|
smartexpect.expect(testArray).toContain(hello);
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartexpect',
|
||||||
|
version: '1.0.21',
|
||||||
|
description: 'manage expectations in code'
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
import * as plugins from './smartexpect.plugins';
|
import * as plugins from './smartexpect.plugins.js';
|
||||||
|
|
||||||
import { Assertion } from './smartexpect.classes.assertion';
|
import { Assertion } from './smartexpect.classes.assertion.js';
|
||||||
|
|
||||||
export const expect = (baseArg: any) => {
|
export const expect = (baseArg: any) => {
|
||||||
const assertion = new Assertion(baseArg, 'sync');
|
const assertion = new Assertion(baseArg, 'sync');
|
||||||
return assertion;
|
return assertion;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const expectAsync = (baseArg: any) => {
|
export const expectAsync = (baseArg: any) => {
|
||||||
const assertion = new Assertion(baseArg, 'async');
|
const assertion = new Assertion(baseArg, 'async');
|
||||||
return assertion;
|
return assertion;
|
||||||
}
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartexpect.plugins';
|
import * as plugins from './smartexpect.plugins.js';
|
||||||
|
|
||||||
export type TExecutionType = 'sync' | 'async';
|
export type TExecutionType = 'sync' | 'async';
|
||||||
|
|
||||||
@ -75,8 +75,9 @@ export class Assertion {
|
|||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
if (typeof this.getObjectToTestReference() !== 'string') {
|
if (typeof this.getObjectToTestReference() !== 'string') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Assertion failed: ${this.baseReference} with drill down ${this.propertyDrillDown} is not of type string, but typeof ${typeof this
|
`Assertion failed: ${this.baseReference} with drill down ${
|
||||||
.baseReference}`
|
this.propertyDrillDown
|
||||||
|
} is not of type string, but typeof ${typeof this.baseReference}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -86,8 +87,9 @@ export class Assertion {
|
|||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
if (typeof this.getObjectToTestReference() !== 'number') {
|
if (typeof this.getObjectToTestReference() !== 'number') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Assertion failed: ${this.baseReference} with drill down ${this.propertyDrillDown} is not of type string, but typeof ${typeof this
|
`Assertion failed: ${this.baseReference} with drill down ${
|
||||||
.baseReference}`
|
this.propertyDrillDown
|
||||||
|
} is not of type string, but typeof ${typeof this.baseReference}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -97,8 +99,9 @@ export class Assertion {
|
|||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
if (typeof this.getObjectToTestReference() !== 'boolean') {
|
if (typeof this.getObjectToTestReference() !== 'boolean') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Assertion failed: ${this.baseReference} with drill down ${this.propertyDrillDown} is not of type string, but typeof ${typeof this
|
`Assertion failed: ${this.baseReference} with drill down ${
|
||||||
.baseReference}`
|
this.propertyDrillDown
|
||||||
|
} is not of type string, but typeof ${typeof this.baseReference}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -108,25 +111,46 @@ export class Assertion {
|
|||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = plugins.fastDeepEqual(this.getObjectToTestReference(), comparisonObject);
|
const result = plugins.fastDeepEqual(this.getObjectToTestReference(), comparisonObject);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} does not equal ${comparisonObject}`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does not equal ${comparisonObject}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toMatch(comparisonObject: RegExp) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const result = comparisonObject.test(this.getObjectToTestReference());
|
||||||
|
if (!result) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does not equal ${comparisonObject}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public toBeTrue() {
|
public toBeTrue() {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = typeof this.getObjectToTestReference() === 'boolean' && this.getObjectToTestReference() === true;
|
const result =
|
||||||
|
typeof this.getObjectToTestReference() === 'boolean' &&
|
||||||
|
this.getObjectToTestReference() === true;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not true or not of type boolean`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not true or not of type boolean`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public toBeFalse() {
|
public toBeFalse() {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = typeof this.getObjectToTestReference() === 'boolean' && this.getObjectToTestReference() === false;
|
const result =
|
||||||
|
typeof this.getObjectToTestReference() === 'boolean' &&
|
||||||
|
this.getObjectToTestReference() === false;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not false or not of type boolean`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not false or not of type boolean`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -135,16 +159,47 @@ export class Assertion {
|
|||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = this.getObjectToTestReference() instanceof classArg;
|
const result = this.getObjectToTestReference() instanceof classArg;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not an instance of ${classArg}`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not an instance of ${classArg}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public toHaveProperty(propertyArg: string) {
|
public toHaveProperty(propertyArg: string, equalsArg?: any) {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = !!this.getObjectToTestReference()[propertyArg];
|
const result = !!this.getObjectToTestReference()[propertyArg];
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} does not have property ${propertyArg}`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does not have property ${propertyArg}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (equalsArg) {
|
||||||
|
if (result !== equalsArg) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does have property ${propertyArg}, but it does not equal ${equalsArg}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toHaveDeepProperty(properties: string[]) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
let obj = this.getObjectToTestReference();
|
||||||
|
let currentPath = '';
|
||||||
|
|
||||||
|
for (const property of properties) {
|
||||||
|
if (currentPath) {
|
||||||
|
currentPath += `.${property}`;
|
||||||
|
} else {
|
||||||
|
currentPath = property;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!obj || !(property in obj)) {
|
||||||
|
throw new Error(`Missing property at path "${currentPath}" in ${this.baseReference}`);
|
||||||
|
}
|
||||||
|
obj = obj[property];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -153,7 +208,9 @@ export class Assertion {
|
|||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = this.getObjectToTestReference() > numberArg;
|
const result = this.getObjectToTestReference() > numberArg;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not greater than ${numberArg}`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not greater than ${numberArg}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -162,7 +219,9 @@ export class Assertion {
|
|||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = this.getObjectToTestReference() < numberArg;
|
const result = this.getObjectToTestReference() < numberArg;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not less than ${numberArg}`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not less than ${numberArg}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -171,7 +230,9 @@ export class Assertion {
|
|||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = this.getObjectToTestReference() === null;
|
const result = this.getObjectToTestReference() === null;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not null`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not null`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -180,27 +241,77 @@ export class Assertion {
|
|||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = this.getObjectToTestReference() === undefined;
|
const result = this.getObjectToTestReference() === undefined;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not undefined`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not undefined`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public toBeNullOrUndefined() {
|
public toBeNullOrUndefined() {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = this.getObjectToTestReference() === null || this.getObjectToTestReference() === undefined;
|
const result =
|
||||||
|
this.getObjectToTestReference() === null || this.getObjectToTestReference() === undefined;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not null or undefined`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not null or undefined`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Array
|
||||||
|
|
||||||
public toContain(itemArg: any) {
|
public toContain(itemArg: any) {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result =
|
const result =
|
||||||
this.getObjectToTestReference() instanceof Array &&
|
this.getObjectToTestReference() instanceof Array &&
|
||||||
this.getObjectToTestReference().includes(itemArg);
|
this.getObjectToTestReference().includes(itemArg);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not contain ${itemArg}`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not contain ${itemArg}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toBeEmptyArray() {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const arrayRef = this.getObjectToTestReference();
|
||||||
|
if (!Array.isArray(arrayRef) || arrayRef.length !== 0) {
|
||||||
|
throw new Error(`Expected ${this.baseReference} to be an empty array, but it was not.`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toContainAll(values: any[]) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const arrayRef = this.getObjectToTestReference();
|
||||||
|
if (!Array.isArray(arrayRef)) {
|
||||||
|
throw new Error(`Expected ${this.baseReference} to be an array.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const value of values) {
|
||||||
|
if (!arrayRef.includes(value)) {
|
||||||
|
throw new Error(
|
||||||
|
`Expected ${this.baseReference} to include value "${value}", but it did not.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toExclude(value: any) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const arrayRef = this.getObjectToTestReference();
|
||||||
|
if (!Array.isArray(arrayRef)) {
|
||||||
|
throw new Error(`Expected ${this.baseReference} to be an array.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arrayRef.includes(value)) {
|
||||||
|
throw new Error(
|
||||||
|
`Expected ${this.baseReference} to exclude value "${value}", but it included it.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -208,11 +319,11 @@ export class Assertion {
|
|||||||
public toStartWith(itemArg: any) {
|
public toStartWith(itemArg: any) {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const testObject = this.getObjectToTestReference();
|
const testObject = this.getObjectToTestReference();
|
||||||
const result =
|
const result = typeof testObject === 'string' && testObject.startsWith(itemArg);
|
||||||
typeof testObject === 'string' &&
|
|
||||||
testObject.startsWith(itemArg);
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not contain ${itemArg}`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not contain ${itemArg}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -220,11 +331,208 @@ export class Assertion {
|
|||||||
public toEndWith(itemArg: any) {
|
public toEndWith(itemArg: any) {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const testObject = this.getObjectToTestReference();
|
const testObject = this.getObjectToTestReference();
|
||||||
const result =
|
const result = typeof testObject === 'string' && testObject.endsWith(itemArg);
|
||||||
typeof testObject === 'string' &&
|
|
||||||
testObject.endsWith(itemArg);
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Error(`${this.baseReference} with drill down ${this.propertyDrillDown} is not contain ${itemArg}`);
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not contain ${itemArg}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... previous code ...
|
||||||
|
|
||||||
|
public toBeOneOf(values: any[]) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const result = values.includes(this.getObjectToTestReference());
|
||||||
|
if (!result) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not one of ${values}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toHaveLength(length: number) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const obj = this.getObjectToTestReference();
|
||||||
|
if (typeof obj.length !== 'number' || obj.length !== length) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does not have a length of ${length}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toBeCloseTo(value: number, precision = 2) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const difference = Math.abs(this.getObjectToTestReference() - value);
|
||||||
|
if (difference > Math.pow(10, -precision) / 2) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not close to ${value} up to ${precision} decimal places`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toThrow(expectedError?: any) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
let thrown = false;
|
||||||
|
try {
|
||||||
|
this.getObjectToTestReference()();
|
||||||
|
} catch (e) {
|
||||||
|
thrown = true;
|
||||||
|
if (expectedError && !(e instanceof expectedError)) {
|
||||||
|
throw new Error(
|
||||||
|
`Expected function to throw ${expectedError.name}, but it threw ${e.name}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!thrown) {
|
||||||
|
throw new Error(`Expected function to throw, but it didn't.`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toBeTruthy() {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (!this.getObjectToTestReference()) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not truthy`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toBeFalsy() {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (this.getObjectToTestReference()) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not falsy`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toBeGreaterThanOrEqual(numberArg: number) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (this.getObjectToTestReference() <= numberArg) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not greater than or equal to ${numberArg}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toBeLessThanOrEqual(numberArg: number) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (this.getObjectToTestReference() >= numberArg) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not less than or equal to ${numberArg}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toMatchObject(objectArg: object) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const partialMatch = plugins.fastDeepEqual(this.getObjectToTestReference(), objectArg); // Note: Implement a deep comparison function or use one from a library
|
||||||
|
if (!partialMatch) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does not match the object ${objectArg}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toContainEqual(value: any) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const arr = this.getObjectToTestReference();
|
||||||
|
const found = arr.some((item: any) => plugins.fastDeepEqual(item, value)); // Assuming fastDeepEqual checks deep equality
|
||||||
|
if (!found) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does not contain the value ${value}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toBeArray() {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (!Array.isArray(this.getObjectToTestReference())) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not an array`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toInclude(substring: string) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (!this.getObjectToTestReference().includes(substring)) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does not include the substring ${substring}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toHaveLengthGreaterThan(length: number) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const obj = this.getObjectToTestReference();
|
||||||
|
if (typeof obj.length !== 'number' || obj.length <= length) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does not have a length greater than ${length}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toHaveLengthLessThan(length: number) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
const obj = this.getObjectToTestReference();
|
||||||
|
if (typeof obj.length !== 'number' || obj.length >= length) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does not have a length less than ${length}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toBeDate() {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (!(this.getObjectToTestReference() instanceof Date)) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not a date`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toBeBeforeDate(date: Date) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (!(this.getObjectToTestReference() < date)) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not before ${date}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public toBeAfterDate(date: Date) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (!(this.getObjectToTestReference() > date)) {
|
||||||
|
throw new Error(
|
||||||
|
`${this.baseReference} with drill down ${this.propertyDrillDown} is not after ${date}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public customAssertion(assertionFunction: (value: any) => boolean, errorMessage: string) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (!assertionFunction(this.getObjectToTestReference())) {
|
||||||
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@push.rocks/smartdelay';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
|
|
||||||
export {
|
export { smartdelay, smartpromise };
|
||||||
smartdelay,
|
|
||||||
smartpromise
|
|
||||||
}
|
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import fastDeepEqual from 'fast-deep-equal';
|
import fastDeepEqual from 'fast-deep-equal';
|
||||||
|
|
||||||
export {
|
export { fastDeepEqual };
|
||||||
fastDeepEqual,
|
|
||||||
}
|
|
||||||
|
11
tsconfig.json
Normal file
11
tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
}
|
||||||
|
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
|
||||||
"rules": {
|
|
||||||
"semicolon": [true, "always"],
|
|
||||||
"no-console": false,
|
|
||||||
"ordered-imports": false,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"member-ordering": {
|
|
||||||
"options":{
|
|
||||||
"order": [
|
|
||||||
"static-method"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaultSeverity": "warning"
|
|
||||||
}
|
|
Reference in New Issue
Block a user