Skip to content

Commit

Permalink
feat: added country disabling feature (#1084)
Browse files Browse the repository at this point in the history
* feat: added country disabling feature

* fix: lint errors

* test: added test case for disabled countries

* refactor: combined test cases
  • Loading branch information
awais-ansari authored Sep 17, 2024
1 parent b13fc58 commit 87d6a0f
Show file tree
Hide file tree
Showing 6 changed files with 4,296 additions and 5 deletions.
23 changes: 23 additions & 0 deletions src/profile/ProfilePage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,29 @@ describe('<ProfilePage />', () => {

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

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'];
storeData.profilePage.account.country = accountCountry;
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 87d6a0f

Please sign in to comment.