@@ -8,7 +8,6 @@ import { AGG_MODE, VERIFY_MODE } from 'src/const/Connect'
88import { initialState as configInitialState } from 'src/redux/reducers/configSlice'
99
1010// Setup Mocks
11- const setShowSupport = vitest . fn ( )
1211export const dispatch = vitest . fn ( )
1312vitest . mock ( 'react-redux' , async ( importActual ) => {
1413 const actual = ( await importActual ( ) ) as object
@@ -36,17 +35,19 @@ const aggregationPreloadedState = {
3635
3736// Test Component to utilize the hook
3837const TestComponent = ( { errorCode } : { errorCode : number } ) => {
39- const errorDetails = useActionableErrorMap ( errorCode , setShowSupport )
38+ const errorDetails = useActionableErrorMap ( errorCode )
4039
4140 return (
4241 < div >
4342 < h1 > { errorDetails . title } </ h1 >
4443 < button onClick = { errorDetails . primaryAction . action } >
4544 { errorDetails . primaryAction . label }
4645 </ button >
47- < button onClick = { errorDetails . secondaryActions . action } >
48- { errorDetails . secondaryActions . label }
49- </ button >
46+ { errorDetails . secondaryActions && (
47+ < button onClick = { errorDetails . secondaryActions . action } >
48+ { errorDetails . secondaryActions . label }
49+ </ button >
50+ ) }
5051 </ div >
5152 )
5253}
@@ -83,19 +84,15 @@ describe('useActionableErrorMap', () => {
8384 } )
8485 expect ( screen . getByText ( 'No accounts found' ) ) . toBeInTheDocument ( )
8586 expect ( screen . getByText ( 'Return to institution selection' ) ) . toBeInTheDocument ( )
86- expect ( screen . getByText ( 'Get help' ) ) . toBeInTheDocument ( )
87+ expect ( screen . queryByText ( 'Get help' ) ) . not . toBeInTheDocument ( )
8788
8889 const primaryButton = screen . getByText ( 'Return to institution selection' )
89- const secondaryButton = screen . getByText ( 'Get help' )
9090
9191 primaryButton . click ( )
9292 expect ( dispatch ) . toHaveBeenCalledWith ( {
9393 type : ActionTypes . ACTIONABLE_ERROR_CONNECT_DIFFERENT_INSTITUTION ,
9494 payload : AGG_MODE ,
9595 } )
96-
97- secondaryButton . click ( )
98- expect ( setShowSupport ) . toHaveBeenCalledTimes ( 1 )
9996 } )
10097
10198 it ( 'should return correct mapping and actions for ACCESS_DENIED' , ( ) => {
@@ -104,18 +101,14 @@ describe('useActionableErrorMap', () => {
104101 } )
105102 expect ( screen . getByText ( 'Additional permissions needed' ) ) . toBeInTheDocument ( )
106103 expect ( screen . getByText ( 'Review instructions' ) ) . toBeInTheDocument ( )
107- expect ( screen . getByText ( 'Get help' ) ) . toBeInTheDocument ( )
104+ expect ( screen . queryByText ( 'Get help' ) ) . not . toBeInTheDocument ( )
108105
109106 const primaryButton = screen . getByText ( 'Review instructions' )
110- const secondaryButton = screen . getByText ( 'Get help' )
111107
112108 primaryButton . click ( )
113109 expect ( dispatch ) . toHaveBeenCalledWith ( {
114110 type : ActionTypes . ACTIONABLE_ERROR_LOG_IN_AGAIN ,
115111 } )
116-
117- secondaryButton . click ( )
118- expect ( setShowSupport ) . toHaveBeenCalledTimes ( 1 )
119112 } )
120113
121114 it ( 'should return correct mapping and actions for INSTITUTION_DOWN' , ( ) => {
@@ -124,19 +117,15 @@ describe('useActionableErrorMap', () => {
124117 } )
125118 expect ( screen . getByText ( 'Unable to connect' ) ) . toBeInTheDocument ( )
126119 expect ( screen . getByText ( 'Return to institution selection' ) ) . toBeInTheDocument ( )
127- expect ( screen . getByText ( 'Get help' ) ) . toBeInTheDocument ( )
120+ expect ( screen . queryByText ( 'Get help' ) ) . not . toBeInTheDocument ( )
128121
129122 const primaryButton = screen . getByText ( 'Return to institution selection' )
130- const secondaryButton = screen . getByText ( 'Get help' )
131123
132124 primaryButton . click ( )
133125 expect ( dispatch ) . toHaveBeenCalledWith ( {
134126 type : ActionTypes . ACTIONABLE_ERROR_CONNECT_DIFFERENT_INSTITUTION ,
135127 payload : AGG_MODE ,
136128 } )
137-
138- secondaryButton . click ( )
139- expect ( setShowSupport ) . toHaveBeenCalledTimes ( 1 )
140129 } )
141130
142131 it ( 'should return correct mapping and actions for INSTITUTION_MAINTENANCE' , ( ) => {
@@ -145,19 +134,15 @@ describe('useActionableErrorMap', () => {
145134 } )
146135 expect ( screen . getByText ( 'Maintenance in progress' ) ) . toBeInTheDocument ( )
147136 expect ( screen . getByText ( 'Return to institution selection' ) ) . toBeInTheDocument ( )
148- expect ( screen . getByText ( 'Get help' ) ) . toBeInTheDocument ( )
137+ expect ( screen . queryByText ( 'Get help' ) ) . not . toBeInTheDocument ( )
149138
150139 const primaryButton = screen . getByText ( 'Return to institution selection' )
151- const secondaryButton = screen . getByText ( 'Get help' )
152140
153141 primaryButton . click ( )
154142 expect ( dispatch ) . toHaveBeenCalledWith ( {
155143 type : ActionTypes . ACTIONABLE_ERROR_CONNECT_DIFFERENT_INSTITUTION ,
156144 payload : AGG_MODE ,
157145 } )
158-
159- secondaryButton . click ( )
160- expect ( setShowSupport ) . toHaveBeenCalledTimes ( 1 )
161146 } )
162147
163148 it ( 'should return correct mapping and actions for INSTITUTION_UNAVAILABLE' , ( ) => {
@@ -166,18 +151,14 @@ describe('useActionableErrorMap', () => {
166151 } )
167152 expect ( screen . getByText ( 'Unable to connect' ) ) . toBeInTheDocument ( )
168153 expect ( screen . getByText ( 'Return to institution selection' ) ) . toBeInTheDocument ( )
169- expect ( screen . getByText ( 'Get help' ) ) . toBeInTheDocument ( )
154+ expect ( screen . queryByText ( 'Get help' ) ) . not . toBeInTheDocument ( )
170155
171156 const primaryButton = screen . getByText ( 'Return to institution selection' )
172- const secondaryButton = screen . getByText ( 'Get help' )
173157
174158 primaryButton . click ( )
175159 expect ( dispatch ) . toHaveBeenCalledWith ( {
176160 type : ActionTypes . ACTIONABLE_ERROR_CONNECT_DIFFERENT_INSTITUTION ,
177161 payload : AGG_MODE ,
178162 } )
179-
180- secondaryButton . click ( )
181- expect ( setShowSupport ) . toHaveBeenCalledTimes ( 1 )
182163 } )
183164} )
0 commit comments