File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ describe('SharedButton Component', () => {
2323 describe ( 'Renders' , ( ) => {
2424
2525 let wrapper ;
26+ let mockFunc ;
2627 beforeEach ( ( ) => {
28+ mockFunc = jest . fn ( ) ;
2729 const props = {
2830 buttonText : 'Example Button Text' ,
29- emitEvent : ( ) => {
30-
31- }
31+ emitEvent : mockFunc
3232 } ;
3333 wrapper = shallow ( < SharedButton { ...props } /> ) ;
3434 } ) ;
@@ -38,6 +38,13 @@ describe('SharedButton Component', () => {
3838 expect ( button . length ) . toBe ( 1 ) ;
3939 } ) ;
4040
41+ it ( 'Should emit callback on click event' , ( ) => {
42+ const button = findByTestAtrr ( wrapper , 'buttonComponent' ) ;
43+ button . simulate ( 'click' ) ;
44+ const callback = mockFunc . mock . calls . length ;
45+ expect ( callback ) . toBe ( 1 ) ;
46+ } ) ;
47+
4148
4249 } ) ;
4350
You can’t perform that action at this time.
0 commit comments