Add sinon-test for easier test stub cleanup

This commit is contained in:
Adomas Venčkauskas 2018-08-24 11:32:41 +03:00
parent 5b7c0a98f7
commit 2f51c130cc
6 changed files with 71 additions and 58 deletions

6
package-lock.json generated
View file

@ -4634,6 +4634,12 @@
}
}
},
"sinon-test": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/sinon-test/-/sinon-test-2.2.1.tgz",
"integrity": "sha512-j2X8jRz6GG/xBxCss3P36Q8QVdwV7DnOXOe4cNCsI0pbKRc2sErGTsHDimqZ1tiOmxw8ANog68T0SQq8hVMQRw==",
"dev": true
},
"slash": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz",

View file

@ -46,6 +46,7 @@
"multimatch": "^2.1.0",
"node-sass": "^4.9.0",
"sinon": "^4.5.0",
"sinon-test": "^2.2.1",
"universalify": "^0.1.1"
}
}

View file

@ -45,6 +45,13 @@ const browserifyConfigs = [
config: {
standalone: 'chaiAsPromised'
}
},
{
src: 'node_modules/sinon-test/dist/sinon-test.js',
dest: 'test/resource/sinon-test.js',
config: {
standalone: 'sinonTest'
}
}
];

View file

@ -11,6 +11,7 @@
<script src="resource://zotero-unit/mocha.js"></script>
<script src="resource://zotero-unit/co-mocha.js"></script>
<script src="resource://zotero-unit/sinon.js"></script>
<script src="resource://zotero-unit/sinon-test.js"></script>
<script src="resource://zotero-unit/pako_inflate.js"></script>
<script src="support.js" type="application/javascript;version=1.8"></script>
<script src="runtests.js" type="application/javascript;version=1.8"></script>

View file

@ -171,6 +171,8 @@ mocha.setup({
coMocha(Mocha);
sinon.test = sinonTest(sinon);
before(function () {
// Store all prefs set in runtests.sh
Components.utils.import("resource://zotero/config.js");

View file

@ -790,8 +790,7 @@ describe("Connector Server", function () {
assert.equal(item.getField('title'), 'Title');
});
it("should save a PDF to the current selected collection and retrieve metadata", async function () {
try {
it("should save a PDF to the current selected collection and retrieve metadata", sinon.test(async function () {
var collection = await createDataObject('collection');
await waitForItemsLoad(win);
@ -846,10 +845,7 @@ describe("Connector Server", function () {
progressWindow.close();
Zotero.RecognizePDF.cancel();
assert.isFalse(item.isTopLevelItem());
} finally {
stub.restore();
}
});
}));
it("should switch to My Library if a read-only library is selected", function* () {
var group = yield createGroup({