@@ -18,8 +18,8 @@ describe('react-draggable', function () {
18
18
19
19
afterEach ( function ( ) {
20
20
try {
21
- React . unmountComponentAtNode ( React . findDOMNode ( drag ) . parentNode ) ;
22
- // TestUtils.Simulate.mouseUp (ReactDOM.findDOMNode(drag));
21
+ TestUtils . Simulate . mouseUp ( ReactDOM . findDOMNode ( drag ) ) ; // reset user-select
22
+ React . unmountComponentAtNode ( ReactDOM . findDOMNode ( drag ) . parentNode ) ;
23
23
} catch ( e ) { return ; }
24
24
} ) ;
25
25
@@ -40,9 +40,13 @@ describe('react-draggable', function () {
40
40
it ( 'should pass style and className properly from child' , function ( ) {
41
41
drag = ( < Draggable > < div className = "foo" style = { { color : 'black' } } /> </ Draggable > ) ;
42
42
43
- expect ( renderToHTML ( drag ) ) . toEqual ( '<div class="foo react-draggable" ' +
44
- 'style="touch-action:none;color:black;transform:translate(0px,0px);' + dashedBrowserPrefix +
45
- 'transform:translate(0px,0px);" data-reactid=".1"></div>' ) ;
43
+ var node = renderToNode ( drag ) ;
44
+ if ( 'touchAction' in document . body . style ) {
45
+ expect ( node . getAttribute ( 'style' ) ) . toMatch ( 'touch-action: none' ) ;
46
+ }
47
+ expect ( node . getAttribute ( 'style' ) ) . toMatch ( 'color: black' ) ;
48
+ expect ( node . getAttribute ( 'style' ) ) . toMatch ( dashedBrowserPrefix + 'transform: translate\\\(0px, 0px\\\)' ) ;
49
+ expect ( node . getAttribute ( 'class' ) ) . toEqual ( 'foo react-draggable' ) ;
46
50
} ) ;
47
51
48
52
// NOTE: this runs a shallow renderer, which DOES NOT actually render <DraggableCore>
@@ -57,14 +61,14 @@ describe('react-draggable', function () {
57
61
< div
58
62
className = "react-draggable"
59
63
style = { {
60
- 'transform' : 'translate(0px,0px)' ,
61
- [ browserPrefix + 'Transform' ] : 'translate(0px,0px)'
64
+ [ browserPrefix + 'Transform' ] : 'translate(0px, 0px)'
62
65
} }
63
66
transform = { null } />
64
67
</ DraggableCore >
65
68
) ;
69
+
66
70
// Not easy to actually test equality here. The functions are bound as static props so we can't test those easily.
67
- var toOmit = [ 'onStart' , 'onStop' , 'onDrag' ] ;
71
+ var toOmit = [ 'onStart' , 'onStop' , 'onDrag' , 'onMouseDown' , 'children' ] ;
68
72
expect ( _ . isEqual (
69
73
_ . omit ( output . props , toOmit ) ,
70
74
_ . omit ( expected . props , toOmit ) )
@@ -225,8 +229,7 @@ describe('react-draggable', function () {
225
229
226
230
var style = node . getAttribute ( 'style' ) ;
227
231
expect ( dragged ) . toEqual ( true ) ;
228
- // No idea why the spacing is different here
229
- expect ( style . indexOf ( 'transform:translate(0px,0px);' ) ) . not . toEqual ( - 1 ) ;
232
+ expect ( style . indexOf ( 'transform: translate(0px, 0px);' ) ) . not . toEqual ( - 1 ) ;
230
233
} ) ;
231
234
232
235
it ( 'should detect if an element is instanceof SVGElement and set state.isElementSVG to true' , function ( ) {
@@ -261,12 +264,11 @@ describe('react-draggable', function () {
261
264
262
265
var transform = node . getAttribute ( 'transform' ) ;
263
266
expect ( transform . indexOf ( 'translate(100,100)' ) ) . not . toEqual ( - 1 ) ;
264
-
265
267
} ) ;
266
268
267
269
it ( 'should add and remove user-select styles' , function ( ) {
268
270
// Karma runs in firefox in our tests
269
- var userSelectStyle = ';user-select: none; ' + dashedBrowserPrefix + 'user-select: none;' ;
271
+ var userSelectStyle = ';' + dashedBrowserPrefix + 'user-select: none;' ;
270
272
271
273
drag = TestUtils . renderIntoDocument (
272
274
< Draggable >
@@ -285,7 +287,7 @@ describe('react-draggable', function () {
285
287
286
288
it ( 'should not add and remove user-select styles when disabled' , function ( ) {
287
289
// Karma runs in firefox in our tests
288
- var userSelectStyle = ';user-select: none; ' + dashedBrowserPrefix + 'user-select: none;' ;
290
+ var userSelectStyle = ';' + dashedBrowserPrefix + 'user-select: none;' ;
289
291
290
292
drag = TestUtils . renderIntoDocument (
291
293
< Draggable enableUserSelectHack = { false } >
@@ -447,7 +449,11 @@ describe('react-draggable', function () {
447
449
} ) ;
448
450
449
451
function renderToHTML ( component ) {
450
- return ReactDOM . findDOMNode ( TestUtils . renderIntoDocument ( component ) ) . outerHTML ;
452
+ return renderToNode ( component ) . outerHTML ;
453
+ }
454
+
455
+ function renderToNode ( component ) {
456
+ return ReactDOM . findDOMNode ( TestUtils . renderIntoDocument ( component ) ) ;
451
457
}
452
458
453
459
// Simulate a movement; can't use TestUtils here because it uses react's event system only,
0 commit comments