Skip to content

Commit

Permalink
Merge pull request binary-com#5 from suisin-deriv/update_api_token_te…
Browse files Browse the repository at this point in the history
…st_case_based_on_comments

chore: update branch based on comments
  • Loading branch information
utkarsha-deriv committed Sep 7, 2023
2 parents 5dd89d8 + 3808e97 commit 1ea2bf3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('ApiTokenClipboard', () => {
const mock_props = {
scopes: ['read', 'trade', 'Admin'],
text_copy: 'Text Copy',
info_message: 'Info Message',
info_message: 'Copy this token',
success_message: 'Success Message',
};

Expand All @@ -24,16 +24,16 @@ describe('ApiTokenClipboard', () => {
render(<ApiTokenClipboard {...mock_props} />);
const copy_icon = screen.getByTestId('dt_copy_token_icon');
userEvent.hover(copy_icon);
expect(screen.getByText('Info Message')).toBeInTheDocument();
expect(screen.getByText('Copy this token')).toBeInTheDocument();
});

it('should remove "Copy this token" message when mouse leaves', () => {
render(<ApiTokenClipboard {...mock_props} />);
const copy_icon = screen.getByTestId('dt_copy_token_icon');
userEvent.hover(copy_icon);
expect(screen.getByText('Info Message')).toBeInTheDocument();
expect(screen.getByText('Copy this token')).toBeInTheDocument();
userEvent.unhover(copy_icon);
expect(screen.queryByText('Info Message')).not.toBeInTheDocument();
expect(screen.queryByText('Copy this token')).not.toBeInTheDocument();
});

it('should display Popup Modal when user clicks on copy_icon', () => {
Expand All @@ -51,7 +51,7 @@ describe('ApiTokenClipboard', () => {
expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument();
});

it('should display Info Message when user clicks on OK', async () => {
it('should remove Popup modal when user clicks on OK', async () => {
render(<ApiTokenClipboard {...mock_props} />);
const copy_icon = screen.getByTestId('dt_copy_token_icon');
userEvent.click(copy_icon);
Expand All @@ -61,7 +61,6 @@ describe('ApiTokenClipboard', () => {
await waitFor(() => {
expect(screen.queryByText('Add accounts')).not.toBeInTheDocument();
});
expect(screen.getByText('Info Message')).toBeInTheDocument();
});

it('should not display Popup Modal when user clicks on copy_icon with no Admin scope', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('ApiTokenDeleteButton', () => {
expect(screen.getByText('Delete this token')).toBeInTheDocument();
});

it('should not Delete this token when mouse leave', () => {
it('should not display Delete this token when mouse leave', () => {
renderAPIDeleteButton();
const delete_icon = screen.getByTestId('dt_token_delete_icon');
userEvent.hover(delete_icon);
Expand Down Expand Up @@ -85,15 +85,13 @@ describe('ApiTokenDeleteButton', () => {
expect(screen.queryByRole('button', { name: 'Yes, delete' })).not.toBeInTheDocument();
});

it('should should trigger deleteToken when clicked on Yes, delete', async () => {
it('should should trigger deleteToken when clicked on Yes, delete', () => {
renderAPIDeleteButton();
const delete_icon = screen.getByTestId('dt_token_delete_icon');
userEvent.click(delete_icon);
expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument();
const delete_token_button = screen.getByRole('button', { name: 'Yes, delete' });
act(() => {
userEvent.click(delete_token_button);
});
userEvent.click(delete_token_button);
expect(mock_props.deleteToken).toBeCalled();
});
});

0 comments on commit 1ea2bf3

Please sign in to comment.