Skip to content

Commit 5d5903e

Browse files
test(plugin-meetings): add tests for deregister events in annotations
1 parent 10d89e7 commit 5d5903e

File tree

2 files changed

+31
-1
lines changed
  • packages/@webex/plugin-meetings

2 files changed

+31
-1
lines changed

packages/@webex/plugin-meetings/src/annotation/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class AnnotationChannel extends WebexPlugin implements IAnnotationChannel {
124124
if (this.hasSubscribedToEvents) {
125125
// @ts-ignore
126126
this.webex.internal.llm.off('event:relay.event', this.eventDataProcessor);
127+
this.hasSubscribedToEvents = false;
127128
}
128129
}
129130

packages/@webex/plugin-meetings/test/unit/spec/annotation/index.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,35 @@ describe('live-annotation', () => {
413413
});
414414
});
415415
});
416-
});
417416

417+
describe('#deregisterEvents', () => {
418+
let llmOn;
419+
let llmOff;
420+
421+
beforeEach(() => {
422+
llmOn = sinon.spy(webex.internal.llm, 'on');
423+
llmOff = sinon.spy(webex.internal.llm, 'off');
424+
});
425+
426+
it('cleans up events', () => {
427+
annotationService.locusUrlUpdate(locusUrl);
428+
assert.calledWith(
429+
llmOn,
430+
'event:relay.event',
431+
annotationService.eventDataProcessor,
432+
annotationService
433+
);
434+
assert.match(annotationService.hasSubscribedToEvents, true);
435+
436+
annotationService.deregisterEvents();
437+
assert.calledWith(llmOff, 'event:relay.event', annotationService.eventDataProcessor);
438+
assert.match(annotationService.hasSubscribedToEvents, false);
439+
});
440+
441+
it('does not call llm off if events have not been registered', () => {
442+
annotationService.deregisterEvents();
443+
assert.notCalled(llmOff);
444+
});
445+
});
446+
});
418447
});

0 commit comments

Comments
 (0)