@@ -3,6 +3,8 @@ var TestUtils = require('react/lib/ReactTestUtils');
33var Draggable = require ( '../index' ) ;
44var DraggableCore = require ( '../index' ) . DraggableCore ;
55var _ = require ( 'lodash' ) ;
6+ var browserPrefix = require ( '../lib/utils/getPrefix.es6' ) ;
7+ var dashedBrowserPrefix = browserPrefix ? '-' + browserPrefix . toLowerCase ( ) + '-' : '' ;
68
79/*global describe,it,expect,afterEach */
810describe ( 'react-draggable' , function ( ) {
@@ -33,8 +35,8 @@ describe('react-draggable', function () {
3335 drag = ( < Draggable > < div className = "foo" style = { { color : 'black' } } /> </ Draggable > ) ;
3436
3537 expect ( renderToHTML ( drag ) ) . toEqual ( '<div class="foo" ' +
36- 'style="touch-action:none;color:black;transform:translate(0px,0px);-moz-transform:translate(0px,0px);" ' +
37- 'data-reactid=".1"></div>' ) ;
38+ 'style="touch-action:none;color:black;transform:translate(0px,0px);' + dashedBrowserPrefix +
39+ 'transform:translate(0px,0px);" data-reactid=".1"></div>' ) ;
3840 } ) ;
3941
4042 // NOTE: this runs a shallow renderer, which DOES NOT actually render <DraggableCore>
@@ -48,7 +50,7 @@ describe('react-draggable', function () {
4850 < DraggableCore { ...Draggable . defaultProps } handle = ".foo" className = "react-draggable"
4951 style = { {
5052 'transform' : 'translate(0px,0px)' ,
51- 'MozTransform' : 'translate(0px,0px)'
53+ [ browserPrefix + 'Transform' ] : 'translate(0px,0px)'
5254 } } >
5355 < div />
5456 </ DraggableCore >
@@ -131,8 +133,12 @@ describe('react-draggable', function () {
131133 TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
132134 // Simulate a movement; can't use TestUtils here because it uses react's event system only,
133135 // but <DraggableCore> attaches event listeners directly to the document.
134- var e = new MouseEvent ( 'mousemove' , { clientX : 100 , clientY : 100 } ) ;
135- document . dispatchEvent ( e ) ;
136+ // Would love to new MouseEvent() here but it doesn't work with PhantomJS / old browsers.
137+ // var e = new MouseEvent('mousemove', {clientX: 100, clientY: 100});
138+ var evt = document . createEvent ( 'MouseEvents' ) ;
139+ evt . initMouseEvent ( 'mousemove' , true , true , window ,
140+ 0 , 0 , 0 , 100 , 100 , false , false , false , false , 0 , null ) ;
141+ document . dispatchEvent ( evt ) ;
136142 TestUtils . Simulate . mouseUp ( node ) ;
137143
138144 var style = node . getAttribute ( 'style' ) ;
@@ -142,7 +148,7 @@ describe('react-draggable', function () {
142148
143149 it ( 'should add and remove user-select styles' , function ( ) {
144150 // Karma runs in firefox in our tests
145- var userSelectStyle = ';user-select: none;-moz- user-select: none;' ;
151+ var userSelectStyle = ';user-select: none;' + dashedBrowserPrefix + ' user-select: none;';
146152
147153 drag = TestUtils . renderIntoDocument (
148154 < Draggable >
0 commit comments