Add tests for HTTP integration endpoints
This commit is contained in:
parent
f829d7c43e
commit
338afc2b80
2 changed files with 115 additions and 0 deletions
34
test/tests/server_integrationTest.js
Normal file
34
test/tests/server_integrationTest.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
|
||||
describe("MacOS Integration Server", function () {
|
||||
var serverURL;
|
||||
|
||||
before(function* () {
|
||||
this.timeout(20000);
|
||||
Zotero.Prefs.set("httpServer.enabled", true);
|
||||
yield resetDB({
|
||||
thisArg: this,
|
||||
skipBundledFiles: true
|
||||
});
|
||||
|
||||
const serverPort = Zotero.Prefs.get('httpServer.port');
|
||||
serverURL = `http://127.0.0.1:${serverPort}/integration`;
|
||||
});
|
||||
|
||||
describe('/integration/macWordCommand', function () {
|
||||
it('should call Integration.execCommand with passed parameters', async function () {
|
||||
let stub = sinon.stub(Zotero.Integration, 'execCommand');
|
||||
try {
|
||||
await Zotero.HTTP.request(
|
||||
'GET',
|
||||
`${serverURL}/macWordCommand?agent=httpTest&command=httpTestCommand&document=docName&templateVersion=-1`,
|
||||
);
|
||||
|
||||
assert.isTrue(stub.calledOnce);
|
||||
assert.isTrue(stub.firstCall.calledWithExactly('httpTest', 'httpTestCommand', 'docName', '-1'));
|
||||
} finally {
|
||||
stub.restore();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue