Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions packages/gamut/src/Form/__tests__/SelectDropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '@codecademy/gamut-icons';
import { setupRtl } from '@codecademy/gamut-tests';
import { fireEvent, queryByAttribute } from '@testing-library/dom';
import { waitFor } from '@testing-library/react';
import { act } from 'react';

import { SelectDropdown } from '../SelectDropdown';
Expand Down Expand Up @@ -74,11 +73,6 @@ const openDropdown = async (view: ReturnType<typeof renderView>['view']) => {
});
};

const getById = queryByAttribute.bind(null, 'id');

const getMenuList = (view: ReturnType<typeof renderView>['view']) =>
getById(view.container, /listbox/)?.firstChild;

describe('SelectDropdown', () => {
it('sets the id prop on the select tag', () => {
const { view } = renderView();
Expand Down Expand Up @@ -112,30 +106,22 @@ describe('SelectDropdown', () => {
view.getByTitle('Arrow Chevron Down Icon');
});

// TO-DO: Fix these tests

it.skip('renders a dropdown with the correct maxHeight when shownOptionsLimit is specified', async () => {
it('renders a dropdown with the correct maxHeight when shownOptionsLimit is specified', async () => {
const { view } = renderView({ shownOptionsLimit: 4 });

await openDropdown(view);

const menuList = getMenuList(view);

expect(menuList).toHaveStyle('');
expect(view.getByRole('listbox')).toHaveStyle({ maxHeight: '12rem' });
});

// TO-DO: Fix these test
it.skip('renders a dropdown with the correct maxHeight when shownOptionsLimit is specified + size is "small"', async () => {
it('renders a dropdown with the correct maxHeight when shownOptionsLimit is specified + size is "small"', async () => {
const { view } = renderView({
size: 'small',
shownOptionsLimit: 4,
});

await openDropdown(view);

const menuList = getMenuList(view);

expect(menuList).toHaveStyle({ maxHeight: '8rem' });
expect(view.getByRole('listbox')).toHaveStyle({ maxHeight: '8rem' });
});

it('renders a dropdown with icons', async () => {
Expand All @@ -157,17 +143,17 @@ describe('SelectDropdown', () => {
expect(onInputChange).toHaveBeenCalled();
});

it.skip('renders selected & multiple items when passed multiple: true', async () => {
it('renders selected & multiple items when passed multiple: true', async () => {
const { view } = renderView({ multiple: true });

const numSelectedItems = 2;

const multiple = selectOptions.map(async (opt) => {
await openDropdown(view);

await waitFor(() => view.getByText(opt));
const option = await view.findByText(opt);
await act(() => {
fireEvent.click(view.getByText(opt));
fireEvent.click(option);
return Promise.resolve();
});
});
Expand Down
Loading