Skip to content

Commit

Permalink
fix lint:tsc
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardBraham committed Sep 26, 2024
1 parent aa4c25b commit 4ee8ade
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 29 deletions.
5 changes: 4 additions & 1 deletion ui/components/app/assets/nfts/nft-details/nft-full-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default function NftFullImage() {
const nfts = useSelector(getNfts);
const nft = nfts.find(
({ address, tokenId }: { address: string; tokenId: string }) =>
isEqualCaseInsensitive(address, asset) && id === tokenId.toString(),
address &&
asset &&
isEqualCaseInsensitive(address, asset) &&
id === tokenId.toString(),
);

const { image, imageOriginal, name, tokenId } = nft;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ describe('AccountListMenu', () => {
jest
.spyOn(reactRouterDom, 'useHistory')
.mockImplementation()
// @ts-expect-error mocking history return
.mockReturnValue({ push: historyPushMock });
});

Expand Down
32 changes: 14 additions & 18 deletions ui/components/multichain/pages/connections/connections.test.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react';
import { Router, Route } from 'react-router-dom'; // Import Router and Route
import { createMemoryHistory } from 'history';
import { MemoryRouter, Route } from 'react-router-dom';
import mockState from '../../../../../test/data/mock-state.json';
import {
fireEvent,
renderWithProvider,
waitFor,
} from '../../../../../test/jest';
import configureStore from '../../../../store/store';
import mockState from '../../../../../test/data/mock-state.json';
import { Connections } from './connections';

describe('Connections Content', () => {
Expand Down Expand Up @@ -88,46 +87,43 @@ describe('Connections Content', () => {
});

it('should render correctly', () => {
const history = createMemoryHistory();
history.push('/connect/https%3A%2F%2Fmetamask.github.io');

const { container, getByTestId } = renderWithProvider(
<Router history={history}>
<MemoryRouter
initialEntries={['/connect/https%3A%2F%2Fmetamask.github.io']}
>
<Route path="/connect/:origin">
<Connections />
</Route>
</Router>,
</MemoryRouter>,
connectedStore,
);
expect(container).toMatchSnapshot();
expect(getByTestId('connections-page')).toBeInTheDocument();
});

it('it should render Disconnect all Account button of the page', () => {
const history = createMemoryHistory();
history.push('/connect/https%3A%2F%2Fmetamask.github.io');

const { getByText } = renderWithProvider(
<Router history={history}>
<MemoryRouter
initialEntries={['/connect/https%3A%2F%2Fmetamask.github.io']}
>
<Route path="/connect/:origin">
<Connections />
</Route>
</Router>,
</MemoryRouter>,
connectedStore,
);
expect(getByText('Disconnect all accounts')).toBeInTheDocument();
});

it('it should trigger disconnect all accounts modal flow when disconnect all accounts button is clicked', async () => {
const history = createMemoryHistory();
history.push('/connect/https%3A%2F%2Fmetamask.github.io');

const { getByText, getByTestId } = renderWithProvider(
<Router history={history}>
<MemoryRouter
initialEntries={['/connect/https%3A%2F%2Fmetamask.github.io']}
>
<Route path="/connect/:origin">
<Connections />
</Route>
</Router>,
</MemoryRouter>,
connectedStore,
);

Expand Down
7 changes: 3 additions & 4 deletions ui/components/multichain/pages/connections/connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ export const Connections = () => {
setShowDisconnectedAllAccountsUpdatedToast,
] = useState(false);

const urlParams: { origin: string } = useParams();
const securedOrigin = decodeURIComponent(urlParams.origin);
const urlParams = useParams<{ origin: string }>();
const activeTabOrigin = decodeURIComponent(urlParams.origin || '');

const activeTabOrigin: string = securedOrigin;
// TODO: Replace `any` with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const subjectMetadata: { [key: string]: any } = useSelector(
Expand Down Expand Up @@ -246,7 +245,7 @@ export const Connections = () => {
textAlign={TextAlign.Center}
ellipsis
>
{getURLHost(securedOrigin)}
{getURLHost(activeTabOrigin)}
</Text>
</Box>
</Header>
Expand Down
9 changes: 6 additions & 3 deletions ui/pages/asset/asset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ const Asset = () => {
const nfts = useSelector(getNfts);
const { asset, id } = useParams<{ asset: string; id: string }>();

const token = tokens.find(({ address }: { address: string }) =>
isEqualCaseInsensitive(address, asset),
const token = tokens.find(
({ address }: { address: string }) =>
asset && isEqualCaseInsensitive(address, asset),
);

const nft = nfts.find(
({ address, tokenId }: { address: string; tokenId: string }) =>
isEqualCaseInsensitive(address, asset) && id === tokenId.toString(),
asset &&
isEqualCaseInsensitive(address, asset) &&
id === tokenId.toString(),
);

useEffect(() => {
Expand Down
1 change: 0 additions & 1 deletion ui/pages/bridge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const CrossChainSwap = () => {
const redirectToDefaultRoute = async () => {
history.push({
pathname: DEFAULT_ROUTE,
// @ts-expect-error - property 'state' does not exist on type PartialPath.
state: { stayOnHomePage: true },
});
dispatch(clearSwapsState());
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/confirmations/confirm/stories/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function ConfirmStoryTemplate(
}`,
]}
>
<Route path="/confirmation/:id" render={() => <ConfirmPage />} />
<Route path="/confirmation/:id" element={<ConfirmPage />} />
</MemoryRouter>
</Provider>
);
Expand Down

0 comments on commit 4ee8ade

Please sign in to comment.