Skip to content

Commit

Permalink
fix: failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
chanceaclark committed Nov 6, 2019
1 parent eb2492d commit 67d32a6
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions packages/big-design/src/components/Dropdown/spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,17 @@ test('does not forward styles', () => {
expect(getByRole('listbox')).not.toHaveStyle('background: red');
});

test('dropdown component renders items with tooltip (when item disabled)', () => {
test('renders tooltip with disabled item', () => {
const tooltipContent = 'Option with tooltip';
const tooltipText = 'This is tooltip message';
const { getByRole, getByText } = render(
<Dropdown
onClick={onClick}
options={[
{ content: 'Option 1', type: 'string', value: '0' },
{
content: 'Option with tooltip',
tooltip: { message: 'This is tooltip message' },
content: tooltipContent,
tooltip: tooltipText,
disabled: true,
type: 'string',
},
Expand All @@ -297,7 +299,33 @@ test('dropdown component renders items with tooltip (when item disabled)', () =>
const trigger = getByRole('button');

fireEvent.click(trigger);
fireEvent.mouseEnter(getByText('Option with tooltip'));
fireEvent.mouseEnter(getByText(tooltipContent));

expect(getByText('This is tooltip message')).toBeInTheDocument();
expect(getByText(tooltipText)).toBeInTheDocument();
});

test("doesn't render tooltip on enabled item", () => {
const tooltipContent = 'Option with tooltip';
const tooltipText = 'This is tooltip message';
const { getByRole, getByText, queryByText } = render(
<Dropdown
onClick={onClick}
options={[
{ content: 'Option 1', type: 'string', value: '0' },
{
content: tooltipContent,
tooltip: tooltipText,
type: 'string',
},
{ content: 'Option 3', type: 'string', value: '2', actionType: 'destructive' },
]}
trigger={<Button>Button</Button>}
/>,
);
const trigger = getByRole('button');

fireEvent.click(trigger);
fireEvent.mouseEnter(getByText(tooltipContent));

expect(queryByText(tooltipText)).not.toBeInTheDocument();
});

0 comments on commit 67d32a6

Please sign in to comment.