88
99const expect = require ( 'expect' ) ;
1010const {
11- selectedFeatures
12- } = require ( '../highlight' ) ;
11+ selectedFeatures, filteredspatialObject, filteredspatialObjectCoord,
12+ filteredGeometry, filteredSpatialObjectId, filteredSpatialObjectCrs,
13+ filteredspatialObjectType, filteredFeatures, highlighedFeatures} = require ( '../highlight' ) ;
1314
1415const idFt1 = "idFt1" ;
1516const idFt2 = "idFt2" ;
@@ -36,14 +37,42 @@ let feature2 = {
3637 someProp : "someValue"
3738 }
3839} ;
40+
41+ let feature3 = [ {
42+ type : "Feature" ,
43+ geometry : {
44+ type : 'Polygon' ,
45+ coordinates : [ [ 0.000008983152841195214 , 0.000017966305681987637 ] ]
46+ } ,
47+ style : {
48+ fillColor : 'rgba(255, 255, 255, 0.2)' ,
49+ color : '#ffcc33'
50+ } ,
51+ id : 'spatial_object'
52+ } ] ;
3953const initialState = {
4054 featuregrid : {
4155 mode : modeEdit ,
4256 select : [ feature1 , feature2 ] ,
43- changes : [ feature2 ]
57+ changes : [ feature2 ] ,
58+ showFilteredObject : true ,
59+ open : true
4460 } ,
4561 highlight : {
4662 featuresPath : "featuregrid.select"
63+ } ,
64+ query : {
65+ filterObj : {
66+ spatialField : {
67+ geometry : {
68+ type : 'Polygon' ,
69+ coordinates : [ [ 1 , 2 ] ] ,
70+ projection : 'EPSG:3857' ,
71+ id : 'spatial_object'
72+
73+ }
74+ }
75+ }
4776 }
4877} ;
4978
@@ -60,4 +89,52 @@ describe('Test highlight selectors', () => {
6089 expect ( features ) . toExist ( ) ;
6190 expect ( features . length ) . toBe ( 0 ) ;
6291 } ) ;
92+ it ( 'test filteredspatialObject' , ( ) => {
93+ const spatialObject = initialState . query . filterObj . spatialField ;
94+ const features = filteredspatialObject ( initialState ) ;
95+ expect ( features ) . toExist ( ) ;
96+ expect ( features ) . toBe ( spatialObject ) ;
97+ } ) ;
98+ it ( 'test filteredGeometry' , ( ) => {
99+ const geometry = initialState . query . filterObj . spatialField . geometry ;
100+ const features = filteredGeometry ( initialState ) ;
101+ expect ( features ) . toExist ( ) ;
102+ expect ( features ) . toBe ( geometry ) ;
103+ } ) ;
104+ it ( 'test filteredspatialObjectCoord' , ( ) => {
105+ const coordinates = initialState . query . filterObj . spatialField . geometry . coordinates ;
106+ const features = filteredspatialObjectCoord ( initialState ) ;
107+ expect ( features ) . toExist ( ) ;
108+ expect ( features ) . toBe ( coordinates ) ;
109+ } ) ;
110+ it ( 'test filteredSpatialObjectId' , ( ) => {
111+ const geometryId = initialState . query . filterObj . spatialField . geometry . id ;
112+ const features = filteredSpatialObjectId ( initialState ) ;
113+ expect ( features ) . toExist ( ) ;
114+ expect ( features ) . toBe ( geometryId ) ;
115+ } ) ;
116+ it ( 'test filteredSpatialObjectCrs' , ( ) => {
117+ const geometryCrs = initialState . query . filterObj . spatialField . geometry . projection ;
118+ const features = filteredSpatialObjectCrs ( initialState ) ;
119+ expect ( features ) . toExist ( ) ;
120+ expect ( features ) . toBe ( geometryCrs ) ;
121+ } ) ;
122+ it ( 'test filteredspatialObjectType' , ( ) => {
123+ const geometryType = initialState . query . filterObj . spatialField . geometry . type ;
124+ const features = filteredspatialObjectType ( initialState ) ;
125+ expect ( features ) . toExist ( ) ;
126+ expect ( features ) . toBe ( geometryType ) ;
127+ } ) ;
128+ it ( 'test filteredFeatures' , ( ) => {
129+ const features = filteredFeatures ( initialState ) ;
130+ expect ( features ) . toExist ( ) ;
131+ expect ( features ) . toEqual ( feature3 ) ;
132+ } ) ;
133+ it ( 'test highlighedFeatures' , ( ) => {
134+ const features = highlighedFeatures ( initialState ) ;
135+ const featuresSelected = initialState . featuregrid . select ;
136+ const combinedFeatures = [ ...featuresSelected , ...feature3 ] ;
137+ expect ( features ) . toExist ( ) ;
138+ expect ( features ) . toEqual ( combinedFeatures ) ;
139+ } ) ;
63140} ) ;
0 commit comments