@@ -73,7 +73,7 @@ exports[`LicenseWidget snapshots snapshots: renders as expected with isLibrary t
fontSize=""
subtitle={
-
@@ -124,7 +124,7 @@ exports[`LicenseWidget snapshots snapshots: renders as expected with licenseType
fontSize=""
subtitle={
-
diff --git a/src/editors/sharedComponents/TinyMceWidget/__snapshots__/index.test.jsx.snap b/src/editors/sharedComponents/TinyMceWidget/__snapshots__/index.test.jsx.snap
deleted file mode 100644
index ea6fc97b3..000000000
--- a/src/editors/sharedComponents/TinyMceWidget/__snapshots__/index.test.jsx.snap
+++ /dev/null
@@ -1,207 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`TinyMceWidget snapshots ImageUploadModal is not rendered 1`] = `
-
-
-
-
-`;
-
-exports[`TinyMceWidget snapshots SourcecodeModal is not rendered 1`] = `
-
-
-
-
-`;
-
-exports[`TinyMceWidget snapshots renders as expected with default behavior 1`] = `
-
-
-
-
-
-`;
diff --git a/src/editors/sharedComponents/TinyMceWidget/index.test.jsx b/src/editors/sharedComponents/TinyMceWidget/index.test.tsx
similarity index 63%
rename from src/editors/sharedComponents/TinyMceWidget/index.test.jsx
rename to src/editors/sharedComponents/TinyMceWidget/index.test.tsx
index 35e32a727..c85bc869f 100644
--- a/src/editors/sharedComponents/TinyMceWidget/index.test.jsx
+++ b/src/editors/sharedComponents/TinyMceWidget/index.test.tsx
@@ -1,9 +1,10 @@
import React from 'react';
-import { shallow } from '@edx/react-unit-test-utils';
-import SourceCodeModal from '../SourceCodeModal';
-import ImageUploadModal from '../ImageUploadModal';
-import { imgModalToggle, sourceCodeModalToggle } from './hooks';
-import { TinyMceWidgetInternal as TinyMceWidget } from '.';
+import {
+ screen, initializeMocks,
+} from '@src/testUtils';
+import editorRender from '@src/editors/editorTestRender';
+import * as hooks from './hooks';
+import TinyMceWidget from '.';
const staticUrl = '/assets/sOmEaSsET';
@@ -42,6 +43,8 @@ jest.mock('./hooks', () => ({
}));
describe('TinyMceWidget', () => {
+ beforeEach(() => initializeMocks());
+
const props = {
editorType: 'text',
editorRef: { current: { value: 'something' } },
@@ -53,30 +56,41 @@ describe('TinyMceWidget', () => {
id: 'sOMeiD',
updateContent: () => ({}),
learningContextId: 'course+org+run',
+ editorContentHtml: undefined,
+ enableImageUpload: undefined,
+ onChange: undefined,
+ staticRootUrl: undefined,
};
- describe('snapshots', () => {
- imgModalToggle.mockReturnValue({
+
+ describe('render', () => {
+ jest.spyOn(hooks, 'imgModalToggle').mockReturnValue({
isImgOpen: false,
openImgModal: jest.fn().mockName('modal.openModal'),
closeImgModal: jest.fn().mockName('modal.closeModal'),
});
- sourceCodeModalToggle.mockReturnValue({
+ jest.spyOn(hooks, 'sourceCodeModalToggle').mockReturnValue({
isSourceCodeOpen: false,
openSourceCodeModal: jest.fn().mockName('modal.openModal'),
closeSourceCodeModal: jest.fn().mockName('modal.closeModal'),
});
+
test('renders as expected with default behavior', () => {
- expect(shallow().snapshot).toMatchSnapshot();
+ const { container } = editorRender();
+ expect(screen.getByText('TiNYmCE EDitOR')).toBeInTheDocument();
+ expect(container.querySelector('sourcecodemodal')).toBeInTheDocument();
+ expect(container.querySelector('imageuploadmodal')).toBeInTheDocument();
});
+
test('SourcecodeModal is not rendered', () => {
- const wrapper = shallow();
- expect(wrapper.snapshot).toMatchSnapshot();
- expect(wrapper.instance.findByType(SourceCodeModal).length).toBe(0);
+ const { container } = editorRender();
+ expect(container.querySelector('imageuploadmodal')).toBeInTheDocument();
+ expect(container.querySelector('sourcecodemodal')).not.toBeInTheDocument();
});
+
test('ImageUploadModal is not rendered', () => {
- const wrapper = shallow();
- expect(wrapper.snapshot).toMatchSnapshot();
- expect(wrapper.instance.findByType(ImageUploadModal).length).toBe(0);
+ const { container } = editorRender();
+ expect(container.querySelector('imageuploadmodal')).not.toBeInTheDocument();
+ expect(container.querySelector('sourcecodemodal')).toBeInTheDocument();
});
});
});