feat: tests

This commit is contained in:
2023-04-21 12:08:35 +02:00
parent 8cb9285462
commit d8c79256c9
140 changed files with 2100 additions and 2693 deletions

View File

@@ -14,69 +14,51 @@
*/
import {slow, suite, test, timeout} from '@testdeck/mocha';
import {expect} from 'chai';
import {slow, suite, test, timeout} from '@testdeck/mocha';
import {SCBulkRoute} from '../src/protocol/routes/bulk-request.js';
import {SCBulkAddRoute} from '../src/protocol/routes/bulk-add.js';
import {SCThingUpdateRoute} from '../src/protocol/routes/thing-update.js';
import {SCBulkRoute} from '../src/index.js';
import {SCBulkAddRoute} from '../src/index.js';
import {SCThingUpdateRoute} from '../src/index.js';
@suite(timeout(10000), slow(5000))
export class RoutesSpec {
@test
public bulkAddRouteUrlPath() {
const bulkAddRoute = new SCBulkAddRoute();
describe('Routes', function () {
this.timeout(10_000);
this.slow(5000);
it('should produce correct BulkAddRoute url path', function () {
expect(
bulkAddRoute.getUrlPath({
new SCBulkAddRoute().getUrlPath({
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
}),
).to.equal('/bulk/540862f3-ea30-5b8f-8678-56b4dc217140');
}
});
@test
public bulkRouteUrlPath() {
const bulkRoute = new SCBulkRoute();
expect(bulkRoute.getUrlPath()).to.equal('/bulk');
}
@test
public thingUpdateRouteUrlPath() {
const thingUpdateRoute = new SCThingUpdateRoute();
it('should produce correct BlukRoute url path', function () {
expect(new SCBulkRoute().getUrlPath()).to.equal('/bulk');
});
it('should produce correct ThingUpdateRoute url path', function () {
expect(
thingUpdateRoute.getUrlPath({
new SCThingUpdateRoute().getUrlPath({
TYPE: 'dish',
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
}),
).to.equal('/dish/540862f3-ea30-5b8f-8678-56b4dc217140');
}
});
@test
public tooManyParameters() {
const thingUpdateRoute = new SCThingUpdateRoute();
const fn = () => {
thingUpdateRoute.getUrlPath({
it('should throw an error if too many parameters are provided', function () {
expect(() =>
new SCThingUpdateRoute().getUrlPath({
FOO: 'bar',
TYPE: 'dish',
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
});
};
}),
).to.throw('Extraneous parameters provided.');
});
expect(fn).to.throw('Extraneous parameters provided.');
}
@test
public wrongParameters() {
const thingUpdateRoute = new SCThingUpdateRoute();
const fn = () => {
thingUpdateRoute.getUrlPath({
it('should throw an error if wrong parameters are provided', function () {
expect(() =>
new SCThingUpdateRoute().getUrlPath({
TYPO: 'dish',
UID: '540862f3-ea30-5b8f-8678-56b4dc217140',
});
};
expect(fn).to.throw("Parameter 'TYPE' not provided.");
}
}
}),
).to.throw("Parameter 'TYPE' not provided.");
});
});