zoteroTest.js (1737B)
1 "use strict"; 2 3 describe("Zotero", function() { 4 describe("#getString()", function () { 5 it("should return the right plural form", function* () { 6 if (Zotero.locale != 'en-US') { 7 this.skip(); 8 } 9 Components.utils.import("resource://gre/modules/PluralForm.jsm"); 10 var str1 = Zotero.getString('fileInterface.itemsWereImported') 11 .split(/;/)[1] 12 .replace('%1$S', 2); 13 var str2 = Zotero.getString('fileInterface.itemsWereImported', 2, 2); 14 Zotero.debug(str1); 15 Zotero.debug(str2); 16 assert.equal(str1, str2); 17 }); 18 }); 19 20 21 describe("#localeCompare", function () { 22 it("shouldn't ignore whitespace", function () { 23 assert.equal(Zotero.localeCompare("Chang", "Chan H"), 1); 24 }); 25 26 it("shouldn't ignore leading punctuation", function () { 27 assert.equal(Zotero.localeCompare("_Abcd", "Abcd"), -1); 28 }); 29 }); 30 31 describe("VersionHeader", function () { 32 describe("#update()", function () { 33 var majorMinorVersion; 34 35 before(function () { 36 majorMinorVersion = Zotero.version.replace(/(\d+\.\d+).*/, '$1'); 37 }); 38 39 it("should add Zotero/[major.minor] to Chrome user agent", function () { 40 var ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36'; 41 assert.equal(Zotero.VersionHeader.update('example.com', ua, ZOTERO_CONFIG.CLIENT_NAME), ua + ` Zotero/${majorMinorVersion}`); 42 }); 43 44 it("should add Zotero/[major.minor] to Firefox user agent", function () { 45 var ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Firefox/60.0'; 46 assert.equal(Zotero.VersionHeader.update('example.com', ua, ZOTERO_CONFIG.CLIENT_NAME), ua + ` Zotero/${majorMinorVersion}`); 47 }); 48 }); 49 }); 50 });