mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 17:12:43 +00:00
feat: add minimal connector
This commit is contained in:
51
test/index.spec.ts
Normal file
51
test/index.spec.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* 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 {SCValidator} from '@openstapps/core-validator';
|
||||
import {expect} from 'chai';
|
||||
import {suite, test} from 'mocha-typescript';
|
||||
import {MinimalConnector} from '../src';
|
||||
|
||||
@suite
|
||||
export class MinimalConnectorSpec {
|
||||
|
||||
private static connector: MinimalConnector;
|
||||
private static validator: SCValidator;
|
||||
|
||||
static before() {
|
||||
this.validator = new SCValidator('./node_modules/@openstapps/core/lib/schema');
|
||||
this.validator.feedValidator();
|
||||
this.connector = new MinimalConnector();
|
||||
}
|
||||
|
||||
static validateThings(things: SCMessage[]) {
|
||||
things.forEach((thing: SCMessage) => {
|
||||
// validate thing
|
||||
expect(MinimalConnectorSpec.validator.validateThing(thing).errors).to.have.lengthOf(0, JSON.stringify({
|
||||
errors: MinimalConnectorSpec.validator.validateThing(thing).errors,
|
||||
thing: thing,
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@test
|
||||
getSampleThings() {
|
||||
return MinimalConnectorSpec.connector.getItems().then(<T extends SCMessage>(items: T[]) => {
|
||||
if (items.length > 0) {
|
||||
MinimalConnectorSpec.validateThings(items);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user