1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/ui/components/app/terms-of-use-popup/terms-of-use-popup.test.js
vthomas13 40e4a3653f
Updating Terms of Use, Adding popover and onboarding flow check (#18221)
* WIP commit

* Moving copy out of messages.json, styling changes

* handling scroll button click and disable logic

* moving scrollButton up to popover component, adding logic for accepting terms of use in popover and onboarding flows

* adding terms of use to e2e wallet creation/import

* adjusting failing unit test

* fixing QR code e2e

* updating welcome test

* setting app state in fixtures

* Update app/scripts/controllers/app-state.js

removing console log

Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>

* Update ui/components/app/terms-of-use-popup/terms-of-use-popup.stories.js

adding args to ToU popup storybook

Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>

* Update ui/components/app/terms-of-use-popup/terms-of-use-popup.js

Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>

* updating DS components in terms of use

* popover styling changes

* adding metametrics tracking

* editing scrollbutton behavior

* adding unit test

* code fencing

---------

Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>
2023-04-14 12:51:13 -04:00

49 lines
1.4 KiB
JavaScript

import React from 'react';
import { fireEvent, screen } from '@testing-library/react';
import { renderWithProvider } from '../../../../test/jest';
import configureStore from '../../../store/store';
import mockState from '../../../../test/data/mock-state.json';
import TermsOfUsePopup from './terms-of-use-popup';
const render = () => {
const store = configureStore({
metamask: {
...mockState.metamask,
},
});
const onAccept = jest.fn();
return renderWithProvider(<TermsOfUsePopup onAccept={onAccept} />, store);
};
describe('TermsOfUsePopup', () => {
beforeEach(() => {
const mockIntersectionObserver = jest.fn();
mockIntersectionObserver.mockReturnValue({
observe: () => null,
unobserve: () => null,
disconnect: () => null,
});
window.IntersectionObserver = mockIntersectionObserver;
});
it('renders TermsOfUse component and shows Terms of Use text', () => {
render();
expect(
screen.getByText('Our Terms of Use have updated'),
).toBeInTheDocument();
});
it('scrolls down when handleScrollDownClick is called', () => {
render();
const mockScrollIntoView = jest.fn();
window.HTMLElement.prototype.scrollIntoView = mockScrollIntoView;
const button = document.querySelector(
"[data-testid='popover-scroll-button']",
);
fireEvent.click(button);
expect(mockScrollIntoView).toHaveBeenCalledWith({
behavior: 'smooth',
});
});
});