Skip to content

Commit

Permalink
chore: address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Conrad Chan committed Jun 8, 2020
1 parent cfa4958 commit adc8586
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/store/annotations/__mocks__/annotations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default jest.fn(() => ({
getActiveAnnotationsId: jest.fn(),
}));
3 changes: 3 additions & 0 deletions src/store/common/__mocks__/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default jest.fn(() => ({
getFileVersionId: jest.fn(),
}));
17 changes: 9 additions & 8 deletions src/store/eventing/__tests__/active-test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { handleActiveAnnotationEvents } from '../active';
import { AppState } from '../../types';
import eventManager from '../../../common/EventManager';
import { AppState } from '../../types';
import { getActiveAnnotationId } from '../../annotations';
import { getFileVersionId } from '../../options';
import { handleActiveAnnotationEvents } from '../active';

jest.mock('../../../common/EventManager');
jest.mock('../../annotations', () => ({
getActiveAnnotationId: jest.fn(),
}));
jest.mock('../../options', () => ({
getFileVersionId: jest.fn().mockReturnValue('456'),
}));
jest.mock('../../annotations');
jest.mock('../../options');

describe('store/eventing/active', () => {
beforeEach(() => {
(getFileVersionId as jest.Mock).mockReturnValue('456');
});

test('should not emit event if prev and next ids are the same', () => {
const state = {} as AppState;
(getActiveAnnotationId as jest.Mock).mockImplementationOnce(() => '123').mockImplementationOnce(() => '123');
Expand Down
4 changes: 2 additions & 2 deletions src/store/eventing/active.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import eventManager from '../../common/EventManager';
import { getActiveAnnotationId } from '../annotations';
import { getFileVersionId } from '../options';
import { AppState } from '../types';
import { Event } from '../../@types';
import { getActiveAnnotationId } from '../annotations';
import { getFileVersionId } from '../options';

const handleActiveAnnotationEvents = (prevState: AppState, nextState: AppState): void => {
const prevActiveAnnotationId = getActiveAnnotationId(prevState);
Expand Down

0 comments on commit adc8586

Please sign in to comment.