Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/@buffetjs/core/src/components/Select/tests/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import React from 'react';
import { mount } from 'enzyme';
import Select from '../index';
const initProps = {
name: 'inputSelect',
onChange: jest.fn(),
value: '',
};
let renderedComponent;
const renderComponent = (props = initProps) => mount(<Select {...props} />);
describe('<Select />', () => {
afterEach(() => {
renderedComponent.unmount();
});
it('Should render the component with no errors', () => {
renderedComponent = renderComponent();
const wrapper = renderedComponent.find(Select);
expect(wrapper.exists()).toBe(true);
});
it('Testing options prop with an array of string', () => {
const options = ['option 1', 'option 2'];
renderedComponent = renderComponent({ ...initProps, options });
const wrapper = renderedComponent.find(Select);
const optionsElements = wrapper.find('option');
expect(optionsElements).toHaveLength(2);
expect(optionsElements.first().text()).toBe('option 1');
expect(optionsElements.last().text()).toBe('option 2');
});
it('Testing options prop with an array of objects [{ label, value }]', () => {
const options = [
{
label: 'option 1',
value: 'option1',
},
{
label: 'option 2',
value: 'option2',
},
];
renderedComponent = renderComponent({ ...initProps, options });
const wrapper = renderedComponent.find(Select);
const optionsElements = wrapper.find('option');
expect(optionsElements).toHaveLength(2);
expect(optionsElements.first().text()).toBe('option 1');
expect(optionsElements.last().text()).toBe('option 2');
});
it('Should render the options with an array of React Nodes', () => {
const first = (
<option key="first" value="first">
First
</option>
);
const second = (
<option key="second" value="second">
Second
</option>
);
const options = [first, second];
renderedComponent = renderComponent({ ...initProps, options });
const wrapper = renderedComponent.find(Select);
const optionsElements = wrapper.find('option');
expect(wrapper.find(first)).toBeDefined();
expect(wrapper.find(second)).toBeDefined();
expect(optionsElements).toHaveLength(2);
expect(optionsElements.first().text()).toBe('First');
expect(optionsElements.last().text()).toBe('Second');
});
});
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0048 ]-- |