Skip to content

Commit

Permalink
[fix] ut
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxianhuii committed Sep 6, 2023
1 parent fd86d37 commit 4b8b03c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/mapboxgl/web-map/__tests__/WebMapViewModel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,15 @@ const commonMap = {
getPitch: () => 2,
setPitch: () => jest.fn(),
getStyle: () => {
let layers = [];
if (layerIdMapList) {
for (const key in layerIdMapList) {
layers.push(layerIdMapList[key]);
}
}
return {
sources: sourceIdMapList
sources: sourceIdMapList,
layers
};
},
addSource: (sourceId, sourceInfo) => {
Expand Down Expand Up @@ -421,6 +428,23 @@ describe('WebMapViewModel.spec', () => {
viewModel.on({ addlayerssucceeded: callback });
});

it('add markerLayer layerOrder correctly', done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/datas/123456/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData_geojson['MARKER_GEOJSON']
};
mockFetch(fetchResource);
const id = markerLayer;
const callback = function (data) {
expect(data.layers.length).toBe(id.layers.length);
const layers = data.map.getStyle().layers;
expect(layers[layers.length - 2].id).toBe('POLYGON-6-strokeLine');
done();
};
const viewModel = new WebMapViewModel(id, { ...commonOption }, { ...commonMapOptions }, { ...commonMap });
viewModel.on({ addlayerssucceeded: callback });
});

it('markerLayer url is error', done => {
const newLayerData_geojson = {
...layerData_geojson['MARKER_GEOJSON'],
Expand Down

0 comments on commit 4b8b03c

Please sign in to comment.