Skip to content

Commit 5ee0010

Browse files
refactored out AdminPage components
1 parent 326fc85 commit 5ee0010

File tree

17 files changed

+953
-870
lines changed

17 files changed

+953
-870
lines changed

__tests__/Admin/AdminModal.test.js renamed to __tests__/AdminPage/AdminModal.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import React from 'react';
55
import { render, screen } from '../../test-utils';
6-
import AdminModal from '../../components/Admin/AdminModal';
6+
import AdminModal from '../../components/AdminPage/AdminModal';
77
import InitialState from '../../store/Store/InitialState';
88
import { waitFor } from '@testing-library/react';
99
import Constants from '../../test-utils/constant';

__tests__/Admin/AdminPage.test.js renamed to __tests__/AdminPage/AdminPage.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import React from 'react';
55
import { render, screen } from '../../test-utils';
6-
import AdminPage from '../../components/Admin/AdminPage';
6+
import AdminPage from '../../components/AdminPage/AdminPage';
77
import InitialState from '../../store/Store/InitialState';
88
import { waitFor } from '@testing-library/react';
99
import Constants from '../../test-utils/constant';
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @jest-environment jsdom
3+
*/
4+
import React from 'react';
5+
import { render, screen } from '../../test-utils';
6+
import SetBudgetAdminPage from '../../components/AdminPage/SetBudgetAdminPage';
7+
import InitialState from '../../store/Store/InitialState';
8+
import Constants from '../../test-utils/constant';
9+
import userEvent from '@testing-library/user-event';
10+
import MockOpenQClient from '../../services/ethers/MockOpenQClient';
11+
describe('SetBudgetAdminPage', () => {
12+
const bounty = Constants.bounty;
13+
beforeEach(() => {
14+
InitialState.openQClient.reset();
15+
const observe = jest.fn();
16+
const disconnect = jest.fn();
17+
window.IntersectionObserver = jest.fn(() => ({
18+
observe,
19+
disconnect,
20+
}));
21+
});
22+
it('should allow user to update budget', async () => {
23+
// ARRANGE
24+
const user = userEvent.setup();
25+
const setFundingGoal = jest.fn();
26+
const customInitialState = {
27+
...InitialState,
28+
openQClient: new MockOpenQClient({ setFundingGoal }),
29+
};
30+
render(<SetBudgetAdminPage refreshBounty={() => {}} bounty={bounty} />, {}, customInitialState);
31+
expect(screen.getByText('Set a New Budget for this Contract')).toBeInTheDocument();
32+
await user.type(screen.getByRole('textbox'), '100');
33+
await user.click(screen.getByRole('button', { name: 'Set New Budget' }));
34+
expect(screen.getByText(/Updating Budget.../)).toBeInTheDocument();
35+
expect(screen.getByText(/our request is being processed.../)).toBeInTheDocument();
36+
expect(await screen.findByText(/updated/i)).toBeInTheDocument();
37+
expect(await screen.findByText(/budget set to/i)).toBeInTheDocument();
38+
expect(await screen.findByText(/100.0 MATIC/)).toBeInTheDocument();
39+
expect(setFundingGoal).toBeCalledWith(bounty.bountyId, '100');
40+
});
41+
});

__tests__/lib/getBigNumberVol.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// test getBigNumberVol function from lib
2+
import { getBigNumberVol } from '../../services/utils/lib';
3+
describe('getBigNumberVol', () => {
4+
it('should return 1', () => {
5+
const volume = '1';
6+
const token = {
7+
decimals: 18,
8+
};
9+
const result = getBigNumberVol(volume, token);
10+
expect(result.toLocaleString('fullwide', { useGrouping: false })).toBe('1000000000000000000');
11+
});
12+
it('should return 0 when given .', () => {
13+
const volume = '.';
14+
const token = {
15+
decimals: 18,
16+
};
17+
const result = getBigNumberVol(volume, token);
18+
expect(result.toLocaleString('fullwide', { useGrouping: false })).toBe('0');
19+
});
20+
});

0 commit comments

Comments
 (0)