Skip to content

Commit

Permalink
Chore: Add tests for annotationsLoadHandler (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Press authored and pramodsum committed Dec 11, 2017
1 parent 062ea38 commit ae68bcb
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/lib/viewers/__tests__/BaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ describe('lib/viewers/BaseViewer', () => {
scale: 1.5
});

base.annotationsLoadPromise.then(() => {
return base.annotationsLoadPromise.then(() => {
expect(base.annotationsLoadHandler).to.be.called;
});
});
Expand Down Expand Up @@ -782,6 +782,35 @@ describe('lib/viewers/BaseViewer', () => {
});
});

describe('annotationsLoadHandler()', () => {
const conf = {
annotationsEnabled: true,
types: {
point: true,
highlight: false
}
};

beforeEach(() => {
window.BoxAnnotations = function BoxAnnotations() {
this.determineAnnotator = sandbox.stub().returns(conf);
}

sandbox.stub(base, 'initAnnotations');
});

it('should determine the annotator', () => {
base.annotationsLoadHandler();
expect(base.annotatorConf).to.equal(conf);
});

it('should init annotations if a conf is present', () => {
base.annotationsLoadHandler();
expect(base.initAnnotations).to.be.called;

});
});

describe('initAnnotations()', () => {
beforeEach(() => {
base.options = {
Expand Down

0 comments on commit ae68bcb

Please sign in to comment.