|
3 | 3 | * @jest-environment jsdom
|
4 | 4 | */
|
5 | 5 | import React from 'react';
|
6 |
| -import { render, screen } from '../../test-utils'; |
7 |
| -import nextRouter from 'next/router'; |
8 | 6 | import ConnectModal from '../../components/WalletConnect/ConnectModal';
|
9 |
| -// Test cases for full balances, empty balances, and undefined balances. |
10 |
| -const subgraphBounty = { |
11 |
| - __typename: 'Bounty', |
12 |
| - bountyAddress: '0x13f7816057de7256daf5028eaf8e79775d3a27a3', |
13 |
| - bountyId: 'I_kwDOGWnnz85I9Ahl', |
14 |
| - bountyMintTime: '1654041044', |
15 |
| - bountyClosedTime: null, |
16 |
| - status: 'OPEN', |
17 |
| - claimedTransactionHash: null, |
18 |
| - deposits: [ |
19 |
| - { |
20 |
| - __typename: 'Deposit', |
21 |
| - id: '0xd024e550ba670d71f23f336c63ed0aacda946c6836f416028ffa0888b1a4b691', |
22 |
| - refunded: false, |
23 |
| - refundTime: null, |
24 |
| - expiration: '2592000', |
25 |
| - tokenAddress: '0x5fbdb2315678afecb367f032d93f642f64180aa3', |
26 |
| - volume: '12000000000000000000', |
27 |
| - sender: { |
28 |
| - __typename: 'User', |
29 |
| - id: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', |
30 |
| - }, |
31 |
| - receiveTime: '1642021044', |
32 |
| - }, |
33 |
| - ], |
34 |
| - issuer: { |
35 |
| - __typename: 'User', |
36 |
| - id: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', |
37 |
| - }, |
38 |
| - bountyTokenBalances: [ |
39 |
| - { |
40 |
| - __typename: 'BountyFundedTokenBalance', |
41 |
| - volume: '12000000000000000000', |
42 |
| - tokenAddress: '0x5fbdb2315678afecb367f032d93f642f64180aa3', |
43 |
| - }, |
44 |
| - ], |
45 |
| -}; |
46 |
| - |
47 |
| -describe('WatchButton', () => { |
48 |
| - // Test cases for |
49 |
| - |
50 |
| - const push = jest.fn(() => { |
51 |
| - return { catch: jest.fn }; |
52 |
| - }); |
53 |
| - const closeModal = jest.fn(); |
54 |
| - |
55 |
| - beforeEach(() => { |
56 |
| - const observe = jest.fn(); |
57 |
| - const disconnect = jest.fn(); |
58 |
| - window.IntersectionObserver = jest.fn(() => ({ |
59 |
| - observe, |
60 |
| - disconnect, |
61 |
| - })); |
62 |
| - |
63 |
| - nextRouter.useRouter = jest.fn(); |
64 |
| - nextRouter.useRouter.mockImplementation(() => ({ |
65 |
| - query: { type: null }, |
66 |
| - prefetch: jest.fn(() => { |
67 |
| - return { catch: jest.fn }; |
68 |
| - }), |
69 |
| - push, |
70 |
| - })); |
71 |
| - }); |
72 |
| - |
73 |
| - it('should render watch button', async () => { |
74 |
| - // ARRANGE |
75 |
| - render(<ConnectModal bounty={subgraphBounty} closeModal={closeModal} watchingState={false} />); |
76 |
| - |
77 |
| - // ASSERT |
78 |
| - const nullish = [...screen.queryAllByRole(/null/), ...screen.queryAllByRole(/undefined/)]; |
79 |
| - expect(nullish).toHaveLength(0); |
80 |
| - }); |
81 |
| - |
82 |
| - it('should open modal and display link to profile.', async () => { |
83 |
| - // ARRANGE |
84 |
| - render(<ConnectModal closeModal={closeModal} />); |
85 |
| - |
86 |
| - const heading = screen.getByText(/Connect Wallet/i); |
87 |
| - const metamaskButton = screen.getByRole('button', { name: /Metamask/i }); |
88 |
| - const walletConnect = screen.getByRole('button', { name: /WalletConnect/i }); |
89 |
| - |
90 |
| - // ASSERT |
91 |
| - expect(heading).toBeInTheDocument(); |
92 |
| - expect(metamaskButton).toBeInTheDocument(); |
93 |
| - expect(walletConnect).toBeInTheDocument(); |
| 7 | +import ShallowRenderer from 'react-test-renderer/shallow'; |
| 8 | + |
| 9 | +describe('ConnectModal', () => { |
| 10 | + it('should render match DOM Snapshot', () => { |
| 11 | + const shallow = new ShallowRenderer(); |
| 12 | + shallow.render(<ConnectModal />); |
| 13 | + const tree = shallow.getRenderOutput(); |
| 14 | + expect(tree).toMatchSnapshot(); |
94 | 15 | });
|
95 | 16 | });
|
0 commit comments