Skip to content

Commit

Permalink
chore: get features from BoxAnnotations (#1241)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Chan authored Aug 19, 2020
1 parent c8f8ba2 commit 033668b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/lib/viewers/BaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ class BaseViewer extends EventEmitter {

const annotatorOptions = this.createAnnotatorOptions({
annotator: this.annotatorConf,
features: options && options.features,
intl: (options && options.intl) || intlUtil.createAnnotatorIntl(),
modeButtons: ANNOTATION_BUTTONS,
});
Expand Down
10 changes: 8 additions & 2 deletions src/lib/viewers/__tests__/BaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1166,18 +1166,24 @@ describe('lib/viewers/BaseViewer', () => {
});

it('should call createAnnotatorOptions with locale, language, and messages from options', () => {
const createOptionsArg = {
...annotationsOptions,
features: {
enabledFeature: true,
},
};
sandbox.stub(base, 'areAnnotationsEnabled').returns(true);
sandbox.stub(base, 'createAnnotatorOptions');

base.options.boxAnnotations = {
determineAnnotator: sandbox.stub().returns(conf),
getOptions: sandbox.stub().returns(annotationsOptions),
getOptions: sandbox.stub().returns(createOptionsArg),
};

base.createAnnotator();

expect(base.options.boxAnnotations.getOptions).to.be.called;
expect(base.createAnnotatorOptions).to.be.calledWith(sinon.match(annotationsOptions));
expect(base.createAnnotatorOptions).to.be.calledWith(sinon.match(createOptionsArg));
});

it('should use default intl lib if annotator options not present ', () => {
Expand Down

0 comments on commit 033668b

Please sign in to comment.