11/*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' ) ) ;
1011
1112/*global describe,it,expect,afterEach */
1213describe ( 'react-draggable' , function ( ) {
@@ -45,7 +46,7 @@ describe('react-draggable', function () {
4546 expect ( node . getAttribute ( 'style' ) ) . toMatch ( 'touch-action: none' ) ;
4647 }
4748 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\\\)' ) ;
4950 expect ( node . getAttribute ( 'class' ) ) . toEqual ( 'foo react-draggable' ) ;
5051 } ) ;
5152
@@ -61,7 +62,7 @@ describe('react-draggable', function () {
6162 < div
6263 className = "react-draggable"
6364 style = { {
64- [ browserPrefix + 'Transform' ] : 'translate(0px, 0px)'
65+ [ transformKey ] : 'translate(0px, 0px)'
6566 } }
6667 transform = { null } />
6768 </ DraggableCore >
@@ -267,8 +268,7 @@ describe('react-draggable', function () {
267268 } ) ;
268269
269270 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;` ;
272272
273273 drag = TestUtils . renderIntoDocument (
274274 < Draggable >
@@ -280,14 +280,12 @@ describe('react-draggable', function () {
280280
281281 expect ( document . body . getAttribute ( 'style' ) ) . toEqual ( '' ) ;
282282 TestUtils . Simulate . mouseDown ( node , { clientX : 0 , clientY : 0 } ) ;
283- expect ( document . body . getAttribute ( 'style' ) ) . toEqual ( userSelectStyle ) ;
283+ expect ( document . body . getAttribute ( 'style' ) ) . toEqual ( userSelectStyleStr ) ;
284284 TestUtils . Simulate . mouseUp ( node ) ;
285285 expect ( document . body . getAttribute ( 'style' ) ) . toEqual ( '' ) ;
286286 } ) ;
287287
288288 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;' ;
291289
292290 drag = TestUtils . renderIntoDocument (
293291 < Draggable enableUserSelectHack = { false } >
0 commit comments