import { generatePaginationControl } from "./bal-pagination.util";
describe('bal-pagination-util testing:', () => {
  describe('generate pagination conrols', () => {
    const dots = { type: 'dots', label: '...', active: false };
    const pageOne = { type: 'page', label: '1', active: false };
    const pageTwo = { type: 'page', label: '2', active: false };
    const pageThree = { type: 'page', label: '3', active: false };
    const pageFour = { type: 'page', label: '4', active: false };
    const pageFive = { type: 'page', label: '5', active: false };
    const pageSix = { type: 'page', label: '6', active: false };
    const pageSeven = { type: 'page', label: '7', active: false };
    const pageEight = { type: 'page', label: '8', active: false };
    const pageNine = { type: 'page', label: '9', active: false };
    const pageTen = { type: 'page', label: '10', active: false };
    const pageEleven = { type: 'page', label: '11', active: false };
    const pageTwelve = { type: 'page', label: '12', active: false };
    const pageThirteen = { type: 'page', label: '13', active: false };
    const pageFourteen = { type: 'page', label: '14', active: false };
    const pageFifteen = { type: 'page', label: '15', active: false };
    const pageSixteen = { type: 'page', label: '16', active: false };
    const pageSeventeen = { type: 'page', label: '17', active: false };
    const pageEighteen = { type: 'page', label: '18', active: false };
    const pageNineteen = { type: 'page', label: '19', active: false };
    const pageTwenty = { type: 'page', label: '20', active: false };
    test('should generate 7 page controls without dots', () => {
      const result = generatePaginationControl(1, 7, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(Object.assign(Object.assign({}, pageOne), { active: true }));
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(pageSix);
      expect(result[6]).toStrictEqual(pageSeven);
    });
    test('should generate first page controls with 1st page active', () => {
      const result = generatePaginationControl(1, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(Object.assign(Object.assign({}, pageOne), { active: true }));
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(dots);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate 2nd page controls', () => {
      const result = generatePaginationControl(2, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(Object.assign(Object.assign({}, pageTwo), { active: true }));
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(dots);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate 3rd page controls', () => {
      const result = generatePaginationControl(3, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(Object.assign(Object.assign({}, pageThree), { active: true }));
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(dots);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate 4th page controls', () => {
      const result = generatePaginationControl(4, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(Object.assign(Object.assign({}, pageFour), { active: true }));
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(dots);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate 5th page controls', () => {
      const result = generatePaginationControl(5, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageFour);
      expect(result[3]).toStrictEqual(Object.assign(Object.assign({}, pageFive), { active: true }));
      expect(result[4]).toStrictEqual(pageSix);
      expect(result[5]).toStrictEqual(dots);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate 6th page controls', () => {
      const result = generatePaginationControl(6, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageFive);
      expect(result[3]).toStrictEqual(Object.assign(Object.assign({}, pageSix), { active: true }));
      expect(result[4]).toStrictEqual(pageSeven);
      expect(result[5]).toStrictEqual(dots);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate 7th page controls', () => {
      const result = generatePaginationControl(7, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageSix);
      expect(result[3]).toStrictEqual(Object.assign(Object.assign({}, pageSeven), { active: true }));
      expect(result[4]).toStrictEqual(pageEight);
      expect(result[5]).toStrictEqual(pageNine);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate 8th page controls', () => {
      const result = generatePaginationControl(8, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageSix);
      expect(result[3]).toStrictEqual(pageSeven);
      expect(result[4]).toStrictEqual(Object.assign(Object.assign({}, pageEight), { active: true }));
      expect(result[5]).toStrictEqual(pageNine);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate 9th page controls', () => {
      const result = generatePaginationControl(9, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageSix);
      expect(result[3]).toStrictEqual(pageSeven);
      expect(result[4]).toStrictEqual(pageEight);
      expect(result[5]).toStrictEqual(Object.assign(Object.assign({}, pageNine), { active: true }));
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate 10th page controls', () => {
      const result = generatePaginationControl(10, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageSix);
      expect(result[3]).toStrictEqual(pageSeven);
      expect(result[4]).toStrictEqual(pageEight);
      expect(result[5]).toStrictEqual(pageNine);
      expect(result[6]).toStrictEqual(Object.assign(Object.assign({}, pageTen), { active: true }));
    });
    test('should generate default if not allowed parameters entered - page value greated than number of pages', () => {
      const result = generatePaginationControl(11, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(Object.assign(Object.assign({}, pageOne), { active: true }));
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(dots);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate default if not allowed parameters entered - page value less than 0', () => {
      const result = generatePaginationControl(-1, 10, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(Object.assign(Object.assign({}, pageOne), { active: true }));
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(dots);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate default if not allowed parameters entered - number of pages less than 0', () => {
      const result = generatePaginationControl(1, -1, 1);
      expect(result).toHaveLength(7);
      expect(result[0]).toStrictEqual(Object.assign(Object.assign({}, pageOne), { active: true }));
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(dots);
      expect(result[6]).toStrictEqual(pageTen);
    });
    test('should generate default if not allowed parameters entered - page range less than 0', () => {
      const result = generatePaginationControl(1, 10, -1);
      expect(result).toHaveLength(9);
      expect(result[0]).toStrictEqual(Object.assign(Object.assign({}, pageOne), { active: true }));
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(pageSix);
      expect(result[6]).toStrictEqual(pageSeven);
      expect(result[7]).toStrictEqual(dots);
      expect(result[8]).toStrictEqual(pageTen);
    });
    test('should generate controls with 1st page active and the page range 2', () => {
      const result = generatePaginationControl(1, 10, 2);
      expect(result).toHaveLength(9);
      expect(result[0]).toStrictEqual(Object.assign(Object.assign({}, pageOne), { active: true }));
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(pageSix);
      expect(result[6]).toStrictEqual(pageSeven);
      expect(result[7]).toStrictEqual(dots);
      expect(result[8]).toStrictEqual(pageTen);
    });
    test('should generate controls with 5th page active and the page range 2', () => {
      const result = generatePaginationControl(5, 10, 2);
      expect(result).toHaveLength(9);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(Object.assign(Object.assign({}, pageFive), { active: true }));
      expect(result[5]).toStrictEqual(pageSix);
      expect(result[6]).toStrictEqual(pageSeven);
      expect(result[7]).toStrictEqual(dots);
      expect(result[8]).toStrictEqual(pageTen);
    });
    test('should generate controls with 6th page active and the page range 2', () => {
      const result = generatePaginationControl(6, 10, 2);
      expect(result).toHaveLength(9);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageFour);
      expect(result[3]).toStrictEqual(pageFive);
      expect(result[4]).toStrictEqual(Object.assign(Object.assign({}, pageSix), { active: true }));
      expect(result[5]).toStrictEqual(pageSeven);
      expect(result[6]).toStrictEqual(pageEight);
      expect(result[7]).toStrictEqual(dots);
      expect(result[8]).toStrictEqual(pageTen);
    });
    test('should generate controls with 7th page active and the page range 2', () => {
      const result = generatePaginationControl(7, 10, 2);
      expect(result).toHaveLength(9);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageFour);
      expect(result[3]).toStrictEqual(pageFive);
      expect(result[4]).toStrictEqual(pageSix);
      expect(result[5]).toStrictEqual(Object.assign(Object.assign({}, pageSeven), { active: true }));
      expect(result[6]).toStrictEqual(pageEight);
      expect(result[7]).toStrictEqual(pageNine);
      expect(result[8]).toStrictEqual(pageTen);
    });
    test('should generate controls with 1st page active, page range 3 and total pages 10', () => {
      const result = generatePaginationControl(1, 10, 3);
      expect(result).toHaveLength(10);
      expect(result[0]).toStrictEqual(Object.assign(Object.assign({}, pageOne), { active: true }));
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(pageSix);
      expect(result[6]).toStrictEqual(pageSeven);
      expect(result[7]).toStrictEqual(pageEight);
      expect(result[8]).toStrictEqual(pageNine);
      expect(result[9]).toStrictEqual(pageTen);
    });
    test('should generate controls with 1st page active, page range 3 and total pages 20', () => {
      const result = generatePaginationControl(1, 20, 3);
      expect(result).toHaveLength(11);
      expect(result[0]).toStrictEqual(Object.assign(Object.assign({}, pageOne), { active: true }));
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(pageSix);
      expect(result[6]).toStrictEqual(pageSeven);
      expect(result[7]).toStrictEqual(pageEight);
      expect(result[8]).toStrictEqual(pageNine);
      expect(result[9]).toStrictEqual(dots);
      expect(result[10]).toStrictEqual(pageTwenty);
    });
    test('should generate controls with 6th page active, page range 3 and total pages 20', () => {
      const result = generatePaginationControl(6, 20, 3);
      expect(result).toHaveLength(11);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(pageTwo);
      expect(result[2]).toStrictEqual(pageThree);
      expect(result[3]).toStrictEqual(pageFour);
      expect(result[4]).toStrictEqual(pageFive);
      expect(result[5]).toStrictEqual(Object.assign(Object.assign({}, pageSix), { active: true }));
      expect(result[6]).toStrictEqual(pageSeven);
      expect(result[7]).toStrictEqual(pageEight);
      expect(result[8]).toStrictEqual(pageNine);
      expect(result[9]).toStrictEqual(dots);
      expect(result[10]).toStrictEqual(pageTwenty);
    });
    test('should generate controls with 7th page active, page range 3 and total pages 20', () => {
      const result = generatePaginationControl(7, 20, 3);
      expect(result).toHaveLength(11);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageFour);
      expect(result[3]).toStrictEqual(pageFive);
      expect(result[4]).toStrictEqual(pageSix);
      expect(result[5]).toStrictEqual(Object.assign(Object.assign({}, pageSeven), { active: true }));
      expect(result[6]).toStrictEqual(pageEight);
      expect(result[7]).toStrictEqual(pageNine);
      expect(result[8]).toStrictEqual(pageTen);
      expect(result[9]).toStrictEqual(dots);
      expect(result[10]).toStrictEqual(pageTwenty);
    });
    test('should generate controls with 8th page active, page range 3 and total pages 20', () => {
      const result = generatePaginationControl(8, 20, 3);
      expect(result).toHaveLength(11);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageFive);
      expect(result[3]).toStrictEqual(pageSix);
      expect(result[4]).toStrictEqual(pageSeven);
      expect(result[5]).toStrictEqual(Object.assign(Object.assign({}, pageEight), { active: true }));
      expect(result[6]).toStrictEqual(pageNine);
      expect(result[7]).toStrictEqual(pageTen);
      expect(result[8]).toStrictEqual(pageEleven);
      expect(result[9]).toStrictEqual(dots);
      expect(result[10]).toStrictEqual(pageTwenty);
    });
    test('should generate controls with 16th page active, page range 3 and total pages 20', () => {
      const result = generatePaginationControl(16, 20, 3);
      expect(result).toHaveLength(11);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageThirteen);
      expect(result[3]).toStrictEqual(pageFourteen);
      expect(result[4]).toStrictEqual(pageFifteen);
      expect(result[5]).toStrictEqual(Object.assign(Object.assign({}, pageSixteen), { active: true }));
      expect(result[6]).toStrictEqual(pageSeventeen);
      expect(result[7]).toStrictEqual(pageEighteen);
      expect(result[8]).toStrictEqual(pageNineteen);
      expect(result[9]).toStrictEqual(dots);
      expect(result[10]).toStrictEqual(pageTwenty);
    });
    test('should generate controls with 17th page active, page range 3 and total pages 20', () => {
      const result = generatePaginationControl(17, 20, 3);
      expect(result).toHaveLength(11);
      expect(result[0]).toStrictEqual(pageOne);
      expect(result[1]).toStrictEqual(dots);
      expect(result[2]).toStrictEqual(pageTwelve);
      expect(result[3]).toStrictEqual(pageThirteen);
      expect(result[4]).toStrictEqual(pageFourteen);
      expect(result[5]).toStrictEqual(pageFifteen);
      expect(result[6]).toStrictEqual(pageSixteen);
      expect(result[7]).toStrictEqual(Object.assign(Object.assign({}, pageSeventeen), { active: true }));
      expect(result[8]).toStrictEqual(pageEighteen);
      expect(result[9]).toStrictEqual(pageNineteen);
      expect(result[10]).toStrictEqual(pageTwenty);
    });
  });
});
