feat: migrate enzyme to edx react-unit-test-utils
This commit is contained in:
committed by
GitHub
parent
1bc4e51c22
commit
dcdaace08d
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import { formatMessage } from '../../../../testUtils';
|
||||
import { AltTextControls } from './AltTextControls';
|
||||
@@ -23,11 +23,11 @@ describe('AltTextControls', () => {
|
||||
});
|
||||
describe('render', () => {
|
||||
test('snapshot: isDecorative=true errorProps.showAltTextSubmissionError=true', () => {
|
||||
expect(shallow(<AltTextControls {...props} />)).toMatchSnapshot();
|
||||
expect(shallow(<AltTextControls {...props} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
test('snapshot: isDecorative=true errorProps.showAltTextSubmissionError=false', () => {
|
||||
props.validation.show = false;
|
||||
expect(shallow(<AltTextControls {...props} />)).toMatchSnapshot();
|
||||
expect(shallow(<AltTextControls {...props} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
import * as paragon from '@edx/paragon';
|
||||
import * as icons from '@edx/paragon/icons';
|
||||
|
||||
@@ -53,16 +53,16 @@ describe('DimensionControls', () => {
|
||||
jest.spyOn(hooks, 'onInputChange').mockRestore();
|
||||
});
|
||||
test('snapshot', () => {
|
||||
expect(shallow(<DimensionControls {...props} />)).toMatchSnapshot();
|
||||
expect(shallow(<DimensionControls {...props} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
test('null value: empty snapshot', () => {
|
||||
const el = shallow(<DimensionControls {...props} value={null} />);
|
||||
expect(el).toMatchSnapshot();
|
||||
expect(el.snapshot).toMatchSnapshot();
|
||||
expect(el.isEmptyRender()).toEqual(true);
|
||||
});
|
||||
test('unlocked dimensions', () => {
|
||||
const el = shallow(<DimensionControls {...props} isLocked={false} />);
|
||||
expect(el).toMatchSnapshot();
|
||||
expect(el.snapshot).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
describe('component tests for dimensions', () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`DimensionControls render null value: empty snapshot 1`] = `""`;
|
||||
exports[`DimensionControls render null value: empty snapshot 1`] = `false`;
|
||||
|
||||
exports[`DimensionControls render snapshot 1`] = `
|
||||
<Form.Group>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import { formatMessage } from '../../../../testUtils';
|
||||
import { ImageSettingsModal } from '.';
|
||||
@@ -43,7 +43,7 @@ describe('ImageSettingsModal', () => {
|
||||
});
|
||||
describe('render', () => {
|
||||
test('snapshot', () => {
|
||||
expect(shallow(<ImageSettingsModal {...props} />)).toMatchSnapshot();
|
||||
expect(shallow(<ImageSettingsModal {...props} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import { formatMessage } from '../../../../testUtils';
|
||||
import SelectionModal from '../../SelectionModal';
|
||||
@@ -89,26 +89,26 @@ describe('SelectImageModal', () => {
|
||||
el = shallow(<SelectImageModal {...props} />);
|
||||
});
|
||||
test('snapshot', () => {
|
||||
expect(el).toMatchSnapshot();
|
||||
expect(el.snapshot).toMatchSnapshot();
|
||||
});
|
||||
it('provides confirm action, forwarding selectBtnProps from imgHooks', () => {
|
||||
expect(el.find(SelectionModal).props().selectBtnProps).toEqual(
|
||||
expect(el.instance.findByType(SelectionModal)[0].props.selectBtnProps).toEqual(
|
||||
expect.objectContaining({ ...hooks.imgHooks().selectBtnProps }),
|
||||
);
|
||||
});
|
||||
it('provides file upload button linked to fileInput.click', () => {
|
||||
expect(el.find(SelectionModal).props().fileInput.click).toEqual(
|
||||
expect(el.instance.findByType(SelectionModal)[0].props.fileInput.click).toEqual(
|
||||
imgHooks.fileInput.click,
|
||||
);
|
||||
});
|
||||
it('provides a SearchSort component with searchSortProps from imgHooks', () => {
|
||||
expect(el.find(SelectionModal).props().searchSortProps).toEqual(imgHooks.searchSortProps);
|
||||
expect(el.instance.findByType(SelectionModal)[0].props.searchSortProps).toEqual(imgHooks.searchSortProps);
|
||||
});
|
||||
it('provides a Gallery component with galleryProps from imgHooks', () => {
|
||||
expect(el.find(SelectionModal).props().galleryProps).toEqual(imgHooks.galleryProps);
|
||||
expect(el.instance.findByType(SelectionModal)[0].props.galleryProps).toEqual(imgHooks.galleryProps);
|
||||
});
|
||||
it('provides a FileInput component with fileInput props from imgHooks', () => {
|
||||
expect(el.find(SelectionModal).props().fileInput).toMatchObject(imgHooks.fileInput);
|
||||
expect(el.instance.findByType(SelectionModal)[0].props.fileInput).toMatchObject(imgHooks.fileInput);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable no-import-assign */
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { shallow } from '@edx/react-unit-test-utils';
|
||||
|
||||
import { keyStore } from '../../utils';
|
||||
import tinyMCEKeys from '../../data/constants/tinyMCE';
|
||||
@@ -168,13 +168,13 @@ describe('ImageUploadModal', () => {
|
||||
module.hooks = hooks;
|
||||
});
|
||||
test('snapshot: with selection content (ImageSettingsUpload)', () => {
|
||||
expect(shallow(<ImageUploadModal {...props} />)).toMatchSnapshot();
|
||||
expect(shallow(<ImageUploadModal {...props} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
test('snapshot: selection has no externalUrl (Select Image Modal)', () => {
|
||||
expect(shallow(<ImageUploadModal {...props} selection={null} />)).toMatchSnapshot();
|
||||
expect(shallow(<ImageUploadModal {...props} selection={null} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
test('snapshot: no selection (Select Image Modal)', () => {
|
||||
expect(shallow(<ImageUploadModal {...props} selection={null} />)).toMatchSnapshot();
|
||||
expect(shallow(<ImageUploadModal {...props} selection={null} />).snapshot).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user