1
1
import transformCss , { getStylesForProperty } from '..'
2
2
3
3
it ( 'transforms numbers' , ( ) => {
4
- expect ( transformCss ( [ [ 'zIndex ' , '0' ] ] ) ) . toEqual ( { zIndex : 0 } )
4
+ expect ( transformCss ( [ [ 'z-index ' , '0' ] ] ) ) . toEqual ( { zIndex : 0 } )
5
5
} )
6
6
7
7
it ( 'warns if missing units on unspecialized transform' , ( ) => {
@@ -28,6 +28,30 @@ it('does not warn for unitless 0 length on unspecialized transform', () => {
28
28
consoleSpy . mockRestore ( )
29
29
} )
30
30
31
+ it ( 'warns if adding etraneous units on unspecialized transform' , ( ) => {
32
+ const consoleSpy = jest
33
+ . spyOn ( global . console , 'warn' )
34
+ . mockImplementation ( ( ) => {
35
+ // Silence the warning from the test output
36
+ } )
37
+
38
+ transformCss ( [ [ 'opacity' , '1px' ] ] )
39
+ expect ( consoleSpy ) . toHaveBeenCalledWith (
40
+ 'Expected style "opacity: 1px" to be unitless'
41
+ )
42
+
43
+ consoleSpy . mockRestore ( )
44
+ } )
45
+
46
+ it ( 'does not warn for unitless 0 length on unitless transform' , ( ) => {
47
+ const consoleSpy = jest . spyOn ( global . console , 'warn' )
48
+
49
+ transformCss ( [ [ 'opacity' , '0' ] ] )
50
+ expect ( consoleSpy ) . not . toHaveBeenCalled ( )
51
+
52
+ consoleSpy . mockRestore ( )
53
+ } )
54
+
31
55
it ( 'allows pixels in unspecialized transform' , ( ) => {
32
56
expect ( transformCss ( [ [ 'top' , '0px' ] ] ) ) . toEqual ( { top : 0 } )
33
57
} )
0 commit comments