Commit 57d1e2c9 authored by Juan Corona's avatar Juan Corona

Add tests for when a frame is destroyed

parent db578451
...@@ -21,6 +21,19 @@ describe('frames reducer', function () { ...@@ -21,6 +21,19 @@ describe('frames reducer', function () {
}); });
}); });
describe('#destroyFrame', function () {
it('removes the frame from the list of connected frames', function () {
var frameList = [{uri: 'http://example.com'}, {uri: 'http://example.org'}];
var state = init();
frameList.forEach(function (frame) {
state = update(state, actions.connectFrame(frame));
});
assert.deepEqual(frames.frames(state), frameList);
var updatedState = update(state, actions.destroyFrame(frameList[0]));
assert.deepEqual(frames.frames(updatedState), [frameList[1]]);
});
});
describe('#updateFrameAnnotationFetchStatus', function () { describe('#updateFrameAnnotationFetchStatus', function () {
it('updates the isAnnotationFetchComplete status of the frame', function () { it('updates the isAnnotationFetchComplete status of the frame', function () {
var frame = { var frame = {
......
...@@ -39,6 +39,12 @@ var fixtures = { ...@@ -39,6 +39,12 @@ var fixtures = {
link: [{href: 'http://example.org/paper.pdf'}, {href:'urn:1234'}], link: [{href: 'http://example.org/paper.pdf'}, {href:'urn:1234'}],
}, },
}, },
// The entry in the list of frames currently connected
framesListEntry: {
uri: 'http://example.com',
isAnnotationFetchComplete: true,
},
}; };
describe('FrameSync', function () { describe('FrameSync', function () {
...@@ -55,9 +61,10 @@ describe('FrameSync', function () { ...@@ -55,9 +61,10 @@ describe('FrameSync', function () {
beforeEach(function () { beforeEach(function () {
fakeAnnotationUI = fakeStore({annotations: []}, { fakeAnnotationUI = fakeStore({annotations: []}, {
connectFrame: sinon.stub(), connectFrame: sinon.stub(),
destroyFrame: sinon.stub(),
findIDsForTags: sinon.stub(), findIDsForTags: sinon.stub(),
focusAnnotations: sinon.stub(), focusAnnotations: sinon.stub(),
frames: sinon.stub().returns([{uri: 'http://example.com', isAnnotationFetchComplete: true }]), frames: sinon.stub().returns([fixtures.framesListEntry]),
selectAnnotations: sinon.stub(), selectAnnotations: sinon.stub(),
selectTab: sinon.stub(), selectTab: sinon.stub(),
toggleSelectedAnnotations: sinon.stub(), toggleSelectedAnnotations: sinon.stub(),
...@@ -214,6 +221,16 @@ describe('FrameSync', function () { ...@@ -214,6 +221,16 @@ describe('FrameSync', function () {
}); });
}); });
context('when a frame is destroyed', function () {
var frameUri = fixtures.framesListEntry.uri;
it("adds the page's metadata to the frames list", function () {
fakeBridge.emit('destroyFrame', frameUri);
assert.calledWith(fakeAnnotationUI.destroyFrame, fixtures.framesListEntry);
});
});
describe('on "showAnnotations" message', function () { describe('on "showAnnotations" message', function () {
it('selects annotations which have an ID', function () { it('selects annotations which have an ID', function () {
fakeAnnotationUI.findIDsForTags.returns(['id1','id2','id3']); fakeAnnotationUI.findIDsForTags.returns(['id1','id2','id3']);
......
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