|
| 1 | +import { |
| 2 | + render, screen, waitFor, initializeMocks, |
| 3 | +} from '@src/testUtils'; |
| 4 | + |
| 5 | +import { mockContentTaxonomyTagsData } from './data/api.mocks'; |
| 6 | +import { ContentTagsSnippet } from './ContentTagsSnippet'; |
| 7 | + |
| 8 | +mockContentTaxonomyTagsData.applyMock(); |
| 9 | + |
| 10 | +const { |
| 11 | + otherTagsId, |
| 12 | + largeTagsId, |
| 13 | + veryLongTagsId, |
| 14 | +} = mockContentTaxonomyTagsData; |
| 15 | + |
| 16 | +describe('<ContentTagsSnippet />', () => { |
| 17 | + beforeEach(() => { |
| 18 | + initializeMocks(); |
| 19 | + }); |
| 20 | + |
| 21 | + it('should render the tags correctly', async () => { |
| 22 | + render(<ContentTagsSnippet contentId={otherTagsId} />); |
| 23 | + await waitFor(() => { |
| 24 | + expect(screen.getByText('Taxonomy 1 (2)')).toBeInTheDocument(); |
| 25 | + }); |
| 26 | + expect(screen.getByText('Tag 1')).toBeInTheDocument(); |
| 27 | + expect(screen.getByText('Tag 2')).toBeInTheDocument(); |
| 28 | + expect(screen.getByText('Taxonomy 2 (2)')).toBeInTheDocument(); |
| 29 | + expect(screen.getByText('Tag 3')).toBeInTheDocument(); |
| 30 | + expect(screen.getByText('Tag 4')).toBeInTheDocument(); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should render the tags with lineage correctly', async () => { |
| 34 | + render(<ContentTagsSnippet contentId={largeTagsId} />); |
| 35 | + await waitFor(() => { |
| 36 | + expect(screen.getByText('Taxonomy 3 (1)')).toBeInTheDocument(); |
| 37 | + }); |
| 38 | + expect(screen.getByText('Tag 1 > Tag 1.1 > Tag 1.1.1')).toBeInTheDocument(); |
| 39 | + }); |
| 40 | + |
| 41 | + it('should render the very long lineage correctly', async () => { |
| 42 | + render(<ContentTagsSnippet contentId={veryLongTagsId} />); |
| 43 | + await waitFor(() => { |
| 44 | + expect(screen.getByText('ESDC Skills and Competencies (2)')).toBeInTheDocument(); |
| 45 | + }); |
| 46 | + |
| 47 | + // Skills > Technical Skills Sub-Category > Technical Skills |
| 48 | + // Can fit only first and last level |
| 49 | + expect(screen.getByText('Skills > .. > Technical Skills')).toBeInTheDocument(); |
| 50 | + |
| 51 | + // Abilities > Cognitive Abilities > Communication Abilities |
| 52 | + // can fit only last level |
| 53 | + expect(screen.getByText('.. > Communication Abilities')).toBeInTheDocument(); |
| 54 | + }); |
| 55 | +}); |
0 commit comments