Skip to content

Commit cf938d5

Browse files
committed
Add unit test
1 parent 20be343 commit cf938d5

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

  • src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field

src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_time_field/step_time_field.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,28 @@ describe('StepTimeField', () => {
292292
error: 'foobar',
293293
});
294294
});
295+
296+
it('should call createIndexPattern with undefined time field when no time filter chosen', async () => {
297+
const createIndexPattern = jest.fn();
298+
299+
const component = shallowWithI18nProvider(
300+
<StepTimeField
301+
indexPattern="ki*"
302+
indexPatternsService={indexPatternsService}
303+
goToPreviousStep={noop}
304+
createIndexPattern={createIndexPattern}
305+
indexPatternCreationType={mockIndexPatternCreationType}
306+
/>
307+
);
308+
309+
(component.instance() as StepTimeField).onTimeFieldChanged(({
310+
target: { value: undefined },
311+
} as unknown) as React.ChangeEvent<HTMLSelectElement>);
312+
component.update();
313+
314+
await (component.instance() as StepTimeField).createIndexPattern();
315+
component.update();
316+
317+
expect(createIndexPattern).toHaveBeenCalledWith(undefined, '');
318+
});
295319
});

0 commit comments

Comments
 (0)