Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
e5c47a68dc | |||
3cf4a6566b | |||
113e5f48cb | |||
8a2d34e88a | |||
035138a437 | |||
e0a774852e |
128
.gitlab-ci.yml
128
.gitlab-ci.yml
@ -1,128 +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:
|
|
||||||
- pnpm install -g pnpm
|
|
||||||
- pnpm install -g @shipzone/npmci
|
|
||||||
- npmci npm prepare
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
auditProductionDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command pnpm audit --audit-level=high --prod
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
auditDevDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command pnpm audit --audit-level=high --dev
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testStable:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm 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 typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run buildDocs
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
16
package.json
16
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartexpect",
|
"name": "@push.rocks/smartexpect",
|
||||||
"version": "1.0.17",
|
"version": "1.0.20",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "manage expectations in code",
|
"description": "manage expectations in code",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -16,16 +16,14 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.66",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsbundle": "^2.0.8",
|
"@gitzone/tsbundle": "^2.0.8",
|
||||||
"@gitzone/tsrun": "^1.2.42",
|
"@gitzone/tsrun": "^1.2.44",
|
||||||
"@gitzone/tstest": "^1.0.74",
|
"@gitzone/tstest": "^1.0.77",
|
||||||
"@pushrocks/tapbundle": "^5.0.4",
|
"@push.rocks/tapbundle": "^5.0.12",
|
||||||
"@types/node": "^20.3.1",
|
"@types/node": "^20.4.10"
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^3.0.1",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@pushrocks/smartpromise": "^4.0.2",
|
"@push.rocks/smartpromise": "^4.0.2",
|
||||||
"fast-deep-equal": "^3.1.3"
|
"fast-deep-equal": "^3.1.3"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
|
982
pnpm-lock.yaml
generated
982
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
import { tap } from '@pushrocks/tapbundle';
|
import { tap } from '@push.rocks/tapbundle';
|
||||||
import * as smartexpect from '../ts/index.js';
|
import * as smartexpect from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('sync tests', async () => {
|
tap.test('sync tests', async () => {
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartexpect',
|
name: '@push.rocks/smartexpect',
|
||||||
version: '1.0.17',
|
version: '1.0.20',
|
||||||
description: 'manage expectations in code'
|
description: 'manage expectations in code'
|
||||||
}
|
}
|
||||||
|
@ -184,6 +184,26 @@ export class Assertion {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public toBeGreaterThan(numberArg: number) {
|
public toBeGreaterThan(numberArg: number) {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result = this.getObjectToTestReference() > numberArg;
|
const result = this.getObjectToTestReference() > numberArg;
|
||||||
@ -240,6 +260,8 @@ export class Assertion {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Array
|
||||||
|
|
||||||
public toContain(itemArg: any) {
|
public toContain(itemArg: any) {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const result =
|
const result =
|
||||||
@ -253,6 +275,47 @@ export class Assertion {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public toStartWith(itemArg: any) {
|
public toStartWith(itemArg: any) {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
const testObject = this.getObjectToTestReference();
|
const testObject = this.getObjectToTestReference();
|
||||||
@ -373,43 +436,7 @@ export class Assertion {
|
|||||||
|
|
||||||
public toMatchObject(objectArg: object) {
|
public toMatchObject(objectArg: object) {
|
||||||
return this.runCheck(() => {
|
return this.runCheck(() => {
|
||||||
function deepEqual(obj1: any, obj2: any): boolean {
|
const partialMatch = plugins.fastDeepEqual(this.getObjectToTestReference(), objectArg); // Note: Implement a deep comparison function or use one from a library
|
||||||
// If both are of primitive types and are equal
|
|
||||||
if (obj1 === obj2) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If either of them is null or not an object
|
|
||||||
if (
|
|
||||||
typeof obj1 !== 'object' ||
|
|
||||||
obj1 === null ||
|
|
||||||
typeof obj2 !== 'object' ||
|
|
||||||
obj2 === null
|
|
||||||
) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const keys1 = Object.keys(obj1);
|
|
||||||
const keys2 = Object.keys(obj2);
|
|
||||||
|
|
||||||
// If their properties' count doesn't match
|
|
||||||
if (keys1.length !== keys2.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checking if every property in obj1 has a counterpart in obj2
|
|
||||||
for (const key of keys1) {
|
|
||||||
if (!keys2.includes(key)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!deepEqual(obj1[key], obj2[key])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
const partialMatch = deepEqual(this.getObjectToTestReference(), objectArg); // Note: Implement a deep comparison function or use one from a library
|
|
||||||
if (!partialMatch) {
|
if (!partialMatch) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`${this.baseReference} with drill down ${this.propertyDrillDown} does not match the object ${objectArg}`
|
`${this.baseReference} with drill down ${this.propertyDrillDown} does not match the object ${objectArg}`
|
||||||
@ -502,6 +529,14 @@ export class Assertion {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public customAssertion(assertionFunction: (value: any) => boolean, errorMessage: string) {
|
||||||
|
return this.runCheck(() => {
|
||||||
|
if (!assertionFunction(this.getObjectToTestReference())) {
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public property(propertyNameArg: string) {
|
public property(propertyNameArg: string) {
|
||||||
this.propertyDrillDown.push(propertyNameArg);
|
this.propertyDrillDown.push(propertyNameArg);
|
||||||
return this;
|
return this;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
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 { smartdelay, smartpromise };
|
export { smartdelay, smartpromise };
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user