Skip to content

Commit

Permalink
Chore: adding unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Chan committed Nov 30, 2018
1 parent 24430a8 commit b3ffab9
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/image/__tests__/ImagePointThread-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,24 @@ const html = `<div class="annotated-element" data-page-number="1">

describe('image/ImagePointThread', () => {
let rootElement;
let container;
let annotatedElement;

beforeEach(() => {
rootElement = document.createElement('div');
rootElement.innerHTML = html;
document.body.appendChild(rootElement);

container = document.createElement('div');
container.classList.add('container');

annotatedElement = document.querySelector(SELECTOR_ANNOTATED_ELEMENT);

thread = new ImagePointThread({
annotatedElement: document.querySelector(SELECTOR_ANNOTATED_ELEMENT),
annotatedElement,
annotations: [],
api: {},
container,
fileVersionId: 1,
location: {},
threadID: 2,
Expand Down Expand Up @@ -73,4 +81,22 @@ describe('image/ImagePointThread', () => {
expect(thread.renderAnnotationPopover).not.toBeCalled();
});
});

describe('getPopoverParent()', () => {
beforeEach(() => {
util.shouldDisplayMobileUI = jest.fn();
});

it('should return the container if mobile', () => {
util.shouldDisplayMobileUI.mockReturnValueOnce(true);

expect(thread.getPopoverParent()).toBe(container);
});

it('should return the annotatedEleemnt if not mobile', () => {
util.shouldDisplayMobileUI.mockReturnValueOnce(false);

expect(thread.getPopoverParent()).toBe(annotatedElement);
});
});
});

0 comments on commit b3ffab9

Please sign in to comment.