From c055cf42f3fb152b4bb2a57f7d6896016b2fb8f0 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Thu, 14 May 2020 16:19:36 -0400 Subject: [PATCH] reuse abstract field --- .../vector/properties/__tests__/test_util.ts | 49 +++++-------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/x-pack/plugins/maps/public/classes/styles/vector/properties/__tests__/test_util.ts b/x-pack/plugins/maps/public/classes/styles/vector/properties/__tests__/test_util.ts index a537d05f73c3a..1c478bb85ccc7 100644 --- a/x-pack/plugins/maps/public/classes/styles/vector/properties/__tests__/test_util.ts +++ b/x-pack/plugins/maps/public/classes/styles/vector/properties/__tests__/test_util.ts @@ -13,48 +13,21 @@ import { RangeFieldMeta, StyleMetaDescriptor, } from '../../../../../../common/descriptor_types'; -import { IField } from '../../../../fields/field'; -import { AbstractVectorSource, IVectorSource } from '../../../../sources/vector_source'; -import { ITooltipProperty, TooltipProperty } from '../../../../tooltips/tooltip_property'; +import { AbstractField, IField } from '../../../../fields/field'; -export const mockField: IField = { - canValueBeFormatted(): boolean { - return true; - }, - async createTooltipProperty(value: string | undefined): Promise { - return new TooltipProperty('foobar', 'foobar', 'foo bar value'); - }, - async getCategoricalFieldMetaRequest(size: number): Promise { - return undefined; - }, - async getDataType(): Promise { - return 'string'; - }, - async getOrdinalFieldMetaRequest(): Promise { - return null; - }, - getSource(): IVectorSource { - return new AbstractVectorSource({ type: 'TEST' }); - }, - isValid(): boolean { - return false; - }, +class MockField extends AbstractField { async getLabel(): Promise { - return 'foobar_label'; - }, - getName(): string { - return 'foobar'; - }, - getRootName(): string { - return 'foobar'; - }, - getOrigin(): FIELD_ORIGIN { - return FIELD_ORIGIN.SOURCE; - }, + return this.getName() + '_label'; + } supportsFieldMeta(): boolean { return true; - }, -}; + } +} + +export const mockField: IField = new MockField({ + fieldName: 'foobar', + origin: FIELD_ORIGIN.SOURCE, +}); class MockStyle { getStyleMeta(): StyleMeta {