diff --git a/src/app/pages/details/common/featured-resources/featured-resources.tsx b/src/app/pages/details/common/featured-resources/featured-resources.tsx index eaf97b67b..e4d2200ad 100644 --- a/src/app/pages/details/common/featured-resources/featured-resources.tsx +++ b/src/app/pages/details/common/featured-resources/featured-resources.tsx @@ -15,11 +15,8 @@ function FeaturedResources({header, models, ...props}: ResourcesProps) { const seenTimes = 1 + Number(window.localStorage[storageKey] || 0); const model = Object.assign( { - isNew: seenTimes <= 3, - onClick: () => { - window.localStorage[storageKey] = 5; - model.isNew = false; - } + isNew: seenTimes <= 3 + // There was an onClick defined here that nothing used }, res ); diff --git a/src/app/pages/details/common/resource-box/resource-boxes.tsx b/src/app/pages/details/common/resource-box/resource-boxes.tsx index 16a520951..14b645f0c 100644 --- a/src/app/pages/details/common/resource-box/resource-boxes.tsx +++ b/src/app/pages/details/common/resource-box/resource-boxes.tsx @@ -43,8 +43,14 @@ function CommonsHubBox() { ); } +// There's more, but this is all we need for now export type ResourceModel = { heading: string; + description?: string; + link: { + text: string; + url: string; + } }; export default function ResourceBoxes({ diff --git a/test/src/pages/details/common/featured-resources.test.tsx b/test/src/pages/details/common/featured-resources.test.tsx new file mode 100644 index 000000000..866d2f79b --- /dev/null +++ b/test/src/pages/details/common/featured-resources.test.tsx @@ -0,0 +1,58 @@ +import React from 'react'; +import {render, screen} from '@testing-library/preact'; +import FeaturedResourcesSection from '~/pages/details/common/featured-resources/featured-resources'; +import ShellContextProvider from '../../../../helpers/shell-context'; +import {MemoryRouter} from 'react-router-dom'; +import userEvent from '@testing-library/user-event'; + +const mockUseUserContext = jest.fn(); + +jest.mock('~/contexts/user', () => ({ + ...jest.requireActual('~/contexts/user'), + __esModule: true, + default: () => mockUseUserContext() +})); + +const resourceModels = [ + { + heading: 'one', + link: { + text: 'link1', + url: 'url1' + } + }, + {heading: 'two', + link: { + text: 'link2', + url: 'url2' + } + } +]; + +describe('details/featured-resources', () => { + const user = userEvent.setup(); + const originalError = console.error; + + it('renders', async () => { + mockUseUserContext.mockReturnValue({ + userStatus: { + isInstructor: true + } + }); + render( + + + + + + ); + console.error = jest.fn(); + await user.click(screen.getByRole('link', {name: 'Go to one'})); + expect(console.error).toHaveBeenCalledWith(expect.stringContaining('Not implemented: navigation'), undefined); + console.error = originalError; + }); +});