<commit_before>import assert from 'power-assert';
import React from 'react';
import ReactDOM from 'react-dom';
import sinon from 'sinon';
import TestUtils from 'react-addons-test-utils';
import Resizer from '../node_modules/react-resizable-box/lib/resizer';
import * as Utils from './test-utils';
import ResizeAndMovable from '../src';

describe('react-resizable-and-mpvable', () => {
  it('should have default properties', () => {
    const resizeAndMovable = TestUtils.renderIntoDocument(
      <ResizeAndMovable><div/></ResizeAndMovable>
    );
    assert.equal(resizeAndMovable.props.x, 0);
    assert.equal(resizeAndMovable.props.y, 0);
    assert.equal(resizeAndMovable.props.width, 100);
    assert.equal(resizeAndMovable.props.height, 100);
    assert.equal(resizeAndMovable.props.minWidth, undefined);
    assert.equal(resizeAndMovable.props.minHeight, undefined);
    assert.equal(resizeAndMovable.props.maxWidth, undefined);
    assert.equal(resizeAndMovable.props.maxHeight, undefined);
    assert.equal(resizeAndMovable.props.zIndex, 100);
    assert.equal(resizeAndMovable.props.customClass, '');
    assert.equal(typeof resizeAndMovable.props.onDragStart, 'function');
    assert.equal(typeof resizeAndMovable.props.onDrag, 'function');
    assert.equal(typeof resizeAndMovable.props.onDragStop, 'function');
    assert.equal(typeof resizeAndMovable.props.onResizeStart, 'function');
    assert.equal(typeof resizeAndMovable.props.onResize, 'function');
    assert.equal(typeof resizeAndMovable.props.onResizeStop, 'function');
  });

  it('should honor props', () => {
    const onDragStart = () => {};
    const onDrag = () => {};
    const onDragStop = () => {};
    const onResizeStart = () => {};
    const onResize = () => {};
    const onResizeStop = () => {};
    const resizeAndMovable = TestUtils.renderIntoDocument(
      <ResizeAndMovable
         customStyle={{background:"#333", textAlign:"center"}}
         width={50}
         height={50}
         minWidth={100}
         minHeight={120}
         maxWidth={300}asad
         maxHeight={320}
         zIndex={1000}
         onDragStart={onDragStart}
         onDrag={onDrag}
         onDragStop={onDragStop}
         onResizeStart={onResizeStart}
         onResize={onResize}
         onResizeStop={onResizeStop}>
        <div/>
      </ResizeAndMovable>
    );
    assert.equal(resizeAndMovable.props.width, 50);
    assert.equal(resizeAndMovable.props.height, 50);
    assert.equal(resizeAndMovable.props.minWidth, 100);
    assert.equal(resizeAndMovable.props.minHeight, 120);
    assert.equal(resizeAndMovable.props.maxWidth, 300);
    assert.equal(resizeAndMovable.props.maxHeight, 320);
    assert.equal(resizeAndMovable.props.zIndex, 1000);
    assert.equal(resizeAndMovable.props.onDragStart, onDragStart);
    assert.equal(resizeAndMovable.props.onDrag, onDrag);
    assert.equal(resizeAndMovable.props.onDragStop, onDragStop);
  });

  it('should call onDragStart when dragging begins', () => {
    const onDragStart = sinon.spy();
    const resizeAndMovable = TestUtils.renderIntoDocument(
      <ResizeAndMovable onDragStart={onDragStart}><div/></ResizeAndMovable>
    );
    TestUtils.Simulate.mouseDown(ReactDOM.findDOMNode(resizeAndMovable));
    assert.equal(onDragStart.callCount, 1);
  });

  it('should call onDrag when dragging', () => {
    const onDrag = sinon.spy();
    const resizeAndMovable = TestUtils.renderIntoDocument(
      <ResizeAndMovable onDrag={onDrag}><div/></ResizeAndMovable>
    );
    const node = ReactDOM.findDOMNode(resizeAndMovable);
    TestUtils.Simulate.mouseDown(node, {clientX: 0, clientY: 0});
    const event = document.createEvent('MouseEvents');
    event.initMouseEvent('mousemove', true, true, window,
                       0, 0, 0, 100, 120, false, false, false, false, 0, null);
    document.dispatchEvent(event);
    TestUtils.Simulate.mouseUp(node);<commit_msg>Use mousemove fiunc<commit_after>import assert from 'power-assert';
import React from 'react';
import ReactDOM from 'react-dom';
import sinon from 'sinon';
import TestUtils from 'react-addons-test-utils';
import Resizer from '../node_modules/react-resizable-box/lib/resizer';
import * as Utils from './test-utils';
import ResizeAndMovable from '../src';

describe('react-resizable-and-mpvable', () => {
  it('should have default properties', () => {
    const resizeAndMovable = TestUtils.renderIntoDocument(
      <ResizeAndMovable><div/></ResizeAndMovable>
    );
    assert.equal(resizeAndMovable.props.x, 0);
    assert.equal(resizeAndMovable.props.y, 0);
    assert.equal(resizeAndMovable.props.width, 100);
    assert.equal(resizeAndMovable.props.height, 100);
    assert.equal(resizeAndMovable.props.minWidth, undefined);
    assert.equal(resizeAndMovable.props.minHeight, undefined);
    assert.equal(resizeAndMovable.props.maxWidth, undefined);
    assert.equal(resizeAndMovable.props.maxHeight, undefined);
    assert.equal(resizeAndMovable.props.zIndex, 100);
    assert.equal(resizeAndMovable.props.customClass, '');
    assert.equal(typeof resizeAndMovable.props.onDragStart, 'function');
    assert.equal(typeof resizeAndMovable.props.onDrag, 'function');
    assert.equal(typeof resizeAndMovable.props.onDragStop, 'function');
    assert.equal(typeof resizeAndMovable.props.onResizeStart, 'function');
    assert.equal(typeof resizeAndMovable.props.onResize, 'function');
    assert.equal(typeof resizeAndMovable.props.onResizeStop, 'function');
  });

  it('should honor props', () => {
    const onDragStart = () => {};
    const onDrag = () => {};
    const onDragStop = () => {};
    const onResizeStart = () => {};
    const onResize = () => {};
    const onResizeStop = () => {};
    const resizeAndMovable = TestUtils.renderIntoDocument(
      <ResizeAndMovable
         customStyle={{background:"#333", textAlign:"center"}}
         width={50}
         height={50}
         minWidth={100}
         minHeight={120}
         maxWidth={300}asad
         maxHeight={320}
         zIndex={1000}
         onDragStart={onDragStart}
         onDrag={onDrag}
         onDragStop={onDragStop}
         onResizeStart={onResizeStart}
         onResize={onResize}
         onResizeStop={onResizeStop}>
        <div/>
      </ResizeAndMovable>
    );
    assert.equal(resizeAndMovable.props.width, 50);
    assert.equal(resizeAndMovable.props.height, 50);
    assert.equal(resizeAndMovable.props.minWidth, 100);
    assert.equal(resizeAndMovable.props.minHeight, 120);
    assert.equal(resizeAndMovable.props.maxWidth, 300);
    assert.equal(resizeAndMovable.props.maxHeight, 320);
    assert.equal(resizeAndMovable.props.zIndex, 1000);
    assert.equal(resizeAndMovable.props.onDragStart, onDragStart);
    assert.equal(resizeAndMovable.props.onDrag, onDrag);
    assert.equal(resizeAndMovable.props.onDragStop, onDragStop);
  });

  it('should call onDragStart when dragging begins', () => {
    const onDragStart = sinon.spy();
    const resizeAndMovable = TestUtils.renderIntoDocument(
      <ResizeAndMovable onDragStart={onDragStart}><div/></ResizeAndMovable>
    );
    TestUtils.Simulate.mouseDown(ReactDOM.findDOMNode(resizeAndMovable));
    assert.equal(onDragStart.callCount, 1);
  });

  it('should call onDrag when dragging', () => {
    const onDrag = sinon.spy();
    const resizeAndMovable = TestUtils.renderIntoDocument(
      <ResizeAndMovable onDrag={onDrag}><div/></ResizeAndMovable>
    );
    const node = ReactDOM.findDOMNode(resizeAndMovable);
    TestUtils.Simulate.mouseDown(node, {clientX: 0, clientY: 0});
    Utils.mouseMove(node, 100, 120);
    TestUtils.Simulate.mouseUp(node);
{'fraction_non_alphanumeric': 0.13689460559128494, 'fraction_numerical': 0.017062606641291507, 'mean_word_length': 4.036351619299405, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5305943', 'n_tokens_mistral': 2544, 'n_tokens_neox': 2356, 'n_words': 371}