fix(core): update

This commit is contained in:
Philipp Kunz 2022-02-02 04:24:39 +01:00
parent 57728989b7
commit 6be0f9680b

View File

@ -29,7 +29,7 @@ export class Assertion {
} else {
let isOk = false;
try {
runDirectOrNegated(checkFunction())
runDirectOrNegated(checkFunction());
} catch (e) {
isOk = true;
}
@ -37,7 +37,7 @@ export class Assertion {
throw new Error('Negated assertion is not ok!');
}
}
}
};
if (this.executionMode === 'async') {
const done = plugins.smartpromise.defer();
@ -47,14 +47,14 @@ export class Assertion {
if (this.timeoutSetting) {
plugins.smartdelay.delayFor(this.timeoutSetting).then(() => {
if (done.status === 'pending') {
done.reject(new Error(`${this.baseReference} timed out at ${this.timeoutSetting}!`))
done.reject(new Error(`${this.baseReference} timed out at ${this.timeoutSetting}!`));
}
});
}
this.baseReference.then(promiseResultArg => {
this.baseReference.then((promiseResultArg) => {
this.baseReference = promiseResultArg;
done.resolve(runDirectOrNegated(checkFunction));
})
});
}
return done.promise;
} else {
@ -66,7 +66,8 @@ export class Assertion {
return this.runCheck(() => {
if (typeof this.baseReference !== 'string') {
throw new Error(
`Assertion failed: ${this.baseReference} is not of type string, but typeof ${typeof this.baseReference}`
`Assertion failed: ${this.baseReference} is not of type string, but typeof ${typeof this
.baseReference}`
);
}
});
@ -76,7 +77,8 @@ export class Assertion {
return this.runCheck(() => {
if (typeof this.baseReference !== 'number') {
throw new Error(
`Assertion failed: ${this.baseReference} is not of type string, but typeof ${typeof this.baseReference}`
`Assertion failed: ${this.baseReference} is not of type string, but typeof ${typeof this
.baseReference}`
);
}
});
@ -86,7 +88,8 @@ export class Assertion {
return this.runCheck(() => {
if (typeof this.baseReference !== 'boolean') {
throw new Error(
`Assertion failed: ${this.baseReference} is not of type string, but typeof ${typeof this.baseReference}`
`Assertion failed: ${this.baseReference} is not of type string, but typeof ${typeof this
.baseReference}`
);
}
});
@ -154,4 +157,43 @@ export class Assertion {
}
});
}
public toBeNull() {
return this.runCheck(() => {
const result = this.baseReference === null;
if (!result) {
throw new Error(`${this.baseReference} is not null`);
}
});
}
public toBeUndefined() {
return this.runCheck(() => {
const result = this.baseReference === undefined;
if (!result) {
throw new Error(`${this.baseReference} is not undefined`);
}
});
}
public toBeNullOrUndefined() {
return this.runCheck(() => {
const result = this.baseReference === null || this.baseReference === undefined;
if (!result) {
throw new Error(`${this.baseReference} is not null or undefined`);
}
});
}
public toContain(itemArg: any) {
return this.runCheck(() => {
const result = this.baseReference instanceof Array && this.baseReference.find(itemArg2 => {
itemArg === itemArg2;
})
if (!result) {
throw new Error(`${this.baseReference} is not contain ${itemArg}`);
}
});
}
}