diff --git a/package.json b/package.json index a707e5021..6520216b3 100755 --- a/package.json +++ b/package.json @@ -19,8 +19,7 @@ "dev": "PUBLIC_PATH=/learner-dashboard/ MFE_CONFIG_API_URL='http://localhost:8000/api/mfe_config/v1' fedx-scripts webpack-dev-server --progress --host apps.local.openedx.io", "test": "TZ=GMT fedx-scripts jest --coverage --passWithNoTests", "quality": "npm run lint-fix && npm run test", - "watch-tests": "jest --watch", - "snapshot": "fedx-scripts jest --updateSnapshot" + "watch-tests": "jest --watch" }, "author": "edX", "license": "AGPL-3.0", diff --git a/src/__snapshots__/index.test.jsx.snap b/src/__snapshots__/index.test.jsx.snap deleted file mode 100644 index 73e7db1d6..000000000 --- a/src/__snapshots__/index.test.jsx.snap +++ /dev/null @@ -1,43 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`app registry subscribe: APP_INIT_ERROR. snapshot: displays an ErrorPage to root element 1`] = ` - - - -`; - -exports[`app registry subscribe: APP_READY. links App to root element 1`] = ` - - - - - - - - } - path="/" - /> - - } - path="*" - /> - - - - -`; diff --git a/src/containers/CourseCard/components/CourseCardDetails/__snapshots__/index.test.jsx.snap b/src/containers/CourseCard/components/CourseCardDetails/__snapshots__/index.test.jsx.snap deleted file mode 100644 index 61e49aca0..000000000 --- a/src/containers/CourseCard/components/CourseCardDetails/__snapshots__/index.test.jsx.snap +++ /dev/null @@ -1,56 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`CourseCard Details component does not have change session button on regular course 1`] = ` -
- - provider-name - • - test-course-number - • access-message - -
-`; - -exports[`CourseCard Details component has change session button on entitlement course 1`] = ` -
- - provider-name - • - test-course-number - • access-message - • - - -
-`; - -exports[`CourseCard Details component has change session button on entitlement course but no access message 1`] = ` -
- - provider-name - • - test-course-number - • - - -
-`; diff --git a/src/containers/CourseCard/components/CourseCardDetails/index.test.jsx b/src/containers/CourseCard/components/CourseCardDetails/index.test.jsx index d92e0d26f..8b746ded7 100644 --- a/src/containers/CourseCard/components/CourseCardDetails/index.test.jsx +++ b/src/containers/CourseCard/components/CourseCardDetails/index.test.jsx @@ -1,5 +1,4 @@ -import React from 'react'; -import { render } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import CourseCardDetails from '.'; @@ -48,23 +47,36 @@ describe('CourseCard Details component', () => { return separatorsCount; }; - test('has change session button on entitlement course', () => { + it('has change session button on entitlement course', () => { const wrapper = createWrapper(); - expect(wrapper.container).toMatchSnapshot(); + const sessionButton = screen.getByRole('button', { name: defaultHooks.changeOrLeaveSessionMessage }); + expect(sessionButton).toBeInTheDocument(); + + const accessMessage = screen.getByText((text) => text.includes(defaultHooks.accessMessage)); + expect(accessMessage).toBeInTheDocument(); // it has 3 separator, 4 column expect(fetchSeparators(wrapper)).toBe(3); }); - test('has change session button on entitlement course but no access message', () => { + it('has change session button on entitlement course but no access message', () => { const wrapper = createWrapper({ accessMessage: null }); - expect(wrapper.container).toMatchSnapshot(); + const sessionButton = screen.getByRole('button', { name: defaultHooks.changeOrLeaveSessionMessage }); + expect(sessionButton).toBeInTheDocument(); + + const accessMessage = screen.queryByText((text) => text.includes(defaultHooks.accessMessage)); + expect(accessMessage).toBeNull(); + // it has 2 separator, 3 column expect(fetchSeparators(wrapper)).toBe(2); }); - test('does not have change session button on regular course', () => { + it('does not have change session button on regular course', () => { const wrapper = createWrapper({ isEntitlement: false }); - expect(wrapper.container).toMatchSnapshot(); + const sessionButton = screen.queryByRole('button', { name: defaultHooks.changeOrLeaveSessionMessage }); + expect(sessionButton).toBeNull(); + + const accessMessage = screen.getByText((text) => text.includes(defaultHooks.accessMessage)); + expect(accessMessage).toBeInTheDocument(); // it has 2 separator, 3 column expect(fetchSeparators(wrapper)).toBe(2); }); diff --git a/src/index.test.jsx b/src/index.test.jsx index 5baed7483..53a0fdccb 100644 --- a/src/index.test.jsx +++ b/src/index.test.jsx @@ -55,16 +55,12 @@ describe('app registry', () => { const callArgs = subscribe.mock.calls[0]; expect(callArgs[0]).toEqual(APP_READY); callArgs[1](); - const [rendered] = mockRender.mock.calls[0]; - expect(rendered).toMatchSnapshot(); }); - test('subscribe: APP_INIT_ERROR. snapshot: displays an ErrorPage to root element', () => { + test('subscribe: APP_INIT_ERROR.', () => { const callArgs = subscribe.mock.calls[1]; expect(callArgs[0]).toEqual(APP_INIT_ERROR); const error = { message: 'test-error-message' }; callArgs[1](error); - const [rendered] = mockRender.mock.calls[0]; - expect(rendered).toMatchSnapshot(); }); test('initialize is called with requireAuthenticatedUser', () => { expect(initialize).toHaveBeenCalledTimes(1);