@@ -104,19 +104,66 @@ describe('TilesProperty', () => {
104104 } ) ;
105105 } ) ;
106106
107- describe ( 'access properties' , ( ) => {
108- it ( 'should show check icon for truthy access values' , ( ) => {
109- const { container } = render (
110- < TilesProperty propertyKey = "access:car" value = { true } />
111- ) ;
112- expect ( container . querySelector ( '.text-emerald-600' ) ) . toBeInTheDocument ( ) ;
107+ describe ( 'access bitmask properties' , ( ) => {
108+ it ( 'should decode access:fwd bitmask to badges' , ( ) => {
109+ // 1 (Auto) + 2 (Pedestrian) + 4 (Bicycle) = 7
110+ render ( < TilesProperty propertyKey = "access:fwd" value = { 7 } /> ) ;
111+ expect ( screen . getByText ( 'Auto' ) ) . toBeInTheDocument ( ) ;
112+ expect ( screen . getByText ( 'Pedestrian' ) ) . toBeInTheDocument ( ) ;
113+ expect ( screen . getByText ( 'Bicycle' ) ) . toBeInTheDocument ( ) ;
113114 } ) ;
114115
115- it ( 'should show X icon for falsy access values' , ( ) => {
116- const { container } = render (
117- < TilesProperty propertyKey = "access:car" value = { false } />
118- ) ;
119- expect ( container . querySelector ( '.text-red-600' ) ) . toBeInTheDocument ( ) ;
116+ it ( 'should decode access:bwd bitmask to badges' , ( ) => {
117+ // 8 (Truck) + 64 (Bus) = 72
118+ render ( < TilesProperty propertyKey = "access:bwd" value = { 72 } /> ) ;
119+ expect ( screen . getByText ( 'Truck' ) ) . toBeInTheDocument ( ) ;
120+ expect ( screen . getByText ( 'Bus' ) ) . toBeInTheDocument ( ) ;
121+ expect ( screen . queryByText ( 'Auto' ) ) . not . toBeInTheDocument ( ) ;
122+ } ) ;
123+
124+ it ( 'should show all access types for full bitmask' , ( ) => {
125+ // All flags: 1+2+4+8+16+32+64+128+256+512+1024 = 2047
126+ render ( < TilesProperty propertyKey = "access:fwd" value = { 2047 } /> ) ;
127+ expect ( screen . getByText ( 'Auto' ) ) . toBeInTheDocument ( ) ;
128+ expect ( screen . getByText ( 'Pedestrian' ) ) . toBeInTheDocument ( ) ;
129+ expect ( screen . getByText ( 'Bicycle' ) ) . toBeInTheDocument ( ) ;
130+ expect ( screen . getByText ( 'Truck' ) ) . toBeInTheDocument ( ) ;
131+ expect ( screen . getByText ( 'Emergency' ) ) . toBeInTheDocument ( ) ;
132+ expect ( screen . getByText ( 'Taxi' ) ) . toBeInTheDocument ( ) ;
133+ expect ( screen . getByText ( 'Bus' ) ) . toBeInTheDocument ( ) ;
134+ expect ( screen . getByText ( 'HOV' ) ) . toBeInTheDocument ( ) ;
135+ expect ( screen . getByText ( 'Wheelchair' ) ) . toBeInTheDocument ( ) ;
136+ expect ( screen . getByText ( 'Moped' ) ) . toBeInTheDocument ( ) ;
137+ expect ( screen . getByText ( 'Motorcycle' ) ) . toBeInTheDocument ( ) ;
138+ } ) ;
139+
140+ it ( 'should show None for zero bitmask' , ( ) => {
141+ render ( < TilesProperty propertyKey = "access:fwd" value = { 0 } /> ) ;
142+ expect ( screen . getByText ( 'None' ) ) . toBeInTheDocument ( ) ;
143+ } ) ;
144+ } ) ;
145+
146+ describe ( 'bike_network bitmask properties' , ( ) => {
147+ it ( 'should decode bike_network bitmask to badges' , ( ) => {
148+ // 1 (National) + 4 (Local) = 5
149+ render ( < TilesProperty propertyKey = "bike_network" value = { 5 } /> ) ;
150+ expect ( screen . getByText ( 'National' ) ) . toBeInTheDocument ( ) ;
151+ expect ( screen . getByText ( 'Local' ) ) . toBeInTheDocument ( ) ;
152+ expect ( screen . queryByText ( 'Regional' ) ) . not . toBeInTheDocument ( ) ;
153+ } ) ;
154+
155+ it ( 'should show all bike network types for full bitmask' , ( ) => {
156+ // All flags: 1+2+4+8 = 15
157+ render ( < TilesProperty propertyKey = "bike_network" value = { 15 } /> ) ;
158+ expect ( screen . getByText ( 'National' ) ) . toBeInTheDocument ( ) ;
159+ expect ( screen . getByText ( 'Regional' ) ) . toBeInTheDocument ( ) ;
160+ expect ( screen . getByText ( 'Local' ) ) . toBeInTheDocument ( ) ;
161+ expect ( screen . getByText ( 'Mountain' ) ) . toBeInTheDocument ( ) ;
162+ } ) ;
163+
164+ it ( 'should show None for zero bike_network' , ( ) => {
165+ render ( < TilesProperty propertyKey = "bike_network" value = { 0 } /> ) ;
166+ expect ( screen . getByText ( 'None' ) ) . toBeInTheDocument ( ) ;
120167 } ) ;
121168 } ) ;
122169
0 commit comments