Skip to content

Commit

Permalink
Write test for app search index/routes
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Apr 30, 2020
1 parent 48cf48a commit afa53e6
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import '../test_utils/mock_shallow_usecontext';

import React, { useContext } from 'react';
import { Redirect } from 'react-router-dom';
import { shallow } from 'enzyme';

import { SetupGuide } from './components/setup_guide';
import { EngineOverview } from './components/engine_overview';

import { AppSearch } from './';

describe('App Search Routes', () => {
describe('/app_search', () => {
it('redirects to Setup Guide when enterpriseSearchUrl is not set', () => {
useContext.mockImplementationOnce(() => ({ enterpriseSearchUrl: '' }));
const wrapper = shallow(<AppSearch />);

expect(wrapper.find(Redirect)).toHaveLength(1);
expect(wrapper.find(EngineOverview)).toHaveLength(0);
});

it('renders Engine Overview when enterpriseSearchUrl is set', () => {
useContext.mockImplementationOnce(() => ({ enterpriseSearchUrl: 'https://foo.bar' }));
const wrapper = shallow(<AppSearch />);

expect(wrapper.find(EngineOverview)).toHaveLength(1);
expect(wrapper.find(Redirect)).toHaveLength(0);
});
});

describe('/app_search/setup_guide', () => {
it('renders', () => {
const wrapper = shallow(<AppSearch />);

expect(wrapper.find(SetupGuide)).toHaveLength(1);
});
});
});

0 comments on commit afa53e6

Please sign in to comment.