Skip to content

Commit

Permalink
removing provider from stubbed_saved_object_index_pattern (#38772)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar authored Jun 27, 2019
1 parent 97acab3 commit c0af1d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
27 changes: 12 additions & 15 deletions src/fixtures/stubbed_saved_object_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,19 @@
* under the License.
*/

import fixturesLogstashFieldsProvider from './logstash_fields';
import stubbedLogstashFields from './logstash_fields';
import { SimpleSavedObject } from '../legacy/ui/public/saved_objects/simple_saved_object';

const mockLogstashFields = stubbedLogstashFields();

export function fixturesStubbedSavedObjectIndexPatternProvider() {
const mockLogstashFields = fixturesLogstashFieldsProvider();

return function (id) {
return new SimpleSavedObject(undefined, {
id,
type: 'index-pattern',
attributes: {
customFormats: '{}',
fields: mockLogstashFields
},
version: 2
});
};
export function stubbedSavedObjectIndexPattern(id) {
return new SimpleSavedObject(undefined, {
id,
type: 'index-pattern',
attributes: {
customFormats: '{}',
fields: mockLogstashFields
},
version: 2
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import _ from 'lodash';
import { IndexedArray } from '../../indexed_array';
import { IndexPattern } from '../_index_pattern';
import mockLogstashFields from '../../../../../fixtures/logstash_fields';
import { fixturesStubbedSavedObjectIndexPatternProvider } from '../../../../../fixtures/stubbed_saved_object_index_pattern';
import { stubbedSavedObjectIndexPattern } from '../../../../../fixtures/stubbed_saved_object_index_pattern';

jest.mock('../../errors', () => ({
SavedObjectNotFound: jest.fn(),
Expand Down Expand Up @@ -120,8 +120,6 @@ const config = {
get: jest.fn(),
};

const savedObjectsResponse = fixturesStubbedSavedObjectIndexPatternProvider();

// helper function to create index patterns
function create(id, payload) {
const indexPattern = new IndexPattern(id, config, savedObjectsClient, patternCache, fieldsFetcher, getIds);
Expand All @@ -132,7 +130,7 @@ function create(id, payload) {
}

function setDocsourcePayload(id, providedPayload) {
object = _.defaults(providedPayload || {}, savedObjectsResponse(id));
object = _.defaults(providedPayload || {}, stubbedSavedObjectIndexPattern(id));
}

describe('IndexPattern', () => {
Expand Down

0 comments on commit c0af1d2

Please sign in to comment.