From 473d6a91c572801a916f26da98593f7e4e9e8d8b Mon Sep 17 00:00:00 2001 From: saimedhi Date: Thu, 29 Aug 2024 09:14:27 -0700 Subject: [PATCH] Added unit tests Signed-off-by: saimedhi --- .../resizable_workspace.test.tsx | 41 +++++++++++++++++++ .../workflow_detail/resizable_workspace.tsx | 1 - 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 public/pages/workflow_detail/resizable_workspace.test.tsx diff --git a/public/pages/workflow_detail/resizable_workspace.test.tsx b/public/pages/workflow_detail/resizable_workspace.test.tsx new file mode 100644 index 00000000..08d71b40 --- /dev/null +++ b/public/pages/workflow_detail/resizable_workspace.test.tsx @@ -0,0 +1,41 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { render } from '@testing-library/react'; +import { Provider } from 'react-redux'; +import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; +import { store } from '../../store'; +import { ResizableWorkspace } from './resizable_workspace'; +global.ResizeObserver = class { + observe() {} + unobserve() {} + disconnect() {} +}; +jest.mock('../../services', () => { + const { mockCoreServices } = require('../../../test'); + return { + ...jest.requireActual('../../services'), + ...mockCoreServices, + }; +}); + +const renderWithRouter = () => + render( + + + + } /> + + + + ); + +describe('ResizableWorkspace', () => { + test('renders the page', () => { + const { getAllByText } = renderWithRouter(); + expect(getAllByText('Manage existing workflows').length).toBeGreaterThan(0); + }); +}); diff --git a/public/pages/workflow_detail/resizable_workspace.tsx b/public/pages/workflow_detail/resizable_workspace.tsx index 8c089c06..1d6b1351 100644 --- a/public/pages/workflow_detail/resizable_workspace.tsx +++ b/public/pages/workflow_detail/resizable_workspace.tsx @@ -4,7 +4,6 @@ */ import React, { useRef, useState, useEffect } from 'react'; -import { useSelector } from 'react-redux'; import { Form, Formik } from 'formik'; import * as yup from 'yup'; import {