Skip to content

Commit

Permalink
Update step_time_field.test.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
maryia-lapata committed Mar 4, 2020
1 parent b363f11 commit bebc47a
Showing 1 changed file with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import React from 'react';
import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers';
import { IndexPatternCreationConfig } from '../../../../../../../../management/public';
import { IFieldType } from '../../../../../../../../../../plugins/data/public';
import { dataPluginMock } from '../../../../../../../../../../plugins/data/public/mocks';

import { StepTimeField } from '../step_time_field';

Expand All @@ -43,7 +42,19 @@ const mockIndexPatternCreationType = new IndexPatternCreationConfig({
});

const noop = () => {};
const indexPatternsService = dataPluginMock.createStartContract().indexPatterns;
const fields = [
{
name: '@timestamp',
type: 'date',
},
];
const indexPatternsService = {
make: () => ({
fieldsFetcher: {
fetchForWildcard: jest.fn().mockReturnValue(Promise.resolve(fields)),
},
}),
} as any;

describe('StepTimeField', () => {
it('should render normally', () => {
Expand Down Expand Up @@ -296,24 +307,11 @@ describe('StepTimeField', () => {

it('should call createIndexPattern with undefined time field when no time filter chosen', async () => {
const createIndexPattern = jest.fn();
const fields = [
{
name: '@timestamp',
type: 'date',
},
];
const indPatternsService = {
make: () => ({
fieldsFetcher: {
fetchForWildcard: jest.fn().mockReturnValue(Promise.resolve(fields)),
},
}),
} as any;

const component = shallowWithI18nProvider(
<StepTimeField
indexPattern="ki*"
indexPatternsService={indPatternsService}
indexPatternsService={indexPatternsService}
goToPreviousStep={noop}
createIndexPattern={createIndexPattern}
indexPatternCreationType={mockIndexPatternCreationType}
Expand Down

0 comments on commit bebc47a

Please sign in to comment.