Skip to content

Commit

Permalink
Add unit tests for the EMLAnnotations collection
Browse files Browse the repository at this point in the history
Issue #2542
  • Loading branch information
robyngit committed Oct 15, 2024
1 parent 0ac3cce commit 6189421
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/config/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"./js/specs/unit/models/metadata/eml211/EMLParty.spec.js",
"./js/specs/unit/models/metadata/eml211/EMLTemporalCoverage.spec.js",
"./js/specs/unit/collections/metadata/eml/EMLMissingValueCodes.spec.js",
"./js/specs/unit/collections/metadata/eml/EMLAnnotations.spec.js",
"./js/specs/unit/models/metadata/eml211/EMLMissingValueCode.spec.js",
"./js/specs/unit/models/metadata/eml211/EMLDistribution.spec.js",
"./js/specs/unit/models/metadata/eml211/EMLGeoCoverage.spec.js",
Expand Down
49 changes: 49 additions & 0 deletions test/js/specs/unit/collections/metadata/eml/EMLAnnotations.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"use strict";

define([
"/test/js/specs/shared/clean-state.js",
"collections/metadata/eml/EMLAnnotations",
], (cleanState, EMLAnnotations) => {
const should = chai.should();
const expect = chai.expect;

describe("Accordion Test Suite", () => {
const state = cleanState(() => {
const annotations = new EMLAnnotations({
propertyLabel: "Property Label",
propertyURI: "http://example.com/property",
valueLabel: "Value Label",
valueURI: "http://example.com/value",
});
return { annotations };
}, beforeEach);

it("creates an EMLAnnotations collection", () => {
state.annotations.should.be.instanceof(EMLAnnotations);
});

it("checks for duplicates", () => {
state.annotations.hasDuplicateOf(state.annotations.at(0)).should.be.true;
});

it("replaces duplicates", () => {
state.annotations.replaceDuplicateWith(state.annotations.at(0));
state.annotations.length.should.equal(1);
});

it("adds annotations", () => {
state.annotations.add({
propertyLabel: "Property Label2",
propertyURI: "http://example.com/property2",
valueLabel: "Value Label2",
valueURI: "http://example.com/value2",
});
state.annotations.length.should.equal(2);
});

it("removes annotations", () => {
state.annotations.remove(state.annotations.at(0));
state.annotations.length.should.equal(0);
});
});
});

0 comments on commit 6189421

Please sign in to comment.