Skip to content

Commit

Permalink
Refactored src/components/AddOn/support/components/Action/Action.test…
Browse files Browse the repository at this point in the history
….tsx from Jest to Vitest (#2482)

* Migrated to vitest

* Added ts-doc comment

---------

Co-authored-by: Vamshi Maskuri <[email protected]>
  • Loading branch information
adithyanotfound and varshith257 authored Dec 1, 2024
1 parent 9b5bd3e commit c2630ae
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/components/AddOn/support/components/Action/Action.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Unit tests for the Action component.
*
* This file contains tests for the Action component to ensure it behaves as expected
* under various scenarios.
*/
import React from 'react';
import { render } from '@testing-library/react';
import { Provider } from 'react-redux';
import { describe, test, expect } from 'vitest';

import { store } from 'state/store';
import Action from './Action';

describe('Testing Action Component', () => {
const props = {
children: 'dummy children',
label: 'dummy label',
};

test('should render props and text elements for the page component', () => {
const { getByText } = render(
<Provider store={store}>
<Action {...props} />
</Provider>,
);

expect(getByText(props.label)).toBeInTheDocument();
expect(getByText(props.children)).toBeInTheDocument();
});
});
3 changes: 2 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'vite';
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import tsconfigPaths from 'vite-tsconfig-paths';
Expand All @@ -15,6 +15,7 @@ export default defineConfig({
include: ['src/**/*.spec.{js,jsx,ts,tsx}'],
globals: true,
environment: 'jsdom',
setupFiles: 'vitest.setup.ts',
coverage: {
enabled: true,
provider: 'istanbul',
Expand Down
1 change: 1 addition & 0 deletions vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom';

0 comments on commit c2630ae

Please sign in to comment.