Skip to content

Commit 426144b

Browse files
fix uncovered issue
1 parent 1abdb88 commit 426144b

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/style/style.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {OverscaledTileID} from '../tile/tile_id';
1111
import {fakeServer, type FakeServer} from 'nise';
1212

1313
import {type EvaluationParameters} from './evaluation_parameters';
14-
import {Color, type Feature, type LayerSpecification, type GeoJSONSourceSpecification, type FilterSpecification, type SourceSpecification, type StyleSpecification, type SymbolLayerSpecification, type SkySpecification} from '@maplibre/maplibre-gl-style-spec';
14+
import {Color, type Feature, type LayerSpecification, type GeoJSONSourceSpecification, type FilterSpecification, type SourceSpecification, type StyleSpecification, type SymbolLayerSpecification, type SkySpecification, type AllPaintProperties, type AllLayoutProperties} from '@maplibre/maplibre-gl-style-spec';
1515
import {type GeoJSONSource} from '../source/geojson_source';
1616
import {StubMap, sleep, waitForEvent} from '../util/test/util';
1717
import {RTLPluginLoadedEventName} from '../source/rtl_text_plugin_status';
@@ -2626,7 +2626,7 @@ describe('Style.setPaintProperty', () => {
26262626
});
26272627

26282628
await style.once('style.load');
2629-
const value = {stops: [[0, 'red'], [10, 'blue']]};
2629+
const value: AllPaintProperties['background-color'] = {type: 'exponential', stops: [[0, 'red'], [10, 'blue']]};
26302630
style.setPaintProperty('background', 'background-color', value);
26312631
expect(style.getPaintProperty('background', 'background-color')).not.toBe(value);
26322632
expect(style._changed).toBeTruthy();
@@ -2684,13 +2684,13 @@ describe('Style.getPaintProperty', () => {
26842684
});
26852685

26862686
await style.once('style.load');
2687-
style.setPaintProperty('background', 'background-color', {stops: [[0, 'red'], [10, 'blue']]});
2687+
style.setPaintProperty('background', 'background-color', {type: 'exponential', stops: [[0, 'red'], [10, 'blue']]});
26882688
style.update({} as EvaluationParameters);
26892689
expect(style._changed).toBeFalsy();
26902690

2691-
const value = style.getPaintProperty('background', 'background-color');
2692-
value['stops'][0][0] = 1;
2693-
style.setPaintProperty('background', 'background-color', value);
2691+
const value = style.getPaintProperty('background', 'background-color') as {type: string; stops: [number, string][]};
2692+
value.stops[0][0] = 1;
2693+
style.setPaintProperty('background', 'background-color', value as AllPaintProperties['background-color']);
26942694
expect(style._changed).toBeTruthy();
26952695
});
26962696
});
@@ -2719,7 +2719,7 @@ describe('Style.setLayoutProperty', () => {
27192719
});
27202720

27212721
await style.once('style.load');
2722-
const value = {stops: [[0, 'butt'], [10, 'round']]};
2722+
const value: AllLayoutProperties['line-cap'] = {type: 'exponential', stops: [[0, 'butt'], [10, 'round']]};
27232723
style.setLayoutProperty('line', 'line-cap', value);
27242724
expect(style.getLayoutProperty('line', 'line-cap')).not.toBe(value);
27252725
expect(style._changed).toBeTruthy();
@@ -2758,13 +2758,13 @@ describe('Style.setLayoutProperty', () => {
27582758
const lineLayer = style.getLayer('line');
27592759
const validate = vi.spyOn(lineLayer, '_validate');
27602760

2761-
style.setLayoutProperty('line', 'line-cap', 'invalidcap', {validate: false});
2761+
style.setLayoutProperty('line', 'line-cap', 'invalidcap' as any, {validate: false});
27622762
expect(validate.mock.calls[0][4]).toEqual({validate: false});
27632763
expect(mockConsoleError).not.toHaveBeenCalled();
27642764
expect(style._changed).toBeTruthy();
27652765
style.update({} as EvaluationParameters);
27662766

2767-
style.setLayoutProperty('line', 'line-cap', 'differentinvalidcap');
2767+
style.setLayoutProperty('line', 'line-cap', 'differentinvalidcap' as any);
27682768
expect(mockConsoleError).toHaveBeenCalledTimes(1);
27692769
expect(validate.mock.calls[1][4]).toEqual({});
27702770
});
@@ -2794,11 +2794,11 @@ describe('Style.getLayoutProperty', () => {
27942794
});
27952795

