mirror of
https://github.com/zotero/zotero.git
synced 2026-10-04 02:31:47 +00:00
use local sinon sandbox
to avoid trying to restore sinon on dead reader in later tests
This commit is contained in:
parent
99dbdfa9ac
commit
e53e412504
1 changed files with 11 additions and 12 deletions
|
|
@ -459,9 +459,13 @@ describe("Smart copy", function () {
|
|||
|
||||
describe("Reader tab", function () {
|
||||
var reader;
|
||||
var hasFocusStub;
|
||||
// Use a local sandbox: sinon's default sandbox tracks every stub
|
||||
// forever, so a later `sinon.restore()` elsewhere would
|
||||
// re-invoke our stub's restore against the already dead reader.
|
||||
var sandbox;
|
||||
|
||||
before(async function () {
|
||||
sandbox = sinon.createSandbox();
|
||||
reader = await Zotero.Reader.open(attachment.id);
|
||||
await reader._initPromise;
|
||||
await reader._internalReader._primaryView.initializedPromise;
|
||||
|
|
@ -469,7 +473,7 @@ describe("Smart copy", function () {
|
|||
await Zotero.Promise.delay(50);
|
||||
}
|
||||
// Pretend that the reader is focused
|
||||
hasFocusStub = sinon.stub(reader._iframeWindow.document, 'hasFocus').returns(true);
|
||||
sandbox.stub(reader._iframeWindow.document, 'hasFocus').returns(true);
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
|
|
@ -477,7 +481,7 @@ describe("Smart copy", function () {
|
|||
});
|
||||
|
||||
after(function () {
|
||||
hasFocusStub.restore();
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it("should copy parent citation when nothing is selected in the reader", function () {
|
||||
|
|
@ -487,15 +491,10 @@ describe("Smart copy", function () {
|
|||
});
|
||||
|
||||
it("should copy selected annotation", function () {
|
||||
let stub = sinon.stub(reader, 'getSelectedAnnotationIDs').returns([annotation.key]);
|
||||
try {
|
||||
clearClipboard();
|
||||
doc.getElementById('key_smartCopy').doCommand();
|
||||
assert.include(getClipboardText(), annotation.annotationText);
|
||||
}
|
||||
finally {
|
||||
stub.restore();
|
||||
}
|
||||
sandbox.stub(reader, 'getSelectedAnnotationIDs').returns([annotation.key]);
|
||||
clearClipboard();
|
||||
doc.getElementById('key_smartCopy').doCommand();
|
||||
assert.include(getClipboardText(), annotation.annotationText);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue