Skip to content

Commit

Permalink
fix(routerContext): sw-1089 page display titles (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera authored Apr 4, 2023
1 parent 8f1031f commit 3c4de82
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ exports[`RouterContext should apply a hook for useNavigate: navigation push 1`]
]
`;

exports[`RouterContext should apply a hook for useRouteDetail: document title 1`] = `
[
[
"t(curiosity-view.title, {"appName":"Subscriptions","context":"RHEL"}) - Subscriptions",
],
]
`;

exports[`RouterContext should apply a hook for useRouteDetail: route details, closest 1`] = `
{
"detailProps": [
Expand Down
9 changes: 8 additions & 1 deletion src/components/router/__tests__/routerContext.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ describe('RouterContext', () => {
});

it('should apply a hook for useRouteDetail', async () => {
const { result: exactMatch } = await mountHook(() => useRouteDetail({ useSelector: () => ['rhel'] }));
const mockUpdateDocumentTitle = jest.fn();
const { result: exactMatch } = await mountHook(() =>
useRouteDetail({
useChrome: () => ({ updateDocumentTitle: mockUpdateDocumentTitle }),
useSelector: () => ['rhel']
})
);
expect(mockUpdateDocumentTitle.mock.calls).toMatchSnapshot('document title');
expect({
detailProps: Object.keys(exactMatch),
isClosest: exactMatch.isClosest,
Expand Down
4 changes: 2 additions & 2 deletions src/components/router/routerContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ const useRouteDetail = ({

// Set document title
updateDocumentTitle(
`${helpers.UI_DISPLAY_NAME}: ${t(`curiosity-view.title`, {
`${t(`curiosity-view.title`, {
appName: helpers.UI_DISPLAY_NAME,
context: firstMatch?.productGroup
})}`
})} - ${helpers.UI_DISPLAY_NAME}`
);

// Set route detail
Expand Down

0 comments on commit 3c4de82

Please sign in to comment.