File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1818 "clean" : " rimraf dist" ,
1919 "typecheck:flow" : " flow check --max-warnings=0" ,
2020 "lint" : " eslint src" ,
21- "test:only" : " npm run build:code && jest" ,
21+ "test:only" : " jest" ,
2222 "test:umd" : " jest --setupTestFrameworkScriptFile ./tests/jestUMDSetup.js" ,
2323 "test:cjs" : " jest --setupTestFrameworkScriptFile ./tests/jestCJSSetup.js" ,
2424 "test" : " npm run build && npm run lint && jest && npm run test:umd && npm run test:cjs" ,
Original file line number Diff line number Diff line change 11import * as React from 'react'
22import TestRenderer from 'react-test-renderer'
33import { Focus } from '../../src'
4+ import { last } from './utils'
45
56test ( '<Focus />' , ( ) => {
67 const renderFn = jest . fn ( ) . mockReturnValue ( null )
78 TestRenderer . create ( < Focus render = { renderFn } /> )
8- // TODO
9+ const lastCalled = ( ) => last ( renderFn . mock . calls ) [ 0 ]
10+
11+ expect ( renderFn ) . toHaveBeenCalledTimes ( 1 )
12+ expect ( lastCalled ( ) . isFocused ) . toEqual ( false )
13+
14+ lastCalled ( ) . bind . onFocus ( )
15+ expect ( renderFn ) . toHaveBeenCalledTimes ( 2 )
16+ expect ( lastCalled ( ) . isFocused ) . toEqual ( true )
17+
18+ lastCalled ( ) . bind . onBlur ( )
19+ expect ( lastCalled ( ) . isFocused ) . toEqual ( false )
20+ } )
21+
22+ test ( '<Focus onChange />' , ( ) => {
23+ const renderFn = jest . fn ( ) . mockReturnValue ( null )
24+ const onChangeFn = jest . fn ( )
25+ const lastCalled = ( ) => last ( renderFn . mock . calls ) [ 0 ]
26+ TestRenderer . create ( < Focus onChange = { onChangeFn } render = { renderFn } /> )
27+
28+ expect ( onChangeFn ) . toHaveBeenCalledTimes ( 0 )
29+
30+ lastCalled ( ) . bind . onFocus ( )
31+ expect ( onChangeFn ) . toHaveBeenCalledTimes ( 1 )
32+ expect ( onChangeFn ) . lastCalledWith ( { isFocused : true } )
933} )
You can’t perform that action at this time.
0 commit comments