@transferwise/components 0.0.0-experimental-40b5678 → 0.0.0-experimental-ef26b66
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/build/index.js.map +1 -1
- package/build/index.mjs.map +1 -1
- package/build/types/info/Info.d.ts +2 -2
- package/build/types/info/Info.d.ts.map +1 -1
- package/build/types/info/index.d.ts +1 -1
- package/build/types/info/index.d.ts.map +1 -1
- package/package.json +25 -25
- package/src/accordion/Accordion.spec.js +5 -5
- package/src/accordion/AccordionItem/AccordionItem.spec.js +2 -2
- package/src/actionButton/ActionButton.spec.tsx +5 -4
- package/src/alert/Alert.spec.tsx +4 -4
- package/src/alert/Alert.story.tsx +6 -5
- package/src/button/Button.spec.js +5 -4
- package/src/card/Card.spec.tsx +4 -4
- package/src/carousel/Carousel.spec.tsx +17 -17
- package/src/checkbox/Checkbox.spec.tsx +2 -0
- package/src/checkboxButton/CheckboxButton.spec.tsx +2 -0
- package/src/checkboxOption/CheckboxOption.spec.tsx +2 -0
- package/src/chevron/Chevron.spec.tsx +1 -0
- package/src/chips/Chips.spec.tsx +1 -0
- package/src/chips/Chips.story.tsx +5 -3
- package/src/circularButton/CircularButton.spec.tsx +5 -4
- package/src/common/RadioButton/RadioButton.spec.tsx +2 -2
- package/src/common/card/Card.story.tsx +1 -0
- package/src/common/closeButton/CloseButton.spec.tsx +1 -0
- package/src/common/flowHeader/FlowHeader.spec.tsx +1 -0
- package/src/dateInput/DateInput.story.tsx +21 -16
- package/src/dateLookup/DateLookup.rtl.spec.tsx +16 -18
- package/src/dateLookup/DateLookup.testingLibrary.spec.js +44 -47
- package/src/dateLookup/DateLookup.tests.story.tsx +4 -2
- package/src/decision/Decision.spec.js +2 -0
- package/src/dimmer/Dimmer.rtl.spec.js +10 -10
- package/src/drawer/Drawer.rtl.spec.tsx +2 -2
- package/src/emphasis/Emphasis.spec.tsx +1 -0
- package/src/field/Field.spec.tsx +2 -2
- package/src/flowNavigation/FlowNavigation.spec.js +2 -0
- package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +1 -0
- package/src/header/Header.spec.tsx +6 -6
- package/src/image/Image.spec.tsx +1 -0
- package/src/info/Info.story.tsx +15 -9
- package/src/info/Info.tsx +2 -2
- package/src/info/index.ts +1 -1
- package/src/inlineAlert/InlineAlert.spec.tsx +1 -0
- package/src/inputs/SelectInput.spec.tsx +47 -26
- package/src/link/Link.spec.tsx +1 -0
- package/src/listItem/ListItem.spec.tsx +1 -0
- package/src/moneyInput/MoneyInput.rtl.spec.tsx +2 -2
- package/src/moneyInput/MoneyInput.story.tsx +1 -4
- package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -0
- package/src/popover/Popover.spec.tsx +10 -10
- package/src/progress/Progress.spec.tsx +1 -0
- package/src/progressBar/ProgressBar.spec.tsx +1 -0
- package/src/segmentedControl/SegmentedControl.spec.tsx +11 -10
- package/src/select/Select.spec.js +71 -71
- package/src/test-utils/index.js +1 -1
- package/src/test-utils/jest.setup.js +0 -2
- package/src/tooltip/Tooltip.spec.tsx +16 -15
- package/src/uploadInput/UploadInput.spec.tsx +10 -9
- package/src/uploadInput/UploadInput.story.tsx +23 -21
- package/src/uploadInput/uploadButton/UploadButton.spec.tsx +4 -4
- package/src/uploadInput/uploadItem/UploadItem.spec.tsx +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SizeSmall, SizeLarge } from '../common';
|
|
2
2
|
import { PopoverPreferredPlacement } from '../popover';
|
|
3
|
-
export interface
|
|
3
|
+
export interface InfoProps {
|
|
4
4
|
'aria-label'?: string;
|
|
5
5
|
/**
|
|
6
6
|
* Extra classes applied to Info
|
|
@@ -28,6 +28,6 @@ export interface Props {
|
|
|
28
28
|
*/
|
|
29
29
|
preferredPlacement?: PopoverPreferredPlacement;
|
|
30
30
|
}
|
|
31
|
-
declare const Info: ({ className, content, onClick, presentation, size, title, "aria-label": ariaLabel, preferredPlacement, }:
|
|
31
|
+
declare const Info: ({ className, content, onClick, presentation, size, title, "aria-label": ariaLabel, preferredPlacement, }: InfoProps) => import("react").JSX.Element;
|
|
32
32
|
export default Info;
|
|
33
33
|
//# sourceMappingURL=Info.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Info.d.ts","sourceRoot":"","sources":["../../../src/info/Info.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAkB,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAgB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAKhE,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"Info.d.ts","sourceRoot":"","sources":["../../../src/info/Info.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAkB,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAgB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAKhE,MAAM,WAAW,SAAS;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;CAChD;AAED,QAAA,MAAM,IAAI,6GASP,SAAS,gCAiDX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-ef26b66",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -50,26 +50,25 @@
|
|
|
50
50
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
51
51
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
52
52
|
"@rollup/plugin-url": "^8.0.2",
|
|
53
|
-
"@storybook/addon-a11y": "^
|
|
54
|
-
"@storybook/addon-actions": "^
|
|
55
|
-
"@storybook/addon-essentials": "^
|
|
56
|
-
"@storybook/addon-interactions": "^
|
|
57
|
-
"@storybook/addon-knobs": "^
|
|
58
|
-
"@storybook/addon-viewport": "^
|
|
59
|
-
"@storybook/
|
|
60
|
-
"@storybook/
|
|
61
|
-
"@storybook/
|
|
62
|
-
"@storybook/
|
|
63
|
-
"@storybook/
|
|
64
|
-
"@storybook/react": "^
|
|
65
|
-
"@storybook/
|
|
66
|
-
"@storybook/
|
|
67
|
-
"@storybook/
|
|
68
|
-
"@
|
|
69
|
-
"@testing-library/dom": "^
|
|
70
|
-
"@testing-library/
|
|
71
|
-
"@testing-library/
|
|
72
|
-
"@testing-library/user-event": "^14.5.2",
|
|
53
|
+
"@storybook/addon-a11y": "^8.1.10",
|
|
54
|
+
"@storybook/addon-actions": "^8.1.10",
|
|
55
|
+
"@storybook/addon-essentials": "^8.1.10",
|
|
56
|
+
"@storybook/addon-interactions": "^8.1.10",
|
|
57
|
+
"@storybook/addon-knobs": "^8.0.1",
|
|
58
|
+
"@storybook/addon-viewport": "^8.1.10",
|
|
59
|
+
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
|
|
60
|
+
"@storybook/components": "^8.1.10",
|
|
61
|
+
"@storybook/core-events": "^8.1.10",
|
|
62
|
+
"@storybook/manager-api": "^8.1.10",
|
|
63
|
+
"@storybook/react": "^8.1.10",
|
|
64
|
+
"@storybook/react-webpack5": "^8.1.10",
|
|
65
|
+
"@storybook/test": "^8.1.10",
|
|
66
|
+
"@storybook/theming": "^8.1.10",
|
|
67
|
+
"@storybook/types": "^8.1.10",
|
|
68
|
+
"@testing-library/dom": "^8.20.1",
|
|
69
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
70
|
+
"@testing-library/react": "^13.4.0",
|
|
71
|
+
"@testing-library/user-event": "^13.5.0",
|
|
73
72
|
"@transferwise/icons": "^3.7.0",
|
|
74
73
|
"@transferwise/neptune-tokens": "^8.9.2",
|
|
75
74
|
"@tsconfig/recommended": "^1.0.6",
|
|
@@ -82,6 +81,7 @@
|
|
|
82
81
|
"@types/react": "^18.3.3",
|
|
83
82
|
"@types/react-dom": "^18.3.0",
|
|
84
83
|
"@types/react-transition-group": "4.4.10",
|
|
84
|
+
"@types/testing-library__jest-dom": "^5.14.9",
|
|
85
85
|
"@wise/art": "^2.7.0",
|
|
86
86
|
"babel-plugin-formatjs": "^10.5.14",
|
|
87
87
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
@@ -92,10 +92,10 @@
|
|
|
92
92
|
"lodash.times": "^4.3.2",
|
|
93
93
|
"react-intl": "^6.6.6",
|
|
94
94
|
"rollup": "^4.17.2",
|
|
95
|
-
"storybook": "^
|
|
95
|
+
"storybook": "^8.1.10",
|
|
96
96
|
"@transferwise/less-config": "3.1.0",
|
|
97
|
-
"@
|
|
98
|
-
"@
|
|
97
|
+
"@transferwise/neptune-css": "14.10.0",
|
|
98
|
+
"@wise/components-theming": "1.3.0"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
101
|
"@transferwise/icons": "^3.7.0",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"dev:less:watch": "gulp watchLess --dest=src",
|
|
137
137
|
"dev:translations": "pnpm build:crowdin-source-file",
|
|
138
138
|
"storybook:dev": "storybook dev -p 3001",
|
|
139
|
-
"storybook:build": "storybook build --
|
|
139
|
+
"storybook:build": "storybook build --stats-json",
|
|
140
140
|
"build:css": "gulp compileLess --dest=src",
|
|
141
141
|
"build": "npm-run-all build:*",
|
|
142
142
|
"build:clean": "rm -rf lib build",
|
|
@@ -49,25 +49,25 @@ describe('Accordion', () => {
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
describe('open and close', () => {
|
|
52
|
-
it('can open and close an item when clicked',
|
|
52
|
+
it('can open and close an item when clicked', () => {
|
|
53
53
|
const item = items[0];
|
|
54
54
|
render(<Accordion items={items} />);
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
userEvent.click(screen.getByRole('button', { name: item.title }));
|
|
57
57
|
expect(screen.getByText(item.content)).toBeInTheDocument();
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
userEvent.click(screen.getByRole('button', { name: item.title }));
|
|
60
60
|
expect(screen.queryByText(item.content)).not.toBeInTheDocument();
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
describe('onClick', () => {
|
|
65
|
-
it('calls onClick when an item is clicked',
|
|
65
|
+
it('calls onClick when an item is clicked', () => {
|
|
66
66
|
const onClick = jest.fn();
|
|
67
67
|
|
|
68
68
|
render(<Accordion items={items} onClick={onClick} />);
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
userEvent.click(screen.getAllByRole('button')[0]);
|
|
71
71
|
|
|
72
72
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
73
73
|
expect(onClick).toHaveBeenCalledWith(0);
|
|
@@ -39,12 +39,12 @@ describe('AccordionItem', () => {
|
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
describe('onClick', () => {
|
|
42
|
-
it('calls onClick when item is clicked',
|
|
42
|
+
it('calls onClick when item is clicked', () => {
|
|
43
43
|
const onClick = jest.fn();
|
|
44
44
|
|
|
45
45
|
render(<AccordionItem {...props} onClick={onClick} />);
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
userEvent.click(screen.getByRole('button'));
|
|
48
48
|
|
|
49
49
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
50
50
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
1
2
|
import { render, screen, userEvent } from '../test-utils';
|
|
2
3
|
|
|
3
4
|
import ActionButton from '.';
|
|
@@ -39,17 +40,17 @@ describe('ActionButton', () => {
|
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
describe('onClick', () => {
|
|
42
|
-
it('calls onClick when clicked',
|
|
43
|
+
it('calls onClick when clicked', () => {
|
|
43
44
|
const onClick = jest.fn();
|
|
44
45
|
render(<ActionButton {...props} onClick={onClick} />);
|
|
45
|
-
|
|
46
|
+
userEvent.click(screen.getByRole('button'));
|
|
46
47
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
47
48
|
});
|
|
48
49
|
|
|
49
|
-
it('does not call onClick when clicked if disabled',
|
|
50
|
+
it('does not call onClick when clicked if disabled', () => {
|
|
50
51
|
const onClick = jest.fn();
|
|
51
52
|
render(<ActionButton {...props} disabled onClick={onClick} />);
|
|
52
|
-
|
|
53
|
+
userEvent.click(screen.getByRole('button'));
|
|
53
54
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
54
55
|
});
|
|
55
56
|
});
|
package/src/alert/Alert.spec.tsx
CHANGED
|
@@ -175,14 +175,14 @@ describe('Alert', () => {
|
|
|
175
175
|
expect(element).not.toHaveAttribute('target');
|
|
176
176
|
});
|
|
177
177
|
|
|
178
|
-
it('sets text and onClick',
|
|
178
|
+
it('sets text and onClick', () => {
|
|
179
179
|
action = {
|
|
180
180
|
onClick: jest.fn(),
|
|
181
181
|
text: 'Learn more',
|
|
182
182
|
};
|
|
183
183
|
render(<Alert action={action} message={message} />);
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
userEvent.click(screen.getByText('Learn more'));
|
|
186
186
|
|
|
187
187
|
expect(action.onClick).toHaveBeenCalled();
|
|
188
188
|
});
|
|
@@ -246,12 +246,12 @@ describe('Alert', () => {
|
|
|
246
246
|
expect(screen.getByRole('button')).toBeInTheDocument();
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
it('calls onDismiss when the close button is clicked',
|
|
249
|
+
it('calls onDismiss when the close button is clicked', () => {
|
|
250
250
|
const onDismiss = jest.fn();
|
|
251
251
|
|
|
252
252
|
render(<Alert message={message} onDismiss={onDismiss} />);
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
userEvent.click(screen.getByRole('button'));
|
|
255
255
|
|
|
256
256
|
expect(onDismiss).toHaveBeenCalledTimes(1);
|
|
257
257
|
});
|
|
@@ -41,11 +41,7 @@ export default {
|
|
|
41
41
|
|
|
42
42
|
type Story = StoryObj<typeof Alert>;
|
|
43
43
|
|
|
44
|
-
export const Basic: Story = {
|
|
45
|
-
args: {
|
|
46
|
-
onDismiss: undefined,
|
|
47
|
-
},
|
|
48
|
-
};
|
|
44
|
+
export const Basic: Story = {};
|
|
49
45
|
|
|
50
46
|
export const WithLinkAction: Story = {
|
|
51
47
|
args: {
|
|
@@ -53,6 +49,7 @@ export const WithLinkAction: Story = {
|
|
|
53
49
|
href: '/',
|
|
54
50
|
text: 'Read more',
|
|
55
51
|
},
|
|
52
|
+
onDismiss: () => {},
|
|
56
53
|
},
|
|
57
54
|
};
|
|
58
55
|
|
|
@@ -62,12 +59,14 @@ export const WithButtonAction: Story = {
|
|
|
62
59
|
onClick: action('alert action clicked'),
|
|
63
60
|
text: 'Open',
|
|
64
61
|
},
|
|
62
|
+
onDismiss: () => {},
|
|
65
63
|
},
|
|
66
64
|
};
|
|
67
65
|
|
|
68
66
|
export const WithArrow: Story = {
|
|
69
67
|
args: {
|
|
70
68
|
arrow: AlertArrowPosition.TOP_LEFT,
|
|
69
|
+
onDismiss: () => {},
|
|
71
70
|
},
|
|
72
71
|
};
|
|
73
72
|
|
|
@@ -93,6 +92,7 @@ const CustomIcon = () => {
|
|
|
93
92
|
export const WithCustomIcon: Story = {
|
|
94
93
|
args: {
|
|
95
94
|
icon: <CustomIcon />,
|
|
95
|
+
onDismiss: () => {},
|
|
96
96
|
},
|
|
97
97
|
};
|
|
98
98
|
|
|
@@ -100,5 +100,6 @@ export const WithTitle: Story = {
|
|
|
100
100
|
args: {
|
|
101
101
|
type: Sentiment.NEUTRAL,
|
|
102
102
|
title: 'We’re reviewing your information.',
|
|
103
|
+
onDismiss: () => {},
|
|
103
104
|
},
|
|
104
105
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { createRef } from 'react';
|
|
3
3
|
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
4
5
|
import { ControlType, Type, Priority, Size } from '../common';
|
|
5
6
|
import { render, cleanup, screen, userEvent } from '../test-utils';
|
|
6
7
|
|
|
@@ -93,17 +94,17 @@ describe('Button', () => {
|
|
|
93
94
|
});
|
|
94
95
|
|
|
95
96
|
describe('onClick', () => {
|
|
96
|
-
it('calls onClick when clicked',
|
|
97
|
+
it('calls onClick when clicked', () => {
|
|
97
98
|
const onClick = jest.fn();
|
|
98
99
|
render(<Button {...props} onClick={onClick} />);
|
|
99
|
-
|
|
100
|
+
userEvent.click(screen.getByRole('button'));
|
|
100
101
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
101
102
|
});
|
|
102
103
|
|
|
103
|
-
it('does not call onClick when clicked if disabled',
|
|
104
|
+
it('does not call onClick when clicked if disabled', () => {
|
|
104
105
|
const onClick = jest.fn();
|
|
105
106
|
render(<Button {...props} disabled onClick={onClick} />);
|
|
106
|
-
|
|
107
|
+
userEvent.click(screen.getByRole('button'));
|
|
107
108
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
108
109
|
});
|
|
109
110
|
});
|
package/src/card/Card.spec.tsx
CHANGED
|
@@ -68,10 +68,10 @@ describe('Card', () => {
|
|
|
68
68
|
expect(screen.getByTestId(dataTestId)).toHaveClass('np-card--inactive');
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
it("doesn't call onClick when clicked",
|
|
71
|
+
it("doesn't call onClick when clicked", () => {
|
|
72
72
|
renderCard();
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
userEvent.click(screen.getByText(defaultProps.title));
|
|
75
75
|
|
|
76
76
|
expect(defaultProps.onClick).not.toHaveBeenCalled();
|
|
77
77
|
});
|
|
@@ -84,7 +84,7 @@ describe('Card', () => {
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
describe('when there is children prop', () => {
|
|
87
|
-
it('calls on onClick with inverse of current isExpanded value when clicked',
|
|
87
|
+
it('calls on onClick with inverse of current isExpanded value when clicked', () => {
|
|
88
88
|
const onClick = jest.fn();
|
|
89
89
|
renderCard({
|
|
90
90
|
'aria-label': 'test',
|
|
@@ -94,7 +94,7 @@ describe('Card', () => {
|
|
|
94
94
|
onClick,
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
userEvent.click(screen.getByRole('button', { name: 'test' }));
|
|
98
98
|
expect(onClick).toHaveBeenCalledWith(true);
|
|
99
99
|
});
|
|
100
100
|
|
|
@@ -69,7 +69,7 @@ describe('Carousel', () => {
|
|
|
69
69
|
expect(screen.getByText('Get Quick Pay')).toBeInTheDocument();
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
it('allows user to scroll carousel to the right when at start',
|
|
72
|
+
it('allows user to scroll carousel to the right when at start', () => {
|
|
73
73
|
mockPositions(948, 903);
|
|
74
74
|
|
|
75
75
|
renderCarousel();
|
|
@@ -80,12 +80,12 @@ describe('Carousel', () => {
|
|
|
80
80
|
expect(scrollLeftButton).toBeDisabled();
|
|
81
81
|
expect(scrollRightButton).toBeEnabled();
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
userEvent.click(scrollRightButton);
|
|
84
84
|
|
|
85
85
|
expect(scrollBy).toHaveBeenCalledWith({ left: 300, behavior: 'smooth' });
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
it('allows user to scroll carousel to the left or right when in middle',
|
|
88
|
+
it('allows user to scroll carousel to the left or right when in middle', () => {
|
|
89
89
|
mockPositions(948, 903);
|
|
90
90
|
|
|
91
91
|
renderCarousel();
|
|
@@ -99,16 +99,16 @@ describe('Carousel', () => {
|
|
|
99
99
|
expect(scrollLeftButton).toBeEnabled();
|
|
100
100
|
expect(scrollRightButton).toBeEnabled();
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
userEvent.click(scrollLeftButton);
|
|
103
103
|
|
|
104
104
|
expect(scrollBy).toHaveBeenCalledWith({ left: -300, behavior: 'smooth' });
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
userEvent.click(scrollRightButton);
|
|
107
107
|
|
|
108
108
|
expect(scrollBy).toHaveBeenCalledWith({ left: 300, behavior: 'smooth' });
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
it('allows user to scroll carousel to the left when at end',
|
|
111
|
+
it('allows user to scroll carousel to the left when at end', () => {
|
|
112
112
|
mockPositions(948, 903);
|
|
113
113
|
|
|
114
114
|
renderCarousel();
|
|
@@ -122,7 +122,7 @@ describe('Carousel', () => {
|
|
|
122
122
|
expect(scrollLeftButton).toBeEnabled();
|
|
123
123
|
expect(scrollRightButton).toBeDisabled();
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
userEvent.click(scrollLeftButton);
|
|
126
126
|
|
|
127
127
|
expect(scrollBy).toHaveBeenCalledWith({ left: -300, behavior: 'smooth' });
|
|
128
128
|
});
|
|
@@ -142,23 +142,23 @@ describe('Carousel', () => {
|
|
|
142
142
|
expect(focusSpy).toHaveBeenCalledTimes(0);
|
|
143
143
|
expect(firstCard).toHaveClass('carousel__card--focused');
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
userEvent.click(yourWebsiteIndicator);
|
|
146
146
|
|
|
147
147
|
expect(focusSpy).toHaveBeenCalledTimes(1);
|
|
148
148
|
expect(secondCard).toHaveClass('carousel__card--focused');
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
userEvent.click(shopOrStallIndicator);
|
|
151
151
|
|
|
152
152
|
expect(focusSpy).toHaveBeenCalledTimes(2);
|
|
153
153
|
expect(thirdCard).toHaveClass('carousel__card--focused');
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
userEvent.click(yourInvoiceIndicator);
|
|
156
156
|
|
|
157
157
|
expect(focusSpy).toHaveBeenCalledTimes(3);
|
|
158
158
|
expect(firstCard).toHaveClass('carousel__card--focused');
|
|
159
159
|
});
|
|
160
160
|
|
|
161
|
-
it('is focused on the first element and lets user navigate through them',
|
|
161
|
+
it('is focused on the first element and lets user navigate through them', () => {
|
|
162
162
|
renderCarousel();
|
|
163
163
|
|
|
164
164
|
const firstCard = getFirstCard();
|
|
@@ -170,27 +170,27 @@ describe('Carousel', () => {
|
|
|
170
170
|
firstCard.focus();
|
|
171
171
|
expect(firstCard).toHaveFocus();
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
userEvent.keyboard('{arrowright}');
|
|
174
174
|
|
|
175
175
|
expect(secondCard).toHaveFocus();
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
userEvent.keyboard('{arrowright}');
|
|
178
178
|
|
|
179
179
|
expect(thirdCard).toHaveFocus();
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
userEvent.keyboard('{arrowleft}');
|
|
182
182
|
|
|
183
183
|
expect(secondCard).toHaveFocus();
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
userEvent.keyboard('{arrowleft}');
|
|
186
186
|
|
|
187
187
|
expect(firstCard).toHaveFocus();
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
-
it('calls onClick when a card is clicked',
|
|
190
|
+
it('calls onClick when a card is clicked', () => {
|
|
191
191
|
renderCarousel();
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
userEvent.click(getFirstCard());
|
|
194
194
|
|
|
195
195
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
196
196
|
expect(yourInvoiceOnClick).toHaveBeenCalledTimes(1);
|
package/src/chips/Chips.spec.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StoryFn, Meta } from '@storybook/react';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import Chips, { ChipsProps, ChipValue } from './Chips';
|
|
@@ -10,7 +10,9 @@ const meta: Meta<typeof Chips> = {
|
|
|
10
10
|
};
|
|
11
11
|
export default meta;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
type Story = StoryFn<ChipsProps>;
|
|
14
|
+
|
|
15
|
+
const FilterTemplate: Story = (args: ChipsProps) => {
|
|
14
16
|
const [selected, setSelected] = useState<readonly ChipValue[]>(
|
|
15
17
|
args.selected == null || Array.isArray(args.selected) ? args.selected : [args.selected],
|
|
16
18
|
);
|
|
@@ -31,7 +33,7 @@ const FilterTemplate: Story<ChipsProps> = (args: ChipsProps) => {
|
|
|
31
33
|
);
|
|
32
34
|
};
|
|
33
35
|
|
|
34
|
-
const ChoiceTemplate: Story
|
|
36
|
+
const ChoiceTemplate: Story = (args: ChipsProps) => {
|
|
35
37
|
const [selected, setSelected] = useState<ChipValue>(args.selected as ChipValue);
|
|
36
38
|
return (
|
|
37
39
|
<Chips
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
1
2
|
import { Plus } from '@transferwise/icons';
|
|
2
3
|
|
|
3
4
|
import { ControlType, Priority } from '../common';
|
|
@@ -53,17 +54,17 @@ describe('CircularButton', () => {
|
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
describe('onClick', () => {
|
|
56
|
-
it('calls onClick when clicked',
|
|
57
|
+
it('calls onClick when clicked', () => {
|
|
57
58
|
const onClick = jest.fn();
|
|
58
59
|
render(<CircularButton {...props} onClick={onClick} />);
|
|
59
|
-
|
|
60
|
+
userEvent.click(screen.getByRole('button'));
|
|
60
61
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
61
62
|
});
|
|
62
63
|
|
|
63
|
-
it('does not call onClick when clicked if disabled',
|
|
64
|
+
it('does not call onClick when clicked if disabled', () => {
|
|
64
65
|
const onClick = jest.fn();
|
|
65
66
|
render(<CircularButton {...props} disabled onClick={onClick} />);
|
|
66
|
-
|
|
67
|
+
userEvent.click(screen.getByRole('button'));
|
|
67
68
|
expect(onClick).toHaveBeenCalledTimes(0);
|
|
68
69
|
});
|
|
69
70
|
});
|
|
@@ -21,7 +21,7 @@ describe('Radio button', () => {
|
|
|
21
21
|
expect(container).toMatchSnapshot();
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it('responds to user input',
|
|
24
|
+
it('responds to user input', () => {
|
|
25
25
|
const onChange = jest.fn();
|
|
26
26
|
render(
|
|
27
27
|
<label htmlFor="an-id">
|
|
@@ -29,7 +29,7 @@ describe('Radio button', () => {
|
|
|
29
29
|
</label>,
|
|
30
30
|
);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
userEvent.click(screen.getByLabelText('A radio'));
|
|
33
33
|
|
|
34
34
|
expect(onChange).toHaveBeenCalledWith('a-value');
|
|
35
35
|
});
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { userEvent, within } from '@storybook/test';
|
|
3
|
-
import * as React from 'react';
|
|
4
3
|
|
|
5
4
|
import { DateInput, DateMode, Info, InlineAlert, Title, Typography } from '..';
|
|
6
5
|
import { lorem10, storyConfig } from '../test-utils';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export default {
|
|
7
|
+
const meta = {
|
|
11
8
|
component: DateInput,
|
|
12
9
|
title: 'Forms/DateInput',
|
|
13
10
|
args: {
|
|
@@ -20,16 +17,24 @@ export default {
|
|
|
20
17
|
tags: ['autodocs'],
|
|
21
18
|
} satisfies Meta<typeof DateInput>;
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
export default meta;
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
type Story = StoryObj<typeof meta>;
|
|
26
23
|
|
|
27
|
-
Basic
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
24
|
+
export const Basic = {
|
|
25
|
+
args: {
|
|
26
|
+
onChange: () => {},
|
|
27
|
+
},
|
|
28
|
+
play: async ({ canvasElement }) => {
|
|
29
|
+
const canvas = within(canvasElement);
|
|
30
|
+
await userEvent.click(canvas.getByRole('button'));
|
|
31
|
+
},
|
|
32
|
+
} satisfies Story;
|
|
31
33
|
|
|
32
|
-
export const WithLabel
|
|
34
|
+
export const WithLabel = {
|
|
35
|
+
args: {
|
|
36
|
+
onChange: () => {},
|
|
37
|
+
},
|
|
33
38
|
render: (args) => {
|
|
34
39
|
const id1 = 'date-input-group-label-1';
|
|
35
40
|
const label = 'Date of Birth';
|
|
@@ -71,11 +76,11 @@ export const WithLabel: Story = {
|
|
|
71
76
|
</>
|
|
72
77
|
);
|
|
73
78
|
},
|
|
74
|
-
};
|
|
79
|
+
} satisfies Story;
|
|
75
80
|
|
|
76
|
-
export const BasicMobile
|
|
81
|
+
export const BasicMobile = storyConfig(Basic, { variants: ['mobile'] });
|
|
77
82
|
|
|
78
|
-
export const InputError
|
|
83
|
+
export const InputError = {
|
|
79
84
|
...Basic,
|
|
80
85
|
render: (args) => (
|
|
81
86
|
<div className="form-group has-error">
|
|
@@ -83,6 +88,6 @@ export const InputError: Story = {
|
|
|
83
88
|
<InlineAlert type="error">{lorem10}</InlineAlert>
|
|
84
89
|
</div>
|
|
85
90
|
),
|
|
86
|
-
};
|
|
91
|
+
} satisfies Story;
|
|
87
92
|
|
|
88
|
-
export const InputErrorMobile
|
|
93
|
+
export const InputErrorMobile = storyConfig(InputError, { variants: ['mobile'] });
|