mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-10 19:52:53 +00:00
test: add unit tests to pipeline
This commit is contained in:
@@ -14,33 +14,29 @@
|
||||
*/
|
||||
import {SCThingOriginType} from '@openstapps/core';
|
||||
import {expect} from 'chai';
|
||||
import {suite, test} from '@testdeck/mocha';
|
||||
import {MinimalConnector} from '../src/minimal-connector.js';
|
||||
|
||||
@suite
|
||||
export class ConnectorSpec {
|
||||
private static connector: MinimalConnector;
|
||||
describe('connector', function () {
|
||||
let connector: MinimalConnector;
|
||||
|
||||
static async before() {
|
||||
this.connector = new MinimalConnector('f-u', 'minimal-connector');
|
||||
}
|
||||
beforeEach(function () {
|
||||
connector = new MinimalConnector('f-u', 'minimal-connector');
|
||||
});
|
||||
|
||||
@test
|
||||
testCreateRemoteOrigin() {
|
||||
const remoteOrigin = ConnectorSpec.connector.createRemoteOrigin();
|
||||
expect(remoteOrigin.name).to.equal(ConnectorSpec.connector.origin);
|
||||
it('should create remote origin', function () {
|
||||
const remoteOrigin = connector.createRemoteOrigin();
|
||||
expect(remoteOrigin.name).to.equal(connector.origin);
|
||||
expect(remoteOrigin.type).to.equal(SCThingOriginType.Remote);
|
||||
expect(new Date().valueOf()).to.be.at.least(Date.parse(remoteOrigin.indexed).valueOf());
|
||||
}
|
||||
expect(Date.now()).to.be.at.least(Date.parse(remoteOrigin.indexed).valueOf());
|
||||
});
|
||||
|
||||
@test
|
||||
async testAutomaticMissingUIDGeneration() {
|
||||
it('should automatically generate missing UIDs', async function () {
|
||||
const uuidRegExp = new RegExp(
|
||||
'^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$',
|
||||
);
|
||||
const messages = await ConnectorSpec.connector.getItems();
|
||||
const messages = await connector.getItems();
|
||||
for (const message of messages) {
|
||||
expect(message.uid).to.match(uuidRegExp);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user