mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-08 14:32:50 +00:00
refactor: provide a generic test class
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 StApps
|
||||
* Copyright (C) 2018-2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -12,7 +12,7 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {SCMessage} from '@openstapps/core';
|
||||
import {SCThings} from '@openstapps/core';
|
||||
import {Validator} from '@openstapps/core-tools/lib/validate';
|
||||
import {expect} from 'chai';
|
||||
import {suite, test} from 'mocha-typescript';
|
||||
@@ -30,11 +30,11 @@ export class MinimalConnectorSpec {
|
||||
this.connector = new MinimalConnector();
|
||||
}
|
||||
|
||||
static validateThings(things: SCMessage[]) {
|
||||
things.forEach((thing: SCMessage) => {
|
||||
static validateThings(things: SCThings[]) {
|
||||
things.forEach((thing: SCThings) => {
|
||||
// validate thing
|
||||
expect(MinimalConnectorSpec.validator.validate(thing,'SCMessage').errors).to.have.lengthOf(0, JSON.stringify({
|
||||
errors: MinimalConnectorSpec.validator.validate(thing,'SCMessage').errors,
|
||||
expect(MinimalConnectorSpec.validator.validateThing(thing).errors).to.have.lengthOf(0, JSON.stringify({
|
||||
errors: MinimalConnectorSpec.validator.validateThing(thing).errors,
|
||||
thing: thing,
|
||||
}));
|
||||
});
|
||||
@@ -42,7 +42,7 @@ export class MinimalConnectorSpec {
|
||||
|
||||
@test
|
||||
getSampleThings() {
|
||||
return MinimalConnectorSpec.connector.getItems().then(<T extends SCMessage>(items: T[]) => {
|
||||
return MinimalConnectorSpec.connector.getItems().then(<T extends SCThings>(items: T[]) => {
|
||||
if (items.length > 0) {
|
||||
MinimalConnectorSpec.validateThings(items);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user