fix(core): update

This commit is contained in:
2022-07-24 12:45:29 +02:00
parent af12f068aa
commit 3e5121171a
10 changed files with 2935 additions and 18982 deletions

8
ts/00_commitinfo_data.ts Normal file
View 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'
}

View File

@ -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) => {
const assertion = new Assertion(baseArg, 'sync');
return assertion;
}
};
export const expectAsync = (baseArg: any) => {
const assertion = new Assertion(baseArg, 'async');
return assertion;
}
};

View File

@ -1,4 +1,4 @@
import * as plugins from './smartexpect.plugins';
import * as plugins from './smartexpect.plugins.js';
export type TExecutionType = 'sync' | 'async';
@ -75,8 +75,9 @@ export class Assertion {
return this.runCheck(() => {
if (typeof this.getObjectToTestReference() !== 'string') {
throw new Error(
`Assertion failed: ${this.baseReference} with drill down ${this.propertyDrillDown} is not of type string, but typeof ${typeof this
.baseReference}`
`Assertion failed: ${this.baseReference} with drill down ${
this.propertyDrillDown
} is not of type string, but typeof ${typeof this.baseReference}`
);
}
});
@ -86,8 +87,9 @@ export class Assertion {
return this.runCheck(() => {
if (typeof this.getObjectToTestReference() !== 'number') {
throw new Error(
`Assertion failed: ${this.baseReference} with drill down ${this.propertyDrillDown} is not of type string, but typeof ${typeof this
.baseReference}`
`Assertion failed: ${this.baseReference} with drill down ${
this.propertyDrillDown
} is not of type string, but typeof ${typeof this.baseReference}`
);
}
});
@ -97,8 +99,9 @@ export class Assertion {
return this.runCheck(() => {
if (typeof this.getObjectToTestReference() !== 'boolean') {
throw new Error(
`Assertion failed: ${this.baseReference} with drill down ${this.propertyDrillDown} is not of type string, but typeof ${typeof this
.baseReference}`
`Assertion failed: ${this.baseReference} with drill down ${
this.propertyDrillDown
} is not of type string, but typeof ${typeof this.baseReference}`
);
}
});
@ -108,25 +111,35 @@ export class Assertion {
return this.runCheck(() => {
const result = plugins.fastDeepEqual(this.getObjectToTestReference(), comparisonObject);
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() {
return this.runCheck(() => {
const result = typeof this.getObjectToTestReference() === 'boolean' && this.getObjectToTestReference() === true;
const result =
typeof this.getObjectToTestReference() === 'boolean' &&
this.getObjectToTestReference() === true;
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() {
return this.runCheck(() => {
const result = typeof this.getObjectToTestReference() === 'boolean' && this.getObjectToTestReference() === false;
const result =
typeof this.getObjectToTestReference() === 'boolean' &&
this.getObjectToTestReference() === false;
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(() => {
const result = this.getObjectToTestReference() instanceof classArg;
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(() => {
const result = !!this.getObjectToTestReference()[propertyArg];
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(() => {
const result = this.getObjectToTestReference() > numberArg;
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(() => {
const result = this.getObjectToTestReference() < numberArg;
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(() => {
const result = this.getObjectToTestReference() === null;
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(() => {
const result = this.getObjectToTestReference() === undefined;
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() {
return this.runCheck(() => {
const result = this.getObjectToTestReference() === null || this.getObjectToTestReference() === undefined;
const result =
this.getObjectToTestReference() === null || this.getObjectToTestReference() === undefined;
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().includes(itemArg);
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) {
return this.runCheck(() => {
const testObject = this.getObjectToTestReference();
const result =
typeof testObject === 'string' &&
testObject.startsWith(itemArg);
const result = typeof testObject === 'string' && testObject.startsWith(itemArg);
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) {
return this.runCheck(() => {
const testObject = this.getObjectToTestReference();
const result =
typeof testObject === 'string' &&
testObject.endsWith(itemArg);
const result = typeof testObject === 'string' && testObject.endsWith(itemArg);
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}`
);
}
});
}

View File

@ -1,14 +1,9 @@
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartpromise from '@pushrocks/smartpromise';
export {
smartdelay,
smartpromise
}
export { smartdelay, smartpromise };
// third party scope
import fastDeepEqual from 'fast-deep-equal';
export {
fastDeepEqual,
}
export { fastDeepEqual };