|
| 1 | +import { renderClient, renderServer } from '#util/components'; |
| 2 | +import { NotificationBanner } from '#components/content-presentation/notification-banner'; |
| 3 | + |
| 4 | +describe('NotificationBanner', () => { |
| 5 | + it('matches snapshot', async () => { |
| 6 | + const { container } = await renderClient( |
| 7 | + <NotificationBanner> |
| 8 | + <NotificationBanner.Heading> |
| 9 | + The service will be unavailable from 8pm to 9pm on Thursday 1 January 2025. |
| 10 | + </NotificationBanner.Heading> |
| 11 | + </NotificationBanner>, |
| 12 | + { className: 'nhsuk-notification-banner' }, |
| 13 | + ); |
| 14 | + |
| 15 | + expect(container).toMatchSnapshot(); |
| 16 | + }); |
| 17 | + it('matches snapshot success', async () => { |
| 18 | + const { container } = await renderClient( |
| 19 | + <NotificationBanner success> |
| 20 | + <NotificationBanner.Heading>Patient record updated</NotificationBanner.Heading> |
| 21 | + </NotificationBanner>, |
| 22 | + { className: 'nhsuk-notification-banner' }, |
| 23 | + ); |
| 24 | + |
| 25 | + expect(container).toMatchSnapshot(); |
| 26 | + }); |
| 27 | + it('matches snapshot custom title', async () => { |
| 28 | + const { container } = await renderClient( |
| 29 | + <NotificationBanner title={'Upcoming Maintenance'}> |
| 30 | + <NotificationBanner.Heading> |
| 31 | + The service will be unavailable from 8pm to 9pm on Thursday 1 January 2025. |
| 32 | + </NotificationBanner.Heading> |
| 33 | + </NotificationBanner>, |
| 34 | + { className: 'nhsuk-notification-banner' }, |
| 35 | + ); |
| 36 | + |
| 37 | + expect(container).toMatchSnapshot(); |
| 38 | + }); |
| 39 | + it('matches snapshot with link in heading', async () => { |
| 40 | + const { container } = await renderClient( |
| 41 | + <NotificationBanner> |
| 42 | + <NotificationBanner.Heading> |
| 43 | + You have 7 days left to send your application.{' '} |
| 44 | + <NotificationBanner.Link href={'#'}>View application</NotificationBanner.Link>. |
| 45 | + </NotificationBanner.Heading> |
| 46 | + </NotificationBanner>, |
| 47 | + { className: 'nhsuk-notification-banner' }, |
| 48 | + ); |
| 49 | + |
| 50 | + expect(container).toMatchSnapshot(); |
| 51 | + }); |
| 52 | + it('matches snapshot with link in body', async () => { |
| 53 | + const { container } = await renderClient( |
| 54 | + <NotificationBanner> |
| 55 | + <NotificationBanner.Heading>Patient record updated</NotificationBanner.Heading> |
| 56 | + <p> |
| 57 | + Contact{' '} |
| 58 | + <NotificationBanner.Link href={'#'}>[email protected]</NotificationBanner.Link> if |
| 59 | + you think there's a problem. |
| 60 | + </p> |
| 61 | + </NotificationBanner>, |
| 62 | + { className: 'nhsuk-notification-banner' }, |
| 63 | + ); |
| 64 | + |
| 65 | + expect(container).toMatchSnapshot(); |
| 66 | + }); |
| 67 | + |
| 68 | + it('matches snapshot (via server)', async () => { |
| 69 | + const { container } = await renderServer( |
| 70 | + <NotificationBanner> |
| 71 | + <NotificationBanner.Heading> |
| 72 | + The service will be unavailable from 8pm to 9pm on Thursday 1 January 2025. |
| 73 | + </NotificationBanner.Heading> |
| 74 | + </NotificationBanner>, |
| 75 | + { className: 'nhsuk-notification-banner' }, |
| 76 | + ); |
| 77 | + |
| 78 | + expect(container).toMatchSnapshot(); |
| 79 | + }); |
| 80 | + it('matches snapshot success (via server)', async () => { |
| 81 | + const { container } = await renderServer( |
| 82 | + <NotificationBanner success> |
| 83 | + <NotificationBanner.Heading>Patient record updated</NotificationBanner.Heading> |
| 84 | + </NotificationBanner>, |
| 85 | + { className: 'nhsuk-notification-banner' }, |
| 86 | + ); |
| 87 | + |
| 88 | + expect(container).toMatchSnapshot(); |
| 89 | + }); |
| 90 | + it('matches snapshot custom title (via server)', async () => { |
| 91 | + const { container } = await renderServer( |
| 92 | + <NotificationBanner title={'Upcoming Maintenance'}> |
| 93 | + <NotificationBanner.Heading> |
| 94 | + The service will be unavailable from 8pm to 9pm on Thursday 1 January 2025. |
| 95 | + </NotificationBanner.Heading> |
| 96 | + </NotificationBanner>, |
| 97 | + { className: 'nhsuk-notification-banner' }, |
| 98 | + ); |
| 99 | + |
| 100 | + expect(container).toMatchSnapshot(); |
| 101 | + }); |
| 102 | + it('matches snapshot with link in heading (via server)', async () => { |
| 103 | + const { container } = await renderServer( |
| 104 | + <NotificationBanner> |
| 105 | + <NotificationBanner.Heading> |
| 106 | + You have 7 days left to send your application.{' '} |
| 107 | + <NotificationBanner.Link href={'#'}>View application</NotificationBanner.Link>. |
| 108 | + </NotificationBanner.Heading> |
| 109 | + </NotificationBanner>, |
| 110 | + { className: 'nhsuk-notification-banner' }, |
| 111 | + ); |
| 112 | + |
| 113 | + expect(container).toMatchSnapshot(); |
| 114 | + }); |
| 115 | + it('matches snapshot with link in body (via server)', async () => { |
| 116 | + const { container } = await renderServer( |
| 117 | + <NotificationBanner> |
| 118 | + <NotificationBanner.Heading>Patient record updated</NotificationBanner.Heading> |
| 119 | + <p> |
| 120 | + Contact{' '} |
| 121 | + <NotificationBanner.Link href={'#'}>[email protected]</NotificationBanner.Link> if |
| 122 | + you think there's a problem. |
| 123 | + </p> |
| 124 | + </NotificationBanner>, |
| 125 | + { className: 'nhsuk-notification-banner' }, |
| 126 | + ); |
| 127 | + |
| 128 | + expect(container).toMatchSnapshot(); |
| 129 | + }); |
| 130 | +}); |
0 commit comments