Skip to content

Commit c055cf4

Browse files
reuse abstract field
1 parent 09a05d9 commit c055cf4

1 file changed

Lines changed: 11 additions & 38 deletions

File tree

  • x-pack/plugins/maps/public/classes/styles/vector/properties/__tests__

x-pack/plugins/maps/public/classes/styles/vector/properties/__tests__/test_util.ts

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,21 @@ import {
1313
RangeFieldMeta,
1414
StyleMetaDescriptor,
1515
} from '../../../../../../common/descriptor_types';
16-
import { IField } from '../../../../fields/field';
17-
import { AbstractVectorSource, IVectorSource } from '../../../../sources/vector_source';
18-
import { ITooltipProperty, TooltipProperty } from '../../../../tooltips/tooltip_property';
16+
import { AbstractField, IField } from '../../../../fields/field';
1917

20-
export const mockField: IField = {
21-
canValueBeFormatted(): boolean {
22-
return true;
23-
},
24-
async createTooltipProperty(value: string | undefined): Promise<ITooltipProperty> {
25-
return new TooltipProperty('foobar', 'foobar', 'foo bar value');
26-
},
27-
async getCategoricalFieldMetaRequest(size: number): Promise<unknown> {
28-
return undefined;
29-
},
30-
async getDataType(): Promise<string> {
31-
return 'string';
32-
},
33-
async getOrdinalFieldMetaRequest(): Promise<unknown> {
34-
return null;
35-
},
36-
getSource(): IVectorSource {
37-
return new AbstractVectorSource({ type: 'TEST' });
38-
},
39-
isValid(): boolean {
40-
return false;
41-
},
18+
class MockField extends AbstractField {
4219
async getLabel(): Promise<string> {
43-
return 'foobar_label';
44-
},
45-
getName(): string {
46-
return 'foobar';
47-
},
48-
getRootName(): string {
49-
return 'foobar';
50-
},
51-
getOrigin(): FIELD_ORIGIN {
52-
return FIELD_ORIGIN.SOURCE;
53-
},
20+
return this.getName() + '_label';
21+
}
5422
supportsFieldMeta(): boolean {
5523
return true;
56-
},
57-
};
24+
}
25+
}
26+
27+
export const mockField: IField = new MockField({
28+
fieldName: 'foobar',
29+
origin: FIELD_ORIGIN.SOURCE,
30+
});
5831

5932
class MockStyle {
6033
getStyleMeta(): StyleMeta {

0 commit comments

Comments
 (0)