Skip to content

Commit

Permalink
fix: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Nov 5, 2024
1 parent 4079ecb commit 81bcaf6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 23 deletions.
31 changes: 29 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-11-05T07:23:15.731Z\n"
"PO-Revision-Date: 2024-11-05T07:23:15.732Z\n"
"POT-Creation-Date: 2024-11-05T14:43:19.245Z\n"
"PO-Revision-Date: 2024-11-05T14:43:19.245Z\n"

msgid "schemas"
msgstr "schemas"
Expand All @@ -33,6 +33,12 @@ msgstr "Not found"
msgid "The page you are looking for does not exist."
msgstr "The page you are looking for does not exist."

msgid "New {{modelName}}"
msgstr "New {{modelName}}"

msgid "Edit {{modelName}}"
msgstr "Edit {{modelName}}"

msgid "Metadata Overview"
msgstr "Metadata Overview"

Expand Down Expand Up @@ -1154,6 +1160,27 @@ msgstr ""
"included. PHU will still be available for the PHU level, but not included "
"in the aggregations to the levels above."

msgid "Setup"
msgstr "Setup"

msgid "Data"
msgstr "Data"

msgid "Data Elements"
msgstr "Data Elements"

msgid "Periods"
msgstr "Periods"

msgid "Organisation Units"
msgstr "Organisation Units"

msgid "Form"
msgstr "Form"

msgid "Advanced"
msgstr "Advanced"

msgid "Longitude"
msgstr "Longitude"

Expand Down
45 changes: 24 additions & 21 deletions src/app/layout/Breadcrumb.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import '@testing-library/jest-dom'
import { configure, render } from '@testing-library/react'
import React from 'react'
import { useMatches, HashRouter } from 'react-router-dom'
import { OVERVIEW_SECTIONS, SECTIONS_MAP } from '../../lib'
import {
getOverviewPath,
getSectionPath,
OVERVIEW_SECTIONS,
SECTIONS_MAP,
} from '../../lib'
import { MatchRouteHandle, RouteHandle } from '../routes/types'
import { Breadcrumbs, BreadcrumbItem } from './Breadcrumb'

Expand Down Expand Up @@ -34,9 +39,12 @@ beforeEach(() => {
})

describe('BreadcrumbItem', () => {
it('should render a link based on the section title', () => {
it('should render a link based on the given label', () => {
const { getByRole } = render(
<BreadcrumbItem section={SECTIONS_MAP.dataElement} />,
<BreadcrumbItem
label={'Data element'}
to={`/${getSectionPath(SECTIONS_MAP.dataElement)}`}
/>,
{ wrapper: HashRouter }
)

Expand All @@ -46,9 +54,12 @@ describe('BreadcrumbItem', () => {
expect(DataElementLink).toHaveAttribute('href', '#/dataElements')
})

it('should render a link to overview-section using plural title if overview-section', () => {
it('should render a correct link to overview-section using plural title if overview-section', () => {
const { getByRole } = render(
<BreadcrumbItem section={OVERVIEW_SECTIONS.dataElement} />,
<BreadcrumbItem
to={`/${getOverviewPath(OVERVIEW_SECTIONS.dataElement)}`}
label={'Data elements'}
/>,
{ wrapper: HashRouter }
)

Expand All @@ -60,20 +71,6 @@ describe('BreadcrumbItem', () => {
'#/overview/dataElements'
)
})
it('should render a link with label-prop instead of section title if provided', () => {
const { getByRole } = render(
<BreadcrumbItem
section={SECTIONS_MAP.dataElement}
label={'Custom label'}
/>,
{ wrapper: HashRouter }
)

const DataElementLink = getByRole('link')
expect(DataElementLink).toBeDefined()
expect(DataElementLink).toHaveTextContent('Data elements')
expect(DataElementLink).toHaveAttribute('href', '#/dataElements')
})
})
describe('Breadcrumbs', () => {
it('should render crumb components in handle', () => {
Expand All @@ -97,13 +94,19 @@ describe('Breadcrumbs', () => {
mockHandle({
crumb: () => (
<BreadcrumbItem
section={OVERVIEW_SECTIONS.dataElement}
to={`/${getOverviewPath(
OVERVIEW_SECTIONS.dataElement
)}`}
label={OVERVIEW_SECTIONS.dataElement.titlePlural}
/>
),
}),
mockHandle({
crumb: () => (
<BreadcrumbItem section={SECTIONS_MAP.dataElement} />
<BreadcrumbItem
to={`/${getSectionPath(SECTIONS_MAP.dataElement)}`}
label={SECTIONS_MAP.dataElement.titlePlural}
/>
),
}),
])
Expand Down

0 comments on commit 81bcaf6

Please sign in to comment.