Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Roes committed Oct 8, 2020
1 parent f581dc1 commit 93026f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ describe('useSavedVisInstance', () => {
useSavedVisInstance(mockServices, eventEmitter, true, savedVisId)
);

result.current.visEditorRef.current = document.createElement('div');
expect(mockGetVisualizationInstance).toHaveBeenCalledWith(mockServices, savedVisId);
expect(mockGetVisualizationInstance.mock.calls.length).toBe(1);

Expand All @@ -129,10 +130,12 @@ describe('useSavedVisInstance', () => {
});

test('should destroy the editor and the savedVis on unmount if chrome exists', async () => {
const { unmount, waitForNextUpdate } = renderHook(() =>
const { result, unmount, waitForNextUpdate } = renderHook(() =>
useSavedVisInstance(mockServices, eventEmitter, true, savedVisId)
);

result.current.visEditorRef.current = document.createElement('div');

await waitForNextUpdate();
unmount();

Expand All @@ -158,6 +161,8 @@ describe('useSavedVisInstance', () => {
useSavedVisInstance(mockServices, eventEmitter, true, undefined)
);

result.current.visEditorRef.current = document.createElement('div');

expect(mockGetVisualizationInstance).toHaveBeenCalledWith(mockServices, {
indexPattern: '1a2b3c4d',
type: 'area',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { useEffect, useRef, useState } from 'react';
import { MutableRefObject, useEffect, useRef, useState } from 'react';
import { EventEmitter } from 'events';
import { parse } from 'query-string';
import { i18n } from '@kbn/i18n';
Expand All @@ -44,7 +44,7 @@ export const useSavedVisInstance = (
savedVisInstance?: SavedVisInstance;
visEditorController?: IEditorController;
}>({});
const visEditorRef = useRef<HTMLDivElement>(null);
const visEditorRef = useRef<HTMLDivElement>();
const visId = useRef('');

useEffect(() => {
Expand Down

0 comments on commit 93026f9

Please sign in to comment.