@transferwise/components 46.87.2 → 46.88.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/build/avatarLayout/AvatarLayout.js +9 -2
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +9 -2
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/button/Button.js +92 -79
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +93 -80
- package/build/button/Button.mjs.map +1 -1
- package/build/button/Button.resolver.js +74 -0
- package/build/button/Button.resolver.js.map +1 -0
- package/build/button/Button.resolver.mjs +72 -0
- package/build/button/Button.resolver.mjs.map +1 -0
- package/build/button/LegacyButton.js +114 -0
- package/build/button/LegacyButton.js.map +1 -0
- package/build/button/LegacyButton.mjs +112 -0
- package/build/button/LegacyButton.mjs.map +1 -0
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +2 -2
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/header/Header.js +2 -2
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/link/Link.js +8 -3
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +8 -3
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +247 -0
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +2 -4
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +2 -4
- package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +3 -5
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +3 -5
- package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
- package/build/select/Select.js +2 -2
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +11 -0
- package/build/styles/button/Button.css +228 -15
- package/build/styles/button/Button.vars.css +46 -0
- package/build/styles/button/LegacyButton.css +23 -0
- package/build/styles/main.css +247 -0
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/button/Button.d.ts +2 -23
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/Button.resolver.d.ts +35 -0
- package/build/types/button/Button.resolver.d.ts.map +1 -0
- package/build/types/button/Button.types.d.ts +70 -0
- package/build/types/button/Button.types.d.ts.map +1 -0
- package/build/types/button/LegacyButton.d.ts +44 -0
- package/build/types/button/LegacyButton.d.ts.map +1 -0
- package/build/types/button/index.d.ts +2 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/circularButton/CircularButton.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +6 -2
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
- package/build/types/test-utils/story-config.d.ts +1 -1
- package/build/types/test-utils/story-config.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +2 -2
- package/build/upload/steps/completeStep/completeStep.js.map +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +2 -2
- package/build/upload/steps/processingStep/processingStep.js.map +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +3 -3
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/package.json +3 -3
- package/src/alert/Alert.tests.story.tsx +1 -1
- package/src/avatar/Avatar.story.tsx +1 -1
- package/src/avatarLayout/AvatarLayout.css +11 -0
- package/src/avatarLayout/AvatarLayout.less +18 -1
- package/src/avatarLayout/AvatarLayout.tsx +10 -2
- package/src/avatarWrapper/AvatarWrapper.story.tsx +1 -1
- package/src/badge/Badge.story.tsx +1 -1
- package/src/button/Button.accessibility.docs.mdx +103 -0
- package/src/button/Button.css +228 -15
- package/src/button/Button.less +242 -14
- package/src/button/Button.resolver.tsx +73 -0
- package/src/button/Button.spec.tsx +329 -213
- package/src/button/Button.story.tsx +782 -134
- package/src/button/Button.tests.story.tsx +27 -0
- package/src/button/Button.tsx +103 -132
- package/src/button/Button.types.ts +92 -0
- package/src/button/Button.vars.css +46 -0
- package/src/button/Button.vars.less +59 -0
- package/src/button/LegacyButton.css +23 -0
- package/src/button/LegacyButton.less +24 -0
- package/src/button/LegacyButton.spec.tsx +147 -0
- package/src/button/LegacyButton.story.tsx +228 -0
- package/src/button/LegacyButton.tsx +177 -0
- package/src/button/index.ts +2 -3
- package/src/card/Card.story.tsx +6 -1
- package/src/circularButton/CircularButton.tsx +1 -0
- package/src/field/Field.story.tsx +1 -1
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -2
- package/src/inputs/SelectInput.story.tsx +1 -1
- package/src/label/Label.story.tsx +1 -1
- package/src/link/Link.tsx +15 -6
- package/src/main.css +247 -0
- package/src/main.less +1 -0
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +2 -8
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +7 -2
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +4 -12
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +16 -13
- package/src/select/Select.story.tsx +4 -1
- package/src/test-utils/Parameters.d.ts +9 -1
- package/src/test-utils/story-config.ts +10 -1
- package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
|
@@ -1,246 +1,362 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Freeze } from '@transferwise/icons';
|
|
2
|
+
import { mockMatchMedia, render, screen } from '../test-utils';
|
|
3
|
+
import Button, { ButtonProps } from './Button.resolver';
|
|
4
|
+
import { CommonProps } from './Button.types';
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
import { render, screen, userEvent } from '../test-utils';
|
|
5
|
-
|
|
6
|
-
import Button from '.';
|
|
7
|
-
import messages from '../i18n/commonMessages/Button.messages';
|
|
8
|
-
import { ButtonReferenceType } from './Button';
|
|
9
|
-
|
|
10
|
-
const { ACCENT, POSITIVE, NEGATIVE } = ControlType;
|
|
11
|
-
const { PAY, LINK, DANGER } = Type;
|
|
12
|
-
const { PRIMARY, SECONDARY, TERTIARY } = Priority;
|
|
13
|
-
const { SMALL, MEDIUM, LARGE } = Size;
|
|
6
|
+
mockMatchMedia();
|
|
14
7
|
|
|
15
8
|
describe('Button', () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
onClick: jest.fn(),
|
|
22
|
-
onFocus: jest.fn(),
|
|
23
|
-
onBlur: jest.fn(),
|
|
24
|
-
children: 'Send money',
|
|
9
|
+
const legacyProps: ButtonProps = {
|
|
10
|
+
as: 'button',
|
|
11
|
+
priority: 'primary',
|
|
12
|
+
size: 'md',
|
|
13
|
+
type: 'accent',
|
|
25
14
|
};
|
|
26
15
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// eslint-disable-next-line no-console
|
|
34
|
-
console.warn = mockedWarn;
|
|
35
|
-
});
|
|
16
|
+
const newProps: ButtonProps = {
|
|
17
|
+
as: 'button',
|
|
18
|
+
v2: true,
|
|
19
|
+
priority: 'primary',
|
|
20
|
+
size: 'md',
|
|
21
|
+
};
|
|
36
22
|
|
|
37
|
-
|
|
23
|
+
const testId = 'new-button';
|
|
38
24
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
it('renders LegacyButton when v2 is false', () => {
|
|
26
|
+
render(<Button {...legacyProps}>Legacy Button</Button>);
|
|
27
|
+
const button = screen.getByText('Legacy Button');
|
|
28
|
+
expect(button).toBeInTheDocument();
|
|
29
|
+
expect(button).toHaveClass('btn btn-md np-btn np-btn-md btn-accent btn-priority-1');
|
|
42
30
|
});
|
|
43
31
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
expect(reference.current).toBeFalsy();
|
|
54
|
-
render(<Button ref={reference}>Click me!</Button>);
|
|
55
|
-
expect(reference.current).toBeTruthy();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('is not disabled', () => {
|
|
59
|
-
render(<Button {...props} />);
|
|
60
|
-
expect(screen.getByRole('button')).toBeEnabled();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('renders a medium button of type accent and priority primary', () => {
|
|
64
|
-
expect(render(<Button {...props} />).container).toMatchSnapshot();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('renders an anchor tag with button styles of type accent and priority primary', () => {
|
|
68
|
-
expect(render(<Button {...props} as="a" href="#" />).container).toMatchSnapshot();
|
|
69
|
-
});
|
|
32
|
+
it('renders the new Button when v2 is true', () => {
|
|
33
|
+
render(
|
|
34
|
+
<Button data-testid={testId} {...newProps}>
|
|
35
|
+
New Button
|
|
36
|
+
</Button>,
|
|
37
|
+
);
|
|
38
|
+
const button = screen.getByTestId('new-button');
|
|
39
|
+
expect(button).toBeInTheDocument();
|
|
40
|
+
expect(button).toHaveClass('wds-Button wds-Button--medium wds-Button--primary');
|
|
70
41
|
});
|
|
71
42
|
|
|
72
|
-
describe('
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
43
|
+
describe('render as HTML anchor', () => {
|
|
44
|
+
const href = 'https://example.com';
|
|
45
|
+
const name = 'Button as link';
|
|
46
|
+
|
|
47
|
+
describe('v2', () => {
|
|
48
|
+
describe('rendered HTMLS element', () => {
|
|
49
|
+
it('should render as button by default', () => {
|
|
50
|
+
render(<Button v2>{name}</Button>);
|
|
51
|
+
expect(screen.getByRole('button', { name })).toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should render as link if href is provided', () => {
|
|
55
|
+
render(
|
|
56
|
+
<Button v2 href={href}>
|
|
57
|
+
{name}
|
|
58
|
+
</Button>,
|
|
59
|
+
);
|
|
60
|
+
expect(screen.getByRole('link', { name })).toHaveAttribute('href', href);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should render a HTML anchor if `as="a"` is provided', () => {
|
|
64
|
+
render(
|
|
65
|
+
<Button v2 as="a">
|
|
66
|
+
{name}
|
|
67
|
+
</Button>,
|
|
68
|
+
);
|
|
69
|
+
expect(screen.getByText(name).closest('a')).toBeInTheDocument();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should render as a button if `href` is set together with `as="button"`', () => {
|
|
73
|
+
render(
|
|
74
|
+
<Button v2 href={href} as="button">
|
|
75
|
+
{name}
|
|
76
|
+
</Button>,
|
|
77
|
+
);
|
|
78
|
+
expect(screen.getByRole('button', { name })).toBeInTheDocument();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
109
81
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
82
|
+
describe('HTML attributes', () => {
|
|
83
|
+
it('should not set `type` if rendered as HTML anchor', () => {
|
|
84
|
+
render(
|
|
85
|
+
<Button v2 type="submit" href="wise.com">
|
|
86
|
+
{name}
|
|
87
|
+
</Button>,
|
|
88
|
+
);
|
|
89
|
+
expect(screen.getByRole('link')).not.toHaveAttribute('type');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should not set `href` or `target` if rendered as HTML button', () => {
|
|
93
|
+
render(
|
|
94
|
+
<Button v2 as="button" href="wise.com" target="_blank">
|
|
95
|
+
{name}
|
|
96
|
+
</Button>,
|
|
97
|
+
);
|
|
98
|
+
const button = screen.getByRole('button');
|
|
99
|
+
expect(button).not.toHaveAttribute('href');
|
|
100
|
+
expect(button).not.toHaveAttribute('target');
|
|
101
|
+
});
|
|
102
|
+
});
|
|
118
103
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
104
|
+
describe('disabled mode', () => {
|
|
105
|
+
describe('button', () => {
|
|
106
|
+
it('should not be disabled by default', () => {
|
|
107
|
+
render(<Button v2>{name}</Button>);
|
|
108
|
+
const button = screen.getByRole('button');
|
|
109
|
+
expect(button).toBeEnabled();
|
|
110
|
+
expect(button).not.toHaveAttribute('aria-disabled');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should respect disabled mode and set it only via the `disabled` attribute', () => {
|
|
114
|
+
render(
|
|
115
|
+
<Button v2 disabled>
|
|
116
|
+
{name}
|
|
117
|
+
</Button>,
|
|
118
|
+
);
|
|
119
|
+
const button = screen.getByRole('button');
|
|
120
|
+
expect(button).toBeDisabled();
|
|
121
|
+
expect(button).not.toHaveAttribute('aria-disabled');
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('anchor', () => {
|
|
126
|
+
it('should not be disabled by default', () => {
|
|
127
|
+
render(
|
|
128
|
+
<Button v2 href="wise.com">
|
|
129
|
+
{name}
|
|
130
|
+
</Button>,
|
|
131
|
+
);
|
|
132
|
+
const button = screen.getByRole('link');
|
|
133
|
+
expect(button).toBeEnabled();
|
|
134
|
+
expect(button).not.toHaveAttribute('aria-disabled');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('should respect disabled mode', () => {
|
|
138
|
+
render(
|
|
139
|
+
<Button v2 href="wise.com" disabled>
|
|
140
|
+
{name}
|
|
141
|
+
</Button>,
|
|
142
|
+
);
|
|
143
|
+
const button = screen.getByRole('link');
|
|
144
|
+
expect(button).toHaveAttribute('aria-disabled');
|
|
145
|
+
expect(button).toBeEnabled();
|
|
146
|
+
expect(button).not.toHaveAttribute('href');
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
});
|
|
126
150
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
151
|
+
describe('loading mode', () => {
|
|
152
|
+
describe('button', () => {
|
|
153
|
+
it('should not be loading by default', () => {
|
|
154
|
+
render(<Button v2>{name}</Button>);
|
|
155
|
+
const button = screen.getByRole('button');
|
|
156
|
+
expect(button).toBeEnabled();
|
|
157
|
+
expect(button).not.toHaveAttribute('aria-busy');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('should respect loading mode', () => {
|
|
161
|
+
render(
|
|
162
|
+
<Button v2 loading>
|
|
163
|
+
{name}
|
|
164
|
+
</Button>,
|
|
165
|
+
);
|
|
166
|
+
const button = screen.getByRole('button');
|
|
167
|
+
expect(button).toHaveAttribute('aria-busy');
|
|
168
|
+
// the `disabled` attribute is not set to keep the button
|
|
169
|
+
// focusable but aria attribute is defined to make it
|
|
170
|
+
// announced properly by the assistive tech
|
|
171
|
+
expect(button).toBeEnabled();
|
|
172
|
+
expect(button).toHaveAttribute('aria-disabled');
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
describe('anchor', () => {
|
|
177
|
+
it('should not be loading by default', () => {
|
|
178
|
+
render(
|
|
179
|
+
<Button v2 href="wise.com">
|
|
180
|
+
{name}
|
|
181
|
+
</Button>,
|
|
182
|
+
);
|
|
183
|
+
const button = screen.getByRole('link');
|
|
184
|
+
expect(button).toBeEnabled();
|
|
185
|
+
expect(button).not.toHaveAttribute('aria-busy');
|
|
186
|
+
expect(button).not.toHaveAttribute('aria-disabled');
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should respect loading mode', () => {
|
|
190
|
+
render(
|
|
191
|
+
<Button v2 loading href="wise.com">
|
|
192
|
+
{name}
|
|
193
|
+
</Button>,
|
|
194
|
+
);
|
|
195
|
+
const button = screen.getByRole('link');
|
|
196
|
+
expect(button).toHaveAttribute('aria-busy');
|
|
197
|
+
// the `disabled` attribute is not set to keep the button
|
|
198
|
+
// focusable but aria attribute is defined to make it
|
|
199
|
+
// announced properly by the assistive tech
|
|
200
|
+
expect(button).toBeEnabled();
|
|
201
|
+
expect(button).toHaveAttribute('aria-disabled');
|
|
202
|
+
expect(button).not.toHaveAttribute('href');
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
133
206
|
});
|
|
134
207
|
});
|
|
135
208
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
209
|
+
it('does not set type when type is in LegacyButtonType', () => {
|
|
210
|
+
const legacyTypeProps: ButtonProps = {
|
|
211
|
+
...newProps,
|
|
212
|
+
// @ts-expect-error here we intentionally set wrong value to test `type` attr in DOM
|
|
213
|
+
type: 'accent',
|
|
214
|
+
};
|
|
215
|
+
render(
|
|
216
|
+
<Button data-testid={testId} {...legacyTypeProps}>
|
|
217
|
+
Button Type
|
|
218
|
+
</Button>,
|
|
219
|
+
);
|
|
220
|
+
const button = screen.getByTestId('new-button');
|
|
221
|
+
expect(button).toBeInTheDocument();
|
|
222
|
+
expect(button).not.toHaveAttribute('type');
|
|
148
223
|
});
|
|
149
224
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
225
|
+
it('sets type when type is not in LegacyButtonType', () => {
|
|
226
|
+
const buttonTypeProps: ButtonProps = {
|
|
227
|
+
...newProps,
|
|
228
|
+
type: 'submit',
|
|
229
|
+
};
|
|
230
|
+
render(
|
|
231
|
+
<Button data-testid={testId} {...buttonTypeProps}>
|
|
232
|
+
Submit Button
|
|
233
|
+
</Button>,
|
|
234
|
+
);
|
|
235
|
+
const button = screen.getByTestId('new-button');
|
|
236
|
+
expect(button).toBeInTheDocument();
|
|
237
|
+
expect(button).toHaveAttribute('type', 'submit');
|
|
162
238
|
});
|
|
163
239
|
|
|
164
|
-
describe('
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
240
|
+
describe('addons', () => {
|
|
241
|
+
const avatarProp: CommonProps['addonStart'] = {
|
|
242
|
+
type: 'avatar',
|
|
243
|
+
value: [{ asset: <Freeze /> }],
|
|
244
|
+
};
|
|
245
|
+
const iconProp: CommonProps['addonStart'] = { type: 'icon', value: <Freeze /> };
|
|
246
|
+
|
|
247
|
+
const renderAllPriorities = (props: CommonProps) =>
|
|
248
|
+
render(
|
|
249
|
+
<>
|
|
250
|
+
<Button {...props} priority="primary">
|
|
251
|
+
primary
|
|
252
|
+
</Button>
|
|
253
|
+
<Button {...props} priority="secondary">
|
|
254
|
+
secondary
|
|
255
|
+
</Button>
|
|
256
|
+
<Button {...props} priority="secondary-neutral">
|
|
257
|
+
secondary-neutral
|
|
258
|
+
</Button>
|
|
259
|
+
<Button {...props} priority="tertiary">
|
|
260
|
+
tertiary
|
|
261
|
+
</Button>
|
|
262
|
+
</>,
|
|
178
263
|
);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it('renders tertiary buttons', () => {
|
|
182
|
-
expect(
|
|
183
|
-
render(<Button {...props} priority={TERTIARY} type={ACCENT} />).container,
|
|
184
|
-
).toMatchSnapshot();
|
|
185
|
-
});
|
|
186
264
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
265
|
+
describe('addonsStart', () => {
|
|
266
|
+
describe('large', () => {
|
|
267
|
+
it('should not support avatars', () => {
|
|
268
|
+
renderAllPriorities({
|
|
269
|
+
v2: true,
|
|
270
|
+
size: 'lg',
|
|
271
|
+
addonStart: avatarProp,
|
|
272
|
+
});
|
|
273
|
+
expect(screen.queryAllByTestId('freeze-icon')).toHaveLength(0);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('should not support icons', () => {
|
|
277
|
+
renderAllPriorities({
|
|
278
|
+
v2: true,
|
|
279
|
+
size: 'lg',
|
|
280
|
+
addonStart: iconProp,
|
|
281
|
+
});
|
|
282
|
+
expect(screen.queryAllByTestId('freeze-icon')).toHaveLength(0);
|
|
283
|
+
});
|
|
201
284
|
});
|
|
202
|
-
expect(button).toBeInTheDocument();
|
|
203
|
-
expect(button).toBeEnabled();
|
|
204
|
-
expect(button).toHaveClass('btn-loading');
|
|
205
|
-
expect(button).toHaveAttribute('aria-disabled', 'true');
|
|
206
|
-
expect(button).toHaveAttribute('aria-busy', 'true');
|
|
207
|
-
expect(button).toHaveAttribute('aria-live', 'polite');
|
|
208
|
-
expect(screen.getByTestId('ButtonProgressIndicator')).toBeInTheDocument();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('disables the button', () => {
|
|
212
|
-
render(<Button {...props} disabled />);
|
|
213
|
-
const button = screen.queryByRole('button');
|
|
214
|
-
expect(button).toBeDisabled();
|
|
215
|
-
expect(button).toHaveClass('disabled');
|
|
216
|
-
expect(button).toHaveAttribute('aria-disabled', 'false');
|
|
217
|
-
expect(button).toHaveAttribute('aria-busy', 'false');
|
|
218
|
-
expect(button).toHaveAttribute('aria-live', 'off');
|
|
219
|
-
});
|
|
220
285
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
286
|
+
describe('medium', () => {
|
|
287
|
+
it('should support avatar', () => {
|
|
288
|
+
renderAllPriorities({
|
|
289
|
+
v2: true,
|
|
290
|
+
size: 'md',
|
|
291
|
+
addonStart: avatarProp,
|
|
292
|
+
});
|
|
293
|
+
expect(screen.getAllByTestId('freeze-icon')).toHaveLength(4);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('should support icon', () => {
|
|
297
|
+
renderAllPriorities({
|
|
298
|
+
v2: true,
|
|
299
|
+
size: 'md',
|
|
300
|
+
addonStart: iconProp,
|
|
301
|
+
});
|
|
302
|
+
expect(screen.getAllByTestId('freeze-icon')).toHaveLength(4);
|
|
303
|
+
});
|
|
304
|
+
});
|
|
225
305
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
306
|
+
describe('small', () => {
|
|
307
|
+
it('should not support avatar', () => {
|
|
308
|
+
renderAllPriorities({
|
|
309
|
+
v2: true,
|
|
310
|
+
size: 'sm',
|
|
311
|
+
addonStart: avatarProp,
|
|
312
|
+
});
|
|
313
|
+
expect(screen.queryAllByTestId('freeze-icon')).toHaveLength(0);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('should support icon', () => {
|
|
317
|
+
renderAllPriorities({
|
|
318
|
+
v2: true,
|
|
319
|
+
size: 'sm',
|
|
320
|
+
addonStart: iconProp,
|
|
321
|
+
});
|
|
322
|
+
expect(screen.getAllByTestId('freeze-icon')).toHaveLength(4);
|
|
323
|
+
});
|
|
324
|
+
});
|
|
230
325
|
});
|
|
231
326
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
327
|
+
describe('addonEnd', () => {
|
|
328
|
+
describe('large', () => {
|
|
329
|
+
it('should support icon', () => {
|
|
330
|
+
renderAllPriorities({
|
|
331
|
+
v2: true,
|
|
332
|
+
size: 'lg',
|
|
333
|
+
addonEnd: iconProp,
|
|
334
|
+
});
|
|
335
|
+
expect(screen.queryAllByTestId('freeze-icon')).toHaveLength(0);
|
|
336
|
+
});
|
|
337
|
+
});
|
|
236
338
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
339
|
+
describe('medium', () => {
|
|
340
|
+
it('should support icon', () => {
|
|
341
|
+
renderAllPriorities({
|
|
342
|
+
v2: true,
|
|
343
|
+
size: 'sm',
|
|
344
|
+
addonEnd: iconProp,
|
|
345
|
+
});
|
|
346
|
+
expect(screen.getAllByTestId('freeze-icon')).toHaveLength(4);
|
|
347
|
+
});
|
|
348
|
+
});
|
|
241
349
|
|
|
242
|
-
|
|
243
|
-
|
|
350
|
+
describe('small', () => {
|
|
351
|
+
it('should support icon', () => {
|
|
352
|
+
renderAllPriorities({
|
|
353
|
+
v2: true,
|
|
354
|
+
size: 'md',
|
|
355
|
+
addonEnd: iconProp,
|
|
356
|
+
});
|
|
357
|
+
expect(screen.getAllByTestId('freeze-icon')).toHaveLength(4);
|
|
358
|
+
});
|
|
359
|
+
});
|
|
244
360
|
});
|
|
245
361
|
});
|
|
246
362
|
});
|