mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 11:40:05 -03:30
Adds sort to IG modal
This commit is contained in:
@@ -162,6 +162,7 @@ describe('<DataListToolbar />', () => {
|
||||
onSearch={onSearch}
|
||||
onSort={onSort}
|
||||
onSelectAll={onSelectAll}
|
||||
showDelete
|
||||
/>
|
||||
</I18nProvider>
|
||||
);
|
||||
|
||||
@@ -3,7 +3,10 @@ import { mount } from 'enzyme';
|
||||
import { I18nProvider } from '@lingui/react';
|
||||
import Lookup from '../../src/components/Lookup';
|
||||
|
||||
let mockData = [{ name: 'foo', id: 1 }];
|
||||
let mockData = [{ name: 'foo', id: 1, isChecked: false }];
|
||||
const mockColumns = [
|
||||
{ name: 'Name', key: 'name', isSortable: true }
|
||||
];
|
||||
describe('<Lookup />', () => {
|
||||
test('initially renders succesfully', () => {
|
||||
mount(
|
||||
@@ -14,6 +17,8 @@ describe('<Lookup />', () => {
|
||||
value={mockData}
|
||||
onLookupSave={() => { }}
|
||||
getItems={() => { }}
|
||||
columns={mockColumns}
|
||||
sortedColumnKey="name"
|
||||
/>
|
||||
</I18nProvider>
|
||||
);
|
||||
@@ -27,6 +32,8 @@ describe('<Lookup />', () => {
|
||||
value={mockData}
|
||||
onLookupSave={() => { }}
|
||||
getItems={() => ({ data: { results: [{ name: 'test instance', id: 1 }] } })}
|
||||
columns={mockColumns}
|
||||
sortedColumnKey="name"
|
||||
/>
|
||||
</I18nProvider>
|
||||
).find('Lookup');
|
||||
@@ -47,6 +54,8 @@ describe('<Lookup />', () => {
|
||||
value={mockSelected}
|
||||
onLookupSave={() => { }}
|
||||
getItems={() => { }}
|
||||
columns={mockColumns}
|
||||
sortedColumnKey="name"
|
||||
/>
|
||||
</I18nProvider>
|
||||
).find('Lookup');
|
||||
@@ -72,6 +81,8 @@ describe('<Lookup />', () => {
|
||||
value={mockSelected}
|
||||
onLookupSave={() => { }}
|
||||
getItems={() => ({ data: { results: [{ name: 'test instance', id: 1 }] } })}
|
||||
columns={mockColumns}
|
||||
sortedColumnKey="name"
|
||||
/>
|
||||
</I18nProvider>
|
||||
);
|
||||
@@ -94,6 +105,8 @@ describe('<Lookup />', () => {
|
||||
value={mockData}
|
||||
onLookupSave={() => { }}
|
||||
getItems={() => { }}
|
||||
columns={mockColumns}
|
||||
sortedColumnKey="name"
|
||||
/>
|
||||
</I18nProvider>
|
||||
);
|
||||
@@ -112,6 +125,8 @@ describe('<Lookup />', () => {
|
||||
value={mockData}
|
||||
selected={[]}
|
||||
getItems={() => { }}
|
||||
columns={mockColumns}
|
||||
sortedColumnKey="name"
|
||||
/>
|
||||
</I18nProvider>
|
||||
);
|
||||
@@ -129,6 +144,8 @@ describe('<Lookup />', () => {
|
||||
value={mockData}
|
||||
selected={[]}
|
||||
getItems={() => { }}
|
||||
columns={mockColumns}
|
||||
sortedColumnKey="name"
|
||||
/>
|
||||
</I18nProvider>
|
||||
).find('Lookup');
|
||||
@@ -174,4 +191,42 @@ describe('<Lookup />', () => {
|
||||
name: 'foo'
|
||||
}], 'fooBar');
|
||||
});
|
||||
test('onSort sets state and calls getData ', () => {
|
||||
const spy = jest.spyOn(Lookup.prototype, 'getData');
|
||||
const wrapper = mount(
|
||||
<I18nProvider>
|
||||
<Lookup
|
||||
lookup_header="Foo Bar"
|
||||
onLookupSave={() => { }}
|
||||
data={mockData}
|
||||
selected={[]}
|
||||
columns={mockColumns}
|
||||
sortedColumnKey="name"
|
||||
/>
|
||||
</I18nProvider>
|
||||
).find('Lookup');
|
||||
wrapper.instance().onSort('id', 'descending');
|
||||
expect(wrapper.state('sortedColumnKey')).toEqual('id');
|
||||
expect(wrapper.state('sortOrder')).toEqual('descending');
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
test('onSetPage sets state and calls getData ', () => {
|
||||
const spy = jest.spyOn(Lookup.prototype, 'getData');
|
||||
const wrapper = mount(
|
||||
<I18nProvider>
|
||||
<Lookup
|
||||
lookup_header="Foo Bar"
|
||||
onLookupSave={() => { }}
|
||||
data={mockData}
|
||||
selected={[]}
|
||||
columns={mockColumns}
|
||||
sortedColumnKey="name"
|
||||
/>
|
||||
</I18nProvider>
|
||||
).find('Lookup');
|
||||
wrapper.instance().onSetPage(2, 10);
|
||||
expect(wrapper.state('page')).toEqual(2);
|
||||
expect(wrapper.state('page_size')).toEqual(10);
|
||||
expect(spy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
11
__tests__/components/VerticalSeparator.test.jsx
Normal file
11
__tests__/components/VerticalSeparator.test.jsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import VerticalSeparator from '../../src/components/VerticalSeparator';
|
||||
|
||||
describe('VerticalSeparator', () => {
|
||||
test('renders the expected content', () => {
|
||||
const wrapper = mount(<VerticalSeparator />);
|
||||
expect(wrapper).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user