Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao committed Mar 11, 2024
1 parent 06919b2 commit 8c56788
Show file tree
Hide file tree
Showing 118 changed files with 1,703 additions and 3,227 deletions.
1 change: 0 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"postpack": "clean-package restore"
},
"dependencies": {
"@interlay/coin-icons": "workspace:*",
"@interlay/hooks": "workspace:*",
"@interlay/icons": "workspace:*",
"@interlay/system": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import * as React from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Accordion, AccordionItem } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Alert/__tests__/Alert.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Alert } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { BreadcrumbItem, Breadcrumbs } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Button } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@testing-library/react';
import { render } from '@interlay/test-utils';

import { CSSReset } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/CTA/__tests__/CTA.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { render, testA11y } from '@interlay/test-utils';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';

import { CTA } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Card/__tests__/Card.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';
import { createRef } from 'react';

import { Card } from '..';
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Dialog/__tests__/Dialog.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { render, testA11y } from '@interlay/test-utils';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';

import { Dialog, DialogBody, DialogFooter, DialogHeader } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Divider/__tests__/Divider.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { render, testA11y } from '@interlay/test-utils';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';

import { Divider } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Drawer/__tests__/Drawer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { render, testA11y } from '@interlay/test-utils';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';

import { Drawer } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Field/__tests__/Field.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { render, testA11y } from '@interlay/test-utils';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';

import { Field } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Flex/__tests__/Flex.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Flex } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { HelperText } from '..';

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/Input/__tests__/Input.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { blur, focus, testA11y } from '@interlay/test-utils';
import { render, screen, waitFor } from '@testing-library/react';
import { blur, focus, testA11y, render } from '@interlay/test-utils';
import { screen, waitFor } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { createRef, useState } from 'react';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Label/__tests__/Label.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Label } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/List/__tests__/List.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { List, ListItem } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Meter/__tests__/Meter.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Meter } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Modal/__tests__/Modal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Modal, ModalBody, ModalFooter, ModalHeader } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { blur, focus, testA11y } from '@interlay/test-utils';
import { render, screen, waitFor } from '@testing-library/react';
import { blur, focus, testA11y, render } from '@interlay/test-utils';
import { screen, waitFor } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { createRef, useState } from 'react';

Expand Down
5 changes: 2 additions & 3 deletions packages/components/src/Overlay/__tests__/Overlay.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import React, { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { render, testA11y } from '@interlay/test-utils';
import { createRef } from 'react';

import { Overlay } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Overlay/__tests__/Underlay.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { render, testA11y } from '@interlay/test-utils';

import { Underlay } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Popover/__tests__/Popover.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { render, testA11y } from '@interlay/test-utils';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';

import { Popover, PopoverBody, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { ProgressBar } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { ProgressCircle } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Radio/__tests__/Radio.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { RadioGroup } from '../RadioGroup';
import { Radio } from '../Radio';
Expand Down
9 changes: 6 additions & 3 deletions packages/components/src/Select/Select.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ const StyledTriggerValue = styled(Span)<StyledTriggerValueProps>`
font-weight: inherit;
`;

const StyledList = styled(List)`
overflow: auto;
padding: 0 12px 12px;
const StyledList: any = styled(List)`
${({ theme }) => theme.tokenInput.list.base};
> :last-child {
margin-bottom: ${({ theme }) => theme.spacing('lg')};
}
`;

const StyledChevronDown = styled(ChevronDown)`
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Select/__tests__/Select.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';
import { createRef } from 'react';

import { Select, Item } from '..';
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Slider/__tests__/Slider.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';
import { createRef } from 'react';

import { Slider } from '..';
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Spinner/__tests__/Spinner.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Spinner } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Stack/__tests__/Stack.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Stack } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Switch/__tests__/Switch.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Switch } from '..';

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/Table/__tests__/Table.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { testA11y } from '@interlay/test-utils';
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { testA11y, render } from '@interlay/test-utils';
import { fireEvent, screen, waitFor, within } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { createRef } from 'react';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Tabs/__tests__/Tabs.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { Tabs, TabsItem } from '..';

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Text/__tests__/Text.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from '@testing-library/react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';
import { createRef } from 'react';

