forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from amina-deriv/amina/feature/90115/update_ju…
…risdiction Amina/feature/90115/update jurisdiction
- Loading branch information
Showing
76 changed files
with
72,067 additions
and
26,452 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
packages/account/src/Sections/Security/Passwords/__tests__/deriv-password.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import React from 'react'; | ||
import { render, screen, waitFor, fireEvent } from '@testing-library/react'; | ||
import DerivPassword from '../deriv-password'; | ||
import { WS } from '@deriv/shared'; | ||
|
||
jest.mock('Assets/ic-brand-deriv-red.svg', () => () => 'BrandDerivRed'); | ||
|
||
jest.mock('@deriv/shared', () => ({ | ||
...jest.requireActual('@deriv/shared'), | ||
WS: { | ||
verifyEmail: jest.fn(), | ||
}, | ||
})); | ||
|
||
describe('<DerivPassword />', () => { | ||
let mock_props = { | ||
email: 'mf@deriv.com', | ||
is_social_signup: false, | ||
social_identity_provider: undefined, | ||
landing_company_shortcode: 'maltainvest', | ||
}; | ||
|
||
let modal_root_el; | ||
|
||
beforeAll(() => { | ||
modal_root_el = document.createElement('div'); | ||
modal_root_el.setAttribute('id', 'modal_root'); | ||
document.body.appendChild(modal_root_el); | ||
}); | ||
|
||
afterAll(() => { | ||
document.body.removeChild(modal_root_el); | ||
}); | ||
it('Should render properly', async () => { | ||
render(<DerivPassword {...mock_props} />); | ||
expect( | ||
screen.getByRole('heading', { | ||
name: /deriv password/i, | ||
}) | ||
).toBeInTheDocument(); | ||
// expect BrandDerivRed not to be in the document | ||
expect(screen.queryByText(/BrandDerivRed/i)).toBeInTheDocument(); | ||
// expect button with text change password to be in the document | ||
expect(screen.getByRole('button', { name: /change password/i })).toBeInTheDocument(); | ||
// expect button with text unlink from to not be in the document | ||
expect(screen.queryByText(/unlink from/i)).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('displays the correct platform information for non-MF clients', () => { | ||
render(<DerivPassword {...mock_props} landing_company_shortcode='svg' />); | ||
const popover_wrapper = screen.getAllByTestId('dt_popover_wrapper'); | ||
// expect popover to have length of 4 | ||
expect(popover_wrapper).toHaveLength(4); | ||
// expect button with text change password to be in the document | ||
expect(screen.getByRole('button', { name: /change password/i })).toBeInTheDocument(); | ||
}); | ||
|
||
it('displays the correct platform information for MF clients', () => { | ||
render(<DerivPassword {...mock_props} />); | ||
const popover_wrapper = screen.getAllByTestId('dt_popover_wrapper'); | ||
// expect popover to have length of 4 | ||
expect(popover_wrapper).toHaveLength(1); | ||
// expect button with text change password to be in the document | ||
expect(screen.getByRole('button', { name: /change password/i })).toBeInTheDocument(); | ||
}); | ||
|
||
it('displays a change password button for non-social signups', () => { | ||
render(<DerivPassword {...mock_props} />); | ||
const change_password_button = screen.getByRole('button', { | ||
name: /change password/i, | ||
}); | ||
expect(change_password_button).toBeInTheDocument(); | ||
}); | ||
|
||
it('should invoke verifyEmail when change password is clicked', async () => { | ||
render(<DerivPassword {...mock_props} />); | ||
const ele_change_btn = screen.getByRole('button', { | ||
name: /change password/i, | ||
}); | ||
fireEvent.click(ele_change_btn); | ||
expect(screen.queryByText(/we’ve sent you an email/i)).toBeInTheDocument(); | ||
expect(screen.getByText(/please click on the link in the email to reset your password\./i)).toBeInTheDocument(); | ||
await waitFor(() => { | ||
expect(WS.verifyEmail).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
it('displays a button to unlink social identity provider', async () => { | ||
const social_props = { | ||
...mock_props, | ||
is_social_signup: true, | ||
social_identity_provider: 'apple', | ||
}; | ||
render(<DerivPassword {...social_props} />); | ||
const unlink_button = screen.getByText(/unlink from/i); | ||
expect(unlink_button).toBeInTheDocument(); | ||
fireEvent.click(unlink_button); | ||
|
||
await waitFor(() => { | ||
expect(WS.verifyEmail).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
} | ||
&--deposit-button { | ||
cursor: not-allowed; | ||
pointer-events: none; | ||
&-blurry { | ||
opacity: 0.2; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
&--active, | ||
&--blurry { | ||
cursor: not-allowed; | ||
pointer-events: none; | ||
} | ||
&--blurry { | ||
opacity: 0.2; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.