@automattic/jetpack-components 0.41.2 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/components/boost-score-graph/background.tsx +183 -0
- package/components/boost-score-graph/index.tsx +24 -16
- package/components/boost-score-graph/style.scss +17 -0
- package/components/boost-score-graph/types/declarations.d.ts +4 -0
- package/components/boost-score-graph/uplot-line-chart.tsx +11 -5
- package/components/boost-score-graph/use-boost-score-transform.ts +21 -18
- package/components/gridicon/index.tsx +13 -0
- package/components/{pricing-slider → number-slider}/index.tsx +12 -12
- package/components/{pricing-slider → number-slider}/style.scss +8 -8
- package/components/{pricing-slider → number-slider}/types.ts +2 -2
- package/components/popover/index.tsx +19 -0
- package/components/popover/style.scss +25 -0
- package/index.ts +2 -1
- package/package.json +3 -3
- package/.gitattributes +0 -8
- package/components/action-button/stories/index.stories.jsx +0 -38
- package/components/action-button/test/component.jsx +0 -16
- package/components/action-popover/stories/index.stories.jsx +0 -115
- package/components/action-popover/stories/styles.module.scss +0 -7
- package/components/admin-page/stories/index.stories.tsx +0 -35
- package/components/admin-page/stories/style.module.scss +0 -13
- package/components/admin-section/stories/index.stories.tsx +0 -60
- package/components/alert/stories/index.stories.jsx +0 -24
- package/components/automattic-byline-logo/stories/index.stories.tsx +0 -20
- package/components/automattic-byline-logo/test/component.tsx +0 -28
- package/components/boost-score-bar/stories/index.stories.tsx +0 -39
- package/components/boost-score-bar/test/component.tsx +0 -102
- package/components/boost-score-graph/stories/index.stories.tsx +0 -187
- package/components/boost-score-graph/stories/tooltip.stories.tsx +0 -41
- package/components/button/stories/index.mdx +0 -90
- package/components/button/stories/index.stories.tsx +0 -400
- package/components/button/stories/style.module.scss +0 -20
- package/components/contextual-upgrade-trigger/stories/index.stories.tsx +0 -25
- package/components/decorative-card/stories/index.stories.tsx +0 -18
- package/components/dialog/stories/boost.png +0 -0
- package/components/dialog/stories/declaration.d.ts +0 -1
- package/components/dialog/stories/index.stories.tsx +0 -118
- package/components/dialog/stories/js-components.components.dialog.mdx +0 -62
- package/components/dialog/stories/js-components.components.dialog.stories.js +0 -37
- package/components/dialog/stories/style.module.scss +0 -21
- package/components/donut-meter/stories/index.stories.tsx +0 -51
- package/components/donut-meter/test/component.tsx +0 -24
- package/components/gridicon/stories/index.stories.tsx +0 -18
- package/components/icon-tooltip/stories/index.stories.tsx +0 -108
- package/components/icon-tooltip/stories/style.scss +0 -36
- package/components/icon-tooltip/test/component.tsx +0 -15
- package/components/icons/stories/index.stories.tsx +0 -65
- package/components/icons/stories/style.module.scss +0 -33
- package/components/indeterminate-progress-bar/stories/index.stories.tsx +0 -14
- package/components/jetpack-footer/stories/index.stories.tsx +0 -39
- package/components/jetpack-footer/test/__snapshots__/component.tsx.snap +0 -186
- package/components/jetpack-footer/test/component.tsx +0 -159
- package/components/jetpack-logo/stories/index.stories.tsx +0 -20
- package/components/jetpack-logo/test/component.tsx +0 -16
- package/components/jetpack-search-logo/stories/index.stories.tsx +0 -21
- package/components/jetpack-search-logo/test/component.tsx +0 -16
- package/components/jetpack-vaultpress-backup-logo/stories/index.stories.tsx +0 -20
- package/components/jetpack-vaultpress-backup-logo/test/component.tsx +0 -18
- package/components/jetpack-videopress-logo/stories/index.stories.tsx +0 -20
- package/components/jetpack-videopress-logo/test/component.tsx +0 -16
- package/components/layout/stories/index.stories.tsx +0 -145
- package/components/layout/stories/styles.module.scss +0 -22
- package/components/loading-placeholder/stories/index.stories.tsx +0 -78
- package/components/notice/stories/index.stories.jsx +0 -90
- package/components/pricing-card/stories/index.stories.tsx +0 -55
- package/components/pricing-card/test/component.tsx +0 -89
- package/components/pricing-slider/stories/index.stories.tsx +0 -44
- package/components/pricing-slider/test/component.tsx +0 -14
- package/components/pricing-table/stories/index.stories.tsx +0 -74
- package/components/pricing-table/test/component.tsx +0 -41
- package/components/product-offer/stories/index.stories.tsx +0 -104
- package/components/product-price/stories/index.stories.tsx +0 -33
- package/components/product-price/test/component.tsx +0 -26
- package/components/qr-code/stories/index.stories.tsx +0 -32
- package/components/record-meter-bar/stories/index.stories.tsx +0 -39
- package/components/record-meter-bar/test/component.tsx +0 -52
- package/components/spinner/stories/index.stories.jsx +0 -20
- package/components/spinner/test/component.jsx +0 -17
- package/components/split-button/stories/index.stories.tsx +0 -35
- package/components/stat-card/stories/index.mdx +0 -35
- package/components/stat-card/stories/index.stories.tsx +0 -41
- package/components/stat-card/test/component.tsx +0 -24
- package/components/status/stories/index.stories.tsx +0 -44
- package/components/terms-of-service/test/index.test.jsx +0 -52
- package/components/testimonials/test/component.tsx +0 -103
- package/components/text/stories/headings.index.stories.tsx +0 -80
- package/components/text/stories/index.mdx +0 -195
- package/components/text/stories/index.stories.tsx +0 -69
- package/components/text/stories/style.module.scss +0 -64
- package/components/text/stories/title.index.stories.tsx +0 -34
- package/components/theme-provider/stories/index.stories.tsx +0 -164
- package/components/theme-provider/stories/style.module.scss +0 -79
- package/components/toggle-control/stories/index.stories.tsx +0 -83
- package/components/zendesk-chat/stories/index.stories.tsx +0 -15
- package/components/zendesk-chat/test/component.tsx +0 -16
- package/lib/locale/test/index.ts +0 -21
- package/tools/jp-redirect/test/index.tsx +0 -89
- package/tools/pricing-utils/test/index.ts +0 -39
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import QRCode from '../index';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'JS Packages/Components/QRCode',
|
|
5
|
-
component: QRCode,
|
|
6
|
-
argTypes: {
|
|
7
|
-
value: {
|
|
8
|
-
control: { type: 'text' },
|
|
9
|
-
},
|
|
10
|
-
size: {
|
|
11
|
-
control: { type: 'number' },
|
|
12
|
-
},
|
|
13
|
-
level: {
|
|
14
|
-
control: { type: 'select' },
|
|
15
|
-
options: [ 'L', 'M', 'Q', 'H' ],
|
|
16
|
-
},
|
|
17
|
-
fgColor: {
|
|
18
|
-
control: { type: 'color' },
|
|
19
|
-
},
|
|
20
|
-
bgColor: {
|
|
21
|
-
control: { type: 'color' },
|
|
22
|
-
},
|
|
23
|
-
renderAs: {
|
|
24
|
-
control: { type: 'select' },
|
|
25
|
-
options: [ 'canvas', 'svg' ],
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const Template = args => <QRCode { ...args } />;
|
|
31
|
-
|
|
32
|
-
export const _default = Template.bind( {} );
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import RecordMeterBar, { RecordMeterBarProps } from '../index';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'JS Packages/Components/RecordMeterBar',
|
|
5
|
-
component: RecordMeterBar,
|
|
6
|
-
argTypes: {
|
|
7
|
-
sortByCount: {
|
|
8
|
-
control: { type: 'select' },
|
|
9
|
-
options: [ undefined, 'ascending', 'descending' ],
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const Template = args => <RecordMeterBar { ...args } />;
|
|
15
|
-
|
|
16
|
-
const DefaultArgs: RecordMeterBarProps = {
|
|
17
|
-
items: [
|
|
18
|
-
{ count: 18, label: 'Posts', backgroundColor: '#00BA37' },
|
|
19
|
-
{ count: 30, label: 'Plugins', backgroundColor: '#3895BA' },
|
|
20
|
-
{ count: 52, label: 'Comments', backgroundColor: '#E68B28' },
|
|
21
|
-
{ count: 24, label: 'Authors', backgroundColor: '#3859BA' },
|
|
22
|
-
],
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Export Default story
|
|
26
|
-
export const _default = Template.bind( {} );
|
|
27
|
-
_default.args = DefaultArgs;
|
|
28
|
-
|
|
29
|
-
export const WithTotalCount = Template.bind( {} );
|
|
30
|
-
WithTotalCount.args = {
|
|
31
|
-
...DefaultArgs,
|
|
32
|
-
totalCount: 200,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const LabelBeforeCount = Template.bind( {} );
|
|
36
|
-
LabelBeforeCount.args = {
|
|
37
|
-
...DefaultArgs,
|
|
38
|
-
showLegendLabelBeforeCount: true,
|
|
39
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { render, queryByAttribute } from '@testing-library/react';
|
|
2
|
-
import RecordMeterBar, { RecordMeterBarProps } from '../index';
|
|
3
|
-
|
|
4
|
-
const getRecordBarItems = ( container: HTMLElement ) => {
|
|
5
|
-
// eslint-disable-next-line testing-library/no-node-access
|
|
6
|
-
return queryByAttribute( 'class', container, 'record-meter-bar__items' ).children;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const getRecordBarLegendItems = ( container: HTMLElement ) => {
|
|
10
|
-
// eslint-disable-next-line testing-library/no-node-access
|
|
11
|
-
return queryByAttribute( 'class', container, 'record-meter-bar__legend--items' ).children;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
describe( 'RecordMeterBar', () => {
|
|
15
|
-
const testProps: RecordMeterBarProps = {
|
|
16
|
-
items: [
|
|
17
|
-
{ count: 18, label: 'Posts', backgroundColor: '#00BA37' },
|
|
18
|
-
{ count: 30, label: 'Plugins', backgroundColor: '#3895BA' },
|
|
19
|
-
{ count: 52, label: 'Comments', backgroundColor: '#E68B28' },
|
|
20
|
-
{ count: 24, label: 'Authors', backgroundColor: '#3859BA' },
|
|
21
|
-
],
|
|
22
|
-
};
|
|
23
|
-
it( 'renders nothing when no items are passed', () => {
|
|
24
|
-
const { container } = render( <RecordMeterBar items={ [] } /> );
|
|
25
|
-
|
|
26
|
-
expect( getRecordBarItems( container ) ).toHaveLength( 0 );
|
|
27
|
-
} );
|
|
28
|
-
|
|
29
|
-
it( 'renders the bar when NO totalCount is passed', () => {
|
|
30
|
-
const { container } = render( <RecordMeterBar { ...testProps } /> );
|
|
31
|
-
|
|
32
|
-
expect( getRecordBarItems( container ) ).toHaveLength( 4 );
|
|
33
|
-
} );
|
|
34
|
-
|
|
35
|
-
it( 'renders the bar when totalCount IS passed', () => {
|
|
36
|
-
const { container } = render( <RecordMeterBar { ...testProps } totalCount={ 200 } /> );
|
|
37
|
-
|
|
38
|
-
expect( getRecordBarItems( container ) ).toHaveLength( 4 );
|
|
39
|
-
} );
|
|
40
|
-
|
|
41
|
-
it( 'renders the legend when NO totalCount is passed', () => {
|
|
42
|
-
const { container } = render( <RecordMeterBar { ...testProps } /> );
|
|
43
|
-
|
|
44
|
-
expect( getRecordBarLegendItems( container ) ).toHaveLength( 4 );
|
|
45
|
-
} );
|
|
46
|
-
|
|
47
|
-
it( 'renders the legend when totalCount IS passed', () => {
|
|
48
|
-
const { container } = render( <RecordMeterBar { ...testProps } totalCount={ 200 } /> );
|
|
49
|
-
|
|
50
|
-
expect( getRecordBarLegendItems( container ) ).toHaveLength( 4 );
|
|
51
|
-
} );
|
|
52
|
-
} );
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/react-in-jsx-scope */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import Spinner from '../index.jsx';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'JS Packages/Components/Spinner',
|
|
7
|
-
component: Spinner,
|
|
8
|
-
argTypes: {
|
|
9
|
-
color: { control: 'color' },
|
|
10
|
-
},
|
|
11
|
-
parameters: {
|
|
12
|
-
backgrounds: {
|
|
13
|
-
default: 'dark',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const Template = args => <Spinner { ...args } />;
|
|
19
|
-
|
|
20
|
-
export const _default = Template.bind( {} );
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
2
|
-
import Spinner from '../index';
|
|
3
|
-
|
|
4
|
-
describe( 'Spinner', () => {
|
|
5
|
-
const testProps = {
|
|
6
|
-
className: 'sample-classname',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
describe( 'Render the Spinner component', () => {
|
|
10
|
-
const { container } = render( <Spinner { ...testProps } /> );
|
|
11
|
-
|
|
12
|
-
it( 'validate the class name', () => {
|
|
13
|
-
// eslint-disable-next-line testing-library/no-node-access
|
|
14
|
-
expect( container.firstChild ).toHaveClass( 'sample-classname' );
|
|
15
|
-
} );
|
|
16
|
-
} );
|
|
17
|
-
} );
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import SplitButton from '../index';
|
|
2
|
-
import type { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: 'JS Packages/Components/Split Button',
|
|
6
|
-
component: SplitButton,
|
|
7
|
-
argTypes: {
|
|
8
|
-
variant: { type: 'select', options: [ undefined, 'secondary', 'primary', 'tertiary', 'link' ] },
|
|
9
|
-
},
|
|
10
|
-
args: {
|
|
11
|
-
controls: [
|
|
12
|
-
{
|
|
13
|
-
title: 'Add to cart',
|
|
14
|
-
icon: null,
|
|
15
|
-
onClick: () => null,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
title: 'Add to wishlist',
|
|
19
|
-
icon: null,
|
|
20
|
-
onClick: () => null,
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
parameters: {
|
|
25
|
-
backgrounds: {
|
|
26
|
-
default: 'dark',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
} as ComponentMeta< typeof SplitButton >;
|
|
30
|
-
|
|
31
|
-
const Template: ComponentStory< typeof SplitButton > = args => (
|
|
32
|
-
<SplitButton { ...args }>Buy now!</SplitButton>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
export const _default = Template.bind( {} );
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, Canvas } from '@storybook/blocks';
|
|
2
|
-
import StatCard from '../index';
|
|
3
|
-
import * as StatCardStories from './index.stories';
|
|
4
|
-
|
|
5
|
-
<Meta of={StatCardStories} />
|
|
6
|
-
|
|
7
|
-
# StatCard
|
|
8
|
-
|
|
9
|
-
Component that shows a stat value.
|
|
10
|
-
|
|
11
|
-
## API
|
|
12
|
-
|
|
13
|
-
### icon
|
|
14
|
-
|
|
15
|
-
- type: `JSX.Element`
|
|
16
|
-
|
|
17
|
-
### label
|
|
18
|
-
|
|
19
|
-
- type: `string`
|
|
20
|
-
|
|
21
|
-
### value
|
|
22
|
-
|
|
23
|
-
- type: `number`
|
|
24
|
-
|
|
25
|
-
### variant
|
|
26
|
-
|
|
27
|
-
- type: `string`
|
|
28
|
-
- default: `"square"`
|
|
29
|
-
|
|
30
|
-
It accepts 2 values: `square` and `horizontal`.
|
|
31
|
-
|
|
32
|
-
<Canvas withSource="open">
|
|
33
|
-
<Story id="js-packages-components-stat-card--default" />
|
|
34
|
-
<Story id="js-packages-components-stat-card--horizontal" />
|
|
35
|
-
</Canvas>
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Icon, postList } from '@wordpress/icons';
|
|
2
|
-
import StatCard from '..';
|
|
3
|
-
import type { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'JS Packages/Components/Stat Card',
|
|
7
|
-
component: StatCard,
|
|
8
|
-
argTypes: {
|
|
9
|
-
variant: {
|
|
10
|
-
control: { type: 'radio' },
|
|
11
|
-
options: [ 'square', 'horizontal' ],
|
|
12
|
-
},
|
|
13
|
-
label: {
|
|
14
|
-
control: { type: 'text' },
|
|
15
|
-
},
|
|
16
|
-
value: {
|
|
17
|
-
control: { type: 'number' },
|
|
18
|
-
},
|
|
19
|
-
icon: {
|
|
20
|
-
table: {
|
|
21
|
-
disable: true,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
} as ComponentMeta< typeof StatCard >;
|
|
26
|
-
|
|
27
|
-
const defaultArgs = {
|
|
28
|
-
icon: <Icon icon={ postList } color="green" />,
|
|
29
|
-
label: 'Posted this month',
|
|
30
|
-
value: 1806,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const Template: ComponentStory< typeof StatCard > = args => {
|
|
34
|
-
return <StatCard { ...args } />;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const _default = Template.bind( {} );
|
|
38
|
-
_default.args = defaultArgs;
|
|
39
|
-
|
|
40
|
-
export const Horizontal = Template.bind( {} );
|
|
41
|
-
Horizontal.args = { ...defaultArgs, variant: 'horizontal' };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import StatCard from '../index';
|
|
3
|
-
|
|
4
|
-
describe( 'StatCard', () => {
|
|
5
|
-
const testProps = {
|
|
6
|
-
icon: <div></div>,
|
|
7
|
-
label: 'Label',
|
|
8
|
-
value: 1806,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
describe( 'when using the square variant', () => {
|
|
12
|
-
it( 'renders the compact value', () => {
|
|
13
|
-
render( <StatCard { ...testProps } variant="square" /> );
|
|
14
|
-
expect( screen.getByText( '1.8K' ) ).toBeInTheDocument();
|
|
15
|
-
} );
|
|
16
|
-
} );
|
|
17
|
-
|
|
18
|
-
describe( 'when using the horizontal variant', () => {
|
|
19
|
-
it( 'renders the full value', () => {
|
|
20
|
-
render( <StatCard { ...testProps } variant="horizontal" /> );
|
|
21
|
-
expect( screen.getByText( '1,806' ) ).toBeInTheDocument();
|
|
22
|
-
} );
|
|
23
|
-
} );
|
|
24
|
-
} );
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import Status from '..';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'JS Packages/Components/Status',
|
|
5
|
-
component: Status,
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: 'centered',
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
|
-
export const Active = args => {
|
|
13
|
-
return <Status status="active" />;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
|
-
export const Error = args => {
|
|
18
|
-
return <Status status="error" />;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
-
export const ActionNeeded = args => {
|
|
23
|
-
return <Status status="action" />;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
-
export const Initializing = args => {
|
|
28
|
-
return <Status status="initializing" />;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
-
export const Inactive = args => {
|
|
33
|
-
return <Status status="inactive" />;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
-
export const CustomLabel = args => {
|
|
38
|
-
return <Status label="Code is poetry" />;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
42
|
-
export const NoLabel = args => {
|
|
43
|
-
return <Status status="active" label="" />;
|
|
44
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import TermsOfService from '..';
|
|
3
|
-
|
|
4
|
-
describe( 'TermsofService', () => {
|
|
5
|
-
it( "references only 'the buttons above' if multipleButtons is true", () => {
|
|
6
|
-
render( <TermsOfService multipleButtons /> );
|
|
7
|
-
expect(
|
|
8
|
-
screen.getByText(
|
|
9
|
-
( content, { textContent } ) =>
|
|
10
|
-
content !== '' && // filter out parent/wrapper elements
|
|
11
|
-
textContent.startsWith(
|
|
12
|
-
`By clicking the buttons above, you agree to our Terms of Service`
|
|
13
|
-
)
|
|
14
|
-
)
|
|
15
|
-
).toBeInTheDocument();
|
|
16
|
-
} );
|
|
17
|
-
|
|
18
|
-
it( 'references the label of the agreement button if one is defined', () => {
|
|
19
|
-
const buttonLabel = 'The best button ever';
|
|
20
|
-
|
|
21
|
-
render( <TermsOfService agreeButtonLabel={ buttonLabel } /> );
|
|
22
|
-
expect(
|
|
23
|
-
screen.getByText(
|
|
24
|
-
( content, { textContent } ) =>
|
|
25
|
-
content !== '' && // filter out parent/wrapper elements
|
|
26
|
-
textContent.startsWith(
|
|
27
|
-
`By clicking the ${ buttonLabel } button, you agree to our Terms of Service`
|
|
28
|
-
)
|
|
29
|
-
)
|
|
30
|
-
).toBeInTheDocument();
|
|
31
|
-
} );
|
|
32
|
-
|
|
33
|
-
it( 'links to the Terms of Service document (single button)', () => {
|
|
34
|
-
render( <TermsOfService agreeButtonLabel={ 'whatever' } /> );
|
|
35
|
-
expect( screen.getByText( 'Terms of Service', { selector: 'a' } ) ).toBeInTheDocument();
|
|
36
|
-
} );
|
|
37
|
-
|
|
38
|
-
it( 'links to the Terms of Service document (multiple buttons)', () => {
|
|
39
|
-
render( <TermsOfService multipleButtons /> );
|
|
40
|
-
expect( screen.getByText( 'Terms of Service', { selector: 'a' } ) ).toBeInTheDocument();
|
|
41
|
-
} );
|
|
42
|
-
|
|
43
|
-
it( 'links to the data sharing document (single button)', () => {
|
|
44
|
-
render( <TermsOfService agreeButtonLabel={ 'whatever' } /> );
|
|
45
|
-
expect( screen.getByText( 'share details', { selector: 'a' } ) ).toBeInTheDocument();
|
|
46
|
-
} );
|
|
47
|
-
|
|
48
|
-
it( 'links to the data sharing document (multiple buttons)', () => {
|
|
49
|
-
render( <TermsOfService multipleButtons /> );
|
|
50
|
-
expect( screen.getByText( 'share details', { selector: 'a' } ) ).toBeInTheDocument();
|
|
51
|
-
} );
|
|
52
|
-
} );
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import userEvent from '@testing-library/user-event';
|
|
3
|
-
import Testimonials from '../index';
|
|
4
|
-
import { Testimonial } from '../testimonial';
|
|
5
|
-
|
|
6
|
-
const testimonials = [
|
|
7
|
-
{
|
|
8
|
-
quote: 'This is a quote',
|
|
9
|
-
author: 'John Doe',
|
|
10
|
-
profession: 'CEO',
|
|
11
|
-
img: 'https://via.placeholder.com/150',
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
quote: 'This is another quote',
|
|
15
|
-
author: 'Jane Doe',
|
|
16
|
-
profession: 'CTO',
|
|
17
|
-
img: 'https://via.placeholder.com/149',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
quote: 'This is yet another quote',
|
|
21
|
-
author: 'Mary Doe',
|
|
22
|
-
profession: 'CFO',
|
|
23
|
-
img: 'https://via.placeholder.com/148',
|
|
24
|
-
},
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
describe( 'Testimonial', () => {
|
|
28
|
-
it( 'should render the testimonial', () => {
|
|
29
|
-
const { quote, author, profession } = testimonials[ 0 ];
|
|
30
|
-
|
|
31
|
-
render( <Testimonial { ...testimonials[ 0 ] } hidden={ false } /> );
|
|
32
|
-
|
|
33
|
-
expect( screen.getByText( `“${ quote }”` ) ).toBeInTheDocument();
|
|
34
|
-
expect( screen.getByText( author ) ).toBeInTheDocument();
|
|
35
|
-
expect( screen.getByText( profession ) ).toBeInTheDocument();
|
|
36
|
-
expect( screen.getByAltText( author ) ).toBeInTheDocument();
|
|
37
|
-
} );
|
|
38
|
-
} );
|
|
39
|
-
|
|
40
|
-
describe( 'Testimonials', () => {
|
|
41
|
-
it( 'should render the first testimonial on load', () => {
|
|
42
|
-
const { quote, author, profession } = testimonials[ 0 ];
|
|
43
|
-
render( <Testimonials testimonials={ testimonials } /> );
|
|
44
|
-
|
|
45
|
-
expect( screen.getByText( `“${ quote }”` ) ).toBeInTheDocument();
|
|
46
|
-
expect( screen.getByText( author ) ).toBeInTheDocument();
|
|
47
|
-
expect( screen.getByText( profession ) ).toBeInTheDocument();
|
|
48
|
-
expect( screen.getByAltText( author ) ).toBeInTheDocument();
|
|
49
|
-
} );
|
|
50
|
-
|
|
51
|
-
it( 'should render the next testimonial when the right arrow is clicked', () => {
|
|
52
|
-
const { author: secondAuthor } = testimonials[ 1 ];
|
|
53
|
-
|
|
54
|
-
render( <Testimonials testimonials={ testimonials } /> );
|
|
55
|
-
|
|
56
|
-
const rightArrow = screen.getByTestId( 'right-arrow' );
|
|
57
|
-
userEvent.click( rightArrow );
|
|
58
|
-
|
|
59
|
-
expect( screen.getByText( secondAuthor ) ).toBeInTheDocument();
|
|
60
|
-
|
|
61
|
-
userEvent.click( rightArrow );
|
|
62
|
-
|
|
63
|
-
const { author: thirdAuthor } = testimonials[ 2 ];
|
|
64
|
-
|
|
65
|
-
expect( screen.getByText( thirdAuthor ) ).toBeInTheDocument();
|
|
66
|
-
|
|
67
|
-
userEvent.click( rightArrow );
|
|
68
|
-
|
|
69
|
-
const { author } = testimonials[ 0 ];
|
|
70
|
-
|
|
71
|
-
expect( screen.getByText( author ) ).toBeInTheDocument();
|
|
72
|
-
} );
|
|
73
|
-
|
|
74
|
-
it( 'should render the previous testimonial when the left arrow is clicked', () => {
|
|
75
|
-
const { author: thirdAuthor } = testimonials[ 2 ];
|
|
76
|
-
|
|
77
|
-
render( <Testimonials testimonials={ testimonials } /> );
|
|
78
|
-
|
|
79
|
-
const leftArrow = screen.getByTestId( 'left-arrow' );
|
|
80
|
-
userEvent.click( leftArrow );
|
|
81
|
-
|
|
82
|
-
expect( screen.getByText( thirdAuthor ) ).toBeInTheDocument();
|
|
83
|
-
|
|
84
|
-
userEvent.click( leftArrow );
|
|
85
|
-
|
|
86
|
-
const { author: secondAuthor } = testimonials[ 1 ];
|
|
87
|
-
|
|
88
|
-
expect( screen.getByText( secondAuthor ) ).toBeInTheDocument();
|
|
89
|
-
|
|
90
|
-
userEvent.click( leftArrow );
|
|
91
|
-
|
|
92
|
-
const { author } = testimonials[ 0 ];
|
|
93
|
-
|
|
94
|
-
expect( screen.getByText( author ) ).toBeInTheDocument();
|
|
95
|
-
} );
|
|
96
|
-
|
|
97
|
-
it( 'should not render the arrows if there is only one testimonial', () => {
|
|
98
|
-
render( <Testimonials testimonials={ [ testimonials[ 0 ] ] } /> );
|
|
99
|
-
|
|
100
|
-
expect( screen.queryByTestId( 'left-arrow' ) ).not.toBeInTheDocument();
|
|
101
|
-
expect( screen.queryByTestId( 'right-arrow' ) ).not.toBeInTheDocument();
|
|
102
|
-
} );
|
|
103
|
-
} );
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { H2, H3 } from '../index';
|
|
3
|
-
import styles from './style.module.scss';
|
|
4
|
-
import type { H3Props } from '../types';
|
|
5
|
-
|
|
6
|
-
const TIPOGRAPHY_WEIGHTS: Array< H3Props[ 'weight' ] > = [ 'regular', 'bold' ];
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
title: 'JS Packages/Components/Text/Heading',
|
|
10
|
-
component: H2,
|
|
11
|
-
argTypes: {
|
|
12
|
-
children: {
|
|
13
|
-
control: { type: 'text' },
|
|
14
|
-
},
|
|
15
|
-
weight: {
|
|
16
|
-
control: { type: 'select' },
|
|
17
|
-
options: TIPOGRAPHY_WEIGHTS,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Helper component to create a the story.
|
|
24
|
-
*
|
|
25
|
-
* @param {object} props - Component props.
|
|
26
|
-
* @param {React.Component} props.children - Icon component children.
|
|
27
|
-
* @returns {React.Component} Text component instance.
|
|
28
|
-
*/
|
|
29
|
-
function Instance( { children } ) {
|
|
30
|
-
return (
|
|
31
|
-
<div className={ styles.instance }>
|
|
32
|
-
<span>Text above to the the component...</span>
|
|
33
|
-
{ children }
|
|
34
|
-
<span>Text below to the the component...</span>
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const TemplateH2 = args => (
|
|
40
|
-
<Instance>
|
|
41
|
-
<H2 { ...args }>
|
|
42
|
-
{ args?.children ||
|
|
43
|
-
'Headline Medium - Manage your Jetpack plan and products all in one place' }
|
|
44
|
-
</H2>
|
|
45
|
-
</Instance>
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const TemplateH3 = args => (
|
|
49
|
-
<Instance>
|
|
50
|
-
<H3 { ...args }>
|
|
51
|
-
{ args?.children ||
|
|
52
|
-
'Headline Small - Manage your Jetpack plan and products all in one place' }
|
|
53
|
-
</H3>
|
|
54
|
-
</Instance>
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const Template = args => {
|
|
58
|
-
return (
|
|
59
|
-
<>
|
|
60
|
-
<TemplateH2 { ...args } />
|
|
61
|
-
<TemplateH3 { ...args } />
|
|
62
|
-
</>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const DefaultArgs = {};
|
|
67
|
-
export const Default = Template.bind( {} );
|
|
68
|
-
Default.args = DefaultArgs;
|
|
69
|
-
|
|
70
|
-
export const HeadlineH2 = TemplateH2.bind( {} );
|
|
71
|
-
HeadlineH2.storyName = 'H2';
|
|
72
|
-
HeadlineH2.args = {
|
|
73
|
-
weight: 'bold',
|
|
74
|
-
} as H3Props;
|
|
75
|
-
|
|
76
|
-
export const HeadlineH3 = TemplateH3.bind( {} );
|
|
77
|
-
HeadlineH3.storyName = 'H3';
|
|
78
|
-
HeadlineH3.args = {
|
|
79
|
-
weight: 'bold',
|
|
80
|
-
} as H3Props;
|