commit 01c71fd970c297c417d16741e26b5966efefdab9
parent 24507a73f6a4f7198fef1fbd5ab26545758c7896
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 7 Nov 2017 15:27:58 -0500
Add cleanDOI() tests
In advance of #1356
We're not properly handling DOIs in parentheses or brackets (which would
require non-regex logic), so those tests are skipped for now.
Diffstat:
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/test/tests/utilitiesTest.js b/test/tests/utilitiesTest.js
@@ -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');