@@ -11,6 +11,7 @@ import ReactDOM from 'react-dom';
1111import expect from 'expect' ;
1212import TestUtils from 'react-dom/test-utils' ;
1313import CatalogCard from '../datasets/CatalogCard' ;
14+ import { GEONODE_CATEGORY_FILTER } from '../../../api/catalog/GeoNode' ;
1415
1516describe ( 'CatalogCard component' , ( ) => {
1617 const record = {
@@ -136,4 +137,44 @@ describe('CatalogCard component', () => {
136137 const card = document . querySelector ( '.ms-catalog-card.disabled' ) ;
137138 expect ( card ) . toBeTruthy ( ) ;
138139 } ) ;
140+
141+ it ( 'renders GeoNode category tag label while preserving identifier as filter value' , ( ) => {
142+ const actions = {
143+ onTagClick : ( ) => { }
144+ } ;
145+ const spyOnTagClick = expect . spyOn ( actions , 'onTagClick' ) ;
146+ const geonodeRecord = {
147+ ...record ,
148+ tagFilterType : 'category' ,
149+ tags : [ {
150+ identifier : 'boundaries' ,
151+ label : 'Boundaries'
152+ } ]
153+ } ;
154+
155+ ReactDOM . render ( < CatalogCard
156+ includeAddToMap = { false }
157+ multiSelect = { false }
158+ loadingRecords = { false }
159+ filters = { {
160+ [ GEONODE_CATEGORY_FILTER ] : [ 'boundaries' ]
161+ } }
162+ record = { geonodeRecord }
163+ onToggle = { ( ) => { } }
164+ onAdd = { ( ) => { } }
165+ onTagClick = { actions . onTagClick }
166+ /> , document . getElementById ( 'container' ) ) ;
167+
168+ const tagButton = document . querySelector ( '.ms-resource-card-tag-button' ) ;
169+ expect ( tagButton ) . toBeTruthy ( ) ;
170+ expect ( tagButton . textContent ) . toBe ( 'Boundaries' ) ;
171+ expect ( tagButton . getAttribute ( 'title' ) ) . toBe ( 'Boundaries' ) ;
172+ expect ( tagButton . className . includes ( 'selected' ) ) . toBe ( true ) ;
173+
174+ TestUtils . Simulate . click ( tagButton , { stopPropagation : ( ) => { } } ) ;
175+
176+ expect ( spyOnTagClick ) . toHaveBeenCalled ( ) ;
177+ expect ( spyOnTagClick . calls [ 0 ] . arguments [ 0 ] ) . toBe ( 'boundaries' ) ;
178+ expect ( spyOnTagClick . calls [ 0 ] . arguments [ 1 ] ) . toEqual ( geonodeRecord ) ;
179+ } ) ;
139180} ) ;
0 commit comments