fix: test formatting

This commit is contained in:
StevanFreeborn
2023-02-01 23:45:14 -06:00
parent f7229b5344
commit e6cde7fbe7
27 changed files with 156 additions and 82 deletions
+8 -6
View File
@@ -59,7 +59,7 @@ describe('ApiResponseFactory', function () {
it('should return an ApiResponse object when request is forbidden and the response contains a message property', function () {
const response: AxiosResponse = {
data: {
message: 'Does not have permission to access this resource.'
message: 'Does not have permission to access this resource.',
},
status: 403,
statusText: 'Forbidden',
@@ -74,7 +74,9 @@ describe('ApiResponseFactory', function () {
expect(apiResponse).to.have.property('message');
expect(apiResponse).to.have.property('data');
expect(apiResponse.statusCode).to.equal(403);
expect(apiResponse.message).to.equal('Does not have permission to access this resource.');
expect(apiResponse.message).to.equal(
'Does not have permission to access this resource.'
);
expect(apiResponse.data).to.equal(null);
});
@@ -101,7 +103,7 @@ describe('ApiResponseFactory', function () {
it('should return an ApiResponse object with a message value when request is not found and the response contains a message property', function () {
const response: AxiosResponse = {
data: {
message: 'Resource not found.'
message: 'Resource not found.',
},
status: 404,
statusText: 'Not Found',
@@ -143,7 +145,7 @@ describe('ApiResponseFactory', function () {
it('should return an ApiResponse object with a message when request is unauthorized and the response contains a message property', function () {
const response: AxiosResponse = {
data: {
message: 'Unauthorized.'
message: 'Unauthorized.',
},
status: 401,
statusText: 'Unauthorized',
@@ -165,7 +167,7 @@ describe('ApiResponseFactory', function () {
it('should return an ApiResponse object with a message when request is a bad request', function () {
const response: AxiosResponse = {
data: {
field: 'Invalid input.'
field: 'Invalid input.',
},
status: 400,
statusText: 'Bad Request',
@@ -184,4 +186,4 @@ describe('ApiResponseFactory', function () {
expect(apiResponse.data).to.equal(null);
});
});
});
});
+1 -1
View File
@@ -28,4 +28,4 @@ describe('App', function () {
expect(app.id).to.equal(1);
expect(app.name).to.equal('name');
});
});
});
+7 -7
View File
@@ -187,23 +187,23 @@ describe('ArgumentValidator', function () {
expect(ArgumentValidator.isValidPageSize(undefined)).to.be.false;
});
it('should return false when the value is greater than 1000', function (){
it('should return false when the value is greater than 1000', function () {
expect(ArgumentValidator.isValidPageSize(1001)).to.be.false;
});
it('should return false when the value is less than 1', function (){
it('should return false when the value is less than 1', function () {
expect(ArgumentValidator.isValidPageSize(0)).to.be.false;
});
it('should return true when the value is 1', function (){
it('should return true when the value is 1', function () {
expect(ArgumentValidator.isValidPageSize(1)).to.be.true;
});
it('should return true when the value is 1000', function (){
it('should return true when the value is 1000', function () {
expect(ArgumentValidator.isValidPageSize(1000)).to.be.true;
});
it('should return true when the value is 500', function (){
it('should return true when the value is 500', function () {
expect(ArgumentValidator.isValidPageSize(500)).to.be.true;
});
});
@@ -225,11 +225,11 @@ describe('ArgumentValidator', function () {
expect(ArgumentValidator.isValidPageNumber(undefined)).to.be.false;
});
it('should return false when the value is less than 1', function (){
it('should return false when the value is less than 1', function () {
expect(ArgumentValidator.isValidPageNumber(0)).to.be.false;
});
it('should return true when the value is 1', function (){
it('should return true when the value is 1', function () {
expect(ArgumentValidator.isValidPageNumber(1)).to.be.true;
});
});
+1 -1
View File
@@ -15,4 +15,4 @@ describe('DataFormat', function () {
expect(result).to.equal('Formatted');
});
});
});
});
+6 -3
View File
@@ -14,7 +14,10 @@ describe('EndpointFactory', function () {
describe('getAppsEndpoint', function () {
it('should return the correct apps endpoint with paging params based on paging request parameter passed', function () {
const result = EndpointFactory.getAppsEndpoint(baseUrl, new PagingRequest(2, 1000));
const result = EndpointFactory.getAppsEndpoint(
baseUrl,
new PagingRequest(2, 1000)
);
expect(result).to.equal(`${baseUrl}/Apps?pageSize=1000&pageNumber=2`);
});
});
@@ -139,8 +142,8 @@ describe('EndpointFactory', function () {
});
});
describe('getQueryRecordsEndpoint', function(){
it('should return the correct query records endpoint', function(){
describe('getQueryRecordsEndpoint', function () {
it('should return the correct query records endpoint', function () {
const result = EndpointFactory.getQueryRecordsEndpoint(baseUrl);
expect(result).to.equal(`${baseUrl}/Records/query`);
});
+1 -1
View File
@@ -22,4 +22,4 @@ describe('FieldStatus', function () {
expect(result).to.equal('Invalid');
});
});
});
});
+1 -1
View File
@@ -85,4 +85,4 @@ describe('FieldType', function () {
expect(result).to.equal('Attachment');
});
});
});
});
+1 -1
View File
@@ -22,4 +22,4 @@ describe('FileStorageSite', function () {
expect(result).to.equal('Internal');
});
});
});
});
+1 -1
View File
@@ -29,4 +29,4 @@ describe('FormulaOutputType', function () {
expect(result).to.equal('ListValue');
});
});
});
});
+28 -7
View File
@@ -16,14 +16,35 @@ describe('GetPagedAppsResponse', function () {
});
it('should construct a new instance of GetPagedAppsResponse', function () {
const getPagedAppsResponse = new GetPagedAppsResponse([new App('test', 1, 'test'), new App('test', 1, 'test')], 1, 10, 100, 100);
const getPagedAppsResponse = new GetPagedAppsResponse(
[new App('test', 1, 'test'), new App('test', 1, 'test')],
1,
10,
100,
100
);
expect(getPagedAppsResponse).to.not.be.undefined;
expect(getPagedAppsResponse).to.be.instanceOf(GetPagedAppsResponse);
expect(getPagedAppsResponse).to.have.property('items').to.be.an('array').to.have.lengthOf(2);
expect(getPagedAppsResponse).to.have.property('pageNumber').to.be.a('number').to.equal(1);
expect(getPagedAppsResponse).to.have.property('pageSize').to.be.a('number').to.equal(10);
expect(getPagedAppsResponse).to.have.property('totalPages').to.be.a('number').to.equal(100);
expect(getPagedAppsResponse).to.have.property('totalRecords').to.be.a('number').to.equal(100);
expect(getPagedAppsResponse)
.to.have.property('items')
.to.be.an('array')
.to.have.lengthOf(2);
expect(getPagedAppsResponse)
.to.have.property('pageNumber')
.to.be.a('number')
.to.equal(1);
expect(getPagedAppsResponse)
.to.have.property('pageSize')
.to.be.a('number')
.to.equal(10);
expect(getPagedAppsResponse)
.to.have.property('totalPages')
.to.be.a('number')
.to.equal(100);
expect(getPagedAppsResponse)
.to.have.property('totalRecords')
.to.be.a('number')
.to.equal(100);
});
});
});
+1 -1
View File
@@ -106,4 +106,4 @@ describe('HttpStatusCode', () => {
expect(result).to.equal(504);
});
});
});
});
+1 -1
View File
@@ -15,4 +15,4 @@ describe('Multiplicity', function () {
expect(result).to.equal('MultiSelect');
});
});
});
});
+15 -5
View File
@@ -305,7 +305,10 @@ describe('OnspringClient', function () {
expect(result).to.be.instanceOf(ApiResponse);
expect(result).to.have.property('statusCode', 400);
expect(result).to.have.property('isSuccessful', false);
expect(result).to.have.property('message', '{"PageSize":["The field PageSize must be between 0 and 1000."]}');
expect(result).to.have.property(
'message',
'{"PageSize":["The field PageSize must be between 0 and 1000."]}'
);
expect(result).to.have.property('data');
expect(result.data).to.be.null;
});
@@ -344,19 +347,26 @@ describe('OnspringClient', function () {
describe('getAppById', function () {
it('should be defined', function () {
expect(new OnspringClient(baseUrl, apiKey).getAppById).to.not.be.undefined;
expect(new OnspringClient(baseUrl, apiKey).getAppById).to.not.be
.undefined;
});
it('should be a function', function () {
expect(new OnspringClient(baseUrl, apiKey).getAppById).to.be.a('function');
expect(new OnspringClient(baseUrl, apiKey).getAppById).to.be.a(
'function'
);
});
it('should have 1 parameter', function () {
expect(new OnspringClient(baseUrl, apiKey).getAppById).to.have.lengthOf(1);
expect(new OnspringClient(baseUrl, apiKey).getAppById).to.have.lengthOf(
1
);
});
it('should return a promise', function () {
expect(new OnspringClient(baseUrl, apiKey).getAppById(1)).to.be.a('promise');
expect(new OnspringClient(baseUrl, apiKey).getAppById(1)).to.be.a(
'promise'
);
});
it('should return a promise that resolves to an api response of an app when request is successful', async function () {
+27 -6
View File
@@ -15,14 +15,35 @@ describe('PagedResponse', function () {
});
it('should construct a new instance of PagedResponse', function () {
const pagedResponse = new PagedResponse<number>([1, 2, 3, 4], 1, 10, 100, 100);
const pagedResponse = new PagedResponse<number>(
[1, 2, 3, 4],
1,
10,
100,
100
);
expect(pagedResponse).to.not.be.undefined;
expect(pagedResponse).to.be.instanceOf(PagedResponse);
expect(pagedResponse).to.have.property('items').to.be.an('array').to.have.lengthOf(4);
expect(pagedResponse).to.have.property('pageNumber').to.be.a('number').to.equal(1);
expect(pagedResponse).to.have.property('pageSize').to.be.a('number').to.equal(10);
expect(pagedResponse).to.have.property('totalPages').to.be.a('number').to.equal(100);
expect(pagedResponse).to.have.property('totalRecords').to.be.a('number').to.equal(100);
expect(pagedResponse)
.to.have.property('items')
.to.be.an('array')
.to.have.lengthOf(4);
expect(pagedResponse)
.to.have.property('pageNumber')
.to.be.a('number')
.to.equal(1);
expect(pagedResponse)
.to.have.property('pageSize')
.to.be.a('number')
.to.equal(10);
expect(pagedResponse)
.to.have.property('totalPages')
.to.be.a('number')
.to.equal(100);
expect(pagedResponse)
.to.have.property('totalRecords')
.to.be.a('number')
.to.equal(100);
});
});
+10 -4
View File
@@ -15,15 +15,21 @@ describe('PagingRequest', function () {
});
it('should throw an error when the pageNumber is less than 1', function () {
expect(() => new PagingRequest(0, 1)).to.throw('pageNumber must be greater than 0.');
expect(() => new PagingRequest(0, 1)).to.throw(
'pageNumber must be greater than 0.'
);
});
it('should throw an error when the pageSize is less than 1', function () {
expect(() => new PagingRequest(1, 0)).to.throw('pageSize must be greater than 0 and less than 1001.');
expect(() => new PagingRequest(1, 0)).to.throw(
'pageSize must be greater than 0 and less than 1001.'
);
});
it('should throw an error when the pageSize is greater than 1000', function () {
expect(() => new PagingRequest(1, 1001)).to.throw('pageSize must be greater than 0 and less than 1001.');
expect(() => new PagingRequest(1, 1001)).to.throw(
'pageSize must be greater than 0 and less than 1001.'
);
});
it('should create a new instance of the PagingRequest class when the pageNumber is greater than 0 and the pageSize is between 1 and 1000', function () {
@@ -38,4 +44,4 @@ describe('PagingRequest', function () {
expect(pagingRequest.pageNumber).to.equal(1);
expect(pagingRequest.pageSize).to.equal(1);
});
});
});
+1 -1
View File
@@ -15,4 +15,4 @@ describe('ReportDataType', function () {
expect(result).to.equal('ChartData');
});
});
});
});
+1 -1
View File
@@ -85,4 +85,4 @@ describe('ResultValueType', function () {
expect(result).to.equal('FileList');
});
});
});
});
+1 -1
View File
@@ -50,4 +50,4 @@ describe('TimeSpanIncrement', function () {
expect(result).to.equal('Years');
});
});
});
});
+1 -1
View File
@@ -22,4 +22,4 @@ describe('TimeSpanRecurrenceType', function () {
expect(result).to.equal('EndAfterOccurrences');
});
});
});
});