diff --git a/src/fragmentarium/domain/archaeology.test.ts b/src/fragmentarium/domain/archaeology.test.ts index e259bf7e4..920f33103 100644 --- a/src/fragmentarium/domain/archaeology.test.ts +++ b/src/fragmentarium/domain/archaeology.test.ts @@ -135,6 +135,7 @@ test.each([ }, 'some area > a house (Residential), II (1200 BCE - 1150 BCE), ' + 'Room 42, On the floor (primary context). General notes.', + 'de-DE', ], [ 'with secondary context', @@ -144,36 +145,43 @@ test.each([ date: null, }, 'a house (Residential), II, in shelf (secondary context).', + 'de-DE', ], [ 'with area and notes', { area: 'some area', notes: 'General notes.' }, 'some area > a house (Residential), II (1200 BCE - 1150 BCE). General notes.', + 'de-DE', ], [ 'without area or notes', { area: '' }, 'a house (Residential), II (1200 BCE - 1150 BCE).', + 'en-US', ], [ 'without notes', { notes: '' }, 'a house (Residential), II (1200 BCE - 1150 BCE).', + 'en-US', ], [ 'without building', { building: '' }, '(Residential), II (1200 BCE - 1150 BCE).', + 'de-DE', ], [ 'without buildingType', { buildingType: null }, 'a house, II (1200 BCE - 1150 BCE).', + 'en-US', ], [ 'without levelLayerPhase and date', { levelLayerPhase: '', date: null }, 'a house (Residential).', + 'de-DE', ], [ 'with date notes', @@ -181,6 +189,7 @@ test.each([ date: { ...defaultParams.date, notes: 'date notes' }, }, 'a house (Residential), II (1200 BCE - 1150 BCE, date notes).', + 'en-US', ], [ 'with CE date (en-US)', @@ -214,6 +223,6 @@ test.each([ ...overrideParams, }) - expect(findspot.toString(locale)).toEqual(expected) + expect(findspot.toString()).toEqual(expected) } ) diff --git a/src/fragmentarium/ui/info/Details.test.tsx b/src/fragmentarium/ui/info/Details.test.tsx index f0d47c579..2a9228a95 100644 --- a/src/fragmentarium/ui/info/Details.test.tsx +++ b/src/fragmentarium/ui/info/Details.test.tsx @@ -171,42 +171,47 @@ describe('All details', () => { }) describe('ExcavationDate', () => { + beforeEach(() => { + fragmentService.fetchGenres.mockResolvedValue([]) + fragmentService.fetchPeriods.mockResolvedValue([]) + Object.defineProperty(navigator, 'language', { + value: 'en-US', + writable: true, + }) + }) + it('renders excavation date when isRegularExcavation is true', async () => { const excavationDate = { - start: new PartialDate(2024, 10, 5), + start: new PartialDate(2024, 5, 10), end: new PartialDate(2024, 10, 10), } - fragment = fragmentFactory.build({ archaeology: { isRegularExcavation: true, date: excavationDate, }, }) - await renderDetails() expect(screen.getByText('Regular Excavation')).toBeInTheDocument() - expect(screen.getByText('2024.10.05 – 2024.10.10')).toBeInTheDocument() // or use the specific date format + expect(screen.getByText('05/10/2024 – 10/10/2024')).toBeInTheDocument() }) it('renders only start date when end date is missing', async () => { const excavationDate = { - start: new PartialDate(2024, 10, 5), + start: new PartialDate(2024, 5, 10), end: null, } - fragment = fragmentFactory.build({ archaeology: { isRegularExcavation: true, date: excavationDate, }, }) - await renderDetails() expect(screen.getByText('Regular Excavation')).toBeInTheDocument() - expect(screen.getByText('2024.10.05')).toBeInTheDocument() + expect(screen.getByText('05/10/2024')).toBeInTheDocument() }) it('does not render excavation date when isRegularExcavation is false', async () => { @@ -216,11 +221,10 @@ describe('ExcavationDate', () => { date: undefined, }, }) - await renderDetails() - expect(screen.queryByText('Regular Excavation')).not.toBeInTheDocument() - expect(screen.queryByText('2024.10.05')).not.toBeInTheDocument() + expect(screen.queryByText(/Regular Excavation/)).not.toBeInTheDocument() + expect(screen.queryByText(/10\/05\/2024/)).not.toBeInTheDocument() }) })