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

Unit tests for public components #383

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f78f8dd
[FEATURE] Detector must have at least one alert set #288
jovancvetkovic3006 Jan 9, 2023
1ea796c
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 11, 2023
0d514d8
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 16, 2023
ff8117e
[BUG] Create detector | Interval field can be empty #378
jovancvetkovic3006 Jan 23, 2023
b308059
Adjust styling for Finding details flyout #369
jovancvetkovic3006 Jan 24, 2023
73fae1f
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 24, 2023
7a41744
unit tests
jovancvetkovic3006 Jan 24, 2023
06be7da
detector unit tests
jovancvetkovic3006 Jan 25, 2023
f0ccd00
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 25, 2023
6bf765e
detector unit tests
jovancvetkovic3006 Jan 26, 2023
36b6390
detector unit tests
jovancvetkovic3006 Jan 26, 2023
c23a669
detector unit tests
jovancvetkovic3006 Jan 26, 2023
ce0944b
detector unit tests
jovancvetkovic3006 Jan 26, 2023
d37fb41
detector unit tests
jovancvetkovic3006 Jan 26, 2023
d523098
detector unit tests
jovancvetkovic3006 Jan 26, 2023
8ef0bd0
detector unit tests
jovancvetkovic3006 Jan 26, 2023
9c71aa8
detector unit tests
jovancvetkovic3006 Jan 27, 2023
bc50e0a
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 31, 2023
31c02b0
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Jan 31, 2023
460e7d2
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Feb 1, 2023
482b2c7
unit tests review
jovancvetkovic3006 Feb 1, 2023
b4ed7fa
unit tests review
jovancvetkovic3006 Feb 3, 2023
8381d32
unit tests review
jovancvetkovic3006 Feb 3, 2023
2933d63
unit tests review
jovancvetkovic3006 Feb 3, 2023
378ea69
unit tests review
jovancvetkovic3006 Feb 3, 2023
84b225a
unit tests review
jovancvetkovic3006 Feb 3, 2023
9fa4df8
unit tests review
jovancvetkovic3006 Feb 3, 2023
7e03bfd
unit tests review
jovancvetkovic3006 Feb 3, 2023
237325a
Feature/update vertical domain #372
jovancvetkovic3006 Feb 3, 2023
5422508
Unit tests for public components #383
jovancvetkovic3006 Feb 10, 2023
d54ce17
Unit tests for public components #383
jovancvetkovic3006 Feb 10, 2023
926e249
Unit tests for public components #383
jovancvetkovic3006 Feb 10, 2023
092efff
Unit tests for public components #383
jovancvetkovic3006 Feb 10, 2023
8a2246b
Unit tests for public components #383
jovancvetkovic3006 Feb 11, 2023
fa436c4
Merge branch 'main' of https://github.com/opensearch-project/security…
jovancvetkovic3006 Feb 16, 2023
95c6db8
Unit tests for public components #383
jovancvetkovic3006 Feb 16, 2023
6dab0ee
PR code review
jovancvetkovic3006 Feb 16, 2023
239150f
PR code review
jovancvetkovic3006 Feb 16, 2023
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
2 changes: 1 addition & 1 deletion models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface Rule {

export interface Detector {
id?: string;
type: 'detector';
type: string;
detector_type: string;
name: string;
enabled: boolean;
Expand Down
1 change: 1 addition & 0 deletions public/components/DeleteModal/DeleteModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('<DeleteModal /> spec', () => {
type={'some type'}
/>
);

expect(tree).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FormFieldHeader } from './FormFieldHeader';
describe('<FormFieldHeader /> spec', () => {
it('renders the component', () => {
const tree = render(<FormFieldHeader headerTitle={'some title'} />);

expect(tree).toMatchSnapshot();
});
});
8 changes: 4 additions & 4 deletions public/components/Modal/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { EuiButton, EuiOverlayMask, EuiModal } from '@elastic/eui';
import { render, fireEvent } from '@testing-library/react';
import ModalRoot from './ModalRoot';
import { ModalConsumer, ModalProvider } from './Modal';
import { ServicesConsumer, ServicesContext } from '../../services/Services';
import { browserServicesMock } from '../../../test/mocks';
import { ServicesConsumer, ServicesContext } from '../../services';
import services from '../../../test/mocks/services';

describe('<ModalRoot /> spec', () => {
it('renders nothing when not used', () => {
const { container } = render(
<ServicesContext.Provider value={browserServicesMock}>
<ServicesContext.Provider value={services}>
<ModalProvider>
<ServicesConsumer>
{(services) => services && <ModalRoot services={services} />}
Expand All @@ -34,7 +34,7 @@ describe('<ModalRoot /> spec', () => {
);
const { queryByText, getByTestId, getByLabelText } = render(
<div>
<ServicesContext.Provider value={browserServicesMock}>
<ServicesContext.Provider value={services}>
<ModalProvider>
<ServicesConsumer>
{(services) => services && <ModalRoot services={services} />}
Expand Down
16 changes: 16 additions & 0 deletions public/pages/Alerts/components/AlertFlyout/AlertFlyout.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { render } from '@testing-library/react';
import { AlertFlyout } from './AlertFlyout';
import alertFlyoutMock from '../../../../../test/mocks/Alerts/components/AlertFlyout/AlertFlyout.mock';

describe('<AlertFlyout /> spec', () => {
it('renders the component', () => {
const { container } = render(<AlertFlyout {...alertFlyoutMock} />);
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<AlertFlyout /> spec renders the component 1`] = `
<div
aria-hidden="true"
data-aria-hidden="true"
/>
`;
28 changes: 28 additions & 0 deletions public/pages/Alerts/containers/Alerts/Alerts.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import Alerts from './Alerts';
import contextMock from '../../../../../test/mocks/useContext.mock';
import { mount } from 'enzyme';
import alertsMock from '../../../../../test/mocks/Alerts/Alerts.mock';
import { shallowToJson } from 'enzyme-to-json';
import { Router } from 'react-router-dom';
import browserHistoryMock from '../../../../../test/mocks/services/browserHistory.mock';

describe('<Alerts /> spec', () => {
it('renders the component', () => {
Alerts.WrappedComponent.contextType = contextMock;
const wrapper = mount(
<Router history={browserHistoryMock}>
<Alerts {...alertsMock} />
</Router>,
{
context: contextMock,
}
);
expect(shallowToJson(wrapper.root().children())).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion public/pages/Alerts/containers/Alerts/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const groupByOptions = [
{ text: 'Alert severity', value: 'severity' },
];

class Alerts extends Component<AlertsProps, AlertsState> {
export class Alerts extends Component<AlertsProps, AlertsState> {
static contextType = CoreServicesContext;

constructor(props: AlertsProps) {
Expand Down
Loading