feat: add get apps method
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { EndpointFactory } from '../src/models/EndpointFactory';
|
||||
import { expect } from 'chai';
|
||||
import { PagingRequest } from '../src/models/PagingRequest';
|
||||
|
||||
describe('EndpointFactory', function () {
|
||||
const baseUrl = 'https://api.onspring.com';
|
||||
@@ -12,9 +13,9 @@ describe('EndpointFactory', function () {
|
||||
});
|
||||
|
||||
describe('getAppsEndpoint', function () {
|
||||
it('should return the correct apps endpoint', function () {
|
||||
const result = EndpointFactory.getAppsEndpoint(baseUrl);
|
||||
expect(result).to.equal(`${baseUrl}/Apps`);
|
||||
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));
|
||||
expect(result).to.equal(`${baseUrl}/Apps?page=2&pageSize=1000`);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { GetPagedAppsResponse } from '../src/models/GetPagedAppsResponse';
|
||||
import { expect } from 'chai';
|
||||
import { App } from '../src/models/App';
|
||||
|
||||
describe('GetPagedAppsResponse', function () {
|
||||
it('should be defined', function () {
|
||||
expect(GetPagedAppsResponse).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(GetPagedAppsResponse).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should have 4 parameters', function () {
|
||||
expect(GetPagedAppsResponse).to.have.lengthOf(4);
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
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('totalCount').to.be.a('number').to.equal(100);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { PagedResponse } from '../src/models/PagedResponse';
|
||||
import { expect } from 'chai';
|
||||
|
||||
describe('PagedResponse', function () {
|
||||
it('should be defined', function () {
|
||||
expect(PagedResponse).to.not.be.undefined;
|
||||
});
|
||||
|
||||
it('should have a constructor', function () {
|
||||
expect(PagedResponse).to.have.property('constructor');
|
||||
});
|
||||
|
||||
it('should have 4 parameters', function () {
|
||||
expect(PagedResponse).to.have.lengthOf(4);
|
||||
});
|
||||
|
||||
it('should construct a new instance of PagedResponse', function () {
|
||||
const pagedResponse = new PagedResponse<number>([1, 2, 3, 4], 1, 10, 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('totalCount').to.be.a('number').to.equal(100);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user