Skip to content

Commit

Permalink
Fixed tests (deephaven#2065)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Jun 12, 2024
1 parent dd669c1 commit 0f363b9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
6 changes: 4 additions & 2 deletions packages/code-studio/src/styleguide/Inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,13 @@ function Inputs(): React.ReactElement {
<div className="form-group">
<h5>Input with Select</h5>
<div className="input-group">
<ComboBox>{items}</ComboBox>
<ComboBox aria-label="ComboBox">{items}</ComboBox>
</div>
<br />
<div className="input-group">
<ComboBox isDisabled>{items}</ComboBox>
<ComboBox aria-label="Disabled ComboBox" isDisabled>
{items}
</ComboBox>
</div>
</div>

Expand Down
28 changes: 21 additions & 7 deletions packages/jsapi-components/src/usePickerWithSelectedValues.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { act, renderHook } from '@testing-library/react-hooks';
import type { FilterCondition, Table } from '@deephaven/jsapi-types';
import type { dh as DhType } from '@deephaven/jsapi-types';
import { useComboBoxItemScale } from '@deephaven/components';
import {
createSearchTextFilter,
createSelectedValuesFilter,
Expand All @@ -21,6 +22,10 @@ jest.mock('./useFilterConditionFactories');
jest.mock('./useTableUtils');
jest.mock('./useViewportData');
jest.mock('./useViewportFilter');
jest.mock('@deephaven/components', () => ({
...jest.requireActual('@deephaven/components'),
useComboBoxItemScale: jest.fn(),
}));
jest.mock('@deephaven/jsapi-utils', () => ({
...jest.requireActual('@deephaven/jsapi-utils'),
createSearchTextFilter: jest.fn(),
Expand Down Expand Up @@ -48,8 +53,8 @@ const mock = {
typeof useDebouncedValue
>,
filter: [
createMockProxy<FilterCondition>(),
createMockProxy<FilterCondition>(),
createMockProxy<DhType.FilterCondition>(),
createMockProxy<DhType.FilterCondition>(),
],
filterConditionFactories: [jest.fn(), jest.fn()] as FilterConditionFactory[],
keyedItem: createMockProxy<KeyedItem<MockItem>>({
Expand All @@ -67,20 +72,24 @@ const mock = {
};

const mockTable = {
usersAndGroups: createMockProxy<Table>(),
list: createMockProxy<Table>(),
usersAndGroups: createMockProxy<DhType.Table>(),
list: createMockProxy<DhType.Table>(),
};

function mockUseViewportData(size: number) {
const viewportData = createMockProxy<UseViewportDataResult<MockItem, Table>>({
const viewportData = createMockProxy<
UseViewportDataResult<MockItem, DhType.Table>
>({
table: mockTable.list,
viewportData: mock.viewportData,
size,
});

asMock(useViewportData)
.mockName('useViewportData')
.mockReturnValue(viewportData as UseViewportDataResult<unknown, Table>);
.mockReturnValue(
viewportData as UseViewportDataResult<unknown, DhType.Table>
);
}

async function renderOnceAndWait(
Expand All @@ -104,6 +113,11 @@ async function renderOnceAndWait(
beforeEach(() => {
jest.clearAllMocks();

asMock(useComboBoxItemScale)
.mockName('useComboBoxItemScale')
.mockReturnValue({
itemHeight: 32,
});
asMock(useTableUtils).mockName('useTableUtils').mockReturnValue(tableUtils);

asMock(mock.mapItemToValue)
Expand Down

0 comments on commit 0f363b9

Please sign in to comment.