Files
frontend-app-learning/src/courseware/course/sequence/sequence-navigation/UnitIcon.test.jsx
2020-07-31 16:02:38 -04:00

28 lines
769 B
JavaScript

import React from 'react';
import { render, screen } from '../../../../setupTest';
import UnitIcon from './UnitIcon';
describe('Unit Icon', () => {
const types = {
video: 'fa-film',
other: 'fa-book',
vertical: 'fa-tasks',
problem: 'fa-edit',
lock: 'fa-lock',
undefined: 'fa-book',
};
Object.entries(types).forEach(([key, value]) => {
it(`renders correct icon for ${key} unit`, () => {
// Suppress warning for undefined prop type.
if (key === 'undefined') {
jest.spyOn(console, 'error').mockImplementation(() => {});
}
const { asFragment } = render(<UnitIcon type={key} />);
expect(screen.getByAltText(value)).toBeInTheDocument();
expect(asFragment()).toMatchSnapshot();
});
});
});