Commit e3d67074 authored by Robert Knight's avatar Robert Knight

Add a couple of missing `FrameSyncService` tests

 - Add tests for `scrollToAnnotation`

 - Add test for failed `getDocumentInfo` request to host page
parent f4d8b73b
......@@ -46,7 +46,7 @@ const fixtures = {
},
};
describe('sidebar/services/frame-sync', function () {
describe('FrameSyncService', () => {
let fakeAnnotationsService;
let fakeStore;
let fakeBridge;
......@@ -306,6 +306,7 @@ describe('sidebar/services/frame-sync', function () {
call: function (name, callback) {
callback(null, frameInfo);
},
destroy: sinon.stub(),
};
it("adds the page's metadata to the frames list", function () {
......@@ -319,6 +320,15 @@ describe('sidebar/services/frame-sync', function () {
uri: frameInfo.uri,
});
});
it('closes the channel and does not add frame to store if getting document info fails', () => {
fakeChannel.call = (name, callback) => callback('Something went wrong');
fakeBridge.emit('connect', fakeChannel);
assert.called(fakeChannel.destroy);
assert.notCalled(fakeStore.connectFrame);
});
});
context('when a frame is destroyed', function () {
......@@ -388,7 +398,7 @@ describe('sidebar/services/frame-sync', function () {
});
});
describe('when annotations are focused in the sidebar', () => {
describe('#focusAnnotations', () => {
it('should update the focused annotations in the store', () => {
frameSync.focusAnnotations(['a1', 'a2']);
assert.calledWith(
......@@ -396,7 +406,7 @@ describe('sidebar/services/frame-sync', function () {
sinon.match.array.deepEquals(['a1', 'a2'])
);
});
it('notify the host page', () => {
it('should notify the host page', () => {
frameSync.focusAnnotations([1, 2]);
assert.calledWith(
fakeBridge.call,
......@@ -405,4 +415,11 @@ describe('sidebar/services/frame-sync', function () {
);
});
});
describe('#scrollToAnnotation', () => {
it('should scroll to the annotation in the host page', () => {
frameSync.scrollToAnnotation('atag');
assert.calledWith(fakeBridge.call, 'scrollToAnnotation', 'atag');
});
});
});
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