fix: add api response factory tests

This commit is contained in:
StevanFreeborn
2023-01-27 18:09:14 -06:00
parent f66edb0e2a
commit cad208cd4c
2 changed files with 51 additions and 16 deletions
+39
View File
@@ -0,0 +1,39 @@
import { ApiResponseFactory } from '../src/models/ApiResponseFactory';
import { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
import { expect } from 'chai';
describe('ApiResponseFactory', function () {
it('should be defined', function () {
expect(ApiResponseFactory).to.not.be.undefined;
});
describe('getApiResponse', function () {
it('should be defined', function () {
expect(ApiResponseFactory.getApiResponse).to.not.be.undefined;
});
it('should have 1 parameter', function () {
expect(ApiResponseFactory.getApiResponse).to.have.lengthOf(1);
});
it('should return an ApiResponse object', function () {
const response: AxiosResponse = {
data: null,
status: 200,
statusText: 'OK',
headers: {},
config: {} as InternalAxiosRequestConfig,
};
const apiResponse = ApiResponseFactory.getApiResponse(response);
expect(apiResponse).to.not.be.undefined;
expect(apiResponse).to.have.property('statusCode');
expect(apiResponse).to.have.property('message');
expect(apiResponse).to.have.property('data');
expect(apiResponse.statusCode).to.equal(200);
expect(apiResponse.message).to.equal('');
expect(apiResponse.data).to.equal(null);
});
});
});