File tree 3 files changed +134
-0
lines changed
3 files changed +134
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import React from 'react' ;
7
+ import { render } from '@testing-library/react' ;
8
+ import { Provider } from 'react-redux' ;
9
+
10
+ import {
11
+ BrowserRouter as Router ,
12
+ RouteComponentProps ,
13
+ Route ,
14
+ Switch ,
15
+ } from 'react-router-dom' ;
16
+ import { store } from '../../../store' ;
17
+ import { ImportWorkflowModal } from './import_workflow_modal' ;
18
+
19
+ jest . mock ( '../../../services' , ( ) => {
20
+ const { mockCoreServices } = require ( '../../../../test' ) ;
21
+ return {
22
+ ...jest . requireActual ( '../../../services' ) ,
23
+ ...mockCoreServices ,
24
+ } ;
25
+ } ) ;
26
+
27
+ const renderWithRouter = ( ) => ( {
28
+ ...render (
29
+ < Provider store = { store } >
30
+ < Router >
31
+ < Switch >
32
+ < Route
33
+ render = { ( props : RouteComponentProps ) => (
34
+ < ImportWorkflowModal
35
+ isImportModalOpen = { true }
36
+ setIsImportModalOpen = { jest . fn ( ) }
37
+ setSelectedTabId = { jest . fn ( ) }
38
+ { ...props }
39
+ />
40
+ ) }
41
+ />
42
+ </ Switch >
43
+ </ Router >
44
+ </ Provider >
45
+ ) ,
46
+ } ) ;
47
+
48
+ describe ( 'ImportWorkflowModal' , ( ) => {
49
+ test ( 'renders the page' , ( ) => {
50
+ const { getAllByText } = renderWithRouter ( ) ;
51
+ expect (
52
+ getAllByText ( 'Import a workflow (JSON/YAML)' ) . length
53
+ ) . toBeGreaterThan ( 0 ) ;
54
+ } ) ;
55
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import React from 'react' ;
7
+ import { render } from '@testing-library/react' ;
8
+ import '@testing-library/jest-dom' ;
9
+ import { Provider } from 'react-redux' ;
10
+
11
+ import {
12
+ BrowserRouter as Router ,
13
+ RouteComponentProps ,
14
+ Route ,
15
+ Switch ,
16
+ } from 'react-router-dom' ;
17
+ import { store } from '../../../store' ;
18
+ import { NewWorkflow } from './new_workflow' ;
19
+
20
+ const renderWithRouter = ( ) => ( {
21
+ ...render (
22
+ < Provider store = { store } >
23
+ < Router >
24
+ < Switch >
25
+ < Route
26
+ render = { ( props : RouteComponentProps ) => < NewWorkflow { ...props } /> }
27
+ />
28
+ </ Switch >
29
+ </ Router >
30
+ </ Provider >
31
+ ) ,
32
+ } ) ;
33
+
34
+ describe ( 'NewWorkflow' , ( ) => {
35
+ test ( 'renders the search bar' , ( ) => {
36
+ const { getByPlaceholderText } = renderWithRouter ( ) ;
37
+ expect ( getByPlaceholderText ( 'Search' ) ) . toBeInTheDocument ( ) ;
38
+ } ) ;
39
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright OpenSearch Contributors
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ import React from 'react' ;
7
+ import { render } from '@testing-library/react' ;
8
+ import { Provider } from 'react-redux' ;
9
+
10
+ import {
11
+ BrowserRouter as Router ,
12
+ RouteComponentProps ,
13
+ Route ,
14
+ Switch ,
15
+ } from 'react-router-dom' ;
16
+ import { store } from '../../../store' ;
17
+ import { WorkflowList } from './workflow_list' ;
18
+
19
+ const renderWithRouter = ( ) => ( {
20
+ ...render (
21
+ < Provider store = { store } >
22
+ < Router >
23
+ < Switch >
24
+ < Route
25
+ render = { ( props : RouteComponentProps ) => (
26
+ < WorkflowList setSelectedTabId = { jest . fn ( ) } { ...props } />
27
+ ) }
28
+ />
29
+ </ Switch >
30
+ </ Router >
31
+ </ Provider >
32
+ ) ,
33
+ } ) ;
34
+
35
+ describe ( 'WorkflowList' , ( ) => {
36
+ test ( 'renders the page' , ( ) => {
37
+ const { getAllByText } = renderWithRouter ( ) ;
38
+ expect ( getAllByText ( 'Manage existing workflows' ) . length ) . toBeGreaterThan ( 0 ) ;
39
+ } ) ;
40
+ } ) ;
You can’t perform that action at this time.
0 commit comments