27962796
await style.once('style.load');
2797-
style.setLayoutProperty('line', 'line-cap', {stops: [[0, 'butt'], [10, 'round']]});
2797+
style.setLayoutProperty('line', 'line-cap', {type: 'exponential', stops: [[0, 'butt'], [10, 'round']]});
27982798
style.update({} as EvaluationParameters);
27992799
expect(style._changed).toBeFalsy();
28002800

2801-
const value = style.getLayoutProperty('line', 'line-cap');
2801+
const value: AllLayoutProperties['line-cap'] = style.getLayoutProperty('line', 'line-cap');
28022802
value.stops[0][0] = 1;
28032803
style.setLayoutProperty('line', 'line-cap', value);
28042804
expect(style._changed).toBeTruthy();

src/style/style_layer.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ describe('StyleLayer.setPaintProperty', () => {
196196
} as LayerSpecification, {});
197197

198198
const errorPromise = layer.once('error');
199-
layer.setPaintProperty('visibility', 'visible');
199+
layer.setPaintProperty('visibility' as any, 'visible');
200200
const {error} = await errorPromise;
201201
expect(error.message).toContain('Use get/setLayoutProperty instead?');
202202
});
@@ -212,7 +212,7 @@ describe('StyleLayer.getPaintProperty', () => {
212212
}
213213
} as LayerSpecification, {});
214214

215-
expect(() => layer.getPaintProperty('text-transform')).toThrow(
215+
expect(() => layer.getPaintProperty('text-transform' as any)).toThrow(
216216
'Use get/setLayoutProperty instead?'
217217
);
218218
});
@@ -226,7 +226,7 @@ describe('StyleLayer.getPaintProperty', () => {
226226
}
227227
} as LayerSpecification, {});
228228

229-
expect(() => layer.getPaintProperty('text-transform-transition')).toThrow(
229+
expect(() => layer.getPaintProperty('text-transform-transition' as any)).toThrow(
230230
'Use get/setLayoutProperty instead?'
231231
);
232232
});
@@ -237,7 +237,7 @@ describe('StyleLayer.getPaintProperty', () => {
237237
'type': 'symbol',
238238
} as LayerSpecification, {});
239239

240-
expect(() => layer.getPaintProperty('visibility')).toThrow(
240+
expect(() => layer.getPaintProperty('visibility' as any)).toThrow(
241241
'Use get/setLayoutProperty instead?'
242242
);
243243
});
@@ -250,7 +250,7 @@ describe('StyleLayer.getLayoutProperty', () => {
250250
'type': 'background',
251251
} as LayerSpecification, {});
252252

253-
expect(() => layer.getLayoutProperty('some-property')).toThrow(
253+
expect(() => layer.getLayoutProperty('some-property' as any)).toThrow(
254254
'Cannot get layout property "some-property" on layer type "background" which has no layout properties.'
255255
);
256256
});
@@ -264,7 +264,7 @@ describe('StyleLayer.getLayoutProperty', () => {
264264
}
265265
} as LayerSpecification, {});
266266

267-
expect(() => layer.getLayoutProperty('text-color')).toThrow(
267+
expect(() => layer.getLayoutProperty('text-color' as any)).toThrow(
268268
'Use get/setPaintProperty instead?'
269269
);
270270
});
@@ -290,7 +290,7 @@ describe('StyleLayer.setLayoutProperty', () => {
290290

291291
const errorPromise = layer.once('error');
292292

293-
layer.setLayoutProperty('text-transform', 'invalidValue');
293+
layer.setLayoutProperty('text-transform', 'invalidValue' as any);
294294
await expect(errorPromise).resolves.toBeDefined();
295295
});
296296

@@ -333,7 +333,7 @@ describe('StyleLayer.setLayoutProperty', () => {
333333
} as LayerSpecification, {});
334334

335335
const errorPromise = layer.once('error');
336-
layer.setLayoutProperty('text-color', 'blue');
336+
layer.setPaintProperty('text-color', 'blue');
337337
const {error} = await errorPromise;
338338
expect(error.message).toContain('Use get/setPaintProperty instead?');
339339
});

src/webgl/draw/draw_fill.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ describe('drawFill', () => {
7474
// 'fill-pattern': 'pattern0'
7575
// so tile.imageAtlas.patternPositions['pattern0'] would return nothing
7676
// mimicking the transitioning fill-pattern value
77-
layer.getPaintProperty = () => {
77+
layer.getPaintProperty = (() => {
7878
return 'pattern1';
79-
};
79+
}) as any;
8080

8181
return layer;
8282
}

0 commit comments

Comments
 (0)