-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
245 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
|
||
const expectedDataCiteStructure = { | ||
"data": { | ||
"type": "dois", | ||
"attributes": { | ||
"prefix": "10.21966", | ||
"creators": [ | ||
{ | ||
"name": "Sorochak, Austen", | ||
"nameType": "Personal", | ||
"givenName": "Austen", | ||
"familyName": "Sorochak", | ||
"affiliation": [ | ||
{ | ||
"name": "Royal Roads University", | ||
"schemeUri": "https://ror.org", | ||
"affiliationIdentifier": "https://ror.org/05w4ste42", | ||
"affiliationIdentifierScheme": "ROR", | ||
}, | ||
], | ||
}, | ||
{ | ||
"name": "PumpkinKing, Jack", | ||
"nameType": "Personal", | ||
"givenName": "Jack", | ||
"familyName": "PumpkinKing", | ||
"affiliation": [], | ||
}, | ||
], | ||
"titles": [ | ||
{ | ||
"lang": "en", | ||
"title": "This is a mock record", | ||
}, | ||
{ | ||
"lang": "fr", | ||
"title": "Il s'agit d'un faux record", | ||
}, | ||
], | ||
"publisher": "Royal Roads University", | ||
"publicationYear": 2023, | ||
"subjects": [ | ||
{ | ||
"lang": "en", | ||
"subject": "abundance and biomass", | ||
}, | ||
{ | ||
"lang": "fr", | ||
"subject": "abondance et biomasse", | ||
}, | ||
], | ||
"dates": [ | ||
{ | ||
"date": "2023-10-01T19:00:00.000Z", | ||
"dateType": "Collected", | ||
"dateInformation": "Start date when data was first collected", | ||
}, | ||
{ | ||
"date": "2023-10-04T19:00:00.000Z", | ||
"dateType": "Collected", | ||
"dateInformation": "End date when data was last collected", | ||
}, | ||
], | ||
"rightsList": [ | ||
{ | ||
"rights": "Creative Commons Attribution 4.0 Attribution", | ||
"rightsUri": "https://creativecommons.org/licenses/by/4.0", | ||
"schemeUri": "https://spdx.org/licenses/", | ||
"rightsIdentifier": "CC-BY-4.0", | ||
"rightsIdentifierScheme": "SPDX", | ||
}, | ||
], | ||
"descriptions": [ | ||
{ | ||
"lang": "en", | ||
"description": "This is a mock record to be used in unit tests, to ensure the continued functionality of the mapping function.", | ||
"descriptionType": "Abstract", | ||
}, | ||
{ | ||
"lang": "fr", | ||
"description": "Il s'agit d'un enregistrement fictif à utiliser dans les tests unitaires, afin de garantir la fonctionnalité continue de la fonction de mappage.", | ||
"descriptionType": "Abstract", | ||
}, | ||
], | ||
"geoLocations": [ | ||
{ | ||
"geoLocationBox": { | ||
"eastBoundLongitude": -160, | ||
"northBoundLatitude": 60, | ||
"southBoundLatitude": 45, | ||
"westBoundLongitude": -120, | ||
}, | ||
}, | ||
], | ||
"types": { | ||
"resourceTypeGeneral": "Dataset", | ||
}, | ||
"url": "https://catalogue.hakai.org/dataset/ca-cioos_b6f44266-5815-48bb-bd0c-dd050c6fe465", | ||
}, | ||
}, | ||
} | ||
|
||
export default expectedDataCiteStructure; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
|
||
const mockMetadataRecord = { | ||
"title": { | ||
"en": "This is a mock record", | ||
"fr": "Il s'agit d'un faux record", | ||
}, | ||
"abstract": { | ||
"en": "This is a mock record to be used in unit tests, to ensure the continued functionality of the mapping function.", | ||
"fr": "Il s'agit d'un enregistrement fictif à utiliser dans les tests unitaires, afin de garantir la fonctionnalité continue de la fonction de mappage.", | ||
}, | ||
"keywords": { | ||
"en": [ | ||
"abundance and biomass", | ||
], | ||
"fr": [ | ||
"abondance et biomasse", | ||
], | ||
}, | ||
"eov": [ | ||
"dissolvedOrganicCarbon", | ||
], | ||
"progress": "onGoing", | ||
"distribution": [], | ||
"dateStart": "2023-10-01T19:00:00.000Z", | ||
"dateEnd": "2023-10-04T19:00:00.000Z", | ||
"map": { | ||
"east": "-160", | ||
"north": "60", | ||
"polygon": "", | ||
"south": "45", | ||
"west": "-120", | ||
}, | ||
"verticalExtentMin": "", | ||
"verticalExtentMax": "", | ||
"datePublished": "2023-10-26T19:00:00.000Z", | ||
"dateRevised": null, | ||
"edition": "", | ||
"recordID": "-Nhi6_2lQjNwKkzdv_Qu", | ||
"instruments": [], | ||
"platform": "", | ||
"platformID": "", | ||
"platformDescription": "", | ||
"language": "en", | ||
"license": "CC-BY-4.0", | ||
"contacts": [ | ||
{ | ||
"role": [ | ||
"custodian", | ||
], | ||
"orgName": "Royal Roads University", | ||
"orgEmail": "", | ||
"orgURL": "http://www.royalroads.ca/", | ||
"orgAdress": "", | ||
"orgCity": "Victoria", | ||
"orgCountry": "Canada", | ||
"orgRor": "https://ror.org/05w4ste42", | ||
"indPosition": "", | ||
"indEmail": "", | ||
"indOrcid": "", | ||
"givenNames": "Austen", | ||
"lastName": "Sorochak", | ||
"inCitation": true, | ||
}, | ||
{ | ||
"role": [], | ||
"orgName": "", | ||
"orgEmail": "", | ||
"orgURL": "", | ||
"orgAdress": "", | ||
"orgCity": "", | ||
"orgCountry": "", | ||
"orgRor": "", | ||
"indPosition": "", | ||
"indEmail": "", | ||
"indOrcid": "", | ||
"givenNames": "Jack", | ||
"lastName": "PumpkinKing", | ||
"inCitation": true, | ||
}, | ||
{ | ||
"role": [ | ||
"publisher", | ||
], | ||
"orgName": "Royal Roads University", | ||
"orgEmail": "", | ||
"orgURL": "", | ||
"orgAdress": "", | ||
"orgCity": "", | ||
"orgCountry": "", | ||
"orgRor": "", | ||
"indPosition": "", | ||
"indEmail": "", | ||
"indOrcid": "", | ||
"givenNames": "", | ||
"lastName": "", | ||
"inCitation": true, | ||
}, | ||
], | ||
"status": "", | ||
"comment": "", | ||
"limitations": "", | ||
"lastEditedBy": { | ||
"displayName": "Austen Sorochak", | ||
"email": "[email protected]", | ||
}, | ||
"category": "", | ||
"verticalExtentDirection": "", | ||
"datasetIdentifier": "", | ||
"doiCreationStatus": "", | ||
"noPlatform": false, | ||
"filename": "", | ||
"organization": "", | ||
"timeFirstPublished": "", | ||
"identifier": "b6f44266-5815-48bb-bd0c-dd050c6fe465", | ||
"created": "2023-11-03T21:04:37.548Z", | ||
"userID": "gP03Su7SUndv1bwlW6YnBhtAwSw2", | ||
} | ||
|
||
export default mockMetadataRecord |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import recordToDataCite from './../utils/recordToDataCite' | ||
import licenses from './../utils/licenses'; | ||
import regions from './../regions'; | ||
import mockMetadataRecord from '../__testData__/mockMetadataRecord'; | ||
import expectedDataCiteStructure from '../__testData__/expectedDataCiteStructure'; | ||
|
||
const language = 'en'; | ||
const region = 'hakai'; | ||
|
||
describe('recordToDataCite', () => { | ||
it('should correctly map metadata record to DataCite format', () => { | ||
|
||
const testResult = recordToDataCite(mockMetadataRecord, language, region); | ||
|
||
// Assert that the output matches the expected structure | ||
expect(testResult).toEqual(expectedDataCiteStructure); | ||
|
||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters