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.
feat: added content left and right to match v2 and v3
- Loading branch information
Showing
16 changed files
with
371 additions
and
139 deletions.
There are no files selected for viewing
50 changes: 32 additions & 18 deletions
50
libs/blocks/src/lib/features/content-left/content-left.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 |
---|---|---|
@@ -1,38 +1,52 @@ | ||
import { render } from '@testing-library/react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import ContentLeft from '.'; | ||
import { Button, Heading } from '@deriv/quill-design'; | ||
|
||
const ContentLeftContent = () => ( | ||
<Heading.H2>This is a heading content</Heading.H2> | ||
); | ||
const className = 'text-heading-h2'; | ||
const title = 'This is the title'; | ||
const description = 'Description here'; | ||
const content = 'This is a heading content'; | ||
const child = 'This is a button'; | ||
|
||
describe('ContentLeft', () => { | ||
it('renders with correct class names and content', () => { | ||
const className = 'text-heading-h2'; | ||
const title = 'This is the title'; | ||
const description = 'Description here'; | ||
const ContentLeftContent = () => <Heading.H3>{content}</Heading.H3>; | ||
|
||
const { getByText } = render( | ||
describe('ContentLeft', () => { | ||
beforeEach(() => { | ||
render( | ||
<ContentLeft | ||
className={className} | ||
title={title} | ||
description={description} | ||
content={ContentLeftContent} | ||
> | ||
<Button>This is a button</Button> | ||
<Button>{child}</Button> | ||
</ContentLeft>, | ||
); | ||
const titleElement = getByText(title); | ||
}); | ||
|
||
//renders with correct classname | ||
expect(titleElement).toHaveClass(className); | ||
it('renders with correct class names passing in', () => { | ||
expect(document.querySelector(`.${className}`)).toBeInTheDocument(); | ||
}); | ||
|
||
//renders with the correct title | ||
expect(getByText(title)).toBeInTheDocument(); | ||
it(`renders with correct title '${title}'`, () => { | ||
expect( | ||
screen.getByRole('heading', { name: title, level: 2 }), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it(`renders with correct description '${description}'`, () => { | ||
expect(screen.getByText(description)).toBeInTheDocument(); | ||
}); | ||
|
||
it(`renders with correct content`, () => { | ||
expect( | ||
screen.getByRole('heading', { name: content, level: 3 }), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
//renders with the correct description | ||
expect(getByText(description)).toBeInTheDocument(); | ||
it(`renders with correct children`, () => { | ||
expect(screen.getByRole('button', { name: child })).toBeInTheDocument(); | ||
}); | ||
}); |
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
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
52 changes: 33 additions & 19 deletions
52
libs/blocks/src/lib/features/content-right/content-right.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 |
---|---|---|
@@ -1,38 +1,52 @@ | ||
import { render } from '@testing-library/react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import ContentRight from '.'; | ||
import { Button, Heading } from '@deriv/quill-design'; | ||
|
||
const ContentRightContent = () => ( | ||
<Heading.H2>This is a heading content</Heading.H2> | ||
); | ||
const className = 'text-heading-h2'; | ||
const title = 'This is the title'; | ||
const description = 'Description here'; | ||
const content = 'This is a heading content'; | ||
const child = 'This is a button'; | ||
|
||
describe('ContentLeft', () => { | ||
it('renders with correct class names and content', () => { | ||
const className = 'text-heading-h2'; | ||
const title = 'This is the title'; | ||
const description = 'Description here'; | ||
const ContentRightContent = () => <Heading.H3>{content}</Heading.H3>; | ||
|
||
const { getByText } = render( | ||
describe('ContentRight', () => { | ||
beforeEach(() => { | ||
render( | ||
<ContentRight | ||
className={className} | ||
title={title} | ||
content={ContentRightContent} | ||
description={description} | ||
content={ContentRightContent} | ||
> | ||
<Button>This is a button</Button> | ||
<Button>{child}</Button> | ||
</ContentRight>, | ||
); | ||
const titleElement = getByText(title); | ||
}); | ||
|
||
//renders with correct classname | ||
expect(titleElement).toHaveClass(className); | ||
it('renders with correct class names passing in', () => { | ||
expect(document.querySelector(`.${className}`)).toBeInTheDocument(); | ||
}); | ||
|
||
//renders with the correct title | ||
expect(getByText(title)).toBeInTheDocument(); | ||
it(`renders with correct title '${title}'`, () => { | ||
expect( | ||
screen.getByRole('heading', { name: title, level: 2 }), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it(`renders with correct description '${description}'`, () => { | ||
expect(screen.getByText(description)).toBeInTheDocument(); | ||
}); | ||
|
||
it(`renders with correct content`, () => { | ||
expect( | ||
screen.getByRole('heading', { name: content, level: 3 }), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
//renders with the correct description | ||
expect(getByText(description)).toBeInTheDocument(); | ||
it(`renders with correct children`, () => { | ||
expect(screen.getByRole('button', { name: child })).toBeInTheDocument(); | ||
}); | ||
}); |
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
57 changes: 43 additions & 14 deletions
57
libs/blocks/src/lib/features/content-slider/content-slider.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 |
---|---|---|
@@ -1,30 +1,59 @@ | ||
import { render } from '@testing-library/react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import ContentSlider from '.'; | ||
import { Button } from '@deriv/quill-design'; | ||
import { cards } from './mock-data'; | ||
|
||
describe('CardSlider', () => { | ||
it('renders with correct class names and content', () => { | ||
const className = 'text-heading-h2'; | ||
const title = 'This is the title'; | ||
const description = 'Description here'; | ||
const className = 'text-heading-h2'; | ||
const title = 'This is the title'; | ||
const description = 'Description here'; | ||
const cta = 'CTA'; | ||
|
||
const { getByText } = render( | ||
describe('CardSlider', () => { | ||
beforeEach(() => { | ||
render( | ||
<ContentSlider | ||
className={className} | ||
title={title} | ||
description={description} | ||
cardSliderProps={{ | ||
slideClasses: 'max-w-xs', | ||
variant: 'ContentBottom', | ||
cards: cards, | ||
}} | ||
cta={() => <Button>{cta}</Button>} | ||
/>, | ||
); | ||
const titleElement = getByText(title); | ||
}); | ||
|
||
it(`should render the correct class name '${className}' passing in`, () => { | ||
expect(document.querySelector(`.${className}`)).toBeInTheDocument(); | ||
}); | ||
|
||
//renders with correct classname | ||
expect(titleElement).toHaveClass(className); | ||
it(`should render the correct title '${title}'`, () => { | ||
expect( | ||
screen.getByRole('heading', { name: title, level: 2 }), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it(`should render the correct description '${description}'`, () => { | ||
expect(screen.getByText(description)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render the correct cta', () => { | ||
expect(screen.getByRole('button', { name: cta })).toBeInTheDocument(); | ||
}); | ||
|
||
//renders with the correct title | ||
expect(getByText(title)).toBeInTheDocument(); | ||
cards.forEach((_, i) => { | ||
it(`should render the correct title '${title}'`, () => { | ||
expect( | ||
screen.getByRole('heading', { name: `Card ${i + 1}`, level: 4 }), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
//renders with the correct description | ||
expect(getByText(description)).toBeInTheDocument(); | ||
it(`should render the correct description '${description}'`, () => { | ||
expect(screen.getByText(`Description here ${i + 1}`)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
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,14 @@ | ||
import { CardVariantProps } from '@deriv-com/components'; | ||
import { IllustrativeProtectedAndSecureIcon } from '@deriv/quill-icons'; | ||
|
||
export const cards: CardVariantProps<'ContentBottom'>[] = Array.from({ | ||
length: 6, | ||
}).map((_, i) => ({ | ||
id: i, | ||
header: `Card ${i + 1}`, | ||
description: `Description here ${i + 1}`, | ||
icon: <IllustrativeProtectedAndSecureIcon />, | ||
color: 'gray', | ||
align: 'start', | ||
size: 'sm', | ||
})); |
54 changes: 29 additions & 25 deletions
54
libs/blocks/src/lib/features/features-v4/features-v4.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 |
---|---|---|
@@ -1,38 +1,42 @@ | ||
import { render } from '@testing-library/react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import FeaturesV4 from '.'; | ||
import { Button, Heading } from '@deriv/quill-design'; | ||
|
||
const ContentLeftContent = () => ( | ||
<Heading.H2>This is a heading content</Heading.H2> | ||
); | ||
const content = <Heading.H3>content</Heading.H3>; | ||
const title = 'this is title'; | ||
const description = 'this is description'; | ||
|
||
describe('ContentLeft', () => { | ||
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( | ||
<FeaturesV4 | ||
className={className} | ||
title={title} | ||
description={description} | ||
content={ContentLeftContent} | ||
> | ||
<Button>This is a button</Button> | ||
describe('FeaturesV4', () => { | ||
beforeEach(() => { | ||
render( | ||
<FeaturesV4 title={title} description={description} content={content}> | ||
<Button>Click me</Button> | ||
</FeaturesV4>, | ||
); | ||
const titleElement = getByText(title); | ||
}); | ||
|
||
it('should rebder heading correctly', () => { | ||
const heading = screen.getByRole('heading', { | ||
name: title, | ||
level: 2, | ||
}); | ||
expect(heading).toBeInTheDocument(); | ||
}); | ||
|
||
//renders with correct classname | ||
expect(titleElement).toHaveClass(className); | ||
it('should render description correctly', () => { | ||
const desc = screen.getByText(description); | ||
expect(desc).toBeInTheDocument(); | ||
}); | ||
|
||
//renders with the correct title | ||
expect(getByText(title)).toBeInTheDocument(); | ||
it('should render children passed to it', () => { | ||
const button = screen.getByRole('button', { name: 'Click me' }); | ||
expect(button).toBeInTheDocument(); | ||
}); | ||
|
||
//renders with the correct description | ||
expect(getByText(description)).toBeInTheDocument(); | ||
it('should render content passed to it', () => { | ||
const data = screen.getByRole('heading', { name: 'content', level: 3 }); | ||
expect(data).toBeInTheDocument(); | ||
}); | ||
}); |
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
Oops, something went wrong.