mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 09:32:41 +00:00
refactor: provide a generic test class
This commit is contained in:
19
package-lock.json
generated
19
package-lock.json
generated
@@ -161,6 +161,19 @@
|
||||
"moment": "2.24.0",
|
||||
"request": "2.88.0",
|
||||
"uuid": "3.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@openstapps/core": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@openstapps/core/-/core-0.3.0.tgz",
|
||||
"integrity": "sha512-ljGYPWXiG4JMV2ZaJQmYK6hQbiXlRPAZwYzcMBTI5m/9Y6tXudawiCDP8EFcZj6OXCQ2tnkEP7Bhwic7flu2Eg==",
|
||||
"requires": {
|
||||
"@types/geojson": "1.0.6",
|
||||
"@types/json-patch": "0.0.30",
|
||||
"json-patch": "0.7.0",
|
||||
"jsonschema": "1.2.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@openstapps/configuration": {
|
||||
@@ -215,9 +228,9 @@
|
||||
}
|
||||
},
|
||||
"@openstapps/core-tools": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@openstapps/core-tools/-/core-tools-0.2.0.tgz",
|
||||
"integrity": "sha512-sDRibFLdJP0K2eLx8wNHVYjizwKP2t5iZpnsBQGnybppAjOPXlDPwdJuDi6OGo0A0QSW/eiqdnDmAGnlh0a32Q==",
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@openstapps/core-tools/-/core-tools-0.3.0.tgz",
|
||||
"integrity": "sha512-8swLstFYUsbFQ0FfdSp1YTVIMYrspPYllh/DnviEpNlZcoa9o3QAxdJr/B8K8YdI06SEvmqyt5uHNw5d7noOlw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@openstapps/logger": "0.0.3",
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/configuration": "0.5.1",
|
||||
"@openstapps/core-tools": "0.2.0",
|
||||
"@openstapps/core-tools": "0.3.0",
|
||||
"@types/chai": "4.1.7",
|
||||
"@types/mocha": "5.2.5",
|
||||
"@types/node": "10.12.18",
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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