removing provider from stubbed_saved_object_index_pattern (#38772) (#39775)

This commit is contained in:
Peter Pisljar 2019-06-28 08:15:38 +02:00 committed by GitHub
parent 7a63599755
commit 54d46696eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 19 deletions

View file

@ -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
});
}

View file

@ -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(),
@ -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);
@ -132,7 +130,7 @@ function create(id, payload) {
}
function setDocsourcePayload(id, providedPayload) {
object = _.defaults(providedPayload || {}, savedObjectsResponse(id));
object = _.defaults(providedPayload || {}, stubbedSavedObjectIndexPattern(id));
}
describe('IndexPattern', () => {