Commit d5ace953 authored by Robert Knight's avatar Robert Knight

Reset callback before checking for absence of call

This pattern makes it clearer that we are testing for a callback not
being invoked after a sequence of events.
parent f7ab8ac0
...@@ -235,12 +235,13 @@ describe('annotator/frame-observer', () => { ...@@ -235,12 +235,13 @@ describe('annotator/frame-observer', () => {
const unsubscribe = onDocumentReady(frame, callback); const unsubscribe = onDocumentReady(frame, callback);
await waitForCall(callback); await waitForCall(callback);
callback.resetHistory();
unsubscribe(); unsubscribe();
frame.src = sameOriginURL + '?v2'; frame.src = sameOriginURL + '?v2';
await waitForEvent(frame, 'load'); await waitForEvent(frame, 'load');
assert.calledOnce(callback); assert.notCalled(callback);
}); });
it('does not start polling if "unload" event is received after subscription is canceled', async () => { it('does not start polling if "unload" event is received after subscription is canceled', async () => {
...@@ -253,6 +254,7 @@ describe('annotator/frame-observer', () => { ...@@ -253,6 +254,7 @@ describe('annotator/frame-observer', () => {
const unsubscribe = onDocumentReady(frame, callback); const unsubscribe = onDocumentReady(frame, callback);
clock.tick(); clock.tick();
assert.calledOnce(callback); assert.calledOnce(callback);
callback.resetHistory();
const contentWindow = frame.contentWindow; const contentWindow = frame.contentWindow;
unsubscribe(); unsubscribe();
...@@ -262,7 +264,7 @@ describe('annotator/frame-observer', () => { ...@@ -262,7 +264,7 @@ describe('annotator/frame-observer', () => {
await waitForEvent(frame, 'load'); await waitForEvent(frame, 'load');
clock.tick(50); // Wait for any active polling to trigger clock.tick(50); // Wait for any active polling to trigger
assert.calledOnce(callback); assert.notCalled(callback);
} finally { } finally {
clock.restore(); clock.restore();
} }
......
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