@@ -137,6 +137,9 @@ describe('Gn4FieldMapper', () => {
137137 const result = mappingFn ( output , source )
138138 expect ( result ) . toEqual ( {
139139 title : 'Default title' ,
140+ extras : {
141+ resourceTitleObject : { default : 'Default title' , langfre : 'French title' } ,
142+ } ,
140143 } )
141144 } )
142145 it ( 'resourceAbstractObject - should return a function that correctly maps the field to fre lang' , ( ) => {
@@ -153,6 +156,27 @@ describe('Gn4FieldMapper', () => {
153156 const result = mappingFn ( output , source )
154157 expect ( result ) . toEqual ( {
155158 abstract : 'French abstract' ,
159+ extras : {
160+ resourceAbstractObject : { default : 'Default abstract' , langfre : 'French abstract' } ,
161+ } ,
162+ } )
163+ } )
164+ it ( 'resourceAltTitleObject - should store alt title array in extras' , ( ) => {
165+ const fieldName = 'resourceAltTitleObject'
166+ const mappingFn = service . getMappingFn ( fieldName )
167+ const output = { }
168+ const source = {
169+ resourceAltTitleObject : [
170+ { langfre : 'Titre alternatif FR' , langger : 'Alternativer Titel DE' } ,
171+ ] ,
172+ }
173+ const result = mappingFn ( output , source )
174+ expect ( result ) . toEqual ( {
175+ extras : {
176+ resourceAltTitleObject : [
177+ { langfre : 'Titre alternatif FR' , langger : 'Alternativer Titel DE' } ,
178+ ] ,
179+ } ,
156180 } )
157181 } )
158182 it ( 'overview - should return a function that correctly maps the field' , ( ) => {
@@ -194,7 +218,43 @@ describe('Gn4FieldMapper', () => {
194218 } ,
195219 }
196220 const result = mappingFn ( output , source )
197- expect ( result ) . toEqual ( { status : 'completed' } )
221+ expect ( result ) . toEqual ( { status : 'completed' , extras : { cl_statusObject : { key : 'completed' , default : 'Finalisé' , langfre : 'Finalisé' , link : 'http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_ProgressCode' } } } )
222+ } )
223+ it ( 'cl_subTopicCategory - should return a function that maps subtopics' , ( ) => {
224+ translateService . currentLang = 'de'
225+ const fieldName = 'cl_subTopicCategory'
226+ const mappingFn = service . getMappingFn ( fieldName )
227+ const output = { }
228+ const source = {
229+ cl_subTopicCategory : [
230+ { default : 'Subtopic 1' , langger : 'Unterthema 1' } ,
231+ { default : 'Subtopic 2' , langger : 'Unterthema 2' } ,
232+ ] ,
233+ }
234+ const result = mappingFn ( output , source )
235+ expect ( result ) . toEqual ( {
236+ subtopics : [ 'Unterthema 1' , 'Unterthema 2' ] ,
237+ } )
238+ } )
239+ it ( 'MD_LegalConstraintsOtherConstraintsObject - should store in extras and add to legalConstraints' , ( ) => {
240+ translateService . currentLang = 'de'
241+ const fieldName = 'MD_LegalConstraintsOtherConstraintsObject'
242+ const mappingFn = service . getMappingFn ( fieldName )
243+ const output = { }
244+ const source = {
245+ MD_LegalConstraintsOtherConstraintsObject : [
246+ { default : 'CC-BY' , langger : 'CC-BY' } ,
247+ ] ,
248+ }
249+ const result = mappingFn ( output , source )
250+ expect ( result ) . toEqual ( {
251+ legalConstraints : [ { text : 'CC-BY' } ] ,
252+ extras : {
253+ MD_LegalConstraintsOtherConstraintsObject : [
254+ { default : 'CC-BY' , langger : 'CC-BY' } ,
255+ ] ,
256+ } ,
257+ } )
198258 } )
199259 it ( 'isHarvested - should return a function that correctly maps the field' , ( ) => {
200260 const fieldName = 'isHarvested'
@@ -216,6 +276,60 @@ describe('Gn4FieldMapper', () => {
216276 const result = mappingFn ( output , source )
217277 expect ( result ) . toEqual ( { extras : { edit : true } } )
218278 } )
279+ it ( 'linkProtocol - should return a function that stores protocols in extras' , ( ) => {
280+ const fieldName = 'linkProtocol'
281+ const mappingFn = service . getMappingFn ( fieldName )
282+ const output = { }
283+ const source = {
284+ linkProtocol : [ 'MAP:Preview' , 'OGC:WMS' , 'WWW:DOWNLOAD-URL' ] ,
285+ }
286+ const result = mappingFn ( output , source )
287+ expect ( result ) . toEqual ( {
288+ extras : {
289+ linkProtocol : [ 'MAP:Preview' , 'OGC:WMS' , 'WWW:DOWNLOAD-URL' ] ,
290+ } ,
291+ } )
292+ } )
293+ it ( 'format - should return a function that stores formats in extras' , ( ) => {
294+ const fieldName = 'format'
295+ const mappingFn = service . getMappingFn ( fieldName )
296+ const output = { }
297+ const source = {
298+ format : [ 'ESRI Shapefile (SHP)' , 'GeoJSON' ] ,
299+ }
300+ const result = mappingFn ( output , source )
301+ expect ( result ) . toEqual ( {
302+ extras : {
303+ format : [ 'ESRI Shapefile (SHP)' , 'GeoJSON' ] ,
304+ } ,
305+ } )
306+ } )
307+ it ( 'featureTypes - should return a function that stores featureTypes in extras' , ( ) => {
308+ const fieldName = 'featureTypes'
309+ const mappingFn = service . getMappingFn ( fieldName )
310+ const output = { }
311+ const source = {
312+ featureTypes : [
313+ {
314+ typeName : 'Bornes parcellaires' ,
315+ definition : '' ,
316+ attributeTable : [ { name : 'ID' , type : 'string' } ] ,
317+ } ,
318+ ] ,
319+ }
320+ const result = mappingFn ( output , source )
321+ expect ( result ) . toEqual ( {
322+ extras : {
323+ featureTypes : [
324+ {
325+ typeName : 'Bornes parcellaires' ,
326+ definition : '' ,
327+ attributeTable : [ { name : 'ID' , type : 'string' } ] ,
328+ } ,
329+ ] ,
330+ } ,
331+ } )
332+ } )
219333 it ( 'languages - should return a list of languages even with unsupported ones and without defaultLang' , ( ) => {
220334 const fieldName = 'otherLanguage'
221335 const mappingFn = service . getMappingFn ( fieldName )
0 commit comments