mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 05:01:19 -03:30
* make all chips the same size * create DetailList, Detail components; clean up Chips, ChipGroup * delete BasicChip in favor of <Chip isReadOnly> * create our own ChipGroup to handle overflow
64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import SelectedList from '../../src/components/SelectedList';
|
|
import { ChipGroup } from '../../src/components/Chip';
|
|
|
|
describe('<SelectedList />', () => {
|
|
test('initially renders succesfully', () => {
|
|
const mockSelected = [
|
|
{
|
|
id: 1,
|
|
name: 'foo'
|
|
}, {
|
|
id: 2,
|
|
name: 'bar'
|
|
}
|
|
];
|
|
mount(
|
|
<SelectedList
|
|
label="Selected"
|
|
selected={mockSelected}
|
|
showOverflowAfter={5}
|
|
onRemove={() => {}}
|
|
/>
|
|
);
|
|
});
|
|
|
|
test('showOverflow should set showOverflow on ChipGroup', () => {
|
|
const wrapper = mount(
|
|
<SelectedList
|
|
label="Selected"
|
|
selected={[]}
|
|
showOverflowAfter={5}
|
|
onRemove={() => {}}
|
|
/>
|
|
);
|
|
const chipGroup = wrapper.find(ChipGroup);
|
|
expect(chipGroup).toHaveLength(1);
|
|
expect(chipGroup.prop('showOverflowAfter')).toEqual(5);
|
|
});
|
|
|
|
test('Clicking remove on chip calls onRemove callback prop with correct params', () => {
|
|
const onRemove = jest.fn();
|
|
const mockSelected = [
|
|
{
|
|
id: 1,
|
|
name: 'foo'
|
|
}
|
|
];
|
|
const wrapper = mount(
|
|
<SelectedList
|
|
label="Selected"
|
|
selected={mockSelected}
|
|
showOverflowAfter={3}
|
|
onRemove={onRemove}
|
|
/>
|
|
);
|
|
wrapper.find('.pf-c-chip button').first().simulate('click');
|
|
expect(onRemove).toBeCalledWith({
|
|
id: 1,
|
|
name: 'foo'
|
|
});
|
|
});
|
|
});
|