|
| 1 | +import { newE2EPage } from '@stencil/core/testing'; |
| 2 | +import { Datetime } from '../../datetime'; |
| 3 | + |
| 4 | +describe('Footer', () => { |
| 5 | + test('should render default buttons', async () => { |
| 6 | + const page = await newE2EPage({ |
| 7 | + components: [Datetime], |
| 8 | + html: '<ion-datetime show-default-buttons="true"></ion-datetime>' |
| 9 | + }); |
| 10 | + |
| 11 | + const cancelButton = await page.find('ion-datetime >>> #cancel-button'); |
| 12 | + expect(cancelButton).toEqualText('Cancel'); |
| 13 | + |
| 14 | + const confirmButton = await page.find('ion-datetime >>> #confirm-button'); |
| 15 | + expect(confirmButton).toEqualText('Done'); |
| 16 | + |
| 17 | + expect(await page.compareScreenshot()).toMatchScreenshot(); |
| 18 | + }); |
| 19 | + |
| 20 | + test('should render clear button', async () => { |
| 21 | + const page = await newE2EPage({ |
| 22 | + components: [Datetime], |
| 23 | + html: '<ion-datetime show-clear-button="true"></ion-datetime>' |
| 24 | + }); |
| 25 | + |
| 26 | + const clearButton = await page.find('ion-datetime >>> #clear-button'); |
| 27 | + expect(clearButton).toEqualText('Clear'); |
| 28 | + |
| 29 | + expect(await page.compareScreenshot()).toMatchScreenshot(); |
| 30 | + }); |
| 31 | + |
| 32 | + test('should render clear and default buttons', async () => { |
| 33 | + const page = await newE2EPage({ |
| 34 | + components: [Datetime], |
| 35 | + html: '<ion-datetime show-default-buttons="true" show-clear-button="true"></ion-datetime>' |
| 36 | + }); |
| 37 | + |
| 38 | + const cancelButton = await page.find('ion-datetime >>> #cancel-button'); |
| 39 | + expect(cancelButton).toEqualText('Cancel'); |
| 40 | + |
| 41 | + const confirmButton = await page.find('ion-datetime >>> #confirm-button'); |
| 42 | + expect(confirmButton).toEqualText('Done'); |
| 43 | + |
| 44 | + const clearButton = await page.find('ion-datetime >>> #clear-button'); |
| 45 | + expect(clearButton).toEqualText('Clear'); |
| 46 | + |
| 47 | + expect(await page.compareScreenshot()).toMatchScreenshot(); |
| 48 | + }); |
| 49 | + |
| 50 | + test('should render custom buttons', async () => { |
| 51 | + const page = await newE2EPage({ |
| 52 | + components: [Datetime], |
| 53 | + html: ` |
| 54 | + <ion-datetime show-default-buttons="true" show-clear-button="true"> |
| 55 | + <ion-buttons slot="buttons"> |
| 56 | + <ion-button id="custom-button">Hello!</ion-button> |
| 57 | + </ion-buttons> |
| 58 | + </ion-datetime> |
| 59 | + ` |
| 60 | + }); |
| 61 | + |
| 62 | + const customButton = await page.find('ion-datetime #custom-button'); |
| 63 | + expect(customButton).not.toBeNull(); |
| 64 | + |
| 65 | + expect(await page.compareScreenshot()).toMatchScreenshot(); |
| 66 | + }); |
| 67 | + |
| 68 | + test('should render custom buttons', async () => { |
| 69 | + const page = await newE2EPage({ |
| 70 | + components: [Datetime], |
| 71 | + html: ` |
| 72 | + <ion-datetime show-default-buttons="true" show-clear-button="true"> |
| 73 | + <ion-buttons slot="buttons"> |
| 74 | + <ion-button id="custom-button">Hello!</ion-button> |
| 75 | + </ion-buttons> |
| 76 | + </ion-datetime> |
| 77 | + ` |
| 78 | + }); |
| 79 | + |
| 80 | + const customButton = await page.find('ion-datetime #custom-button'); |
| 81 | + expect(customButton).not.toBeNull(); |
| 82 | + |
| 83 | + expect(await page.compareScreenshot()).toMatchScreenshot(); |
| 84 | + }); |
| 85 | +}); |
| 86 | + |
| 87 | + |
0 commit comments