-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add test for SelectBox regression + remove old fix (re: T12386…
…37) (#27847)
- Loading branch information
1 parent
6c62c5d
commit 41f25ba
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
packages/devextreme-react/src/core/__tests__/integration/integration.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as testingLib from '@testing-library/react'; | ||
import * as React from 'react'; | ||
|
||
import { useState, useEffect } from 'react'; | ||
import SelectBox from '../../../select-box'; | ||
import TextBox from '../../../text-box'; | ||
|
||
jest.useFakeTimers(); | ||
|
||
describe('selectbox', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
testingLib.cleanup(); | ||
}); | ||
|
||
it('renders selectbox in strict mode when data source is specified dynamically without errors', () => { | ||
const Field = (data: any) => { | ||
return (<TextBox defaultValue={data && data.Name} />); | ||
} | ||
|
||
const list = [{ ID: 1, Name: 'Item 1' }]; | ||
|
||
const SelectBoxWithDynamicDataSource = () => { | ||
const [items, setItems] = useState([{}]); | ||
|
||
useEffect(() => { | ||
setItems(list); | ||
}, []); | ||
|
||
return ( | ||
<SelectBox | ||
dataSource={items} | ||
displayExpr="Name" | ||
valueExpr="ID" | ||
fieldRender={Field} | ||
/> | ||
); | ||
}; | ||
|
||
const renderSelectBox = () => testingLib.render( | ||
<React.StrictMode> | ||
<SelectBoxWithDynamicDataSource /> | ||
</React.StrictMode> | ||
); | ||
|
||
expect(renderSelectBox).not.toThrow(); | ||
}); | ||
}); |