@@ -4,6 +4,8 @@ import {ThemeFeature} from '../../../src/openlayers/overlay/theme/ThemeFeature';
44import Map from 'ol/Map' ;
55import View from 'ol/View' ;
66import Point from 'ol/geom/Point' ;
7+ import { unByKey } from 'ol/Observable' ;
8+ import ImageLayer from 'ol/layer/Image' ;
79
810describe ( 'openlayers_RankSymbol' , ( ) => {
911 var testDiv , map , originalTimeout ;
@@ -83,6 +85,11 @@ describe('openlayers_RankSymbol', () => {
8385 circleHoverStyle : { fillOpacity : 1 }
8486 }
8587 } ) ;
88+ var layer = new ImageLayer ( {
89+ source : themeSource
90+ } ) ;
91+ map . addLayer ( layer ) ;
92+ expect ( themeSource . features . length ) . toEqual ( 0 ) ;
8693 var features = [ ] ;
8794 for ( var i = 0 , len = chinaConsumptionLevel . length ; i < len ; i ++ ) {
8895 // 省居民消费水平(单位:元)信息
@@ -94,13 +101,17 @@ describe('openlayers_RankSymbol', () => {
94101 var fea = new ThemeFeature ( geo , attrs ) ;
95102 features . push ( fea ) ;
96103 }
97- themeSource . addFeatures ( features ) ;
98- setTimeout ( ( ) => {
104+ var key = layer . on ( 'postrender' , function ( ) {
105+ if ( themeSource . charts . length > 0 ) {
106+ unByKey ( key ) ;
99107 themeSource . setSymbolType ( "Point" ) ;
100108 expect ( themeSource . symbolType ) . toEqual ( "Point" ) ;
101109 themeSource . destroy ( ) ;
110+ map . removeLayer ( layer ) ;
102111 done ( ) ;
103- } , 0 ) ;
112+ }
113+ } ) ;
114+ themeSource . addFeatures ( features ) ;
104115 } ) ;
105116
106117 it ( 'createThematicFeature' , ( done ) => {
@@ -137,4 +148,4 @@ describe('openlayers_RankSymbol', () => {
137148 } , 0 ) ;
138149 } ) ;
139150
140- } ) ;
151+ } ) ;
0 commit comments