Skip to content

Commit

Permalink
test: Unit tests for CheckoutSummary component (#11061)
Browse files Browse the repository at this point in the history
* test: Unit tests for CheckoutSummary component

* Added changeset: Unit tests for CheckoutSummary component
  • Loading branch information
harsh-akamai authored Oct 9, 2024
1 parent 7a2e989 commit 194d9d4
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11061-tests-1728374977579.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Unit tests for CheckoutSummary component ([#11061](https://github.com/linode/manager/pull/11061))
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';

import { renderWithTheme } from 'src/utilities/testHelpers';

import { CheckoutSummary } from './CheckoutSummary';

import type { CheckoutSummaryProps } from './CheckoutSummary';

const defaultArgs: CheckoutSummaryProps = {
displaySections: [
{ title: 'Debian 11' },
{ details: '$36/month', title: 'Dedicated 4GB' },
],
heading: 'Checkout Summary',
};

describe('CheckoutSummary', () => {
it('should render heading and display section', () => {
const { getByText } = renderWithTheme(<CheckoutSummary {...defaultArgs} />);

expect(getByText('Checkout Summary')).toBeVisible();
expect(getByText('Debian 11')).toBeVisible();
});

it('should render children if provided', () => {
const { getByText } = renderWithTheme(
<CheckoutSummary {...defaultArgs}>
<div>Child items can go here!</div>
</CheckoutSummary>
);

expect(getByText('Child items can go here!')).toBeInTheDocument();
});

it('should render agreement if provided', () => {
const { getByText } = renderWithTheme(
<CheckoutSummary
{...defaultArgs}
agreement={<div>Agreement item can go here!</div>}
/>
);

expect(getByText('Agreement item can go here!')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SummaryItem } from './SummaryItem';

import type { Theme } from '@mui/material/styles';

interface CheckoutSummaryProps {
export interface CheckoutSummaryProps {
/**
* JSX element to be displayed as an agreement section.
*/
Expand Down

0 comments on commit 194d9d4

Please sign in to comment.