File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ import * as React from 'react'
22import renderProps from './renderProps'
33
44const isElement = element => typeof element . type === 'function'
5- const name = element =>
6- ( isElement ( element ) ? element . type . name : element . name ) . toLowerCase ( )
75
86const compose = ( ...elements ) => {
97 return composedProps => {
@@ -31,7 +29,7 @@ const compose = (...elements) => {
3129 return elementFn ( element , { } , renderFn )
3230 }
3331
34- return stackProps ( elements . length - 1 , elements )
32+ return stackProps ( elements . length - 1 , elements . reverse ( ) )
3533 }
3634}
3735
Original file line number Diff line number Diff line change @@ -3,7 +3,21 @@ import TestRenderer from 'react-test-renderer'
33import { Compose , Counter , Toggle } from '../../src'
44
55test ( '<Compose />' , ( ) => {
6- const renderFn = jest . fn ( ) . mockReturnValue ( null )
6+ let lastCallProps = null
7+ const renderFn = ( ...props ) => {
8+ lastCallProps = props
9+ return null
10+ }
11+
712 TestRenderer . create ( < Compose states = { [ Counter , Toggle ] } render = { renderFn } /> )
8- // TODO
13+
14+ expect ( lastCallProps [ 0 ] . count ) . toBe ( 0 )
15+ expect ( lastCallProps [ 1 ] . on ) . toBe ( false )
16+
17+ lastCallProps [ 0 ] . inc ( )
18+ lastCallProps [ 0 ] . incBy ( 3 )
19+ lastCallProps [ 1 ] . toggle ( )
20+
21+ expect ( lastCallProps [ 0 ] . count ) . toBe ( 4 )
22+ expect ( lastCallProps [ 1 ] . on ) . toBe ( true )
923} )
You can’t perform that action at this time.
0 commit comments