feat: update FLCC + add enzyme (#282)

This releases FLCC to stage.
This commit is contained in:
connorhaugh
2022-04-05 14:52:50 -04:00
committed by GitHub
parent bb70e59e8c
commit 397f6c5d2e
7 changed files with 32807 additions and 957 deletions

View File

@@ -1,7 +1,9 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { shallow } from 'enzyme';
import EditorContainer from './EditorContainer';
jest.mock('@edx/frontend-lib-content-components', () => ({ EditorPage: () => 'HeaderTitle' }));
jest.mock('react-router', () => ({
...jest.requireActual('react-router'), // use actual for all non-hook parts
useParams: () => ({
@@ -10,24 +12,12 @@ jest.mock('react-router', () => ({
}),
}));
const mockRole = 'Tiny-MCE-Mock';
jest.mock('@tinymce/tinymce-react', () => {
const originalModule = jest.requireActual('@tinymce/tinymce-react');
return {
__esModule: true,
...originalModule,
Editor: () => <div role={mockRole} />
,
};
});
const props = { courseId: 'cOuRsEId' };
describe('Editor Container', () => {
it('shows a rich text editor loading with an error', () => {
render(<EditorContainer
courseId="demoXDemocourse"
/>);
expect(screen.getByText('Cancel')).toBeTruthy();
expect(screen.getByText('Add To Course')).toBeTruthy();
expect(screen.findByRole(mockRole)).toBeTruthy();
describe('snapshots', () => {
test('rendering correctly with expected Input', () => {
expect(shallow(<EditorContainer {...props} />)).toMatchSnapshot();
});
});
});

View File

@@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Editor Container snapshots rendering correctly with expected Input 1`] = `
<div
className="editor-page"
>
<EditorPage
blockId="company-id1"
blockType="html"
courseId="cOuRsEId"
studioEndpointUrl="http://localhost:18010"
/>
</div>
`;

View File

@@ -4,6 +4,13 @@ import '@testing-library/jest-dom';
import '@testing-library/jest-dom/extend-expect';
import ReactDOM from 'react-dom';
/* eslint-disable import/no-extraneous-dependencies */
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import 'babel-polyfill';
Enzyme.configure({ adapter: new Adapter() });
/* need to mock window for tinymce on import, as it is JSDOM incompatible */
Object.defineProperty(window, 'matchMedia', {