From edfecfcf9be4db76a204f965dca19291fb71e964 Mon Sep 17 00:00:00 2001 From: Gaurav Vaidya Date: Tue, 2 Jul 2019 18:35:21 -0400 Subject: [PATCH] Updated SpecimenWrapper tests to test for basisOfRecord. --- test/specimens.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/specimens.js b/test/specimens.js index 151b9d3e..5ef11b58 100644 --- a/test/specimens.js +++ b/test/specimens.js @@ -24,17 +24,21 @@ describe('SpecimenWrapper', function () { it('should be able to extract an occurenceID and catalogNumber from simple specimen IDs', function () { const wrapper = new phyx.SpecimenWrapper({ occurrenceID: 'Wall 2527, Fiji (uc)', + 'dwc:basisOfRecord': 'PreservedSpecimen', }); expect(wrapper.occurrenceID).to.equal('Wall 2527, Fiji (uc)'); expect(wrapper.catalogNumber).to.equal('Wall 2527, Fiji (uc)'); + expect(wrapper.basisOfRecord).to.equal('PreservedSpecimen'); }); it('should extract institutionCode and catalogNumber from a institutionCode:catalogNumber combination', function () { const wrapper = new phyx.SpecimenWrapper({ occurrenceID: 'FMNH:PR 2081', + 'dwc:basisOfRecord': 'PreservedSpecimen', }); expect(wrapper.occurrenceID).to.equal('FMNH:PR 2081'); expect(wrapper.institutionCode).to.equal('FMNH'); expect(wrapper.catalogNumber).to.equal('PR 2081'); + expect(wrapper.basisOfRecord).to.equal('PreservedSpecimen'); }); it('should extract occurenceID, institutionCode and catalogNumber from Darwin Core triples', function () { const wrapper = new phyx.SpecimenWrapper({ @@ -44,6 +48,7 @@ describe('SpecimenWrapper', function () { expect(wrapper.institutionCode).to.equal('FMNH'); expect(wrapper.collectionCode).to.equal('PR'); expect(wrapper.catalogNumber).to.equal('2081'); + expect(wrapper.basisOfRecord).to.be.undefined; }); it('should be able to extract the same occurrenceID from different representations', function () { expect(new phyx.SpecimenWrapper({ occurrenceID: 'urn:catalog:::MVZ225749' }).occurrenceID) @@ -69,5 +74,13 @@ describe('SpecimenWrapper', function () { expect(wrapper.collectionCode).to.be.undefined; expect(wrapper.catalogNumber).to.be.undefined; }); + it('should be able to create a specimen JSON record from an occurrence ID', function () { + const specimen = phyx.SpecimenWrapper.fromOccurrenceID('FMNH:PR:2081'); + expect(specimen.occurrenceID).to.equal('FMNH:PR:2081'); + expect(specimen.institutionCode).to.equal('FMNH'); + expect(specimen.collectionCode).to.equal('PR'); + expect(specimen.catalogNumber).to.equal('2081'); + expect(specimen['dwc:basisOfRecord']).to.equal('PreservedSpecimen'); + }); }); });