Files
onspring-api-sdk-javascript/tests/PagingRequest.spec.ts
T

48 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-01-26 22:40:13 -06:00
import { PagingRequest } from '../src/models/PagingRequest';
import { expect } from 'chai';
describe('PagingRequest', function () {
it('should be defined', function () {
expect(PagingRequest).to.not.be.undefined;
});
it('should have a constructor', function () {
expect(PagingRequest).to.have.property('constructor');
});
it('should have 2 parameters', function () {
expect(PagingRequest).to.have.lengthOf(2);
});
it('should throw an error when the pageNumber is less than 1', function () {
2023-02-01 23:45:14 -06:00
expect(() => new PagingRequest(0, 1)).to.throw(
'pageNumber must be greater than 0.'
);
2023-01-26 22:40:13 -06:00
});
it('should throw an error when the pageSize is less than 1', function () {
2023-02-01 23:45:14 -06:00
expect(() => new PagingRequest(1, 0)).to.throw(
'pageSize must be greater than 0 and less than 1001.'
);
2023-01-26 22:40:13 -06:00
});
it('should throw an error when the pageSize is greater than 1000', function () {
2023-02-01 23:45:14 -06:00
expect(() => new PagingRequest(1, 1001)).to.throw(
'pageSize must be greater than 0 and less than 1001.'
);
2023-01-26 22:40:13 -06:00
});
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 () {
expect(() => new PagingRequest(1, 1)).to.not.throw();
});
it('should create a new instance of the PagingRequest class with the correct properties and values', function () {
const pagingRequest = new PagingRequest(1, 1);
expect(pagingRequest).to.have.property('pageNumber');
expect(pagingRequest).to.have.property('pageSize');
expect(pagingRequest.pageNumber).to.equal(1);
expect(pagingRequest.pageSize).to.equal(1);
});
2023-02-01 23:45:14 -06:00
});