Skip to content

Commit

Permalink
chore: add test for SelectBox regression + remove old fix (re: T12386…
Browse files Browse the repository at this point in the history
…37) (#27847)
  • Loading branch information
VasilyStrelyaev authored Aug 2, 2024
1 parent 6c62c5d commit 41f25ba
Showing 1 changed file with 48 additions and 0 deletions.
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();
});
});

0 comments on commit 41f25ba

Please sign in to comment.