Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enterprise Search] Miscellaneous test cleanups #88525

Merged
merged 6 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { resetContext } from 'kea';
import { LogicMounter } from '../__mocks__';

import { DEFAULT_INITIAL_APP_DATA } from '../../../common/__mocks__';
import { AppLogic } from './app_logic';

describe('AppLogic', () => {
const { mount } = new LogicMounter(AppLogic);

beforeEach(() => {
resetContext({});
AppLogic.mount();
mount();
});

const DEFAULT_VALUES = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { setMockValues, setMockActions } from '../../../../../__mocks__/kea.mock';
import { rerender } from '../../../../../__mocks__';
import { setMockValues, setMockActions, rerender } from '../../../../../__mocks__';

import React from 'react';
import { shallow } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock';
import { rerender } from '../../../../__mocks__';
import { setMockValues, setMockActions, rerender } from '../../../../__mocks__';

import React from 'react';
import { shallow } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { setMockValues, setMockActions } from '../../../../__mocks__/kea.mock';
import { rerender } from '../../../../__mocks__';
import { setMockValues, setMockActions, rerender } from '../../../../__mocks__';

import React from 'react';
import { shallow } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { setMockValues, setMockActions } from '../../../__mocks__/kea.mock';

import '../../../__mocks__/react_router_history.mock';
import { setMockValues, setMockActions } from '../../../__mocks__/kea.mock';
import { unmountHandler } from '../../../__mocks__/shallow_useeffect.mock';

import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { setMockValues } from '../../../__mocks__/kea.mock';

import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import '../../../../__mocks__/kea.mock';
import { setMockValues } from '../../../../__mocks__';

import '../../../../__mocks__/enterprise_search_url.mock';
import { setMockValues } from '../../../../__mocks__';

const mockSetFields = jest.fn();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';

import { shallow } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';

import { shallow } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { setMockValues } from '../../../__mocks__/kea.mock';
import { rerender } from '../../../__mocks__';
import { setMockValues, rerender } from '../../../__mocks__';

import React from 'react';
import { shallow } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/

import '../../../__mocks__/shallow_useeffect.mock';
import { rerender } from '../../../__mocks__';
import { setMockValues, setMockActions } from '../../../__mocks__/kea.mock';
import { setMockValues, setMockActions, rerender } from '../../../__mocks__';

import React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import React from 'react';

import { shallow, ShallowWrapper } from 'enzyme';
import { EuiPanel } from '@elastic/eui';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import React from 'react';

import { shallow } from 'enzyme';

import { ResultField } from './result_field';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import React from 'react';

import { shallow } from 'enzyme';

import { ResultHeader } from './result_header';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import React from 'react';

import { mount } from 'enzyme';

import { ResultHeaderItem } from './result_header_item';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../../__mocks__/kea.mock';
import { setMockActions, setMockValues } from '../../../../__mocks__';

import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../../__mocks__/kea.mock';
import '../../../../__mocks__/shallow_useeffect.mock';

import { setMockActions, setMockValues } from '../../../../__mocks__';

import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { shallow } from 'enzyme';
import { EuiPageContentBody } from '@elastic/eui';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import '../__mocks__/shallow_useeffect.mock';
import '../__mocks__/kea.mock';
import '../__mocks__/enterprise_search_url.mock';
import { setMockValues, setMockActions } from '../__mocks__';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../__mocks__/kea.mock';
import { mockTelemetryActions } from '../../../__mocks__';
import { setMockValues, mockTelemetryActions } from '../../../__mocks__';

import React from 'react';
import { useValues } from 'kea';
import { shallow } from 'enzyme';

import { EuiCard } from '@elastic/eui';
Expand Down Expand Up @@ -59,7 +57,7 @@ describe('ProductCard', () => {
});

it('renders correct button text when host not present', () => {
(useValues as jest.Mock).mockImplementation(() => ({ config: { host: '' } }));
setMockValues({ config: { host: '' } });

const wrapper = shallow(<ProductCard product={WORKPLACE_SEARCH_PLUGIN} image="ws.jpg" />);
const card = wrapper.find(EuiCard).dive().shallow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import React from 'react';
import { shallow } from 'enzyme';

import { setMockValues } from '../__mocks__/kea.mock';
import { rerender } from '../__mocks__';
import { setMockValues, rerender } from '../__mocks__';

import { EnterpriseSearch } from './';
import { SetupGuide } from './components/setup_guide';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../__mocks__/kea.mock';
import '../../__mocks__/shallow_useeffect.mock';

import { setMockActions, setMockValues } from '../../__mocks__';

import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { setMockValues } from '../../__mocks__/kea.mock';
import { mockKibanaValues, mockHistory } from '../../__mocks__';
import { setMockValues, mockKibanaValues, mockHistory } from '../../__mocks__';

jest.mock('../react_router_helpers', () => ({
letBrowserHandleEvent: jest.fn(() => false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/

import '../../__mocks__/shallow_useeffect.mock';
import { setMockValues } from '../../__mocks__/kea.mock';
import { mockKibanaValues, mockHistory } from '../../__mocks__';
import { setMockValues, mockKibanaValues, mockHistory } from '../../__mocks__';

import React from 'react';
import { shallow } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../__mocks__/kea.mock';
import { setMockValues } from '../../__mocks__/kea.mock';

import React from 'react';
import { useValues } from 'kea';
import { shallow } from 'enzyme';

import { EuiButton as EuiButtonExternal, EuiEmptyPrompt } from '@elastic/eui';
Expand Down Expand Up @@ -45,7 +44,7 @@ describe('NotFound', () => {
});

it('changes the support URL if the user has a gold+ license', () => {
(useValues as jest.Mock).mockReturnValueOnce({ hasGoldLicense: true });
setMockValues({ hasGoldLicense: true });
const wrapper = shallow(<NotFound product={APP_SEARCH_PLUGIN} />);
const prompt = wrapper.find(EuiEmptyPrompt).dive().shallow();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { setMockValues } from '../../__mocks__/kea.mock';
import { rerender } from '../../__mocks__';
import { setMockValues, rerender } from '../../__mocks__';

import React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { resetContext } from 'kea';
import { LogicMounter } from '../__mocks__';

import { DEFAULT_INITIAL_APP_DATA } from '../../../common/__mocks__';
import { AppLogic } from './app_logic';

describe('AppLogic', () => {
const { mount } = new LogicMounter(AppLogic);

beforeEach(() => {
resetContext({});
AppLogic.mount();
mount();
});

const DEFAULT_VALUES = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import '../__mocks__/shallow_useeffect.mock';
import '../__mocks__/kea.mock';
import { setMockValues, setMockActions, mockKibanaValues } from '../__mocks__';

import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../../../__mocks__/kea.mock';
import '../../../../../__mocks__/shallow_useeffect.mock';

import { setMockActions, setMockValues } from '../../../../../__mocks__';
import {
contentSources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { resetContext } from 'kea';

import {
LogicMounter,
mockFlashMessageHelpers,
mockHttpValues,
expectedAsyncError,
Expand All @@ -30,6 +29,7 @@ import {
} from './add_source_logic';

describe('AddSourceLogic', () => {
const { mount } = new LogicMounter(AddSourceLogic);
const { http } = mockHttpValues;
const { clearFlashMessages, flashAPIErrors } = mockFlashMessageHelpers;

Expand Down Expand Up @@ -71,8 +71,7 @@ describe('AddSourceLogic', () => {

beforeEach(() => {
jest.clearAllMocks();
resetContext({});
AddSourceLogic.mount();
mount();
});

it('has expected default values', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../../../__mocks__/kea.mock';
import '../../../../../__mocks__/shallow_useeffect.mock';

import { setMockValues } from '../../../../../__mocks__';

import { mergedAvailableSources } from '../../../../__mocks__/content_sources.mock';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../../../__mocks__/kea.mock';
import '../../../../../__mocks__/shallow_useeffect.mock';

import { setMockActions, setMockValues } from '../../../../../__mocks__';

import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../../../__mocks__/kea.mock';
import '../../../../../__mocks__/shallow_useeffect.mock';

import { setMockActions, setMockValues } from '../../../../../__mocks__';

import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../../../__mocks__/kea.mock';
import '../../../../../__mocks__/shallow_useeffect.mock';

import { setMockActions, setMockValues } from '../../../../../__mocks__';

import React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../../../__mocks__/kea.mock';
import '../../../../../__mocks__/shallow_useeffect.mock';

import { setMockActions, setMockValues } from '../../../../../__mocks__';

import React from 'react';
Expand Down
Loading