From 5f178b12e7034065ffc9d4d631049cd0ff67c88e Mon Sep 17 00:00:00 2001
From: Awais Ansari
Date: Mon, 16 Sep 2024 19:25:14 +0500
Subject: [PATCH] refactor: combined test cases
---
src/profile/ProfilePage.test.jsx | 26 ++++---------------
.../__snapshots__/ProfilePage.test.jsx.snap | 22 ++++++++--------
2 files changed, 16 insertions(+), 32 deletions(-)
diff --git a/src/profile/ProfilePage.test.jsx b/src/profile/ProfilePage.test.jsx
index ae1152a4a..e347ba8c5 100644
--- a/src/profile/ProfilePage.test.jsx
+++ b/src/profile/ProfilePage.test.jsx
@@ -286,31 +286,15 @@ describe('', () => {
expect(container.querySelector('.alert-danger')).toHaveClass('show');
});
- it('test user with non disabled country', () => {
+ it.each([
+ ['test user with non-disabled country', 'PK'],
+ ['test user with disabled country', 'RU'],
+ ])('test user with %s', (_, accountCountry) => {
const storeData = JSON.parse(JSON.stringify(storeMocks.savingEditedBio));
storeData.profilePage.errors.country = {};
storeData.profilePage.currentlyEditingField = 'country';
storeData.profilePage.disabledCountries = ['RU'];
- const contextValue = {
- authenticatedUser: { userId: 123, username: 'staff', administrator: true },
- config: getConfig(),
- };
- const component = (
-
- );
- const { container: tree } = render(component);
- expect(tree).toMatchSnapshot();
- });
-
- it('test user with disabled country', () => {
- const storeData = JSON.parse(JSON.stringify(storeMocks.savingEditedBio));
- storeData.profilePage.errors.country = {};
- storeData.profilePage.currentlyEditingField = 'country';
- storeData.profilePage.disabledCountries = ['RU'];
- storeData.profilePage.account.country = 'RU';
+ storeData.profilePage.account.country = accountCountry;
const contextValue = {
authenticatedUser: { userId: 123, username: 'staff', administrator: true },
config: getConfig(),
diff --git a/src/profile/__snapshots__/ProfilePage.test.jsx.snap b/src/profile/__snapshots__/ProfilePage.test.jsx.snap
index 5e26ad9dc..9648f34b7 100644
--- a/src/profile/__snapshots__/ProfilePage.test.jsx.snap
+++ b/src/profile/__snapshots__/ProfilePage.test.jsx.snap
@@ -2178,7 +2178,7 @@ exports[` Renders correctly in various states test country edit w
class="small mb-2"
>
Completed on
- 3/4/2019
+ 3/5/2019
Renders correctly in various states test education edit
class="small mb-2"
>
Completed on
- 3/4/2019
+ 3/5/2019
Renders correctly in various states test preferreded la
class="small mb-2"
>
Completed on
- 3/4/2019
+ 3/5/2019
Renders correctly in various states test preferreded la
`;
-exports[`
Renders correctly in various states test user with disabled country 1`] = `
+exports[`
Renders correctly in various states test user with test user with disabled country 1`] = `
Renders correctly in various states test user with disa
class="small mb-2"
>
Completed on
- 3/4/2019
+ 3/5/2019
Renders correctly in various states test user with disa
`;
-exports[`
Renders correctly in various states test user with non disabled country 1`] = `
+exports[`
Renders correctly in various states test user with test user with non-disabled country 1`] = `
Renders correctly in various states test user with non
class="small mb-2"
>
Completed on
- 3/4/2019
+ 3/5/2019
Renders correctly in various states viewing own profile
class="small mb-2"
>
Completed on
- 3/4/2019
+ 3/5/2019
Renders correctly in various states while saving an edi
class="small mb-2"
>
Completed on
- 3/4/2019
+ 3/5/2019
Renders correctly in various states while saving an edi
class="small mb-2"
>
Completed on
- 3/4/2019
+ 3/5/2019
Renders correctly in various states without credentials
class="small mb-2"
>
Completed on
- 3/4/2019
+ 3/5/2019