fix(core): update
This commit is contained in:
parent
af12f068aa
commit
3e5121171a
@ -18,17 +18,6 @@ before_script:
|
|||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
auditProductionDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
@ -100,10 +89,9 @@ codequality:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
@ -123,11 +111,10 @@ trigger:
|
|||||||
pages:
|
pages:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command npm run buildDocs
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
21719
package-lock.json
generated
21719
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@ -5,24 +5,26 @@
|
|||||||
"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.63",
|
||||||
"@gitzone/tsbundle": "^1.0.89",
|
"@gitzone/tsbundle": "^2.0.5",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tstest": "^1.0.71",
|
||||||
"@pushrocks/tapbundle": "^4.0.0",
|
"@pushrocks/tapbundle": "^5.0.3",
|
||||||
"@types/node": "^17.0.14",
|
"@types/node": "^18.0.6",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
"@pushrocks/smartpromise": "^3.1.6",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"fast-deep-equal": "^3.1.3"
|
"fast-deep-equal": "^3.1.3"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
@ -40,4 +42,4 @@
|
|||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
]
|
]
|
||||||
}
|
}
|
12
test/test.ts
12
test/test.ts
@ -1,5 +1,5 @@
|
|||||||
import { tap } from '@pushrocks/tapbundle';
|
import { tap } from '@pushrocks/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,11 @@ 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 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 +34,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: '@pushrocks/smartexpect',
|
||||||
|
version: '1.0.14',
|
||||||
|
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,35 @@ 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 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 +148,27 @@ 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}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -153,7 +177,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 +188,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 +199,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,16 +210,21 @@ 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`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -200,7 +235,9 @@ export class Assertion {
|
|||||||
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}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -208,11 +245,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 +257,11 @@ 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}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/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,
|
|
||||||
}
|
|
||||||
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": 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"
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user