Skip to content

Commit 23a1638

Browse files
committed
fix graphiclayer UT引起的问题
1 parent 14648dc commit 23a1638

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/leaflet/overlay/GraphicLayerSpec.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ describe('leaflet_GraphicLayer', function () {
3131
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
3232
});
3333
afterAll(function () {
34-
//canvas渲染时由于Path 相关的子类 -> map.remove()会有重绘操作,从而引起刷新延迟会报错,故弃之
35-
map.off();
36-
map = null;
34+
map.remove();
3735
window.document.body.removeChild(testDiv);
3836
});
3937

@@ -69,8 +67,14 @@ describe('leaflet_GraphicLayer', function () {
6967
}
7068
var isContainsPoint = graphicLayer._containsPoint();
7169
expect(isContainsPoint).not.toBe("false");
70+
//map.remove()时,canvas渲染的场景下render会先移除canvas的ctx,而path的移除会有重绘操作。
71+
//从而引起刷新延迟会报错,故在此移除重绘
72+
graphicLayer.on('remove', function () {
73+
var requestAnimId = map.getRenderer(graphicLayer)._redrawRequest;
74+
(requestAnimId != null) && L.Util.cancelAnimFrame(requestAnimId);
75+
done();
76+
});
7277
graphicLayer.remove();
73-
done();
7478
}, 1000)
7579
});
7680
});

0 commit comments

Comments
 (0)