File tree 1 file changed +24
-15
lines changed
desktop/core/src/desktop/js/apps/admin/Overview
1 file changed +24
-15
lines changed Original file line number Diff line number Diff line change @@ -108,29 +108,38 @@ describe('OverviewTab', () => {
108
108
{ id : 'pig' , name : 'Pig Editor' }
109
109
] ;
110
110
111
- test . each ( exampleApps ) (
112
- 'renders Examples tab and when any of the exampleApp is clicked, the API call for that particular example is executed' ,
113
- async appData => {
114
- const resolvedValue = { status : 0 , message : 'Success' } ;
111
+ const resolvedValue = { status : 0 , message : 'Success' } ;
112
+
113
+ exampleApps . forEach ( appData => {
114
+ test ( `clicking the install button for ' ${ appData . name } ' makes an API call to '/api/v1/install_app_examples'` , async ( ) => {
115
115
( post as jest . Mock ) . mockResolvedValue ( resolvedValue ) ;
116
116
render ( < Examples /> ) ;
117
117
118
- const appIdOrOldName = appData . old_name || appData . id ;
119
- const url = `/${ appIdOrOldName } /install_examples` ;
120
- const expectedData = appData . data ? { data : appData . data } : null ;
121
-
122
118
const button = screen . getByText ( appData . name ) ;
123
119
fireEvent . click ( button ) ;
124
120
125
121
await waitFor ( ( ) => {
126
- expect ( post ) . toHaveBeenCalledWith ( url , expectedData , {
127
- method : 'POST' ,
128
- silenceErrors : true
129
- } ) ;
122
+ if ( appData . data ) {
123
+ expect ( post ) . toHaveBeenCalledWith (
124
+ '/api/v1/install_app_examples' ,
125
+ {
126
+ app_name : appData . id ,
127
+ data : appData . data
128
+ } ,
129
+ expect . anything ( )
130
+ ) ;
131
+ } else {
132
+ expect ( post ) . toHaveBeenCalledWith (
133
+ '/api/v1/install_app_examples' ,
134
+ {
135
+ app_name : appData . id
136
+ } ,
137
+ expect . anything ( )
138
+ ) ;
139
+ }
130
140
} ) ;
131
-
132
141
( post as jest . Mock ) . mockClear ( ) ;
133
- }
134
- ) ;
142
+ } ) ;
143
+ } ) ;
135
144
} ) ;
136
145
} ) ;
You can’t perform that action at this time.
0 commit comments