@@ -11,7 +11,7 @@ describe('src/index', () => {
1111 expect ( wrapper . find ( '.or-input' ) . length ) . toBe ( 1 )
1212 expect ( wrapper . find ( '.or-input input' ) . prop ( 'placeholder' ) ) . toBe ( '' )
1313 expect ( wrapper . find ( '.or-input input' ) . prop ( 'value' ) ) . toBe ( '' )
14- expect ( wrapper . find ( '.or-input .or-clear-icon' ) . length ) . toBe ( 1 )
14+ expect ( wrapper . find ( '.or-input .or-clear-icon' ) . length ) . toBe ( 0 )
1515 } )
1616
1717 it ( 'should render basicly #placeholder' , ( ) => {
@@ -28,8 +28,17 @@ describe('src/index', () => {
2828 wrapper = mount ( < RenderInput /> )
2929 const input = wrapper . find ( '.or-input input' )
3030 input . simulate ( 'change' , { target : { value : 'Changed' } } )
31-
3231 expect ( wrapper . find ( '.or-input input' ) . prop ( 'value' ) ) . toBe ( 'Changed' )
32+ expect ( wrapper . find ( '.or-input .or-clear-icon' ) . length ) . toBe ( 2 )
33+ } )
34+ } )
35+
36+ describe ( 'simulate clear input events' , ( ) => {
37+ let wrapper
38+ it ( 'onchange event' , ( ) => {
39+ wrapper = mount ( < RenderInput value = "Dan" /> )
40+ expect ( wrapper . find ( '.or-input input' ) . prop ( 'value' ) ) . toBe ( 'Dan' )
41+ expect ( wrapper . find ( '.or-input .or-clear-icon' ) . length ) . toBe ( 2 )
3342 } )
3443 } )
3544} )
@@ -38,11 +47,12 @@ interface Props {
3847 numericInput ?: boolean
3948 maxlength ?: number
4049 placeholder ?: string
50+ value ?: string
4151}
4252
4353class RenderInput extends React . Component < Props , { } > {
4454 state = {
45- name : ''
55+ name : this . props . value || ''
4656 }
4757
4858 render ( ) {
0 commit comments