refactor: use async and wait for adding schemas

This commit is contained in:
Michel Jonathan Schmitz
2019-01-30 14:01:04 +01:00
parent 721fa02d5b
commit 2adc0a0213

View File

@@ -24,13 +24,13 @@ 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({
@@ -38,7 +38,6 @@ export class MinimalConnectorSpec {
thing: thing, thing: thing,
})); }));
}); });
});
} }
@test @test