|
19 | 19 | * SPDX-License-Identifier: Apache-2.0 |
20 | 20 | ********************************************************************************/ |
21 | 21 |
|
| 22 | +import { CalendarDateModel } from '@core/model/calendar-date.model'; |
22 | 23 | import { screen } from '@testing-library/angular'; |
23 | 24 | import { renderComponent } from '@tests/test-render.utils'; |
24 | 25 | import { SharedModule } from '..'; |
25 | 26 |
|
26 | 27 | describe('FormatDatePipe', () => { |
27 | 28 | it('should format date having the 1970 value for the year', async () => { |
28 | | - await renderComponent(`{{ 'unitTest.test01' | formatDate }}`, { |
| 29 | + const date = new CalendarDateModel(null); |
| 30 | + await renderComponent(`{{ date | formatDate }}`, { |
29 | 31 | imports: [SharedModule], |
| 32 | + componentProperties: { date }, |
30 | 33 | }); |
31 | 34 |
|
32 | | - expect(screen.getByText('This is for unit tests purposes.')).toBeInTheDocument(); |
| 35 | + expect(screen.getByText('--')).toBeInTheDocument(); |
| 36 | + }); |
| 37 | + |
| 38 | + it('should format date without issues', async () => { |
| 39 | + const date = new CalendarDateModel('2022-02-04T13:48:54Z'); |
| 40 | + await renderComponent(`{{ date | formatDate }}`, { |
| 41 | + imports: [SharedModule], |
| 42 | + componentProperties: { date }, |
| 43 | + }); |
| 44 | + |
| 45 | + expect(screen.getByText('2/4/2022')).toBeInTheDocument(); |
| 46 | + }); |
| 47 | + |
| 48 | + it('should return -- if string is empty', async () => { |
| 49 | + await renderComponent(`{{ '' | formatDate }}`, { |
| 50 | + imports: [SharedModule], |
| 51 | + }); |
| 52 | + |
| 53 | + expect(screen.getByText('--')).toBeInTheDocument(); |
33 | 54 | }); |
34 | 55 | }); |
0 commit comments