Files
frontend-app-learner-dashboard/src/containers/CourseCard/index.test.jsx
Ben Warzeski 9a57f9de13 Bw/segment (#76)
Co-authored-by: Leangseu Kim <lkim@edx.org>
2022-11-30 11:01:39 -05:00

31 lines
1.1 KiB
JavaScript

import React from 'react';
import { shallow } from 'enzyme';
import CourseCard from '.';
import hooks from './hooks';
jest.mock('./hooks', () => ({
useIsCollapsed: jest.fn(),
}));
jest.mock('./components/CourseCardBanners', () => 'CourseCardBanners');
jest.mock('./components/CourseCardImage', () => 'CourseCardImage');
jest.mock('./components/CourseCardMenu', () => 'CourseCardMenu');
jest.mock('./components/CourseCardActions', () => 'CourseCardActions');
jest.mock('./components/CourseCardDetails', () => 'CourseCardDetails');
jest.mock('./components/CourseCardTitle', () => 'CourseCardTitle');
jest.mock('./components/RelatedProgramsBadge', () => 'RelatedProgramsBadge');
const cardId = 'test-card-id';
describe('CourseCard component', () => {
test('snapshot: collapsed', () => {
hooks.useIsCollapsed.mockReturnValueOnce(true);
expect(shallow(<CourseCard cardId={cardId} />)).toMatchSnapshot();
});
test('snapshot: not collapsed', () => {
hooks.useIsCollapsed.mockReturnValueOnce(false);
expect(shallow(<CourseCard cardId={cardId} />)).toMatchSnapshot();
});
});