Fixed typo and added test
Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
'@backstage/plugin-home': patch
|
||||
---
|
||||
|
||||
Added support for customizing the time format used in the `HeaderWorlClock` component
|
||||
Added support for customizing the time format used in the `HeaderWorldClock` component
|
||||
|
||||
Here's an example of how this can be used in the `HomePage.tsx` found in `\packages\app\src\components\home` to change the clock to be in the 24hr time format:
|
||||
|
||||
|
||||
@@ -86,3 +86,32 @@ describe('HeaderWorldClock with invalid Time Zone', () => {
|
||||
expect(rendered.getByText('GMT')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('HeaderWorldClock with custom Time Format', () => {
|
||||
it('uses 24hr clock from custom Time Format', async () => {
|
||||
const clockConfigs: ClockConfig[] = [
|
||||
{
|
||||
label: 'UTC',
|
||||
timeZone: 'UTC',
|
||||
},
|
||||
];
|
||||
|
||||
const timeFormat: Intl.DateTimeFormatOptions = {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
};
|
||||
|
||||
const rendered = await renderInTestApp(
|
||||
<ThemeProvider theme={lightTheme}>
|
||||
<HeaderWorldClock
|
||||
clockConfigs={clockConfigs}
|
||||
customTimeFormat={timeFormat}
|
||||
/>
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
const currentTime = `${new Date().getHours()}:${new Date().getMinutes()}`;
|
||||
expect(rendered.getByText(currentTime)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user