|
|
|
|
@ -36,7 +36,24 @@ describe('<QueryField />', () => { |
|
|
|
|
<QueryField query={`my\r clean query`} onTypeahead={jest.fn()} onChange={onChange} portalOrigin="mock-origin" /> |
|
|
|
|
); |
|
|
|
|
const field = wrapper.instance() as QueryField; |
|
|
|
|
field.runOnChange(); |
|
|
|
|
|
|
|
|
|
field.runOnChange(false); |
|
|
|
|
expect(onChange.mock.calls.length).toBe(1); |
|
|
|
|
expect(onChange.mock.calls[0][0]).toBe('my\r clean query'); |
|
|
|
|
|
|
|
|
|
field.runOnChange(true); |
|
|
|
|
expect(onChange.mock.calls.length).toBe(2); |
|
|
|
|
expect(onChange.mock.calls[1][0]).toBe('my clean query'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should clean the text when running the query', () => { |
|
|
|
|
const onChange = jest.fn(); |
|
|
|
|
const wrapper = shallow( |
|
|
|
|
<QueryField query={`my\r clean query`} onTypeahead={jest.fn()} onChange={onChange} portalOrigin="mock-origin" /> |
|
|
|
|
); |
|
|
|
|
const field = wrapper.instance() as QueryField; |
|
|
|
|
|
|
|
|
|
field.runOnChangeAndRunQuery(); |
|
|
|
|
expect(onChange.mock.calls.length).toBe(1); |
|
|
|
|
expect(onChange.mock.calls[0][0]).toBe('my clean query'); |
|
|
|
|
}); |
|
|
|
|
|