Skip to content

Commit

Permalink
Add cleanDOI() tests
Browse files Browse the repository at this point in the history
In advance of zotero#1356

We're not properly handling DOIs in parentheses or brackets (which would
require non-regex logic), so those tests are skipped for now.
  • Loading branch information
dstillman committed Nov 7, 2017
1 parent 24507a7 commit 01c71fd
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/tests/utilitiesTest.js
Expand Up @@ -32,7 +32,33 @@ describe("Zotero.Utilities", function() {
assert.equal(author.lastName, 'Žolynas');
})
});
describe("cleanISBN", function() {


describe("#cleanDOI()", function () {
var cleanDOI = Zotero.Utilities.cleanDOI;
var doi = '10.1088/1748-9326/11/4/048002';

it("should parse a DOI", function () {
assert.equal(cleanDOI(`${doi}`), doi);
});

it("should parse a DOI at the end of a sentence", function () {
assert.equal(cleanDOI(`Foo bar ${doi}. Foo bar`), doi);
});

// FIXME
it.skip("should parse a DOI in parentheses", function () {
assert.equal(cleanDOI(`Foo bar (${doi}) foo bar`), doi);
});

// FIXME
it.skip("should parse a DOI in brackets", function () {
assert.equal(cleanDOI(`Foo bar [${doi}] foo bar`), doi);
});
});


describe("#cleanISBN()", function() {
let cleanISBN = Zotero.Utilities.cleanISBN;
it("should return false for non-ISBN string", function() {
assert.isFalse(cleanISBN(''), 'returned false for empty string');
Expand Down

0 comments on commit 01c71fd

Please sign in to comment.