From 864bedc518533cb2a575cf93e4f54c54d4978e97 Mon Sep 17 00:00:00 2001 From: Sumedha Pramod Date: Mon, 27 Aug 2018 13:35:33 -0700 Subject: [PATCH] Chore: Cleanup eslint errors --- src/__tests__/Annotator-test.js | 29 ++++++++++------------------- src/doc/CreateHighlightDialog.js | 2 +- src/doc/DocDrawingThread.js | 6 ++++-- src/util.js | 4 +++- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/__tests__/Annotator-test.js b/src/__tests__/Annotator-test.js index 09a62b6b8..2daa793e4 100644 --- a/src/__tests__/Annotator-test.js +++ b/src/__tests__/Annotator-test.js @@ -171,14 +171,10 @@ describe('Annotator', () => { it('should fetch and then render annotations', () => { annotator.fetchPromise = Promise.resolve(); annotator.loadAnnotations(); - return annotator.fetchPromise - .then(() => { - expect(annotator.render).toBeCalled(); - expect(annotator.emit).not.toBeCalled(); - }) - .catch(() => { - sinon.assert.failException; - }); + return annotator.fetchPromise.then(() => { + expect(annotator.render).toBeCalled(); + expect(annotator.emit).not.toBeCalled(); + }); }); it('should emit an error if the annotator fails to fetch and render annotations', () => { @@ -186,10 +182,9 @@ describe('Annotator', () => { annotator.loadAnnotations(); return annotator.fetchPromise .then(() => { - sinon.assert.failException; + expect(annotator.render).not.toBeCalled(); }) .catch((err) => { - expect(annotator.render).not.toBeCalled(); expect(annotator.emit).toBeCalledWith(ANNOTATOR_EVENT.loadError, err); }); }); @@ -355,15 +350,11 @@ describe('Annotator', () => { }; const result = annotator.fetchAnnotations(); - result - .then(() => { - expect(result).toBeTruthy(); - expect(annotator.threadMap).not.toBeUndefined(); - expect(annotator.emit).toBeCalledWith(ANNOTATOR_EVENT.fetch); - }) - .catch(() => { - sinon.assert.failException; - }); + result.then(() => { + expect(result).toBeTruthy(); + expect(annotator.threadMap).not.toBeUndefined(); + expect(annotator.emit).toBeCalledWith(ANNOTATOR_EVENT.fetch); + }); }); it('should fetch existing annotations if the user can view all annotations', () => { diff --git a/src/doc/CreateHighlightDialog.js b/src/doc/CreateHighlightDialog.js index 2ad95b0ad..273103ce5 100644 --- a/src/doc/CreateHighlightDialog.js +++ b/src/doc/CreateHighlightDialog.js @@ -1,7 +1,7 @@ import CreateAnnotationDialog from '../CreateAnnotationDialog'; import { ICON_HIGHLIGHT, ICON_HIGHLIGHT_COMMENT } from '../icons/icons'; import { generateBtn, repositionCaret, getPageInfo, getDialogWidth, showElement } from '../util'; -import { getDialogCoordsFromRange } from '../doc/docUtil'; +import { getDialogCoordsFromRange } from './docUtil'; import { CREATE_EVENT, CLASS_ANNOTATION_CARET, diff --git a/src/doc/DocDrawingThread.js b/src/doc/DocDrawingThread.js index f685dc54e..d7bcaea88 100644 --- a/src/doc/DocDrawingThread.js +++ b/src/doc/DocDrawingThread.js @@ -1,6 +1,6 @@ import DrawingPath from '../drawing/DrawingPath'; import DrawingThread from '../drawing/DrawingThread'; -import DocDrawingDialog from '../doc/DocDrawingDialog'; +import DocDrawingDialog from './DocDrawingDialog'; import { STATES, DRAW_STATES, @@ -41,7 +41,9 @@ class DocDrawingThread extends DrawingThread { handleMove(location) { if (this.drawingFlag !== DRAW_STATES.drawing || !location) { return; - } else if (this.hasPageChanged(location)) { + } + + if (this.hasPageChanged(location)) { this.onPageChange(location); return; } diff --git a/src/util.js b/src/util.js index b97dde7e6..8225984f8 100644 --- a/src/util.js +++ b/src/util.js @@ -500,7 +500,9 @@ export function repositionCaret(dialogEl, dialogX, highlightDialogWidth, browser annotationCaretEl.style.left = `${caretLeftX}px`; return 0; - } else if (dialogPastRight && !dialogPastLeft) { + } + + if (dialogPastRight && !dialogPastLeft) { // Leave a minimum of 10 pixels so caret doesn't go off edge const caretRightX = Math.max(10, pageWidth - browserX);