Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sajid Alam <[email protected]>
  • Loading branch information
SajidAlamQB committed Jul 17, 2024
1 parent 1f22e33 commit 41137d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 5 additions & 9 deletions package/tests/test_api/test_rest/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ def test_get_package_compatibilities(


def test_update_preferences_success(client, mocker):
mocker.patch("kedro_viz.api.rest.responses.DataNodeMetadata.set_is_all_previews_enabled")
response = client.post(
"api/preferences",
json={"showDatasetPreviews": True}
mocker.patch(
"kedro_viz.api.rest.responses.DataNodeMetadata.set_is_all_previews_enabled"
)
response = client.post("api/preferences", json={"showDatasetPreviews": True})

assert response.status_code == 200
assert response.json() == {"message": "Preferences updated successfully"}
Expand All @@ -102,12 +101,9 @@ def test_update_preferences_success(client, mocker):
def test_update_preferences_failure(client, mocker):
mocker.patch(
"kedro_viz.api.rest.responses.DataNodeMetadata.set_is_all_previews_enabled",
side_effect=Exception("Test Exception")
)
response = client.post(
"api/preferences",
json={"showDatasetPreviews": True}
side_effect=Exception("Test Exception"),
)
response = client.post("api/preferences", json={"showDatasetPreviews": True})

assert response.status_code == 500
assert response.json() == {"detail": "Failed to update preferences"}
6 changes: 6 additions & 0 deletions src/components/settings-modal/settings-modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,11 @@ describe('SettingsModal', () => {
type: 'TOGGLE_IS_PRETTY_NAME',
isPrettyName: false,
});

mapDispatchToProps(dispatch).onToggleShowDatasetPreviews(false);
expect(dispatch.mock.calls[3][0]).toEqual({
type: 'TOGGLE_SHOW_DATASET_PREVIEWS',
showDatasetPreviews: false,
});
});
});

0 comments on commit 41137d9

Please sign in to comment.