Skip to content

Commit

Permalink
Start adding new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cgero-eth committed Mar 13, 2024
1 parent 005e04e commit 4b68af2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react';
import { useState } from 'react';
import { AddressInput, type IAddressInputProps, type IAddressInputValue } from './addressInput';
import { AddressInput, type IAddressInputProps, type IAddressInputResolvedValue } from './addressInput';

const meta: Meta<typeof AddressInput> = {
title: 'Modules/Components/Address/AddressInput',
Expand All @@ -18,7 +18,7 @@ type Story = StoryObj<typeof AddressInput>;

const ControlledComponent = (props: IAddressInputProps) => {
const [value, setValue] = useState<string>();
const [addressValue, setAddressValue] = useState<IAddressInputValue>();
const [addressValue, setAddressValue] = useState<IAddressInputResolvedValue>();

const stringAddressValue =
addressValue != null ? `{ address: ${addressValue.address}, name: ${addressValue.name} }` : 'undefined';
Expand Down
20 changes: 18 additions & 2 deletions src/modules/components/address/addressInput/addressInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ describe('<AddressInput /> component', () => {

beforeEach(() => {
getChecksumMock.mockImplementation((value) => value as Address);
useEnsAddressMock.mockReturnValue({ data: undefined, isFetching: false } as UseEnsAddressReturnType);
useEnsNameMock.mockReturnValue({ data: undefined, isFetching: false } as UseEnsNameReturnType);
useEnsAddressMock.mockReturnValue({
data: undefined,
isFetching: false,
queryKey: ['', {}],
} as unknown as UseEnsAddressReturnType);
useEnsNameMock.mockReturnValue({
data: undefined,
isFetching: false,
queryKey: ['', {}],
} as unknown as UseEnsNameReturnType);
});

afterEach(() => {
Expand Down Expand Up @@ -125,4 +133,12 @@ describe('<AddressInput /> component', () => {
render(createTestComponent());
expect(screen.getByTestId('member-avatar-mock')).toBeInTheDocument();
});

it('displays a ENS button to display the ENS value linked to the address input when address has ENS linked', () => {
const ensValue = 'vitalik.eth';
const value = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
useEnsNameMock.mockReturnValue({ data: ensValue, isFetching: false } as UseEnsNameReturnType);
render(createTestComponent({ value }));
// TODO
});
});

0 comments on commit 4b68af2

Please sign in to comment.