mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 09:03:02 +00:00
refactor: use async and wait for adding schemas
This commit is contained in:
@@ -24,20 +24,19 @@ export class MinimalConnectorSpec {
|
|||||||
private static connector: MinimalConnector;
|
private static connector: MinimalConnector;
|
||||||
private static validator: Validator;
|
private static validator: Validator;
|
||||||
|
|
||||||
static before() {
|
static async before() {
|
||||||
this.validator = new Validator();
|
this.validator = new Validator();
|
||||||
|
await this.validator.addSchemas('./node_modules/@openstapps/core/lib/schema');
|
||||||
this.connector = new MinimalConnector();
|
this.connector = new MinimalConnector();
|
||||||
}
|
}
|
||||||
|
|
||||||
static validateThings(things: SCMessage[]) {
|
static validateThings(things: SCMessage[]) {
|
||||||
this.validator.addSchemas('./node_modules/@openstapps/core/lib/schema').then(() => {
|
things.forEach((thing: SCMessage) => {
|
||||||
things.forEach((thing: SCMessage) => {
|
// validate thing
|
||||||
// validate thing
|
expect(MinimalConnectorSpec.validator.validate(thing,"SCMessage").errors).to.have.lengthOf(0, JSON.stringify({
|
||||||
expect(MinimalConnectorSpec.validator.validate(thing,"SCMessage").errors).to.have.lengthOf(0, JSON.stringify({
|
errors: MinimalConnectorSpec.validator.validate(thing,"SCMessage").errors,
|
||||||
errors: MinimalConnectorSpec.validator.validate(thing,"SCMessage").errors,
|
thing: thing,
|
||||||
thing: thing,
|
}));
|
||||||
}));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user