fix: add missing tests

This commit is contained in:
StevanFreeborn
2023-01-26 22:40:13 -06:00
parent 12f32bc731
commit 9ab72bd37c
7 changed files with 142 additions and 19 deletions
+17 -15
View File
@@ -1,7 +1,10 @@
import { OnspringClient } from '../src/OnspringClient';
import { expect } from 'chai';
describe('OnspringClient Tests', function () {
describe('OnspringClient', function () {
const baseUrl = 'https://api.onspring.com';
const apiKey = 'apiKey';
it('should be defined', function () {
expect(OnspringClient).to.not.be.undefined;
});
@@ -15,73 +18,72 @@ describe('OnspringClient Tests', function () {
});
it('should throw an error when the baseUrl is null', function () {
expect(() => new OnspringClient(null, 'apiKey')).to.throw(
expect(() => new OnspringClient(null, apiKey)).to.throw(
'baseUrl must be an absolute and well-formed URI.'
);
});
it('should throw an error when the baseUrl is undefined', function () {
expect(() => new OnspringClient(undefined, 'apiKey')).to.throw(
expect(() => new OnspringClient(undefined, apiKey)).to.throw(
'baseUrl must be an absolute and well-formed URI.'
);
});
it('should throw an error when the baseUrl is an empty string', function () {
expect(() => new OnspringClient('', 'apiKey')).to.throw(
expect(() => new OnspringClient('', apiKey)).to.throw(
'baseUrl must be an absolute and well-formed URI.'
);
});
it('should throw an error when the baseUrl is a string with only spaces', function () {
expect(() => new OnspringClient(' ', 'apiKey')).to.throw(
expect(() => new OnspringClient(' ', apiKey)).to.throw(
'baseUrl must be an absolute and well-formed URI.'
);
});
it('should throw an error when the baseUrl is not a valid url', function () {
expect(() => new OnspringClient('api.onspring.com', 'apiKey')).to.throw(
expect(() => new OnspringClient('api.onspring.com', apiKey)).to.throw(
'baseUrl must be an absolute and well-formed URI.'
);
});
it('should throw an error when the apiKey is null', function () {
expect(() => new OnspringClient('https://api.onspring.com', null)).to.throw(
expect(() => new OnspringClient(baseUrl, null)).to.throw(
'apiKey cannot be null/empty/whitespace.'
);
});
it('should throw an error when the apiKey is undefined', function () {
expect(() => new OnspringClient('https://api.onspring.com', undefined)).to.throw(
expect(() => new OnspringClient(baseUrl, undefined)).to.throw(
'apiKey cannot be null/empty/whitespace.'
);
});
it('should throw an error when the apiKey is an empty string', function () {
expect(() => new OnspringClient('https://api.onspring.com', '')).to.throw(
expect(() => new OnspringClient(baseUrl, '')).to.throw(
'apiKey cannot be null/empty/whitespace.'
);
});
it('should throw an error when the apiKey is a string with only spaces', function () {
expect(() => new OnspringClient('https://api.onspring.com', ' ')).to.throw(
expect(() => new OnspringClient(baseUrl, ' ')).to.throw(
'apiKey cannot be null/empty/whitespace.'
);
});
it('should not throw an error when the baseUrl is a valid url', function () {
expect(() => new OnspringClient('https://api.onspring.com', 'apiKey')).to.not.throw();
expect(() => new OnspringClient(baseUrl, apiKey)).to.not.throw();
});
it('should not throw an error when the baseUrl is a valid url', function () {
expect(() => new OnspringClient('http://api.onspring.com', 'apiKey')).to.not.throw();
expect(() => new OnspringClient('http://api.onspring.com', apiKey)).to.not.throw();
});
it('should not throw an error when the apiKey is a valid string', function () {
expect(() => new OnspringClient('https://api.onspring.com', 'apiKey')).to.not.throw();
expect(() => new OnspringClient(baseUrl, apiKey)).to.not.throw();
});
it('should have a client property', function () {
const client = new OnspringClient('https://api.onspring.com', 'apiKey');
expect(client).to.have.property('client');
expect(new OnspringClient(baseUrl, apiKey)).to.have.property('_client');
});
});