mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-22 17:46:56 +03:00
d49535da03
* stash * stash * compiles * Tests * finish * fix packages * somemore * update snapshot
42 lines
1009 B
TypeScript
42 lines
1009 B
TypeScript
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 () {
|
|
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(),
|
|
};
|
|
};
|
|
|
|
return range;
|
|
};
|
|
const wrapper = mount(<Editor value="var a = 1;" />);
|
|
|
|
it('renders correctly', () => {
|
|
expect(mountToJson(wrapper)).toMatchSnapshot();
|
|
});
|
|
|
|
it('calls getBoundingClientRect', () => {
|
|
expect(getBoundingClientRect).toBeCalled();
|
|
});
|
|
|
|
it('calls getClientRects', () => {
|
|
expect(getClientRects).toBeCalled();
|
|
});
|
|
});
|