redux-devtools/packages/redux-devtools-ui/tests/Editor.test.tsx

42 lines
1009 B
TypeScript
Raw Normal View History

2019-01-03 16:00:55 +03:00
import React from 'react';
import { mount } from 'enzyme';
import { mountToJson } from 'enzyme-to-json';
import { Editor } from '../src';
import 'codemirror/mode/javascript/javascript';
describe('Editor', function () {
2019-01-03 16:00:55 +03:00
const getBoundingClientRect = jest.fn();
const getClientRects = jest.fn();
// See https://github.com/jsdom/jsdom/issues/3002
document.createRange = () => {
const range = new Range();
range.getBoundingClientRect = getBoundingClientRect;
range.getClientRects = () => {
getClientRects();
return {
item: () => null,
length: 0,
[Symbol.iterator]: jest.fn(),
};
2019-01-03 16:00:55 +03:00
};
return range;
2019-01-03 16:00:55 +03:00
};
const wrapper = mount(<Editor value="var a = 1;" />);
2019-01-03 16:00:55 +03:00
it('renders correctly', () => {
expect(mountToJson(wrapper)).toMatchSnapshot();
});
it('calls getBoundingClientRect', () => {
expect(getBoundingClientRect).toBeCalled();
});
it('calls getClientRects', () => {
expect(getClientRects).toBeCalled();
});
});