1
- import { ReactTestRendererJSON } from 'react-test-renderer' ;
2
1
import { defaultMapProps } from '../format-default' ;
3
2
4
- const node : ReactTestRendererJSON = {
5
- type : 'View' ,
6
- props : { } ,
7
- children : null ,
8
- } ;
9
-
10
3
describe ( 'mapPropsForQueryError' , ( ) => {
11
4
test ( 'preserves props that are helpful for debugging' , ( ) => {
12
5
const props = {
@@ -32,89 +25,79 @@ describe('mapPropsForQueryError', () => {
32
25
defaultValue : 'DEFAULT_VALUE' ,
33
26
} ;
34
27
35
- const result = defaultMapProps ( props , node ) ;
28
+ const result = defaultMapProps ( props ) ;
36
29
expect ( result ) . toStrictEqual ( props ) ;
37
30
} ) ;
38
31
39
32
test ( 'does not preserve less helpful props' , ( ) => {
40
- const result = defaultMapProps (
41
- {
42
- style : [ { flex : 1 } , { display : 'flex' } ] ,
43
- onPress : ( ) => null ,
44
- key : 'foo' ,
45
- } ,
46
- node
47
- ) ;
33
+ const result = defaultMapProps ( {
34
+ style : [ { flex : 1 } , { flexDirection : 'row' } ] ,
35
+ onPress : ( ) => null ,
36
+ key : 'foo' ,
37
+ } ) ;
48
38
49
39
expect ( result ) . toStrictEqual ( { } ) ;
50
40
} ) ;
51
41
52
- test ( 'preserves "display: none" style but no other style' , ( ) => {
53
- const result = defaultMapProps (
54
- { style : [ { flex : 1 } , { display : 'none' , flex : 2 } ] } ,
55
- node
56
- ) ;
42
+ test ( 'preserves "display: none" and "opacity: 0" styles but no other style' , ( ) => {
43
+ const result = defaultMapProps ( {
44
+ style : [ { flex : 1 } , { display : 'none' , flex : 2 } , { opacity : 0 } ] ,
45
+ } ) ;
57
46
58
47
expect ( result ) . toStrictEqual ( {
59
- style : { display : 'none' } ,
48
+ style : { display : 'none' , opacity : 0 } ,
60
49
} ) ;
61
50
} ) ;
62
51
63
52
test ( 'removes undefined keys from accessibilityState' , ( ) => {
64
- const result = defaultMapProps (
65
- { accessibilityState : { checked : undefined , selected : false } } ,
66
- node
67
- ) ;
53
+ const result = defaultMapProps ( {
54
+ accessibilityState : { checked : undefined , selected : false } ,
55
+ } ) ;
68
56
69
57
expect ( result ) . toStrictEqual ( {
70
58
accessibilityState : { selected : false } ,
71
59
} ) ;
72
60
} ) ;
73
61
74
62
test ( 'removes accessibilityState if all keys are undefined' , ( ) => {
75
- const result = defaultMapProps (
76
- { accessibilityState : { checked : undefined , selected : undefined } } ,
77
- node
78
- ) ;
63
+ const result = defaultMapProps ( {
64
+ accessibilityState : { checked : undefined , selected : undefined } ,
65
+ } ) ;
79
66
80
67
expect ( result ) . toStrictEqual ( { } ) ;
81
68
} ) ;
82
69
83
70
test ( 'does not fail if accessibilityState is a string, passes through' , ( ) => {
84
- const result = defaultMapProps ( { accessibilityState : 'foo' } , node ) ;
71
+ const result = defaultMapProps ( { accessibilityState : 'foo' } ) ;
85
72
expect ( result ) . toStrictEqual ( { accessibilityState : 'foo' } ) ;
86
73
} ) ;
87
74
88
75
test ( 'does not fail if accessibilityState is an array, passes through' , ( ) => {
89
- const result = defaultMapProps ( { accessibilityState : [ 1 ] } , node ) ;
76
+ const result = defaultMapProps ( { accessibilityState : [ 1 ] } ) ;
90
77
expect ( result ) . toStrictEqual ( { accessibilityState : [ 1 ] } ) ;
91
78
} ) ;
92
79
93
80
test ( 'does not fail if accessibilityState is null, passes through' , ( ) => {
94
- const result = defaultMapProps ( { accessibilityState : null } , node ) ;
81
+ const result = defaultMapProps ( { accessibilityState : null } ) ;
95
82
expect ( result ) . toStrictEqual ( { accessibilityState : null } ) ;
96
83
} ) ;
97
84
98
85
test ( 'does not fail if accessibilityState is nested object, passes through' , ( ) => {
99
86
const accessibilityState = { 1 : { 2 : 3 } , 2 : undefined } ;
100
- const result = defaultMapProps ( { accessibilityState } , node ) ;
87
+ const result = defaultMapProps ( { accessibilityState } ) ;
101
88
expect ( result ) . toStrictEqual ( { accessibilityState : { 1 : { 2 : 3 } } } ) ;
102
89
} ) ;
103
90
104
91
test ( 'removes undefined keys from accessibilityValue' , ( ) => {
105
- const result = defaultMapProps (
106
- { accessibilityValue : { min : 1 , max : undefined } } ,
107
- node
108
- ) ;
92
+ const result = defaultMapProps ( {
93
+ accessibilityValue : { min : 1 , max : undefined } ,
94
+ } ) ;
109
95
110
96
expect ( result ) . toStrictEqual ( { accessibilityValue : { min : 1 } } ) ;
111
97
} ) ;
112
98
113
99
test ( 'removes accessibilityValue if all keys are undefined' , ( ) => {
114
- const result = defaultMapProps (
115
- { accessibilityValue : { min : undefined } } ,
116
- node
117
- ) ;
100
+ const result = defaultMapProps ( { accessibilityValue : { min : undefined } } ) ;
118
101
119
102
expect ( result ) . toStrictEqual ( { } ) ;
120
103
} ) ;
0 commit comments