diff --git a/src/store/annotations/__mocks__/annotations.ts b/src/store/annotations/__mocks__/annotations.ts new file mode 100644 index 000000000..fe12b7ed8 --- /dev/null +++ b/src/store/annotations/__mocks__/annotations.ts @@ -0,0 +1,3 @@ +export default jest.fn(() => ({ + getActiveAnnotationsId: jest.fn(), +})); diff --git a/src/store/common/__mocks__/options.ts b/src/store/common/__mocks__/options.ts new file mode 100644 index 000000000..c33748f61 --- /dev/null +++ b/src/store/common/__mocks__/options.ts @@ -0,0 +1,3 @@ +export default jest.fn(() => ({ + getFileVersionId: jest.fn(), +})); diff --git a/src/store/eventing/__tests__/active-test.ts b/src/store/eventing/__tests__/active-test.ts index 5ac1b9126..d46c307c7 100644 --- a/src/store/eventing/__tests__/active-test.ts +++ b/src/store/eventing/__tests__/active-test.ts @@ -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'); diff --git a/src/store/eventing/active.ts b/src/store/eventing/active.ts index 6956e0a45..0028e7c26 100644 --- a/src/store/eventing/active.ts +++ b/src/store/eventing/active.ts @@ -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);