Skip to content

Commit 2e7ec56

Browse files
[fix]UT
1 parent 7c91e8d commit 2e7ec56

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

test/openlayers/overlay/GraphicSpec.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ describe('openlayers_GraphicLayer', () => {
636636
}
637637
});
638638
});
639+
639640
it('onCLick', (done) => {
640641
const map = new Map({
641642
target: 'map',
@@ -652,41 +653,40 @@ describe('openlayers_GraphicLayer', () => {
652653
highlightColor: [255, 0, 0, 255],
653654
radius: 20
654655
};
655-
map.once('postrender', function () {
656-
var graphicLayer = new ImageLayer({
657-
source: new GraphicSource({
658-
render: 'webgl',
659-
graphics: graphics,
660-
color: graphicStyle.color,
661-
highlightColor: graphicStyle.highlightColor,
662-
radius: graphicStyle.radius,
663-
map: map,
664-
onClick: function (graphic) {
665-
if (graphic) {
666-
graphic.lngLat;
667-
}
656+
var graphicLayer = new ImageLayer({
657+
source: new GraphicSource({
658+
render: 'webgl',
659+
graphics: graphics,
660+
color: graphicStyle.color,
661+
highlightColor: graphicStyle.highlightColor,
662+
radius: graphicStyle.radius,
663+
map: map,
664+
onClick: function (graphic) {
665+
if (graphic) {
666+
graphic.lngLat;
668667
}
669-
})
670-
});
671-
map.addLayer(graphicLayer);
672-
graphicLayer.on('postrender', function () {
673-
const source = graphicLayer.getSource();
674-
if (source.renderer) {
675-
source._forEachFeatureAtCoordinate([0, 0], 1, (result) => {
676-
expect(result).not.toBeNull();
677-
});
678-
const res = source.findGraphicByPixel({ pixel: [0, 0] }, source);
679-
expect(res).toBeUndefined();
680-
const res1 = source.getDeckglArguments(source, { pixel: [0, 0] }, graphics[0]);
681-
expect(res1).not.toBeNull();
682-
let pixel = map.getPixelFromCoordinate([0, 0]);
683-
map.forEachFeatureAtPixel(pixel, (graphic, layer) => {
684-
expect(graphic).toBe(graphics[0]);
685-
expect(layer).toBe(graphicLayer);
686-
});
687-
done();
688668
}
689-
});
669+
})
670+
});
671+
map.addLayer(graphicLayer);
672+
const key = graphicLayer.on('postrender', function () {
673+
const source = graphicLayer.getSource();
674+
if (source.renderer) {
675+
unByKey(key);
676+
source._forEachFeatureAtCoordinate([0, 0], 1, (result) => {
677+
expect(result).not.toBeNull();
678+
});
679+
const res = source.findGraphicByPixel({ pixel: [0, 0] }, source);
680+
expect(res).toBeUndefined();
681+
const res1 = source.getDeckglArguments(source, { pixel: [0, 0] }, graphics[0]);
682+
expect(res1).not.toBeNull();
683+
let pixel = map.getPixelFromCoordinate([0, 0]);
684+
map.forEachFeatureAtPixel(pixel, (graphic, layer) => {
685+
expect(graphic).toBe(graphics[0]);
686+
expect(layer).toBe(graphicLayer);
687+
});
688+
done();
689+
}
690690
});
691691
});
692692
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy