-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for the EMLAnnotations collection
Issue #2542
- Loading branch information
Showing
2 changed files
with
50 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
49 changes: 49 additions & 0 deletions
49
test/js/specs/unit/collections/metadata/eml/EMLAnnotations.spec.js
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,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); | ||
}); | ||
}); | ||
}); |