1
1
/*eslint no-unused-vars:0*/
2
- var React = require ( 'react' ) ;
3
- var ReactDOM = require ( 'react-dom' ) ;
4
- var TestUtils = require ( 'react/lib/ReactTestUtils' ) ;
5
- var Draggable = require ( '../index' ) ;
6
- var DraggableCore = require ( '../index' ) . DraggableCore ;
7
- var _ = require ( 'lodash' ) ;
8
- var browserPrefix = require ( '../lib/utils/getPrefix.es6' ) . default ;
9
- var dashedBrowserPrefix = browserPrefix ? '-' + browserPrefix . toLowerCase ( ) + '-' : '' ;
2
+ import React from 'react' ;
3
+ import ReactDOM from 'react-dom' ;
4
+ import TestUtils from 'react/lib/ReactTestUtils' ;
5
+ import Draggable , { DraggableCore } from '../index' ;
6
+ import _ from 'lodash' ;
7
+ import { getPrefix , browserPrefixToKey , browserPrefixToStyle } from '../lib/utils/getPrefix' ;
8
+ const transformStyle = browserPrefixToStyle ( 'transform' , getPrefix ( 'transform' ) ) ;
9
+ const transformKey = browserPrefixToKey ( 'transform' , getPrefix ( 'transform' ) ) ;
10
+ const userSelectStyle = browserPrefixToStyle ( 'user-select' , getPrefix ( 'user-select' ) ) ;
10
11
11
12
/*global describe,it,expect,afterEach */
12
13
describe ( 'react-draggable' , function ( ) {
@@ -45,7 +46,7 @@ describe('react-draggable', function () {
45
46
expect ( node . getAttribute ( 'style' ) ) . toMatch ( 'touch-action: none' ) ;
46
47
}
47
48
expect ( node . getAttribute ( 'style' ) ) . toMatch ( 'color: black' ) ;
48
- expect ( node . getAttribute ( 'style' ) ) . toMatch ( dashedBrowserPrefix + 'transform : translate\\\(0px, 0px\\\)' ) ;
49
+ expect ( node . getAttribute ( 'style' ) ) . toMatch ( transformStyle + ': translate\\\(0px, 0px\\\)' ) ;
49
50
expect ( node . getAttribute ( 'class' ) ) . toEqual ( 'foo react-draggable' ) ;
50
51
} ) ;
51
52
@@ -61,7 +62,7 @@ describe('react-draggable', function () {
61
62
< div
62
63
className = "react-draggable"
63
64
style = { {
64
- [ browserPrefix + 'Transform' ] : 'translate(0px, 0px)'
65
+ [ transformKey ] : 'translate(0px, 0px)'
65
66
} }
66
67
transform = { null } />
67
68
</ DraggableCore >
@@ -267,8 +268,7 @@ describe('react-draggable', function () {
267
268
} ) ;
268
269
269
270
it ( 'should add and remove user-select styles' , function ( ) {
270
- // Karma runs in firefox in our tests
271
- var userSelectStyle = ';' + dashedBrowserPrefix + 'user-select: none;' ;
271
+ var userSelectStyleStr = `;${ userSelectStyle } : none;` ;
272
272
273
273
drag = TestUtils . renderIntoDocument (
274
274
< Draggable >
@@ -280,14 +280,12 @@ describe('react-draggable', function () {
280
280
281
281
expect ( document . body . getAttribute ( 'style' ) ) . toEqual ( '' ) ;
282
282
TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
283
- expect ( document . body . getAttribute ( 'style' ) ) . toEqual ( userSelectStyle ) ;
283
+ expect ( document . body . getAttribute ( 'style' ) ) . toEqual ( userSelectStyleStr ) ;
284
284
TestUtils . Simulate . mouseUp ( node ) ;
285
285
expect ( document . body . getAttribute ( 'style' ) ) . toEqual ( '' ) ;
286
286
} ) ;
287
287
288
288
it ( 'should not add and remove user-select styles when disabled' , function ( ) {
289
- // Karma runs in firefox in our tests
290
- var userSelectStyle = ';' + dashedBrowserPrefix + 'user-select: none;' ;
291
289
292
290
drag = TestUtils . renderIntoDocument (
293
291
< Draggable enableUserSelectHack = { false } >
0 commit comments