(apiType: 'classic' | 'composition')
| 22 | } |
| 23 | |
| 24 | async function testGrid(apiType: 'classic' | 'composition') { |
| 25 | const baseUrl = `file://${path.resolve( |
| 26 | __dirname, |
| 27 | `../../examples/${apiType}/grid.html`, |
| 28 | )}` |
| 29 | |
| 30 | await page().goto(baseUrl) |
| 31 | await page().waitForSelector('table') |
| 32 | expect(await count('th')).toBe(2) |
| 33 | expect(await count('th.active')).toBe(0) |
| 34 | expect(await text('th:nth-child(1)')).toContain('Name') |
| 35 | expect(await text('th:nth-child(2)')).toContain('Power') |
| 36 | await assertTable([ |
| 37 | { name: 'Chuck Norris', power: Infinity }, |
| 38 | { name: 'Bruce Lee', power: 9000 }, |
| 39 | { name: 'Jackie Chan', power: 7000 }, |
| 40 | { name: 'Jet Li', power: 8000 }, |
| 41 | ]) |
| 42 | |
| 43 | await click('th:nth-child(1)') |
| 44 | expect(await count('th.active:nth-child(1)')).toBe(1) |
| 45 | expect(await count('th.active:nth-child(2)')).toBe(0) |
| 46 | expect(await count('th:nth-child(1) .arrow.dsc')).toBe(1) |
| 47 | expect(await count('th:nth-child(2) .arrow.dsc')).toBe(0) |
| 48 | await assertTable([ |
| 49 | { name: 'Jet Li', power: 8000 }, |
| 50 | { name: 'Jackie Chan', power: 7000 }, |
| 51 | { name: 'Chuck Norris', power: Infinity }, |
| 52 | { name: 'Bruce Lee', power: 9000 }, |
| 53 | ]) |
| 54 | |
| 55 | await click('th:nth-child(2)') |
| 56 | expect(await count('th.active:nth-child(1)')).toBe(0) |
| 57 | expect(await count('th.active:nth-child(2)')).toBe(1) |
| 58 | expect(await count('th:nth-child(1) .arrow.dsc')).toBe(1) |
| 59 | expect(await count('th:nth-child(2) .arrow.dsc')).toBe(1) |
| 60 | await assertTable([ |
| 61 | { name: 'Chuck Norris', power: Infinity }, |
| 62 | { name: 'Bruce Lee', power: 9000 }, |
| 63 | { name: 'Jet Li', power: 8000 }, |
| 64 | { name: 'Jackie Chan', power: 7000 }, |
| 65 | ]) |
| 66 | |
| 67 | await click('th:nth-child(2)') |
| 68 | expect(await count('th.active:nth-child(1)')).toBe(0) |
| 69 | expect(await count('th.active:nth-child(2)')).toBe(1) |
| 70 | expect(await count('th:nth-child(1) .arrow.dsc')).toBe(1) |
| 71 | expect(await count('th:nth-child(2) .arrow.asc')).toBe(1) |
| 72 | await assertTable([ |
| 73 | { name: 'Jackie Chan', power: 7000 }, |
| 74 | { name: 'Jet Li', power: 8000 }, |
| 75 | { name: 'Bruce Lee', power: 9000 }, |
| 76 | { name: 'Chuck Norris', power: Infinity }, |
| 77 | ]) |
| 78 | |
| 79 | await click('th:nth-child(1)') |
| 80 | expect(await count('th.active:nth-child(1)')).toBe(1) |
| 81 | expect(await count('th.active:nth-child(2)')).toBe(0) |
no test coverage detected