mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
add test for Lookup clearing QS params
This commit is contained in:
parent
26e320582a
commit
e854b179e4
@ -186,7 +186,7 @@ class Lookup extends React.Component {
|
||||
const { history } = this.props;
|
||||
const parts = history.location.search.replace(/^\?/, '').split('&');
|
||||
const ns = this.qsConfig.namespace;
|
||||
const otherParts = parts.filter(param => !param.startsWith(`${ns}.`))
|
||||
const otherParts = parts.filter(param => !param.startsWith(`${ns}.`));
|
||||
history.push(`${history.location.pathname}?${otherParts.join('&')}`);
|
||||
}
|
||||
|
||||
|
||||
@ -359,4 +359,33 @@ describe('<Lookup />', () => {
|
||||
expect(getItems).toHaveBeenCalledTimes(2);
|
||||
done();
|
||||
});
|
||||
|
||||
test('should clear its query params when closed', async () => {
|
||||
mockData = [{ name: 'foo', id: 1, isChecked: false }];
|
||||
const history = createMemoryHistory({
|
||||
initialEntries: ['/organizations/add?inventory.name=foo&bar=baz'],
|
||||
});
|
||||
wrapper = mountWithContexts(
|
||||
<_Lookup
|
||||
multiple
|
||||
name="foo"
|
||||
lookupHeader="Foo Bar"
|
||||
onLookupSave={() => {}}
|
||||
value={mockData}
|
||||
columns={mockColumns}
|
||||
sortedColumnKey="name"
|
||||
getItems={() => {}}
|
||||
location={{ history }}
|
||||
history={history}
|
||||
qsNamespace="inventory"
|
||||
i18n={{ _: val => val.toString() }}
|
||||
/>
|
||||
);
|
||||
wrapper
|
||||
.find('InputGroup Button')
|
||||
.at(0)
|
||||
.invoke('onClick')();
|
||||
wrapper.find('Modal').invoke('onClose')();
|
||||
expect(history.location.search).toEqual('?bar=baz');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user