Skip to content

Commit

Permalink
chore: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
committed May 19, 2023
1 parent a086fad commit 8b7e562
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions tests/Select.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fireEvent,render as testingRender } from '@testing-library/react';
import { mount,render } from 'enzyme';
import { fireEvent, render as testingRender } from '@testing-library/react';
import { mount, render } from 'enzyme';
import KeyCode from 'rc-util/lib/KeyCode';
import { spyElementPrototype } from 'rc-util/lib/test/domHook';
import { resetWarned } from 'rc-util/lib/warning';
Expand All @@ -8,7 +8,7 @@ import type { ScrollConfig } from 'rc-virtual-list/lib/List';
import React from 'react';
import { act } from 'react-dom/test-utils';
import type { SelectProps } from '../src';
import Select,{ OptGroup,Option,useBaseProps } from '../src';
import Select, { OptGroup, Option, useBaseProps } from '../src';
import type { BaseSelectRef } from '../src/BaseSelect';
import allowClearTest from './shared/allowClearTest';
import blurTest from './shared/blurTest';
Expand All @@ -17,11 +17,11 @@ import inputFilterTest from './shared/inputFilterTest';
import keyDownTest from './shared/keyDownTest';
import openControlledTest from './shared/openControlledTest';
import {
expectOpen,
findSelection,
injectRunAllTimers,
selectItem,
toggleOpen
expectOpen,
findSelection,
injectRunAllTimers,
selectItem,
toggleOpen,
} from './utils/common';

describe('Select.Basic', () => {
Expand Down Expand Up @@ -148,6 +148,24 @@ describe('Select.Basic', () => {
});
});

it('item label should be the same as user enter when set groupLabel', () => {
const { container } = testingRender(
<Select
options={[
{
label: 'itemLabel',
value: 'itemValue',
},
]}
fieldNames={{
groupLabel: 'groupLabel',
}}
open
/>,
);
expect(container.querySelector('.rc-select-item-option-content').innerHTML).toBe('itemLabel');
});

it('convert value to array', () => {
const wrapper = mount(
<Select value="1" optionLabelProp="children">
Expand Down

0 comments on commit 8b7e562

Please sign in to comment.