Commit c6a65f46 authored by Robert Knight's avatar Robert Knight

Add tests for scenarios where client shouldn't be re-injected

I don't know if these scenarios can actually happen in the real VS viewer, but
this feels like appropriate defensive coding.
parent 1895eec5
...@@ -137,6 +137,31 @@ describe('annotator/integrations/vitalsource', () => { ...@@ -137,6 +137,31 @@ describe('annotator/integrations/vitalsource', () => {
assert.calledWith(fakeGuest.injectClient, fakeViewer.contentFrame); assert.calledWith(fakeGuest.injectClient, fakeViewer.contentFrame);
}); });
it("doesn't re-inject if content frame is removed", async () => {
fakeGuest.injectClient.resetHistory();
// Remove the content frame. This will trigger a re-injection check, but
// do nothing as there is no content frame.
fakeViewer.contentFrame.remove();
await delay(0);
assert.notCalled(fakeGuest.injectClient);
});
it("doesn't re-inject if content frame siblings change", async () => {
fakeGuest.injectClient.resetHistory();
// Modify the DOM tree. This will trigger a re-injection check, but do
// nothing as we've already handled the current frame.
fakeViewer.contentFrame.insertAdjacentElement(
'afterend',
document.createElement('div')
);
await delay(0);
assert.notCalled(fakeGuest.injectClient);
});
it('does not allow annotation in the container frame', async () => { it('does not allow annotation in the container frame', async () => {
assert.equal(integration.canAnnotate(), false); assert.equal(integration.canAnnotate(), false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment