Skip to content

Commit

Permalink
refactor: combined test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
awais-ansari committed Sep 16, 2024
1 parent 0197581 commit 5f178b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
26 changes: 5 additions & 21 deletions src/profile/ProfilePage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,31 +286,15 @@ describe('<ProfilePage />', () => {
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 = (
<ProfilePageWrapper
contextValue={contextValue}
store={mockStore(storeData)}
/>
);
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(),
Expand Down
22 changes: 11 additions & 11 deletions src/profile/__snapshots__/ProfilePage.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ exports[`<ProfilePage /> Renders correctly in various states test country edit w
class="small mb-2"
>
Completed on
3/4/2019
3/5/2019
</p>
<div>
<a
Expand Down Expand Up @@ -3177,7 +3177,7 @@ exports[`<ProfilePage /> Renders correctly in various states test education edit
class="small mb-2"
>
Completed on
3/4/2019
3/5/2019
</p>
<div>
<a
Expand Down Expand Up @@ -5051,7 +5051,7 @@ exports[`<ProfilePage /> Renders correctly in various states test preferreded la
class="small mb-2"
>
Completed on
3/4/2019
3/5/2019
</p>
<div>
<a
Expand Down Expand Up @@ -5107,7 +5107,7 @@ exports[`<ProfilePage /> Renders correctly in various states test preferreded la
</div>
`;

exports[`<ProfilePage /> Renders correctly in various states test user with disabled country 1`] = `
exports[`<ProfilePage /> Renders correctly in various states test user with test user with disabled country 1`] = `
<div>
<div
class="profile-page"
Expand Down Expand Up @@ -7169,7 +7169,7 @@ exports[`<ProfilePage /> Renders correctly in various states test user with disa
class="small mb-2"
>
Completed on
3/4/2019
3/5/2019
</p>
<div>
<a
Expand Down Expand Up @@ -7225,7 +7225,7 @@ exports[`<ProfilePage /> Renders correctly in various states test user with disa
</div>
`;

exports[`<ProfilePage /> Renders correctly in various states test user with non disabled country 1`] = `
exports[`<ProfilePage /> Renders correctly in various states test user with test user with non-disabled country 1`] = `
<div>
<div
class="profile-page"
Expand Down Expand Up @@ -9281,7 +9281,7 @@ exports[`<ProfilePage /> Renders correctly in various states test user with non
class="small mb-2"
>
Completed on
3/4/2019
3/5/2019
</p>
<div>
<a
Expand Down Expand Up @@ -10563,7 +10563,7 @@ exports[`<ProfilePage /> Renders correctly in various states viewing own profile
class="small mb-2"
>
Completed on
3/4/2019
3/5/2019
</p>
<div>
<a
Expand Down Expand Up @@ -11504,7 +11504,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
class="small mb-2"
>
Completed on
3/4/2019
3/5/2019
</p>
<div>
<a
Expand Down Expand Up @@ -12453,7 +12453,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
class="small mb-2"
>
Completed on
3/4/2019
3/5/2019
</p>
<div>
<a
Expand Down Expand Up @@ -13250,7 +13250,7 @@ exports[`<ProfilePage /> Renders correctly in various states without credentials
class="small mb-2"
>
Completed on
3/4/2019
3/5/2019
</p>
<div>
<a
Expand Down

0 comments on commit 5f178b1

Please sign in to comment.