fix: update components for new api fields

This commit is contained in:
Ben Warzeski
2022-09-21 14:01:33 -04:00
parent 9e34eade10
commit 82d7aab264
24 changed files with 122 additions and 285 deletions

View File

@@ -1,18 +1,23 @@
import React from 'react';
import { shallow } from 'enzyme';
import { useProgramData } from './hooks';
import { hooks } from 'data/redux';
import RelatedProgramsModal from '.';
jest.mock('./components/ProgramCard', () => 'ProgramCard');
jest.mock('./hooks', () => ({
useProgramData: jest.fn(),
jest.mock('data/redux', () => ({
hooks: {
useCardCourseData: jest.fn(),
useCardRelatedProgramsData: jest.fn(),
},
}));
const cardId = 'test-course-number';
const hookProps = {
const courseData = {
courseTitle: 'hookProps.courseTitle',
relatedPrograms: [
};
const programData = {
list: [
{
programUrl: 'program-1-url',
programData: { dataFor: 'program1' },
@@ -36,7 +41,13 @@ const props = {
describe('RelatedProgramsModal', () => {
beforeEach(() => {
useProgramData.mockReturnValueOnce(hookProps);
hooks.useCardCourseData.mockReturnValueOnce(courseData);
hooks.useCardRelatedProgramsData.mockReturnValueOnce(programData);
});
it('initializes hooks with cardId', () => {
shallow(<RelatedProgramsModal {...props} />);
expect(hooks.useCardCourseData).toHaveBeenCalledWith(cardId);
expect(hooks.useCardRelatedProgramsData).toHaveBeenCalledWith(cardId);
});
test('snapshot: open', () => {
expect(shallow(<RelatedProgramsModal {...props} />)).toMatchSnapshot();