From 247580b9dca3be04d3809ab5b5c71d75126d024c Mon Sep 17 00:00:00 2001 From: ManojNB Date: Thu, 24 Oct 2024 14:12:00 -0700 Subject: [PATCH] chore: add tests for the composable ActionStart --- .../__tests__/ActionStart.spec.tsx | 30 +++++++++++++++++++ .../hooks/__tests__/useActionStart.spec.ts | 1 - 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 packages/react-storage/src/components/StorageBrowser/composables/__tests__/ActionStart.spec.tsx diff --git a/packages/react-storage/src/components/StorageBrowser/composables/__tests__/ActionStart.spec.tsx b/packages/react-storage/src/components/StorageBrowser/composables/__tests__/ActionStart.spec.tsx new file mode 100644 index 00000000000..7cf3e408565 --- /dev/null +++ b/packages/react-storage/src/components/StorageBrowser/composables/__tests__/ActionStart.spec.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import { ActionStart } from '../ActionStart'; +import { CLASS_BASE } from '../../views/constants'; + +describe('ActionStart', () => { + it('renders a button element', () => { + render(); + const button = screen.getByRole('button'); + expect(button).toBeInTheDocument(); + }); + + it('renders a button with the expected className', () => { + render(); + const button = screen.getByRole('button'); + expect(button).toHaveClass(`${CLASS_BASE}__action-start`); + }); + + it('renders a button with the expected text', () => { + render(); + const button = screen.getByRole('button'); + expect(button).toHaveTextContent('Start'); + }); + + it('renders a button with the expected disabled state', () => { + render(); + const button = screen.getByRole('button'); + expect(button).toBeDisabled(); + }); +}); diff --git a/packages/react-storage/src/components/StorageBrowser/controls/hooks/__tests__/useActionStart.spec.ts b/packages/react-storage/src/components/StorageBrowser/controls/hooks/__tests__/useActionStart.spec.ts index 740f0f50910..49190cf635c 100644 --- a/packages/react-storage/src/components/StorageBrowser/controls/hooks/__tests__/useActionStart.spec.ts +++ b/packages/react-storage/src/components/StorageBrowser/controls/hooks/__tests__/useActionStart.spec.ts @@ -14,7 +14,6 @@ describe('useActionStart', () => { onActionStart: jest.fn(), }; - // Create a spy on the useControlsContext function const useControlsContextSpy = jest.spyOn( controlsContextModule, 'useControlsContext'