mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-04 04:22:50 +00:00
feat: tests
This commit is contained in:
@@ -16,8 +16,7 @@ import chai from 'chai';
|
||||
import {expect} from 'chai';
|
||||
import chaiAsPromised from 'chai-as-promised';
|
||||
import chaiSpies from 'chai-spies';
|
||||
import {suite, test} from '@testdeck/mocha';
|
||||
import {ApiError} from '../src/errors.js';
|
||||
import {ApiError} from '../src/index.js';
|
||||
|
||||
chai.should();
|
||||
chai.use(chaiSpies);
|
||||
@@ -25,36 +24,32 @@ chai.use(chaiAsPromised);
|
||||
|
||||
const sandbox = chai.spy.sandbox();
|
||||
|
||||
@suite()
|
||||
export class ErrorsSpec {
|
||||
async after() {
|
||||
describe('Errors', function () {
|
||||
afterEach(function () {
|
||||
sandbox.restore();
|
||||
}
|
||||
});
|
||||
|
||||
@test
|
||||
async shouldAddAdditionalData() {
|
||||
it('should add additional data', function () {
|
||||
const error = new ApiError({
|
||||
additionalData: 'Lorem ipsum',
|
||||
});
|
||||
|
||||
expect(error.toString()).to.contain('Lorem ipsum');
|
||||
}
|
||||
});
|
||||
|
||||
@test
|
||||
async shouldAddRemoteStackTrace() {
|
||||
it('should add remote stack-trace', async function () {
|
||||
const error = new ApiError({
|
||||
stack: 'Lorem ipsum',
|
||||
});
|
||||
|
||||
expect(error.toString()).to.contain('Lorem ipsum');
|
||||
}
|
||||
});
|
||||
|
||||
@test
|
||||
async shouldSetName() {
|
||||
it('should set name', async function () {
|
||||
const error = new ApiError({
|
||||
name: 'Foo',
|
||||
});
|
||||
|
||||
expect(error.name).to.be.equal('Foo');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user