mirror of
https://github.com/grafana/grafana.git
synced 2025-01-01 03:37:24 -06:00
Convert packages/jaeger-ui-components/src/common/UiFindInput.test.js to RTL (#49994)
* Add selector * Add test * Remove snapshot * Remove uiFindInput selector
This commit is contained in:
parent
52c775368b
commit
3d26502db1
@ -98,9 +98,6 @@ exports[`no enzyme tests`] = {
|
||||
"packages/jaeger-ui-components/src/TraceTimelineViewer/index.test.js:381298544": [
|
||||
[14, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"packages/jaeger-ui-components/src/common/UiFindInput.test.js:2207118020": [
|
||||
[14, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"packages/jaeger-ui-components/src/url/ReferenceLink.test.js:3249503373": [
|
||||
[14, 26, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
|
@ -12,58 +12,25 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { shallow } from 'enzyme';
|
||||
// eslint-disable-next-line lodash/import-scope
|
||||
import _ from 'lodash';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import * as React from 'react';
|
||||
|
||||
import { Input } from '@grafana/ui';
|
||||
|
||||
import UiFindInput from './UiFindInput';
|
||||
|
||||
const debounceMock = jest.spyOn(_, 'debounce').mockImplementation((func) => {
|
||||
return Object.assign(func, { cancel: jest.fn(), flush: jest.fn() });
|
||||
});
|
||||
|
||||
describe('UiFindInput', () => {
|
||||
const flushMock = jest.fn();
|
||||
|
||||
const uiFind = 'uiFind';
|
||||
const ownInputValue = 'ownInputValue';
|
||||
const props = {
|
||||
uiFind: undefined,
|
||||
history: {
|
||||
replace: () => {},
|
||||
},
|
||||
location: {
|
||||
search: null,
|
||||
},
|
||||
};
|
||||
let wrapper;
|
||||
|
||||
beforeAll(() => {
|
||||
debounceMock.mockImplementation((fn) => {
|
||||
function debounceFunction(...args) {
|
||||
fn(...args);
|
||||
}
|
||||
debounceFunction.flush = flushMock;
|
||||
return debounceFunction;
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
flushMock.mockReset();
|
||||
wrapper = shallow(<UiFindInput {...props} />);
|
||||
});
|
||||
|
||||
describe('rendering', () => {
|
||||
it('renders as expected', () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
it('renders as expected with no value', () => {
|
||||
render(<UiFindInput value={undefined} />);
|
||||
const uiFindInput = screen.queryByPlaceholderText('Find...');
|
||||
expect(uiFindInput).toBeInTheDocument();
|
||||
expect(uiFindInput['value']).toEqual('');
|
||||
});
|
||||
|
||||
it('renders props.uiFind when state.ownInputValue is `undefined`', () => {
|
||||
wrapper.setProps({ value: uiFind });
|
||||
expect(wrapper.find(Input).prop('value')).toBe(uiFind);
|
||||
it('renders as expected with value', () => {
|
||||
render(<UiFindInput value="value" />);
|
||||
const uiFindInput = screen.queryByPlaceholderText('Find...');
|
||||
expect(uiFindInput).toBeInTheDocument();
|
||||
expect(uiFindInput['value']).toEqual('value');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,9 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`UiFindInput rendering renders as expected 1`] = `
|
||||
<Input
|
||||
onChange={[Function]}
|
||||
placeholder="Find..."
|
||||
suffix={<React.Fragment />}
|
||||
/>
|
||||
`;
|
Loading…
Reference in New Issue
Block a user