From 15ae7e5bd82302a9530ab62c86d3edbeea16c70f Mon Sep 17 00:00:00 2001 From: Michel Jonathan Schmitz Date: Thu, 7 Feb 2019 16:13:11 +0100 Subject: [PATCH] refactor: provide a generic test class --- package-lock.json | 19 ++++++++++++++++--- package.json | 2 +- src/cli.ts | 2 +- src/index.ts | 2 +- test/index.spec.ts | 14 +++++++------- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 29182752..69eed273 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index ea05956c..6e9cab0a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/cli.ts b/src/cli.ts index 3cac4327..0c614d8b 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -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. diff --git a/src/index.ts b/src/index.ts index 29f5363d..f159ed38 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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. diff --git a/test/index.spec.ts b/test/index.spec.ts index 7738dd9f..51a8c10c 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -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 . */ -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((items: T[]) => { + return MinimalConnectorSpec.connector.getItems().then((items: T[]) => { if (items.length > 0) { MinimalConnectorSpec.validateThings(items); }