UNPKG

react-gantt-timeline

Version:

[![npm](https://img.shields.io/npm/v/react-gantt-timeline.svg?style=flat-square)](http://npm.im/react-gantt-timeline) [![MIT License](https://img.shields.io/npm/l/react-list.svg?style=flat-square)](http://opensource.org/licenses/MIT) [![Travis](https://tr

35 lines (31 loc) 1.3 kB
import React from 'react'; import CreateLink from './CreateLink'; import { shallow } from 'enzyme'; describe('Testing Firing Events ', function() { it('Initialise Properly and not null pointer', () => { let position = { x: 10, y: 10 }; const wrapper = shallow(<CreateLink start={position} />); expect(wrapper.instance().lastX).toBe(-1); expect(wrapper.instance().lastY).toBe(-1); expect(wrapper.state().x).toBe(10); expect(wrapper.state().y).toBe(10); expect(wrapper.instance().init).toBe(false); }); it('It handle mousmove and mouse up', () => { let onFinishCreateLink = jest.fn(); let position = { x: 10, y: 10 }; const wrapper = shallow(<CreateLink start={position} onFinishCreateLink={onFinishCreateLink} />); wrapper.instance().doMouseMove({ clientX: 1, clientY: 2 }); expect(wrapper.instance().lastX).toBe(1); expect(wrapper.instance().lastY).toBe(2); expect(wrapper.state().x).toBe(10); expect(wrapper.state().y).toBe(10); expect(wrapper.instance().init).toBe(true); wrapper.instance().doMouseMove({ clientX: 2, clientY: 3 }); expect(wrapper.state().x).toBe(11); expect(wrapper.state().y).toBe(11); wrapper.instance().doMouseUp(); expect(onFinishCreateLink.mock.calls.length).toBe(1); }); }); //