This repository has been archived by the owner on Jun 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af65c15
commit 7ce3993
Showing
5 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
libs/blocks/src/lib/account-comparison/account-comparison.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import AccountComparison from '.'; | ||
import { Heading } from '@deriv/quill-design'; | ||
|
||
const Content = () => <Heading.H2>This is a heading content</Heading.H2>; | ||
|
||
describe('AccountComparison', () => { | ||
it('renders with correct class names and content', () => { | ||
const className = 'text-heading-h2'; | ||
const title = 'This is the title'; | ||
const description = 'Description here'; | ||
|
||
const { getByText } = render( | ||
<AccountComparison | ||
title={title} | ||
description={description} | ||
content={Content} | ||
/>, | ||
); | ||
const titleElement = getByText(title); | ||
|
||
//renders with correct classname | ||
expect(titleElement).toHaveClass(className); | ||
|
||
//renders with the correct title | ||
expect(getByText(title)).toBeInTheDocument(); | ||
|
||
//renders with the correct description | ||
expect(getByText(description)).toBeInTheDocument(); | ||
}); | ||
}); |
27 changes: 27 additions & 0 deletions
27
libs/blocks/src/lib/account-comparison/account-comparison.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import AccountComparison from '.'; | ||
|
||
const meta = { | ||
title: 'Blocks/AccountComparison', | ||
component: AccountComparison, | ||
} satisfies Meta<typeof AccountComparison>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
className: '', | ||
title: 'Title here', | ||
description: | ||
'Description goes here description goes here description goes here description goes here', | ||
content: () => ( | ||
<img | ||
className="flex w-full flex-1" | ||
src="https://placehold.co/712x200" | ||
alt="Placeholder" | ||
/> | ||
), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { FluidContainer, Heading, Text, Section } from '@deriv/quill-design'; | ||
import clsx from 'clsx'; | ||
|
||
export interface AccountComparisonProps { | ||
className?: string; | ||
title?: string; | ||
description?: string; | ||
content: React.FC; | ||
} | ||
|
||
const AccountComparison = ({ | ||
className, | ||
title, | ||
description, | ||
content: Content, | ||
}: AccountComparisonProps) => { | ||
return ( | ||
<Section | ||
className={clsx( | ||
'py-general-4xl', | ||
'bg-background-primary-container', | ||
className, | ||
)} | ||
> | ||
<FluidContainer className="flex flex-col items-center gap-gap-xl lg:gap-gap-2xl"> | ||
{(title || description) && ( | ||
<div className="flex flex-col items-center gap-gap-lg lg:gap-gap-xl"> | ||
{title && <Heading.H2>{title}</Heading.H2>} | ||
{description && <Text>{description}</Text>} | ||
</div> | ||
)} | ||
{Content && <Content />} | ||
</FluidContainer> | ||
</Section> | ||
); | ||
}; | ||
|
||
export default AccountComparison; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters