Skip to content

Commit 1eb8ce4

Browse files
Test changes
1 parent 090beb4 commit 1eb8ce4

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

Diff for: desktop/core/src/desktop/js/apps/admin/Overview/OverviewTab.test.tsx

+24-15
Original file line numberDiff line numberDiff line change
@@ -108,29 +108,38 @@ describe('OverviewTab', () => {
108108
{ id: 'pig', name: 'Pig Editor' }
109109
];
110110

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 () => {
115115
(post as jest.Mock).mockResolvedValue(resolvedValue);
116116
render(<Examples />);
117117

118-
const appIdOrOldName = appData.old_name || appData.id;
119-
const url = `/${appIdOrOldName}/install_examples`;
120-
const expectedData = appData.data ? { data: appData.data } : null;
121-
122118
const button = screen.getByText(appData.name);
123119
fireEvent.click(button);
124120

125121
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+
}
130140
});
131-
132141
(post as jest.Mock).mockClear();
133-
}
134-
);
142+
});
143+
});
135144
});
136145
});

0 commit comments

Comments
 (0)