Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added country disabling feature #1084

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = {};
awais-ansari marked this conversation as resolved.
Show resolved Hide resolved
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', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use it.each since most of the code is the same, and we are only checking whether the country is disabled or not.

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