Skip to content

Commit

Permalink
chore: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Chan committed Aug 19, 2020
1 parent b91ad6e commit 7dff8f9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/BoxAnnotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ type Annotator = {
};

type AnnotationsOptions = {
features: Features;
intl: IntlOptions;
};

export type Features = {
[key: string]: boolean;
};

type PreviewOptions = {
file?: {
permissions?: Permissions;
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/BoxAnnotations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ describe('BoxAnnotations', () => {
});

describe('getOptions', () => {
it.each([undefined, { intl: { messages: { test: 'Hello' } } }])(
const features = { enabledFeature: true };
test.each([undefined, { features, intl: { messages: { test: 'Hello' } } }])(
'should return the passed in options when they are %o',
mockOptions => {
loader = new BoxAnnotations(null, mockOptions);
Expand Down
9 changes: 3 additions & 6 deletions src/common/BaseAnnotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ import EventEmitter from './EventEmitter';
import i18n from '../utils/i18n';
import messages from '../messages';
import { Event, IntlOptions, LegacyEvent, Permissions } from '../@types';
import { Features } from '../BoxAnnotations';
import './BaseAnnotator.scss';

export type Container = string | HTMLElement;

export type Features = {
[key: string]: boolean;
};

export type FileOptions = {
[key: string]: {
annotations?: {
Expand Down Expand Up @@ -58,7 +55,7 @@ export default class BaseAnnotator extends EventEmitter {

store: store.AppStore;

constructor({ apiHost, container, features = {}, file, fileOptions, intl, token }: Options) {
constructor({ apiHost, container, features, file, fileOptions, intl, token }: Options) {
super();

const fileOptionsValue = fileOptions?.[file.id];
Expand All @@ -79,7 +76,7 @@ export default class BaseAnnotator extends EventEmitter {
};

this.container = container;
this.features = features;
this.features = features || {};
this.intl = i18n.createIntlProvider(intl);
this.store = store.createStore(initialState, {
api: new API({ apiHost, token }),
Expand Down
4 changes: 2 additions & 2 deletions src/common/__tests__/BaseAnnotator-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ describe('BaseAnnotator', () => {

describe('isFeatureEnabled()', () => {
test('should return whether feature is enabled or not', () => {
expect(annotator.isFeatureEnabled('enabledFeature')).toBeTruthy();
expect(annotator.isFeatureEnabled('notEnabledFeature')).toBeFalsy();
expect(annotator.isFeatureEnabled('enabledFeature')).toBe(true);
expect(annotator.isFeatureEnabled('notEnabledFeature')).toBe(false);
});
});
});

0 comments on commit 7dff8f9

Please sign in to comment.