@@ -382,3 +382,57 @@ describe('WebMapV3 - _getLegendInfos', () => {
382382 } ) ;
383383 } ) ;
384384} ) ;
385+
386+ describe ( 'WebMapV3 - legend symbol/style helpers' , ( ) => {
387+ let instance ;
388+
389+ beforeEach ( ( ) => {
390+ instance = createWebMapV3Instance ( ) ;
391+ } ) ;
392+
393+ describe ( '_isAllPictureSymbolSaved' , ( ) => {
394+ it ( 'should return false when symbolsContent type is custom for line symbol' , ( ) => {
395+ // custom 为表达式类型,图例暂不支持,直接返回 false
396+ const symbolsContent = {
397+ type : 'custom' ,
398+ value : { style : { 'line-pattern' : 'some-image' } }
399+ } ;
400+
401+ expect ( instance . _isAllPictureSymbolSaved ( 'line' , symbolsContent , { } ) ) . toBe ( false ) ;
402+ } ) ;
403+
404+ it ( 'should return false when symbolsContent type is custom for polygon symbol' , ( ) => {
405+ const symbolsContent = {
406+ type : 'custom' ,
407+ values : [ { value : { style : { 'fill-pattern' : 'some-image' } } } ] ,
408+ defaultValue : { style : { 'fill-pattern' : 'default-image' } }
409+ } ;
410+
411+ expect ( instance . _isAllPictureSymbolSaved ( 'polygon' , symbolsContent , { } ) ) . toBe ( false ) ;
412+ } ) ;
413+ } ) ;
414+
415+ describe ( '_getLegendStyleType' , ( ) => {
416+ it ( 'should return CUSTOM when currentType is custom' , ( ) => {
417+ const result = instance . _getLegendStyleType ( {
418+ styleField : 'color' ,
419+ currentType : 'custom' ,
420+ custom : [ ] ,
421+ interpolateInfo : { }
422+ } ) ;
423+
424+ expect ( result ) . toBe ( 'CUSTOM' ) ;
425+ } ) ;
426+
427+ it ( 'should return CUSTOM for non-color styleField when currentType is custom' , ( ) => {
428+ const result = instance . _getLegendStyleType ( {
429+ styleField : 'width' ,
430+ currentType : 'custom' ,
431+ custom : [ { key : 'expr' } ] ,
432+ interpolateInfo : { type : 'custom' }
433+ } ) ;
434+
435+ expect ( result ) . toBe ( 'CUSTOM' ) ;
436+ } ) ;
437+ } ) ;
438+ } ) ;
0 commit comments