-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
186 changed files
with
4,634 additions
and
6,127 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": ["next/core-web-vitals", "prettier"], | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": "off" | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1,10 @@ | ||
{} | ||
{ | ||
"semi": true, | ||
"trailingComma": "es5", | ||
"singleQuote": true, | ||
"printWidth": 100, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"bracketSpacing": true, | ||
"arrowParens": "avoid" | ||
} |
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 |
---|---|---|
@@ -1,3 +1,14 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
}, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"[typescriptreact]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"eslint.validate": ["typescript", "typescriptreact"] | ||
} |
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
92 changes: 33 additions & 59 deletions
92
components/admins/components/__tests__/stakingParams.test.tsx
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
62 changes: 29 additions & 33 deletions
62
components/admins/components/__tests__/validatorList.test.tsx
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 |
---|---|---|
@@ -1,65 +1,61 @@ | ||
import { afterEach, describe, expect, test } from "bun:test"; | ||
import React from "react"; | ||
import ValidatorList from "@/components/admins/components/validatorList"; | ||
import { fireEvent, screen, cleanup, waitFor } from "@testing-library/react"; | ||
import matchers from "@testing-library/jest-dom/matchers"; | ||
import { mockActiveValidators, mockPendingValidators } from "@/tests/mock"; | ||
import { renderWithChainProvider } from "@/tests/render"; | ||
import { afterEach, describe, expect, test } from 'bun:test'; | ||
import React from 'react'; | ||
import ValidatorList from '@/components/admins/components/validatorList'; | ||
import { fireEvent, screen, cleanup, waitFor } from '@testing-library/react'; | ||
import matchers from '@testing-library/jest-dom/matchers'; | ||
import { mockActiveValidators, mockPendingValidators } from '@/tests/mock'; | ||
import { renderWithChainProvider } from '@/tests/render'; | ||
|
||
expect.extend(matchers); | ||
|
||
const renderWithProps = (props = {}) => { | ||
const defaultProps = { | ||
admin: "admin1", | ||
admin: 'admin1', | ||
activeValidators: mockActiveValidators, | ||
pendingValidators: mockPendingValidators, | ||
isLoading: false, | ||
}; | ||
return renderWithChainProvider( | ||
<ValidatorList {...defaultProps} {...props} />, | ||
); | ||
return renderWithChainProvider(<ValidatorList {...defaultProps} {...props} />); | ||
}; | ||
|
||
describe("ValidatorList", () => { | ||
describe('ValidatorList', () => { | ||
afterEach(cleanup); | ||
|
||
test("renders correctly", () => { | ||
test('renders correctly', () => { | ||
renderWithProps(); | ||
expect(screen.getByText("Active Validators")).toBeInTheDocument(); | ||
expect(screen.getByText("Validator One")).toBeInTheDocument(); | ||
expect(screen.getByText("Validator Two")).toBeInTheDocument(); | ||
expect(screen.getByText('Active Validators')).toBeInTheDocument(); | ||
expect(screen.getByText('Validator One')).toBeInTheDocument(); | ||
expect(screen.getByText('Validator Two')).toBeInTheDocument(); | ||
}); | ||
|
||
test("search functionality works", () => { | ||
test('search functionality works', () => { | ||
renderWithProps(); | ||
fireEvent.change(screen.getByPlaceholderText("Search for a validator..."), { | ||
target: { value: "Validator One" }, | ||
fireEvent.change(screen.getByPlaceholderText('Search for a validator...'), { | ||
target: { value: 'Validator One' }, | ||
}); | ||
expect(screen.getByText("Validator One")).toBeInTheDocument(); | ||
expect(screen.queryByText("Validator Two")).not.toBeInTheDocument(); | ||
expect(screen.getByText('Validator One')).toBeInTheDocument(); | ||
expect(screen.queryByText('Validator Two')).not.toBeInTheDocument(); | ||
}); | ||
|
||
test("active/pending toggle works", () => { | ||
test('active/pending toggle works', () => { | ||
renderWithProps(); | ||
fireEvent.click(screen.getByText("Pending")); | ||
expect(screen.getByText("Pending Validators")).toBeInTheDocument(); | ||
expect(screen.getByText("Validator Three")).toBeInTheDocument(); | ||
fireEvent.click(screen.getByText('Pending')); | ||
expect(screen.getByText('Pending Validators')).toBeInTheDocument(); | ||
expect(screen.getByText('Validator Three')).toBeInTheDocument(); | ||
}); | ||
|
||
test("clicking on a validator row opens the modal", async () => { | ||
test('clicking on a validator row opens the modal', async () => { | ||
renderWithProps(); | ||
fireEvent.click(screen.getByText("Validator One")); | ||
await waitFor(() => expect(screen.getByRole("dialog")).toBeInTheDocument()); | ||
fireEvent.click(screen.getByText('Validator One')); | ||
await waitFor(() => expect(screen.getByRole('dialog')).toBeInTheDocument()); | ||
}); | ||
|
||
test("remove button works and shows the warning modal", async () => { | ||
test('remove button works and shows the warning modal', async () => { | ||
renderWithProps(); | ||
const allRemoveButtons = screen.getAllByText("Remove"); | ||
const allRemoveButtons = screen.getAllByText('Remove'); | ||
fireEvent.click(allRemoveButtons[0]); | ||
await waitFor(() => | ||
expect( | ||
screen.getByText("Are you sure you want to remove the validator"), | ||
).toBeInTheDocument(), | ||
expect(screen.getByText('Are you sure you want to remove the validator')).toBeInTheDocument() | ||
); | ||
}); | ||
}); |
Oops, something went wrong.