Fixed typo and added test

Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com>
This commit is contained in:
Andre Wanlin
2022-06-20 13:01:20 -05:00
parent a46e317a75
commit cec13be485
2 changed files with 30 additions and 1 deletions
+1 -1
View File
@@ -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();
});
});