Skip to content

Commit

Permalink
test: added test case for disabled countries
Browse files Browse the repository at this point in the history
  • Loading branch information
awais-ansari committed Sep 14, 2024
1 parent 24f8d26 commit 0197581
Show file tree
Hide file tree
Showing 3 changed files with 4,271 additions and 1 deletion.
39 changes: 39 additions & 0 deletions src/profile/ProfilePage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,45 @@ describe('<ProfilePage />', () => {

expect(container.querySelector('.alert-danger')).toHaveClass('show');
});

it('test user with non disabled country', () => {
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';
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();
});
});

describe('handles analytics', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/profile/__mocks__/savingEditedBio.mockStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ module.exports = {
}
],
drafts: {},
isLoadingProfile: false
isLoadingProfile: false,
disabledCountries: [],
},
router: {
location: {
Expand Down
Loading

0 comments on commit 0197581

Please sign in to comment.