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

Update snapshot tests using enzyme json #1308

Closed
wants to merge 2 commits into from
Closed
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { waitFor } from '@testing-library/react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { LogConfig } from '../components/config_components/log_config';
import { coreStartMock } from '../../../../test/__mocks__/coreMocks';
import toJson from 'enzyme-to-json';
import DSLService from 'public/services/requests/dsl';
import React from 'react';
import { coreStartMock } from '../../../../test/__mocks__/coreMocks';
import { LogConfig } from '../components/config_components/log_config';

describe('Log Config component', () => {
configure({ adapter: new Adapter() });

it('renders empty log config', () => {
it('renders empty log config', async () => {
const core = coreStartMock;
const setQuery = jest.fn();
const setFilters = jest.fn();
Expand Down Expand Up @@ -63,10 +65,17 @@ describe('Log Config component', () => {
/>
);

expect(wrapper).toMatchSnapshot();
wrapper.update();
await waitFor(() => {
expect(
toJson(wrapper, {
mode: 'deep',
})
).toMatchSnapshot();
});
});

it('renders with query', () => {
it('renders with query', async () => {
const core = coreStartMock;
const setQuery = jest.fn();
const setFilters = jest.fn();
Expand Down Expand Up @@ -116,6 +125,13 @@ describe('Log Config component', () => {
/>
);

expect(wrapper).toMatchSnapshot();
wrapper.update();
await waitFor(() => {
expect(
toJson(wrapper, {
mode: 'deep',
})
).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { waitFor } from '@testing-library/react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { ServiceConfig } from '../components/config_components/service_config';
import { coreStartMock } from '../../../../test/__mocks__/coreMocks';
import toJson from 'enzyme-to-json';
import DSLService from 'public/services/requests/dsl';
import React from 'react';
import { coreStartMock } from '../../../../test/__mocks__/coreMocks';
import { ServiceConfig } from '../components/config_components/service_config';

describe('Service Config component', () => {
configure({ adapter: new Adapter() });

it('renders empty service config', () => {
it('renders empty service config', async () => {
const core = coreStartMock;
const setQuery = jest.fn();
const setFilters = jest.fn();
Expand Down Expand Up @@ -46,7 +48,7 @@ describe('Service Config component', () => {
setStartTime={setStartTime}
endTime="now"
setEndTime={setEndTime}
mode='data_prepper'
mode="data_prepper"
dslService={dslService}
selectedServices={[]}
setSelectedServices={setSelectedServices}
Expand All @@ -63,10 +65,17 @@ describe('Service Config component', () => {
/>
);

expect(wrapper).toMatchSnapshot();
wrapper.update();
await waitFor(() => {
expect(
toJson(wrapper, {
mode: 'deep',
})
).toMatchSnapshot();
});
});

it('renders with one service selected', () => {
it('renders with one service selected', async () => {
const core = coreStartMock;
const setQuery = jest.fn();
const setFilters = jest.fn();
Expand Down Expand Up @@ -108,7 +117,7 @@ describe('Service Config component', () => {
setStartTime={setStartTime}
endTime="now"
setEndTime={setEndTime}
mode='data_prepper'
mode="data_prepper"
dslService={dslService}
selectedServices={[]}
setSelectedServices={setSelectedServices}
Expand All @@ -125,6 +134,13 @@ describe('Service Config component', () => {
/>
);

expect(wrapper).toMatchSnapshot();
wrapper.update();
await waitFor(() => {
expect(
toJson(wrapper, {
mode: 'deep',
})
).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { waitFor } from '@testing-library/react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { TraceConfig } from '../components/config_components/trace_config';
import { coreStartMock } from '../../../../test/__mocks__/coreMocks';
import toJson from 'enzyme-to-json';
import DSLService from 'public/services/requests/dsl';
import React from 'react';
import { coreStartMock } from '../../../../test/__mocks__/coreMocks';
import { TraceConfig } from '../components/config_components/trace_config';

describe('Trace Config component', () => {
configure({ adapter: new Adapter() });

it('renders empty trace config', () => {
it('renders empty trace config', async () => {
const core = coreStartMock;
const setQuery = jest.fn();
const setFilters = jest.fn();
Expand Down Expand Up @@ -55,11 +57,17 @@ describe('Trace Config component', () => {
setFiltersWithStorage={setFiltersWithStorage}
/>
);

expect(wrapper).toMatchSnapshot();
wrapper.update();
await waitFor(() => {
expect(
toJson(wrapper, {
mode: 'deep',
})
).toMatchSnapshot();
});
});

it('renders with one trace selected', () => {
it('renders with one trace selected', async () => {
const core = coreStartMock;
const setQuery = jest.fn();
const setFilters = jest.fn();
Expand Down Expand Up @@ -111,6 +119,13 @@ describe('Trace Config component', () => {
/>
);

expect(wrapper).toMatchSnapshot();
wrapper.update();
await waitFor(() => {
expect(
toJson(wrapper, {
mode: 'deep',
})
).toMatchSnapshot();
});
});
});
Loading