@@ -2858,12 +2858,30 @@ describe('shallow', () => {
28582858 } ) ;
28592859
28602860 describe ( '.exists()' , ( ) => {
2861- it ( 'should return true if node exists in wrapper' , ( ) => {
2862- const wrapper = shallow ( (
2863- < div className = "foo" />
2864- ) ) ;
2865- expect ( wrapper . find ( '.bar' ) . exists ( ) ) . to . equal ( false ) ;
2866- expect ( wrapper . find ( '.foo' ) . exists ( ) ) . to . equal ( true ) ;
2861+ it ( 'has no required arguments' , ( ) => {
2862+ expect ( ShallowWrapper . prototype . exists ) . to . have . lengthOf ( 0 ) ;
2863+ } ) ;
2864+
2865+ describe ( 'without argument' , ( ) => {
2866+ it ( 'should return true if node exists in wrapper' , ( ) => {
2867+ const wrapper = shallow ( (
2868+ < div className = "foo" />
2869+ ) ) ;
2870+ expect ( wrapper . find ( '.bar' ) . exists ( ) ) . to . equal ( false ) ;
2871+ expect ( wrapper . find ( '.foo' ) . exists ( ) ) . to . equal ( true ) ;
2872+ } ) ;
2873+ } ) ;
2874+ describe ( 'with argument' , ( ) => {
2875+ it ( 'should return .find(arg).exists() instead' , ( ) => {
2876+ const wrapper = shallow ( < div /> ) ;
2877+ const fakeFindExistsReturnVal = Symbol ( 'fake .find(arg).exists() return value' ) ;
2878+ const fakeSelector = '.someClass' ;
2879+ wrapper . find = sinon . stub ( ) . returns ( { exists : ( ) => fakeFindExistsReturnVal } ) ;
2880+ const existsResult = wrapper . exists ( fakeSelector ) ;
2881+ expect ( wrapper . find . callCount ) . to . equal ( 1 ) ;
2882+ expect ( wrapper . find . firstCall . args [ 0 ] ) . to . equal ( fakeSelector ) ;
2883+ expect ( existsResult ) . to . equal ( fakeFindExistsReturnVal ) ;
2884+ } ) ;
28672885 } ) ;
28682886 } ) ;
28692887
0 commit comments