Commit 6f349036 authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo
parent 464f6968
...@@ -397,30 +397,38 @@ describe('Guest', () => { ...@@ -397,30 +397,38 @@ describe('Guest', () => {
}); });
describe('on "loadAnnotations" event', () => { describe('on "loadAnnotations" event', () => {
it('anchors annotations', () => { it('anchors annotations', async () => {
const guest = createGuest(); createGuest();
const ann1 = { id: 1, $tag: 'tag1' }; const ann1 = { target: [], uri: 'uri', $tag: 'tag1' };
const ann2 = { id: 2, $tag: 'tag2' }; const ann2 = { target: [], uri: 'uri', $tag: 'tag2' };
sandbox.stub(guest, 'anchor');
emitSidebarEvent('loadAnnotations', [ann1, ann2]); emitSidebarEvent('loadAnnotations', [ann1, ann2]);
await delay(0);
assert.calledTwice(guest.anchor); assert.calledTwice(fakeBridge.call);
assert.calledWith(guest.anchor, ann1); assert.calledWith(
assert.calledWith(guest.anchor, ann2); fakeBridge.call,
'syncAnchoringStatus',
sinon.match({ target: [], uri: 'uri', $tag: 'tag1' })
);
assert.calledWith(
fakeBridge.call,
'syncAnchoringStatus',
sinon.match({ target: [], uri: 'uri', $tag: 'tag2' })
);
}); });
}); });
describe('on "deleteAnnotation" event', () => { describe('on "deleteAnnotation" event', () => {
it('detaches annotation', () => { it('detaches annotation', () => {
const guest = createGuest(); const guest = createGuest();
const $tag = 'tag1'; const callback = sinon.stub();
sandbox.stub(guest, 'detach'); guest._emitter.subscribe('anchorsChanged', callback);
emitSidebarEvent('deleteAnnotation', $tag); emitSidebarEvent('deleteAnnotation', 'tag1');
assert.calledOnce(guest.detach); assert.calledOnce(callback);
assert.calledWith(guest.detach, $tag); assert.calledWith(callback, []);
}); });
}); });
}); });
......
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