Fix Zotero.Fulltext tests
This commit is contained in:
parent
5815088586
commit
723b4d32e5
|
@ -294,32 +294,7 @@ if(run) {
|
||||||
Zotero.spawn(function* () {
|
Zotero.spawn(function* () {
|
||||||
yield Zotero.Schema.schemaUpdatePromise;
|
yield Zotero.Schema.schemaUpdatePromise;
|
||||||
|
|
||||||
// Init paths for PDF tools and data
|
initPDFToolsPath();
|
||||||
let pdfConvertedFileName = 'pdftotext';
|
|
||||||
let pdfInfoFileName = 'pdfinfo';
|
|
||||||
|
|
||||||
if (Zotero.isWin) {
|
|
||||||
pdfConvertedFileName += '-win.exe';
|
|
||||||
pdfInfoFileName += '-win.exe';
|
|
||||||
}
|
|
||||||
else if (Zotero.isMac) {
|
|
||||||
pdfConvertedFileName += '-mac';
|
|
||||||
pdfInfoFileName += '-mac';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let cpu = Zotero.platform.split(' ')[1];
|
|
||||||
pdfConvertedFileName += '-linux-' + cpu;
|
|
||||||
pdfInfoFileName += '-linux-' + cpu;
|
|
||||||
}
|
|
||||||
|
|
||||||
let pdfToolsPath = OS.Path.join(Zotero.Profile.dir, 'pdftools');
|
|
||||||
let pdfConverterPath = OS.Path.join(pdfToolsPath, pdfConvertedFileName);
|
|
||||||
let pdfInfoPath = OS.Path.join(pdfToolsPath, pdfInfoFileName);
|
|
||||||
let pdfDataPath = OS.Path.join(pdfToolsPath, 'poppler-data');
|
|
||||||
|
|
||||||
Zotero.FullText.setPDFConverterPath(pdfConverterPath);
|
|
||||||
Zotero.FullText.setPDFInfoPath(pdfInfoPath);
|
|
||||||
Zotero.FullText.setPDFDataPath(pdfDataPath);
|
|
||||||
|
|
||||||
return mocha.run();
|
return mocha.run();
|
||||||
})
|
})
|
||||||
|
|
|
@ -473,6 +473,37 @@ function getPromiseError(promise) {
|
||||||
return promise.thenReturn(false).catch(e => e);
|
return promise.thenReturn(false).catch(e => e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init paths for PDF tools and data
|
||||||
|
*/
|
||||||
|
function initPDFToolsPath() {
|
||||||
|
let pdfConvertedFileName = 'pdftotext';
|
||||||
|
let pdfInfoFileName = 'pdfinfo';
|
||||||
|
|
||||||
|
if (Zotero.isWin) {
|
||||||
|
pdfConvertedFileName += '-win.exe';
|
||||||
|
pdfInfoFileName += '-win.exe';
|
||||||
|
}
|
||||||
|
else if (Zotero.isMac) {
|
||||||
|
pdfConvertedFileName += '-mac';
|
||||||
|
pdfInfoFileName += '-mac';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let cpu = Zotero.platform.split(' ')[1];
|
||||||
|
pdfConvertedFileName += '-linux-' + cpu;
|
||||||
|
pdfInfoFileName += '-linux-' + cpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
let pdfToolsPath = OS.Path.join(Zotero.Profile.dir, 'pdftools');
|
||||||
|
let pdfConverterPath = OS.Path.join(pdfToolsPath, pdfConvertedFileName);
|
||||||
|
let pdfInfoPath = OS.Path.join(pdfToolsPath, pdfInfoFileName);
|
||||||
|
let pdfDataPath = OS.Path.join(pdfToolsPath, 'poppler-data');
|
||||||
|
|
||||||
|
Zotero.FullText.setPDFConverterPath(pdfConverterPath);
|
||||||
|
Zotero.FullText.setPDFInfoPath(pdfInfoPath);
|
||||||
|
Zotero.FullText.setPDFDataPath(pdfDataPath);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the nsIFile corresponding to the test data directory
|
* Returns the nsIFile corresponding to the test data directory
|
||||||
* (i.e., test/tests/data)
|
* (i.e., test/tests/data)
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe("Zotero.Fulltext", function () {
|
||||||
// Hidden browser, which requires a browser window, needed for charset detection
|
// Hidden browser, which requires a browser window, needed for charset detection
|
||||||
// (until we figure out a better way)
|
// (until we figure out a better way)
|
||||||
win = yield loadBrowserWindow();
|
win = yield loadBrowserWindow();
|
||||||
|
initPDFToolsPath();
|
||||||
});
|
});
|
||||||
after(function () {
|
after(function () {
|
||||||
if (win) {
|
if (win) {
|
||||||
|
@ -133,7 +134,7 @@ describe("Zotero.Fulltext", function () {
|
||||||
toSync.push({
|
toSync.push({
|
||||||
item: pdfAttachment,
|
item: pdfAttachment,
|
||||||
content: "Zotero [zoh-TAIR-oh] is a free, easy-to-use tool to help you collect, "
|
content: "Zotero [zoh-TAIR-oh] is a free, easy-to-use tool to help you collect, "
|
||||||
+ "organize, cite, and share your research sources.\n\n",
|
+ "organize, cite, and share\nyour research sources.\n\n",
|
||||||
indexedChars: 0,
|
indexedChars: 0,
|
||||||
indexedPages: 1
|
indexedPages: 1
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,6 +9,7 @@ describe("PDF Recognition", function() {
|
||||||
yield Zotero.Promise.all([
|
yield Zotero.Promise.all([
|
||||||
loadZoteroPane().then(w => win = w)
|
loadZoteroPane().then(w => win = w)
|
||||||
]);
|
]);
|
||||||
|
initPDFToolsPath();
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function* () {
|
beforeEach(function* () {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user