Skip to content

Commit

Permalink
Chore: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum committed Nov 20, 2018
1 parent 8239824 commit 2ed7c6c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/__tests__/AnnotationThread-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,34 @@ describe('AnnotationThread', () => {
});
});

describe('getPopoverParent()', () => {
beforeEach(() => {
thread.annotatedElement = 'annotatedElement';
thread.container = 'container';
util.getPageEl = jest.fn().mockReturnValue('pageEl');
});

it('should return the annotated element if no location or location page is set', () => {
thread.location = undefined;
expect(thread.getPopoverParent()).toEqual('annotatedElement');

thread.location = {};
expect(thread.getPopoverParent()).toEqual('annotatedElement');
});

it('should return container if user should see the mobile UI', () => {
thread.location = { page: 1 };
util.shouldDisplayMobileUI = jest.fn().mockReturnValue(true);
expect(thread.getPopoverParent()).toEqual('container');
});

it('should return the page element if user should NOT see the mobile UI', () => {
thread.location = { page: 1 };
util.shouldDisplayMobileUI = jest.fn().mockReturnValue(false);
expect(thread.getPopoverParent()).toEqual('pageEl');
});
});

describe('unmountPopover', () => {
beforeEach(() => {
thread.popoverComponent = {};
Expand Down

0 comments on commit 2ed7c6c

Please sign in to comment.