Merge branch 'master' of https://github.com/openedx/frontend-app-learner-dashboard into mashal-m/replace-edx/paragon-frontend-build
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import LookingForChallengeWidget from '.';
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('LookingForChallengeWidget', () => {
|
||||
describe('snapshots', () => {
|
||||
test('default', () => {
|
||||
const wrapper = shallow(<LookingForChallengeWidget />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(wrapper.snapshot).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import { mockCrossProductCourses, mockOpenCourses } from '../testData';
|
||||
import LoadedView from './LoadedView';
|
||||
@@ -12,7 +12,7 @@ describe('ProductRecommendations LoadedView', () => {
|
||||
crossProductCourses={mockCrossProductCourses}
|
||||
openCourses={mockOpenCourses}
|
||||
/>,
|
||||
),
|
||||
).snapshot,
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
describe('with less than 2 cross product courses', () => {
|
||||
@@ -24,7 +24,7 @@ describe('ProductRecommendations LoadedView', () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
const productCardContainerProps = wrapper.find('ProductCardContainer').props();
|
||||
const productCardContainerProps = wrapper.instance.findByType('ProductCardContainer')[0].props;
|
||||
|
||||
expect(productCardContainerProps.courseTypes.length).toEqual(1);
|
||||
expect(productCardContainerProps.courseTypes[0]).toEqual('Course');
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import LoadingView from './LoadingView';
|
||||
|
||||
describe('ProductRecommendations LoadingView', () => {
|
||||
it('matches snapshot', () => {
|
||||
expect(shallow(<LoadingView />)).toMatchSnapshot();
|
||||
expect(shallow(<LoadingView />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import { mockCrossProductCourses, mockOpenCourses, mockFallbackOpenCourse } from '../testData';
|
||||
import { trackProductCardClicked, trackCourseCardClicked } from '../optimizelyExperiment';
|
||||
@@ -46,12 +46,12 @@ describe('ProductRecommendations ProductCard', () => {
|
||||
const fallbackOpenCourseProps = getProps(mockFallbackOpenCourse[0]);
|
||||
|
||||
it('matches snapshot', () => {
|
||||
expect(shallow(<ProductCard {...crossProductProps} />)).toMatchSnapshot();
|
||||
expect(shallow(<ProductCard {...crossProductProps} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('has the query string parameter attached to a fallback recommendations url', () => {
|
||||
const wrapper = shallow(<ProductCard {...fallbackOpenCourseProps} />);
|
||||
const cardUrl = wrapper.find('Card').props().destination;
|
||||
const cardUrl = wrapper.instance.findByType('Card')[0].props.destination;
|
||||
|
||||
expect(cardUrl).toEqual('https://www.edx.org/course/some-course?linked_from=recommender');
|
||||
});
|
||||
@@ -60,7 +60,7 @@ describe('ProductRecommendations ProductCard', () => {
|
||||
const wrapper = shallow(<ProductCard {...openCourseProps} />);
|
||||
const { courseRunKey, title, url } = openCourseProps;
|
||||
|
||||
wrapper.simulate('click');
|
||||
wrapper.instance.props.onClick();
|
||||
|
||||
expect(trackCourseCardClicked).toHaveBeenCalledWith('1');
|
||||
expect(discoveryCardClicked).toHaveBeenCalledWith(courseRunKey, title, `${url}&linked_from=recommender`);
|
||||
@@ -75,7 +75,7 @@ describe('ProductRecommendations ProductCard', () => {
|
||||
url,
|
||||
} = crossProductProps;
|
||||
|
||||
wrapper.simulate('click');
|
||||
wrapper.instance.props.onClick();
|
||||
|
||||
expect(trackProductCardClicked).toHaveBeenCalledWith('1');
|
||||
expect(productCardClicked).toHaveBeenCalledWith(courseRunKey, title, courseType, `${url}&linked_from=recommender`);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import { mockCrossProductCourses, mockOpenCourses } from '../testData';
|
||||
import ProductCardContainer from './ProductCardContainer';
|
||||
@@ -12,17 +12,17 @@ describe('ProductRecommendations ProductCardContainer', () => {
|
||||
};
|
||||
|
||||
it('matches snapshot', () => {
|
||||
expect(shallow(<ProductCardContainer {...props} />)).toMatchSnapshot();
|
||||
expect(shallow(<ProductCardContainer {...props} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('with finalCourseList containing cross product and open courses', () => {
|
||||
it('renders 3 ProductCardHeaders with the 3 different course types', () => {
|
||||
const wrapper = shallow(<ProductCardContainer {...props} />);
|
||||
const productCardHeaders = wrapper.find('ProductCardHeader');
|
||||
const productCardHeaders = wrapper.instance.findByType('ProductCardHeader');
|
||||
|
||||
expect(productCardHeaders.length).toEqual(3);
|
||||
productCardHeaders.forEach((header, index) => {
|
||||
expect(header.props().courseType).toEqual(props.courseTypes[index]);
|
||||
expect(header.props.courseType).toEqual(props.courseTypes[index]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -35,10 +35,10 @@ describe('ProductRecommendations ProductCardContainer', () => {
|
||||
};
|
||||
|
||||
const wrapper = shallow(<ProductCardContainer {...openCoursesProps} />);
|
||||
const productCardHeaders = wrapper.find('ProductCardHeader');
|
||||
const productCardHeaders = wrapper.instance.findByType('ProductCardHeader');
|
||||
|
||||
expect(productCardHeaders.length).toEqual(1);
|
||||
expect(productCardHeaders.at(0).props().courseType).toEqual(openCoursesProps.courseTypes[0]);
|
||||
expect(productCardHeaders[0].props.courseType).toEqual(openCoursesProps.courseTypes[0]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import ProductCardHeader from './ProductCardHeader';
|
||||
import { executiveEducation, bootCamp } from '../constants';
|
||||
@@ -22,14 +22,14 @@ describe('ProductRecommendations ProductCardHeader', () => {
|
||||
const coursesType = 'Courses';
|
||||
|
||||
it('matches snapshot', () => {
|
||||
expect(shallow(<ProductCardHeader courseType={executiveEducation} />)).toMatchSnapshot();
|
||||
expect(shallow(<ProductCardHeader courseType={executiveEducation} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
|
||||
describe('with bootcamp courseType prop', () => {
|
||||
it('renders a bootcamp header', () => {
|
||||
const wrapper = shallow(<ProductCardHeader courseType={bootCamp} />);
|
||||
|
||||
expect(wrapper.find('h3').text()).toEqual(bootCamp);
|
||||
expect(wrapper.instance.findByType('h3')[0].children[0].el).toEqual(bootCamp);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -37,16 +37,16 @@ describe('ProductRecommendations ProductCardHeader', () => {
|
||||
it('renders a courses header', () => {
|
||||
const wrapper = shallow(<ProductCardHeader courseType={coursesType} />);
|
||||
|
||||
expect(wrapper.find('h3').text()).toEqual(coursesType);
|
||||
expect(wrapper.instance.findByType('h3')[0].children[0].el).toEqual(coursesType);
|
||||
});
|
||||
});
|
||||
|
||||
it('send outs experiment events when clicked', () => {
|
||||
const wrapper = shallow(<ProductCardHeader courseType={executiveEducation} />);
|
||||
const hyperLink = wrapper.find('Hyperlink');
|
||||
const hyperLink = wrapper.instance.findByType('Hyperlink')[0];
|
||||
const execEdLink = 'http://localhost:18000/executive-education?linked_from=recommender';
|
||||
|
||||
hyperLink.simulate('click');
|
||||
hyperLink.props.onClick();
|
||||
|
||||
expect(trackProductHeaderClicked).toHaveBeenCalledWith('1');
|
||||
expect(recommendationsHeaderClicked).toHaveBeenCalledWith(executiveEducation, execEdLink);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
import { reduxHooks } from 'hooks';
|
||||
import hooks from './hooks';
|
||||
import ProductRecommendations from './index';
|
||||
@@ -31,7 +31,7 @@ describe('ProductRecommendations', () => {
|
||||
hasFailed: false,
|
||||
};
|
||||
|
||||
const successfullLoadValues = {
|
||||
const successfulLoadValues = {
|
||||
...defaultValues,
|
||||
isLoaded: true,
|
||||
productRecommendations: mockCrossProductResponse,
|
||||
@@ -42,10 +42,10 @@ describe('ProductRecommendations', () => {
|
||||
it('matches snapshot', () => {
|
||||
hooks.useIsMobile.mockReturnValueOnce(false);
|
||||
hooks.useProductRecommendationsData.mockReturnValueOnce({
|
||||
...successfullLoadValues,
|
||||
...successfulLoadValues,
|
||||
});
|
||||
|
||||
expect(shallow(<ProductRecommendations />)).toMatchSnapshot();
|
||||
expect(shallow(<ProductRecommendations />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders the LoadingView if the request is pending', () => {
|
||||
@@ -55,7 +55,7 @@ describe('ProductRecommendations', () => {
|
||||
isLoading: true,
|
||||
});
|
||||
|
||||
expect(shallow(<ProductRecommendations />)).toMatchObject(
|
||||
expect({ ...shallow(<ProductRecommendations />).shallowWrapper, children: expect.any(Array) }).toMatchObject(
|
||||
shallow(<LoadingView />),
|
||||
);
|
||||
});
|
||||
@@ -68,30 +68,30 @@ describe('ProductRecommendations', () => {
|
||||
|
||||
const wrapper = shallow(<ProductRecommendations />);
|
||||
|
||||
expect(wrapper.type()).toBeNull();
|
||||
expect(wrapper.shallowWrapper).toBeNull();
|
||||
});
|
||||
it('renders nothing if the user is on the mobile view', () => {
|
||||
hooks.useIsMobile.mockReturnValueOnce(true);
|
||||
hooks.useProductRecommendationsData.mockReturnValueOnce({
|
||||
...successfullLoadValues,
|
||||
...successfulLoadValues,
|
||||
});
|
||||
|
||||
const wrapper = shallow(<ProductRecommendations />);
|
||||
|
||||
expect(wrapper.type()).toBeNull();
|
||||
expect(wrapper.shallowWrapper).toBeNull();
|
||||
});
|
||||
|
||||
it('renders NoCoursesView if the request is loaded, user has courses, and the response is empty', () => {
|
||||
hooks.useIsMobile.mockReturnValueOnce(false);
|
||||
hooks.useProductRecommendationsData.mockReturnValueOnce({
|
||||
...successfullLoadValues,
|
||||
...successfulLoadValues,
|
||||
productRecommendations: {
|
||||
amplitudeCourses: [],
|
||||
crossProductCourses: [],
|
||||
},
|
||||
});
|
||||
|
||||
expect(shallow(<ProductRecommendations />)).toMatchObject(
|
||||
expect({ ...shallow(<ProductRecommendations />).shallowWrapper, children: expect.any(Array) }).toMatchObject(
|
||||
shallow(<NoCoursesView />),
|
||||
);
|
||||
});
|
||||
@@ -100,10 +100,10 @@ describe('ProductRecommendations', () => {
|
||||
it('renders with cross product data if the request completed and the user has courses', () => {
|
||||
hooks.useIsMobile.mockReturnValueOnce(false);
|
||||
hooks.useProductRecommendationsData.mockReturnValueOnce({
|
||||
...successfullLoadValues,
|
||||
...successfulLoadValues,
|
||||
});
|
||||
|
||||
expect(shallow(<ProductRecommendations />)).toMatchObject(
|
||||
expect({ ...shallow(<ProductRecommendations />).shallowWrapper, children: expect.any(Array) }).toMatchObject(
|
||||
shallow(
|
||||
<LoadedView
|
||||
openCourses={mockCrossProductResponse.amplitudeCourses}
|
||||
@@ -116,11 +116,11 @@ describe('ProductRecommendations', () => {
|
||||
it('renders the LoadedView with Amplitude course data if the request completed', () => {
|
||||
hooks.useIsMobile.mockReturnValueOnce(false);
|
||||
hooks.useProductRecommendationsData.mockReturnValueOnce({
|
||||
...successfullLoadValues,
|
||||
...successfulLoadValues,
|
||||
productRecommendations: mockAmplitudeResponse,
|
||||
});
|
||||
|
||||
expect(shallow(<ProductRecommendations />)).toMatchObject(
|
||||
expect({ ...shallow(<ProductRecommendations />).shallowWrapper, children: expect.any(Array) }).toMatchObject(
|
||||
shallow(
|
||||
<LoadedView
|
||||
openCourses={mockCrossProductResponse.amplitudeCourses}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import { MockUseState } from 'testUtils';
|
||||
|
||||
@@ -112,7 +112,7 @@ describe('Painted door experiments context', () => {
|
||||
isLoading: false,
|
||||
});
|
||||
|
||||
mount(
|
||||
shallow(
|
||||
<PaintedDoorExperimentProvider>
|
||||
<TestComponent />
|
||||
</PaintedDoorExperimentProvider>,
|
||||
@@ -136,7 +136,7 @@ describe('Painted door experiments context', () => {
|
||||
isLoading: false,
|
||||
});
|
||||
|
||||
mount(
|
||||
shallow(
|
||||
<PaintedDoorExperimentProvider>
|
||||
<TestComponent />
|
||||
</PaintedDoorExperimentProvider>,
|
||||
|
||||
@@ -4,7 +4,7 @@ exports[`ModalView snapshot should renders default ModalView 1`] = `
|
||||
<div
|
||||
className="containers modal-container"
|
||||
>
|
||||
<ModalDialog
|
||||
<[object Object]
|
||||
hasCloseButton={false}
|
||||
isBlocking={true}
|
||||
isFullscreenScroll={true}
|
||||
@@ -13,11 +13,11 @@ exports[`ModalView snapshot should renders default ModalView 1`] = `
|
||||
title=""
|
||||
>
|
||||
<ModalDialog.Header>
|
||||
<Component
|
||||
<ModalDialog.Title
|
||||
className="mt-2"
|
||||
>
|
||||
Thank you for your interest!
|
||||
</Component>
|
||||
</ModalDialog.Title>
|
||||
</ModalDialog.Header>
|
||||
<ModalDialog.Body>
|
||||
<div>
|
||||
@@ -31,22 +31,22 @@ exports[`ModalView snapshot should renders default ModalView 1`] = `
|
||||
</p>
|
||||
</div>
|
||||
</ModalDialog.Body>
|
||||
<Component>
|
||||
<ModalDialog.Footer>
|
||||
<ActionRow>
|
||||
<Component
|
||||
<ModalDialog.CloseButton
|
||||
onClick={[Function]}
|
||||
variant="tertiary"
|
||||
>
|
||||
Skip for now
|
||||
</Component>
|
||||
<Component
|
||||
</ModalDialog.CloseButton>
|
||||
<ModalDialog.CloseButton
|
||||
onClick={[Function]}
|
||||
variant="primary"
|
||||
>
|
||||
Count me in!
|
||||
</Component>
|
||||
</ModalDialog.CloseButton>
|
||||
</ActionRow>
|
||||
</Component>
|
||||
</ModalDialog>
|
||||
</ModalDialog.Footer>
|
||||
</[object Object]>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import ModalView from '.';
|
||||
|
||||
@@ -6,6 +6,17 @@ jest.mock('../../track', () => ({
|
||||
trackPaintedDoorRecommendationHomeSkipBtnClicked: jest.fn(),
|
||||
trackPaintedDoorRecommendationHomeInterestBtnClicked: jest.fn(),
|
||||
}));
|
||||
jest.mock('@edx/paragon', () => ({
|
||||
...jest.requireActual('@edx/paragon'),
|
||||
ModalDialog: {
|
||||
Body: 'ModalDialog.Body',
|
||||
Header: 'ModalDialog.Header',
|
||||
Title: 'ModalDialog.Title',
|
||||
Footer: 'ModalDialog.Footer',
|
||||
CloseButton: 'ModalDialog.CloseButton',
|
||||
},
|
||||
ActionRow: 'ActionRow',
|
||||
}));
|
||||
|
||||
describe('ModalView', () => {
|
||||
const props = {
|
||||
@@ -16,7 +27,7 @@ describe('ModalView', () => {
|
||||
describe('snapshot', () => {
|
||||
test('should renders default ModalView', () => {
|
||||
const wrapper = shallow(<ModalView {...props} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(wrapper.snapshot).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
import { Button, ModalDialog } from '@openedx/paragon';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
import { ModalDialog } from '@openedx/paragon';
|
||||
import RecommendationsPaintedDoorBtn from './index';
|
||||
import { EXPANDED_NAVBAR, RECOMMENDATIONS_PANEL } from './constants';
|
||||
import NavbarButton from './components/NavbarButton';
|
||||
@@ -25,13 +25,13 @@ describe('RecommendationsPaintedDoorBtn', () => {
|
||||
};
|
||||
|
||||
it('matches snapshot', () => {
|
||||
expect(shallow(<RecommendationsPaintedDoorBtn {...props} />)).toMatchSnapshot();
|
||||
expect(shallow(<RecommendationsPaintedDoorBtn {...props} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders painted door modal', () => {
|
||||
const wrapper = shallow(<RecommendationsPaintedDoorBtn {...props} />);
|
||||
|
||||
expect(wrapper.find(ModalDialog)).toBeTruthy();
|
||||
expect(wrapper.instance.findByType(ModalDialog)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('renders painted door navbar button', () => {
|
||||
@@ -41,8 +41,8 @@ describe('RecommendationsPaintedDoorBtn', () => {
|
||||
};
|
||||
const wrapper = shallow(<RecommendationsPaintedDoorBtn {...props} />);
|
||||
|
||||
expect(wrapper.find(NavbarButton).exists()).toBe(true);
|
||||
expect(wrapper.find(RecommendationsPanelButton).exists()).toBe(false);
|
||||
expect(wrapper.instance.findByType(NavbarButton)).not.toHaveLength(0);
|
||||
expect(wrapper.instance.findByType(RecommendationsPanelButton)).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('renders painted door recommendations panel button', () => {
|
||||
@@ -52,8 +52,8 @@ describe('RecommendationsPaintedDoorBtn', () => {
|
||||
};
|
||||
const wrapper = shallow(<RecommendationsPaintedDoorBtn {...props} />);
|
||||
|
||||
expect(wrapper.find(NavbarButton).exists()).toBe(false);
|
||||
expect(wrapper.find(RecommendationsPanelButton).exists()).toBe(true);
|
||||
expect(wrapper.instance.findByType(NavbarButton)).toHaveLength(0);
|
||||
expect(wrapper.instance.findByType(RecommendationsPanelButton)).not.toHaveLength(0);
|
||||
});
|
||||
|
||||
it('test no button (null) rendered for invalid placement', () => {
|
||||
@@ -63,8 +63,8 @@ describe('RecommendationsPaintedDoorBtn', () => {
|
||||
};
|
||||
const wrapper = shallow(<RecommendationsPaintedDoorBtn {...props} />);
|
||||
|
||||
expect(wrapper.find(NavbarButton).exists()).toBe(false);
|
||||
expect(wrapper.find(RecommendationsPanelButton).exists()).toBe(false);
|
||||
expect(wrapper.instance.findByType(NavbarButton)).toHaveLength(0);
|
||||
expect(wrapper.instance.findByType(RecommendationsPanelButton)).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('test track event is fired on navbar button click', () => {
|
||||
@@ -72,10 +72,10 @@ describe('RecommendationsPaintedDoorBtn', () => {
|
||||
...props,
|
||||
placement: EXPANDED_NAVBAR,
|
||||
};
|
||||
const wrapper = mount(<RecommendationsPaintedDoorBtn {...props} />);
|
||||
const navbarButton = wrapper.find(NavbarButton);
|
||||
const wrapper = shallow(<RecommendationsPaintedDoorBtn {...props} />);
|
||||
const navbarButton = wrapper.instance.findByType(NavbarButton)[0];
|
||||
|
||||
navbarButton.find(Button).simulate('click');
|
||||
navbarButton.props.handleClick();
|
||||
|
||||
expect(trackPaintedDoorRecommendationHomeBtnClicked).toHaveBeenCalled();
|
||||
});
|
||||
@@ -85,10 +85,10 @@ describe('RecommendationsPaintedDoorBtn', () => {
|
||||
...props,
|
||||
placement: RECOMMENDATIONS_PANEL,
|
||||
};
|
||||
const wrapper = mount(<RecommendationsPaintedDoorBtn {...props} />);
|
||||
const navbarButton = wrapper.find(RecommendationsPanelButton);
|
||||
const wrapper = shallow(<RecommendationsPaintedDoorBtn {...props} />);
|
||||
const recommendationsPanelButton = wrapper.instance.findByType(RecommendationsPanelButton)[0];
|
||||
|
||||
navbarButton.find(Button).simulate('click');
|
||||
recommendationsPanelButton.props.handleClick();
|
||||
|
||||
expect(trackPaintedDoorRecommendationHomeBtnClicked).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import { Button } from '@openedx/paragon';
|
||||
import LoadedView from './LoadedView';
|
||||
@@ -40,21 +40,21 @@ describe('RecommendationsPanel LoadedView', () => {
|
||||
test('without personalize recommendation', () => {
|
||||
usePaintedDoorExperimentContext.mockReturnValueOnce(mockExperimentContext);
|
||||
const el = shallow(<LoadedView {...props} />);
|
||||
expect(el).toMatchSnapshot();
|
||||
expect(el.find('h3').text()).toEqual(messages.popularCoursesHeading.defaultMessage);
|
||||
expect(el.snapshot).toMatchSnapshot();
|
||||
expect(el.instance.findByType('h3')[0].children[0].el).toEqual(messages.popularCoursesHeading.defaultMessage);
|
||||
});
|
||||
|
||||
test('with personalize recommendation', () => {
|
||||
usePaintedDoorExperimentContext.mockReturnValueOnce(mockExperimentContext);
|
||||
const el = shallow(<LoadedView {...props} isControl={false} />);
|
||||
expect(el).toMatchSnapshot();
|
||||
expect(el.find('h3').text()).toEqual(messages.recommendationsHeading.defaultMessage);
|
||||
expect(el.snapshot).toMatchSnapshot();
|
||||
expect(el.instance.findByType('h3')[0].children[0].el).toEqual(messages.recommendationsHeading.defaultMessage);
|
||||
});
|
||||
|
||||
test('test painted door button is rendered if user is in variation', () => {
|
||||
usePaintedDoorExperimentContext.mockReturnValueOnce(mockExperimentContext);
|
||||
const wrapper = shallow(<LoadedView {...props} />);
|
||||
expect(wrapper.find(RecommendationsPaintedDoorBtn).exists()).toEqual(true);
|
||||
expect(wrapper.instance.findByType(RecommendationsPaintedDoorBtn)).not.toHaveLength(0);
|
||||
});
|
||||
|
||||
test('test explore courses button is returned if user is not in variation', () => {
|
||||
@@ -64,8 +64,9 @@ describe('RecommendationsPanel LoadedView', () => {
|
||||
};
|
||||
usePaintedDoorExperimentContext.mockReturnValueOnce(mockExperimentContext);
|
||||
const wrapper = shallow(<LoadedView {...props} />);
|
||||
expect(wrapper.find(RecommendationsPaintedDoorBtn).exists()).toEqual(false);
|
||||
expect(wrapper.find(Button).text()).toEqual(messages.exploreCoursesButton.defaultMessage);
|
||||
expect(wrapper.instance.findByType(RecommendationsPaintedDoorBtn)).toHaveLength(0);
|
||||
expect(wrapper.instance.findByType(Button)[0].children[0].el)
|
||||
.toEqual(messages.exploreCoursesButton.defaultMessage);
|
||||
});
|
||||
|
||||
test('test explore courses button is returned if experiment is loading', () => {
|
||||
@@ -76,8 +77,9 @@ describe('RecommendationsPanel LoadedView', () => {
|
||||
};
|
||||
usePaintedDoorExperimentContext.mockReturnValueOnce(mockExperimentContext);
|
||||
const wrapper = shallow(<LoadedView {...props} />);
|
||||
expect(wrapper.find(RecommendationsPaintedDoorBtn).exists()).toEqual(false);
|
||||
expect(wrapper.find(Button).text()).toEqual(messages.exploreCoursesButton.defaultMessage);
|
||||
expect(wrapper.instance.findByType(RecommendationsPaintedDoorBtn)).toHaveLength(0);
|
||||
expect(wrapper.instance.findByType(Button)[0].children[0].el)
|
||||
.toEqual(messages.exploreCoursesButton.defaultMessage);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import { useDashboardMessages } from 'containers/Dashboard/hooks';
|
||||
import LoadingView from './LoadingView';
|
||||
@@ -14,6 +14,6 @@ useDashboardMessages.mockReturnValue(spinnerScreenReaderText);
|
||||
|
||||
describe('RecommendationsPanel LoadingView', () => {
|
||||
test('snapshot', () => {
|
||||
expect(shallow(<LoadingView />)).toMatchSnapshot();
|
||||
expect(shallow(<LoadingView />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import LookingForChallengeWidget from 'widgets/LookingForChallengeWidget';
|
||||
import hooks from './hooks';
|
||||
@@ -46,7 +46,8 @@ describe('RecommendationsPanel snapshot', () => {
|
||||
...defaultValues,
|
||||
isLoading: true,
|
||||
});
|
||||
expect(shallow(<RecommendationsPanel />)).toMatchObject(shallow(<LoadingView />));
|
||||
expect({ ...shallow(<RecommendationsPanel />).shallowWrapper, children: expect.any(Array) })
|
||||
.toMatchObject(shallow(<LoadingView />));
|
||||
});
|
||||
it('displays LoadedView with courses if request is loaded', () => {
|
||||
hooks.useRecommendationPanelData.mockReturnValueOnce({
|
||||
@@ -54,7 +55,7 @@ describe('RecommendationsPanel snapshot', () => {
|
||||
courses,
|
||||
isLoaded: true,
|
||||
});
|
||||
expect(shallow(<RecommendationsPanel />)).toMatchObject(
|
||||
expect({ ...shallow(<RecommendationsPanel />).shallowWrapper, children: expect.any(Array) }).toMatchObject(
|
||||
shallow(<LoadedView {...defaultLoadedViewProps} courses={courses} />),
|
||||
);
|
||||
});
|
||||
@@ -63,7 +64,7 @@ describe('RecommendationsPanel snapshot', () => {
|
||||
...defaultValues,
|
||||
isFailed: true,
|
||||
});
|
||||
expect(shallow(<RecommendationsPanel />)).toMatchObject(
|
||||
expect({ ...shallow(<RecommendationsPanel />).shallowWrapper, children: expect.any(Array) }).toMatchObject(
|
||||
shallow(<LookingForChallengeWidget />),
|
||||
);
|
||||
});
|
||||
@@ -71,7 +72,7 @@ describe('RecommendationsPanel snapshot', () => {
|
||||
hooks.useRecommendationPanelData.mockReturnValueOnce({
|
||||
...defaultValues,
|
||||
});
|
||||
expect(shallow(<RecommendationsPanel />)).toMatchObject(
|
||||
expect({ ...shallow(<RecommendationsPanel />).shallowWrapper, children: expect.any(Array) }).toMatchObject(
|
||||
shallow(<LookingForChallengeWidget />),
|
||||
);
|
||||
});
|
||||
@@ -90,7 +91,7 @@ describe('RecommendationsPanel snapshot', () => {
|
||||
});
|
||||
|
||||
const wrapper = shallow(<RecommendationsPanel />);
|
||||
expect(wrapper.find(RecommendationsPaintedDoorBtn).exists()).toBe(true);
|
||||
expect(wrapper.instance.findByType(RecommendationsPaintedDoorBtn)).not.toHaveLength(0);
|
||||
});
|
||||
it('displays painted door btn if user is in variation and no flags are set (defaults)', () => {
|
||||
hooks.useRecommendationPanelData.mockReturnValueOnce({
|
||||
@@ -104,7 +105,7 @@ describe('RecommendationsPanel snapshot', () => {
|
||||
});
|
||||
|
||||
const wrapper = shallow(<RecommendationsPanel />);
|
||||
expect(wrapper.find(RecommendationsPaintedDoorBtn).exists()).toBe(true);
|
||||
expect(wrapper.instance.findByType(RecommendationsPaintedDoorBtn)).not.toHaveLength(0);
|
||||
});
|
||||
it('renders only LookingForChallengeWidget if user is not in variation', () => {
|
||||
hooks.useRecommendationPanelData.mockReturnValueOnce({
|
||||
@@ -117,7 +118,7 @@ describe('RecommendationsPanel snapshot', () => {
|
||||
experimentLoading: false,
|
||||
});
|
||||
|
||||
expect(shallow(<RecommendationsPanel />)).toMatchObject(
|
||||
expect({ ...shallow(<RecommendationsPanel />).shallowWrapper, children: expect.any(Array) }).toMatchObject(
|
||||
shallow(<LookingForChallengeWidget />),
|
||||
);
|
||||
});
|
||||
@@ -132,7 +133,7 @@ describe('RecommendationsPanel snapshot', () => {
|
||||
experimentLoading: true,
|
||||
});
|
||||
|
||||
expect(shallow(<RecommendationsPanel />)).toMatchObject(
|
||||
expect({ ...shallow(<RecommendationsPanel />).shallowWrapper, children: expect.any(Array) }).toMatchObject(
|
||||
shallow(<LookingForChallengeWidget />),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user