Skip to content

Commit

Permalink
Merge pull request #2558 from NCEAS/bugfix-2557-citation-unit-tests
Browse files Browse the repository at this point in the history
Fix citation model unit tests
  • Loading branch information
rushirajnenuji authored Dec 2, 2024
2 parents 6e26e2a + ee8637d commit 5089123
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions test/js/specs/unit/models/CitationModel.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require([
"../../../../../../../../src/js/models/CitationModel",
"../../../../../../../../src/js/collections/Citations",
"../../../../../../../../src/js/models/metadata/eml211/EML211",
"../../../../../../../../src/js/models/metadata/eml211/EMLParty",
"../../../../../../../../src/js/models/SolrResult",
"models/CitationModel",
"collections/Citations",
"models/metadata/eml211/EML211",
"models/metadata/eml211/EMLParty",
"models/SolrResult",
], function (Citation, Citations, EML211, EMLParty, SolrResult) {
// Configure the Chai assertion library
var should = chai.should();
Expand Down Expand Up @@ -91,12 +91,12 @@ require([
});

it("should convert the origin to CSL JSON", function () {
// We convert to a literal for now because it's too challenging to
// parse first and last names from a string when the strings could also
// be an organization.
const author =
cmParsed.citationMetadata.models[0].get("originArray")[0];
author.should.deep.equal({
family: "LastName",
given: "FirstName",
});
author.should.deep.equal({ literal: "FirstName LastName" });
});

it("should add the doi prefix to the pid", function () {
Expand All @@ -116,12 +116,9 @@ require([

it("should convert origin to CSL JSON", function () {
citation.set("origin", "FirstName LastName");
citation.get("originArray").should.deep.equal([
{
family: "LastName",
given: "FirstName",
},
]);
citation
.get("originArray")
.should.deep.equal([{ literal: "FirstName LastName" }]);
});

it("should automatically set DOI URLS from DOIs", function () {
Expand Down Expand Up @@ -236,8 +233,7 @@ require([

it("should set the originArray", function () {
const csl = citation.get("originArray")[0];
csl.family.should.equal("LastName");
csl.given.should.equal("FirstName");
csl.literal.should.equal("FirstName LastName");
});

it("should set the pid", function () {
Expand Down

0 comments on commit 5089123

Please sign in to comment.