@@ -87,6 +87,53 @@ describe('Conversion', function () {
87
87
setTimeout ( check , 150 ) ;
88
88
} ) ;
89
89
90
+
91
+ it ( 'respects handler set on react component' , ( done ) => {
92
+ let onPressCalled = 0 ;
93
+ function main ( sources : { react : ReactSource } ) {
94
+ const inc = Symbol ( ) ;
95
+ const inc$ = sources . react . select ( inc ) . events ( 'press' ) ;
96
+ const count$ = inc$ . fold ( ( acc : number , x : any ) => acc + 1 , 0 ) ;
97
+ const vdom$ = count$ . map ( ( i : number ) =>
98
+ h (
99
+ Touchable ,
100
+ {
101
+ sel : inc ,
102
+ onPress : ( ) => {
103
+ onPressCalled ++ ;
104
+ } ,
105
+ } ,
106
+ [ h ( 'div' , [ h ( 'h1' , { } , '' + i ) ] ) ]
107
+ )
108
+ ) ;
109
+ return { react : vdom$ } ;
110
+ }
111
+
112
+ let turn = 0 ;
113
+ const RootComponent = makeCycleReactComponent ( ( ) => {
114
+ const source = new ReactSource ( ) ;
115
+ const sink = main ( { react : source } ) . react ;
116
+ return { source, sink} ;
117
+ } ) ;
118
+ const r = renderer . create ( createElement ( RootComponent ) ) ;
119
+ const root = r . root ;
120
+ const check = ( ) => {
121
+ const to = root . findByType ( Touchable ) ;
122
+ const view = to . props . children ;
123
+ const text = view . props . children ;
124
+ assert . strictEqual ( text . props . children , `${ turn } ` ) ;
125
+ to . instance . press ( ) ;
126
+ turn ++ ;
127
+ if ( turn === 3 ) {
128
+ assert . strictEqual ( onPressCalled , 3 )
129
+ done ( ) ;
130
+ }
131
+ } ;
132
+ setTimeout ( check , 50 ) ;
133
+ setTimeout ( check , 100 ) ;
134
+ setTimeout ( check , 150 ) ;
135
+ } ) ;
136
+
90
137
it ( 'output React component routes props to sources.react.props()' , ( done ) => {
91
138
function main ( sources : { react : ReactSource } ) {
92
139
sources . react . props ( ) . addListener ( {
0 commit comments