feat: add tests for isValidPageSize and isValidPageNumber methods

This commit is contained in:
StevanFreeborn
2023-01-26 14:44:37 -06:00
parent 7cacd4521f
commit 12f32bc731
2 changed files with 66 additions and 2 deletions
+64
View File
@@ -169,4 +169,68 @@ describe('ArgumentValidator', function () {
expect(ArgumentValidator.isValidUrl('https://www.google.com')).to.be.true;
});
});
describe('isValidPageSize', function () {
it('should be defined', function () {
expect(ArgumentValidator.isValidPageSize).to.not.be.undefined;
});
it('should have 1 parameter of type number', function () {
expect(ArgumentValidator.isValidPageSize).to.have.lengthOf(1);
});
it('should return false when the value is null', function () {
expect(ArgumentValidator.isValidPageSize(null)).to.be.false;
});
it('should return false when the value is undefined', function () {
expect(ArgumentValidator.isValidPageSize(undefined)).to.be.false;
});
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 (){
expect(ArgumentValidator.isValidPageSize(0)).to.be.false;
});
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 (){
expect(ArgumentValidator.isValidPageSize(1000)).to.be.true;
});
it('should return true when the value is 500', function (){
expect(ArgumentValidator.isValidPageSize(500)).to.be.true;
});
});
describe('isValidPageNumber', function () {
it('should be defined', function () {
expect(ArgumentValidator.isValidPageNumber).to.not.be.undefined;
});
it('should have 1 parameter of type number', function () {
expect(ArgumentValidator.isValidPageNumber).to.have.lengthOf(1);
});
it('should return false when the value is null', function () {
expect(ArgumentValidator.isValidPageNumber(null)).to.be.false;
});
it('should return false when the value is undefined', function () {
expect(ArgumentValidator.isValidPageNumber(undefined)).to.be.false;
});
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 (){
expect(ArgumentValidator.isValidPageNumber(1)).to.be.true;
});
});
});