|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
|
|
import ModalWorkflowSource, { getChooserConfig, filterEntityData } from './ModalWorkflowSource';
|
|
|
+import * as DraftUtils from '../DraftUtils';
|
|
|
import { EditorState, convertFromRaw, AtomicBlockUtils, RichUtils, Modifier } from 'draft-js';
|
|
|
|
|
|
global.ModalWorkflow = () => {};
|
|
@@ -9,6 +10,7 @@ global.ModalWorkflow = () => {};
|
|
|
describe('ModalWorkflowSource', () => {
|
|
|
beforeEach(() => {
|
|
|
jest.spyOn(global, 'ModalWorkflow');
|
|
|
+ jest.spyOn(DraftUtils, 'getSelectionText').mockImplementation(() => '');
|
|
|
});
|
|
|
|
|
|
afterEach(() => {
|
|
@@ -29,21 +31,21 @@ describe('ModalWorkflowSource', () => {
|
|
|
|
|
|
describe('#getChooserConfig', () => {
|
|
|
it('IMAGE', () => {
|
|
|
- expect(getChooserConfig({ type: 'IMAGE' })).toEqual({
|
|
|
+ expect(getChooserConfig({ type: 'IMAGE' }, null, '')).toEqual({
|
|
|
url: '/admin/images/chooser/?select_format=true',
|
|
|
urlParams: {},
|
|
|
});
|
|
|
});
|
|
|
|
|
|
it('EMBED', () => {
|
|
|
- expect(getChooserConfig({ type: 'EMBED' })).toEqual({
|
|
|
+ expect(getChooserConfig({ type: 'EMBED' }, null, '')).toEqual({
|
|
|
url: '/admin/embeds/chooser/',
|
|
|
urlParams: {},
|
|
|
});
|
|
|
});
|
|
|
|
|
|
it('DOCUMENT', () => {
|
|
|
- expect(getChooserConfig({ type: 'DOCUMENT' })).toEqual({
|
|
|
+ expect(getChooserConfig({ type: 'DOCUMENT' }, null, '')).toEqual({
|
|
|
url: '/admin/documents/chooser/',
|
|
|
urlParams: {},
|
|
|
});
|
|
@@ -51,25 +53,25 @@ describe('ModalWorkflowSource', () => {
|
|
|
|
|
|
describe('LINK', () => {
|
|
|
it('no entity', () => {
|
|
|
- expect(getChooserConfig({ type: 'LINK' })).toMatchSnapshot();
|
|
|
+ expect(getChooserConfig({ type: 'LINK' }, null, '')).toMatchSnapshot();
|
|
|
});
|
|
|
|
|
|
it('page', () => {
|
|
|
expect(getChooserConfig({ type: 'LINK' }, {
|
|
|
getData: () => ({ id: 1, parentId: 0 })
|
|
|
- })).toMatchSnapshot();
|
|
|
+ }, '')).toMatchSnapshot();
|
|
|
});
|
|
|
|
|
|
it('mail', () => {
|
|
|
expect(getChooserConfig({ type: 'LINK' }, {
|
|
|
getData: () => ({ url: 'mailto:test@example.com' })
|
|
|
- })).toMatchSnapshot();
|
|
|
+ }, '')).toMatchSnapshot();
|
|
|
});
|
|
|
|
|
|
it('external', () => {
|
|
|
expect(getChooserConfig({ type: 'LINK' }, {
|
|
|
getData: () => ({ url: 'https://www.example.com/' })
|
|
|
- })).toMatchSnapshot();
|
|
|
+ }, '')).toMatchSnapshot();
|
|
|
});
|
|
|
});
|
|
|
});
|
|
@@ -146,7 +148,7 @@ describe('ModalWorkflowSource', () => {
|
|
|
it('#componentDidMount', () => {
|
|
|
const wrapper = shallow((
|
|
|
<ModalWorkflowSource
|
|
|
- editorState={{}}
|
|
|
+ editorState={EditorState.createEmpty()}
|
|
|
entityType={{}}
|
|
|
entity={{}}
|
|
|
onComplete={() => {}}
|
|
@@ -171,7 +173,7 @@ describe('ModalWorkflowSource', () => {
|
|
|
|
|
|
const wrapper = shallow((
|
|
|
<ModalWorkflowSource
|
|
|
- editorState={{}}
|
|
|
+ editorState={EditorState.createEmpty()}
|
|
|
entityType={{}}
|
|
|
entity={{}}
|
|
|
onComplete={() => {}}
|
|
@@ -192,7 +194,7 @@ describe('ModalWorkflowSource', () => {
|
|
|
it('#componentWillUnmount', () => {
|
|
|
const wrapper = shallow((
|
|
|
<ModalWorkflowSource
|
|
|
- editorState={{}}
|
|
|
+ editorState={EditorState.createEmpty()}
|
|
|
entityType={{}}
|
|
|
entity={{}}
|
|
|
onComplete={() => {}}
|
|
@@ -335,7 +337,7 @@ describe('ModalWorkflowSource', () => {
|
|
|
const onClose = jest.fn();
|
|
|
const wrapper = shallow((
|
|
|
<ModalWorkflowSource
|
|
|
- editorState={{}}
|
|
|
+ editorState={EditorState.createEmpty()}
|
|
|
entityType={{}}
|
|
|
entity={{}}
|
|
|
onComplete={() => {}}
|