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

@@ -27,12 +27,9 @@ import {
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import chaiSpies from 'chai-spies';
import {suite, test} from '@testdeck/mocha';
import moment from 'moment';
import {copy} from '../src/copy.js';
import {ApiError} from '../src/errors.js';
import {HttpClient, RequestOptions, Response} from '../src/http-client.js';
import {RecursivePartial} from './client.spec';
import {copy, ApiError, HttpClient, RequestOptions, Response} from '../src/index.js';
import {RecursivePartial} from './client.spec.js';
chai.should();
chai.use(chaiSpies);
@@ -47,14 +44,12 @@ const searchRoute = new SCSearchRoute();
const httpClient = new HttpClient();
@suite()
export class CopySpec {
async after() {
describe('Copy', function () {
afterEach(function () {
sandbox.restore();
}
});
@test
async copy() {
it('should copy', async function () {
type responses = Response<SCBulkAddResponse | SCBulkDoneResponse | SCBulkResponse | SCSearchResponse>;
sandbox.on(
@@ -133,10 +128,9 @@ export class CopySpec {
type: SCThingType.Dish,
version: 'foo.bar.foobar',
});
}
});
@test
async copyShouldFail() {
it('should fail to copy', async function () {
type responses = Response<SCBulkAddResponse | SCBulkDoneResponse | SCBulkResponse | SCSearchResponse>;
sandbox.on(
@@ -206,7 +200,7 @@ export class CopySpec {
},
);
return copy(httpClient, {
await copy(httpClient, {
batchSize: 5,
from: 'http://foo.bar',
source: 'stapps-copy',
@@ -214,5 +208,5 @@ export class CopySpec {
type: SCThingType.Dish,
version: 'foo.bar.foobar',
}).should.be.rejectedWith(ApiError);
}
}
});
});