import { H1 } from '..';
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/TextArea/__tests__/TextArea.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { blur, focus, testA11y } from '@interlay/test-utils';
import { render, screen, waitFor } from '@testing-library/react';
import { render, blur, focus, testA11y } from '@interlay/test-utils';
import { screen, waitFor } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { createRef, useState } from 'react';

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/TextLink/__tests__/TextLink.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react';
import { screen } from '@testing-library/react';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';
import { testA11y, render } from '@interlay/test-utils';

import { TextLink } from '..';

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/TokenInput/BaseTokenInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const BaseTokenInput = forwardRef<HTMLInputElement, BaseTokenInputProps>(
<StyledGroupInputWrapper>
<StyledNumberInputWrapper>
<StyledBaseInput
ref={ref}
ref={inputRef}
$adornmentBottom={!!bottomAdornment}
$hasError={error}
$size={size}
Expand Down
14 changes: 7 additions & 7 deletions packages/components/src/TokenInput/__tests__/TokenInput.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { blur, testA11y } from '@interlay/test-utils';
import { render, screen, waitFor, waitForElementToBeRemoved, within } from '@testing-library/react';
import { blur, testA11y, render } from '@interlay/test-utils';
import { screen, waitFor, waitForElementToBeRemoved, within } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { Key, createRef, useState } from 'react';

Expand All @@ -26,7 +26,7 @@ describe('TokenInput', () => {
it('should render with placeholder', () => {
render(<TokenInput label='label' logoUrl='' ticker='BTC' />);

expect(screen.getByPlaceholderText('0')).toBeInTheDocument();
expect(screen.getByPlaceholderText('0.00')).toBeInTheDocument();
});

it('should render with usd value', () => {
Expand Down Expand Up @@ -73,13 +73,13 @@ describe('TokenInput', () => {
it('should render', () => {
render(<TokenInput balance={10} label='label' logoUrl='' ticker='BTC' />);

expect(screen.getByRole('definition')).toHaveTextContent('10');
expect(screen.getByRole('button')).toHaveTextContent('10');
});

it('should render human value', () => {
render(<TokenInput balance={10} humanBalance={11} label='label' logoUrl='' ticker='BTC' />);

expect(screen.getByRole('definition')).toHaveTextContent('11');
expect(screen.getByRole('button')).toHaveTextContent('11');
});

it('should update input when applying max', async () => {
Expand Down Expand Up @@ -176,13 +176,13 @@ describe('TokenInput', () => {
it('should render with ticker adornment', () => {
render(<TokenInput label='label' logoUrl='' ticker='BTC' />);

expect(screen.getAllByText(/btc/i)).toHaveLength(2);
expect(screen.getByText(/btc/i)).toBeInTheDocument();
});

it('should render with unknown ticker', () => {
render(<TokenInput label='label' logoUrl='' ticker='ABC' />);

expect(screen.getAllByText(/abc/i)).toHaveLength(2);
expect(screen.getByText(/abc/i)).toBeInTheDocument();
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Meta, StoryObj } from '@storybook/react';
import { useState } from 'react';

import * as coins from '../../../../icons/coin/src';
import { TokenInput, TokenInputProps } from '..';

export default {
Expand All @@ -10,9 +9,6 @@ export default {
parameters: {
layout: 'centered'
},
argTypes: {
ticker: { control: 'select', options: Object.keys(coins) }
},
args: {
ticker: 'ETH',
logoUrl: 'https://ethereum-optimism.github.io/data/ETH/logo.svg',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Meta, StoryObj } from '@storybook/react';
import { useState } from 'react';
import { mergeProps } from '@react-aria/utils';

import * as coins from '../../../../icons/coin/src';
import { TokenInput, TokenInputProps } from '..';

const items = [
Expand All @@ -22,9 +21,6 @@ export default {
parameters: {
layout: 'centered'
},
argTypes: {
ticker: { control: 'select', options: Object.keys(coins) }
},
args: {
type: 'selectable',
label: 'Amount',
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/Tooltip/__tests__/Tooltip.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react';
import { render, testA11y } from '@interlay/test-utils';
import { createRef } from 'react';
import { testA11y } from '@interlay/test-utils';

import { Tooltip } from '..';

Expand Down
Loading

0 comments on commit 8c56788

Please sign in to comment.