Akron | 26d57f2 | 2021-09-10 16:48:57 +0200 | [diff] [blame] | 1 | define(['pageInfo'], function (pageInfoClass) { |
| 2 | |
| 3 | describe('KorAP.PageInfo', function () { |
| 4 | it('should be initializable', function () { |
| 5 | let pi = pageInfoClass.create(); |
| 6 | expect(pi.total()).toEqual(0); |
| 7 | expect(pi.count()).toEqual(0); |
| 8 | expect(pi.page()).toEqual(0); |
| 9 | }); |
| 10 | |
| 11 | it('should be read the correct values', function () { |
| 12 | |
| 13 | // Create pagination element for pagination information |
| 14 | let p = document.createElement('div'); |
| 15 | p.setAttribute('id', 'pagination') |
| 16 | p.setAttribute('data-page',3); |
| 17 | p.setAttribute('data-total',30); |
| 18 | p.setAttribute('data-count',25); |
| 19 | |
| 20 | document.body.appendChild(p); |
| 21 | |
| 22 | pi = pageInfoClass.create(); |
| 23 | expect(pi.total()).toEqual(30); |
| 24 | expect(pi.count()).toEqual(25); |
| 25 | expect(pi.page()).toEqual(3); |
| 26 | |
| 27 | // Recreate initial state |
| 28 | document.body.removeChild(p); |
| 29 | }); |
| 30 | }); |
| 31 | }); |