Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix citation model unit tests #2558

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading