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';
|
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
describe('Editor', function() {
|
2019-01-03 16:00:55 +03:00
|
|
|
const getBoundingClientRect = jest.fn();
|
|
|
|
const getClientRects = jest.fn();
|
2019-01-10 21:51:14 +03:00
|
|
|
document.body.createTextRange = function() {
|
2019-01-03 16:00:55 +03:00
|
|
|
return {
|
|
|
|
getBoundingClientRect() {
|
|
|
|
getBoundingClientRect();
|
|
|
|
return {};
|
|
|
|
},
|
|
|
|
getClientRects() {
|
|
|
|
getClientRects();
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|