@transferwise/components 0.0.0-experimental-28eac06 → 0.0.0-experimental-e9dbb78
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/alert/Alert.js +17 -17
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +14 -14
- package/build/alert/Alert.mjs.map +1 -1
- package/build/common/action/Action.js +15 -26
- package/build/common/action/Action.js.map +1 -1
- package/build/common/action/Action.mjs +15 -26
- package/build/common/action/Action.mjs.map +1 -1
- package/build/common/propsValues/sentiment.js +0 -1
- package/build/common/propsValues/sentiment.js.map +1 -1
- package/build/common/propsValues/sentiment.mjs +0 -1
- package/build/common/propsValues/sentiment.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +73 -10
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +74 -11
- package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
- package/build/i18n/en.json +0 -1
- package/build/i18n/en.json.js +0 -1
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +0 -1
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/main.css +70 -21
- package/build/statusIcon/StatusIcon.js +1 -5
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.messages.js +0 -3
- package/build/statusIcon/StatusIcon.messages.js.map +1 -1
- package/build/statusIcon/StatusIcon.messages.mjs +0 -3
- package/build/statusIcon/StatusIcon.messages.mjs.map +1 -1
- package/build/statusIcon/StatusIcon.mjs +1 -5
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/styles/button/Button.css +0 -3
- package/build/styles/criticalBanner/CriticalCommsBanner.css +73 -21
- package/build/styles/main.css +70 -21
- package/build/types/alert/Alert.d.ts +4 -3
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/common/action/Action.d.ts +2 -5
- package/build/types/common/action/Action.d.ts.map +1 -1
- package/build/types/common/propsValues/sentiment.d.ts +0 -1
- package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
- package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.messages.d.ts +0 -5
- package/build/types/statusIcon/StatusIcon.messages.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +0 -2
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/alert/Alert.spec.tsx +30 -0
- package/src/alert/Alert.story.tsx +1 -34
- package/src/alert/Alert.tsx +15 -20
- package/src/button/Button.css +0 -3
- package/src/button/Button.less +3 -6
- package/src/button/Button.vars.less +4 -0
- package/src/common/action/Action.tsx +22 -40
- package/src/common/propsValues/sentiment.ts +0 -1
- package/src/criticalBanner/CriticalCommsBanner.css +73 -21
- package/src/criticalBanner/CriticalCommsBanner.less +70 -24
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +4 -26
- package/src/criticalBanner/CriticalCommsBanner.tsx +50 -8
- package/src/i18n/en.json +0 -1
- package/src/index.ts +1 -0
- package/src/main.css +70 -21
- package/src/radio/Radio.spec.tsx +73 -0
- package/src/radio/Radio.story.tsx +22 -52
- package/src/radioGroup/RadioGroup.spec.tsx +91 -0
- package/src/radioGroup/RadioGroup.story.tsx +3 -5
- package/src/statusIcon/StatusIcon.less +0 -1
- package/src/statusIcon/StatusIcon.messages.ts +0 -6
- package/src/statusIcon/StatusIcon.tsx +1 -8
- package/src/radio/Radio.rtl.spec.tsx +0 -24
- package/src/radio/Radio.spec.js +0 -76
- package/src/radio/__snapshots__/Radio.rtl.spec.tsx.snap +0 -49
- package/src/radioGroup/RadioGroup.rtl.spec.tsx +0 -30
- package/src/radioGroup/RadioGroup.spec.js +0 -90
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { render, screen, mockMatchMedia } from '../test-utils';
|
|
2
|
+
import { userEvent } from '@testing-library/user-event';
|
|
3
|
+
import RadioGroup from '.';
|
|
4
|
+
import AvatarView from '../avatarView';
|
|
5
|
+
import { Field } from '../field/Field';
|
|
6
|
+
|
|
7
|
+
describe('RadioGroup', () => {
|
|
8
|
+
const handleChange = jest.fn();
|
|
9
|
+
const avatar = <AvatarView profileName="High Definition" />;
|
|
10
|
+
mockMatchMedia();
|
|
11
|
+
|
|
12
|
+
const RADIOS = [
|
|
13
|
+
{
|
|
14
|
+
id: 'id-test-0',
|
|
15
|
+
value: 'value-test0',
|
|
16
|
+
label: 'Radio1',
|
|
17
|
+
secondary: 'secondary',
|
|
18
|
+
disabled: true,
|
|
19
|
+
avatar,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'id-test-1',
|
|
23
|
+
value: 'value-test1',
|
|
24
|
+
label: 'Radio2',
|
|
25
|
+
secondary: 'secondary',
|
|
26
|
+
disabled: false,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'id-test-2',
|
|
30
|
+
value: 'value-test2',
|
|
31
|
+
label: 'Radio3',
|
|
32
|
+
secondary: 'secondary',
|
|
33
|
+
disabled: false,
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
it('has accessible role', () => {
|
|
37
|
+
render(
|
|
38
|
+
<RadioGroup
|
|
39
|
+
name="currency"
|
|
40
|
+
radios={[{ label: 'USD' }, { label: 'EUR' }]}
|
|
41
|
+
onChange={() => {}}
|
|
42
|
+
/>,
|
|
43
|
+
);
|
|
44
|
+
expect(screen.getByRole('radiogroup')).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('supports `Field` for labeling', () => {
|
|
48
|
+
render(
|
|
49
|
+
<Field label="Currency">
|
|
50
|
+
<RadioGroup
|
|
51
|
+
name="currency"
|
|
52
|
+
radios={[{ label: 'USD' }, { label: 'EUR' }]}
|
|
53
|
+
onChange={() => {}}
|
|
54
|
+
/>
|
|
55
|
+
</Field>,
|
|
56
|
+
);
|
|
57
|
+
expect(screen.getByRole('radiogroup')).toHaveAccessibleName(/^Currency/);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('renders nothing if no radios are provided', () => {
|
|
61
|
+
render(<RadioGroup name="radio-group" radios={[]} onChange={handleChange} />);
|
|
62
|
+
expect(screen.queryByRole('radiogroup')).not.toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('renders radio options', () => {
|
|
66
|
+
render(<RadioGroup name="radio-group" radios={RADIOS} onChange={handleChange} />);
|
|
67
|
+
expect(screen.getAllByRole('radio')).toHaveLength(RADIOS.length);
|
|
68
|
+
const firstRadio = screen.getByRole('radio', { name: /Radio1/i });
|
|
69
|
+
expect(firstRadio).toBeDisabled();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('checks the specified radio value', () => {
|
|
73
|
+
render(
|
|
74
|
+
<RadioGroup
|
|
75
|
+
name="radio-group"
|
|
76
|
+
radios={RADIOS}
|
|
77
|
+
selectedValue="value-test2"
|
|
78
|
+
onChange={handleChange}
|
|
79
|
+
/>,
|
|
80
|
+
);
|
|
81
|
+
const checkedRadio = screen.getByRole('radio', { name: /Radio3/i });
|
|
82
|
+
expect(checkedRadio).toBeChecked();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('calls onChange with the selected value', async () => {
|
|
86
|
+
render(<RadioGroup name="radio-group" radios={RADIOS} onChange={handleChange} />);
|
|
87
|
+
const thirdRadio = screen.getByRole('radio', { name: /Radio3/i });
|
|
88
|
+
await userEvent.click(thirdRadio);
|
|
89
|
+
expect(handleChange).toHaveBeenCalledWith('value-test2');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Flag } from '@wise/art';
|
|
2
|
-
|
|
3
|
-
import Avatar, { AvatarType } from '../avatar';
|
|
4
|
-
|
|
5
2
|
import RadioGroup, { RadioGroupProps, RadioGroupRadio } from './RadioGroup';
|
|
6
3
|
import { Field } from '../field/Field';
|
|
7
4
|
import { Meta, StoryObj } from '@storybook/react';
|
|
8
5
|
import { fn } from '@storybook/test';
|
|
9
6
|
import { useState } from 'react';
|
|
7
|
+
import AvatarView from '../avatarView';
|
|
10
8
|
|
|
11
9
|
const meta = {
|
|
12
10
|
component: RadioGroup,
|
|
@@ -52,9 +50,9 @@ export const WithAvatars = {
|
|
|
52
50
|
({
|
|
53
51
|
...radio,
|
|
54
52
|
avatar: (
|
|
55
|
-
<
|
|
53
|
+
<AvatarView>
|
|
56
54
|
<Flag code="NZD" />
|
|
57
|
-
</
|
|
55
|
+
</AvatarView>
|
|
58
56
|
),
|
|
59
57
|
}) satisfies RadioGroupRadio,
|
|
60
58
|
),
|
|
@@ -19,12 +19,6 @@ export default defineMessages({
|
|
|
19
19
|
description:
|
|
20
20
|
'Visually hidden label read by screen readers, describing the Warning icon – normally a prefix to remaining visible content, e.g. validation result.',
|
|
21
21
|
},
|
|
22
|
-
criticalLabel: {
|
|
23
|
-
id: 'neptune.StatusIcon.iconLabel.critical',
|
|
24
|
-
defaultMessage: 'Critical:',
|
|
25
|
-
description:
|
|
26
|
-
'Visually hidden label read by screen readers, describing the Critical icon – normally a prefix to remaining visible content, e.g. validation result.',
|
|
27
|
-
},
|
|
28
22
|
pendingLabel: {
|
|
29
23
|
id: 'neptune.StatusIcon.iconLabel.pending',
|
|
30
24
|
defaultMessage: 'Pending:',
|
|
@@ -52,10 +52,6 @@ const StatusIcon = ({ sentiment = 'neutral', size: sizeProp = 40, iconLabel }: S
|
|
|
52
52
|
Icon: Alert,
|
|
53
53
|
defaultIconLabel: intl.formatMessage(messages.warningLabel),
|
|
54
54
|
},
|
|
55
|
-
[Sentiment.CRITICAL]: {
|
|
56
|
-
Icon: Alert,
|
|
57
|
-
defaultIconLabel: intl.formatMessage(messages.criticalLabel),
|
|
58
|
-
},
|
|
59
55
|
[Sentiment.PENDING]: {
|
|
60
56
|
Icon: ClockBorderless,
|
|
61
57
|
defaultIconLabel: intl.formatMessage(messages.pendingLabel),
|
|
@@ -80,10 +76,7 @@ const StatusIcon = ({ sentiment = 'neutral', size: sizeProp = 40, iconLabel }: S
|
|
|
80
76
|
};
|
|
81
77
|
const { Icon, defaultIconLabel } = iconMetaBySentiment[sentiment];
|
|
82
78
|
|
|
83
|
-
const iconColor =
|
|
84
|
-
sentiment === 'warning' || sentiment === 'pending' || sentiment === 'critical'
|
|
85
|
-
? 'dark'
|
|
86
|
-
: 'light';
|
|
79
|
+
const iconColor = sentiment === 'warning' || sentiment === 'pending' ? 'dark' : 'light';
|
|
87
80
|
const isTinyViewport = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);
|
|
88
81
|
const size = mapLegacySize[sizeProp] ?? sizeProp;
|
|
89
82
|
return (
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import Avatar, { AvatarType } from '../avatar';
|
|
2
|
-
import { render } from '../test-utils';
|
|
3
|
-
|
|
4
|
-
import Radio from '.';
|
|
5
|
-
|
|
6
|
-
jest.mock('../common/hooks');
|
|
7
|
-
|
|
8
|
-
describe('Radio', () => {
|
|
9
|
-
const props = {
|
|
10
|
-
label: 'This is a label',
|
|
11
|
-
name: 'name',
|
|
12
|
-
onChange: jest.fn(),
|
|
13
|
-
checked: false,
|
|
14
|
-
disabled: false,
|
|
15
|
-
secondary: '',
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
it('shows the avatar when supplied', () => {
|
|
19
|
-
expect(
|
|
20
|
-
render(<Radio {...props} avatar={<Avatar type={AvatarType.INITIALS}>HD</Avatar>} />)
|
|
21
|
-
.container,
|
|
22
|
-
).toMatchSnapshot();
|
|
23
|
-
});
|
|
24
|
-
});
|
package/src/radio/Radio.spec.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { shallow } from 'enzyme';
|
|
2
|
-
|
|
3
|
-
import Body from '../body';
|
|
4
|
-
import RadioButton from '../common/RadioButton';
|
|
5
|
-
|
|
6
|
-
import Radio from '.';
|
|
7
|
-
|
|
8
|
-
jest.mock('../common/hooks');
|
|
9
|
-
|
|
10
|
-
describe('Radio', () => {
|
|
11
|
-
let props;
|
|
12
|
-
let component;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
props = {
|
|
16
|
-
label: 'hello, i am a radio',
|
|
17
|
-
name: 'radio name',
|
|
18
|
-
onChange: jest.fn(),
|
|
19
|
-
checked: false,
|
|
20
|
-
disabled: false,
|
|
21
|
-
secondary: '',
|
|
22
|
-
};
|
|
23
|
-
component = shallow(<Radio {...props} />);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('displays the given label', () => {
|
|
27
|
-
expect(component.find(Body).props().children).toContain(props.label);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('does not render secondary text', () => {
|
|
31
|
-
expect(component.find('small')).toHaveLength(0);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('has id as label for prop', () => {
|
|
35
|
-
component.setProps({ id: 'some-id' });
|
|
36
|
-
expect(component.find('label').prop('htmlFor')).toBe('some-id');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('passes radio button id', () => {
|
|
40
|
-
component.setProps({ id: 'some-id' });
|
|
41
|
-
expect(radioButton().prop('id')).toBe('some-id');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('passes radio button name', () => {
|
|
45
|
-
component.setProps({ name: 'a-name' });
|
|
46
|
-
expect(radioButton().prop('name')).toBe('a-name');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('passes radio button checked', () => {
|
|
50
|
-
expect(radioButton().prop('checked')).toBe(false);
|
|
51
|
-
component.setProps({ checked: true });
|
|
52
|
-
expect(radioButton().prop('checked')).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('passes radio button change handler', () => {
|
|
56
|
-
const onChange = jest.fn();
|
|
57
|
-
component.setProps({ onChange });
|
|
58
|
-
expect(radioButton().prop('onChange')).toBe(onChange);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('passes radio button disabled', () => {
|
|
62
|
-
expect(radioButton().prop('disabled')).toBe(false);
|
|
63
|
-
component.setProps({ disabled: true });
|
|
64
|
-
expect(radioButton().prop('disabled')).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('displays secondary text when supplied', () => {
|
|
68
|
-
component.setProps({ secondary: 'additional info' });
|
|
69
|
-
expect(component.find(Body).last().props().children).toContain('additional info');
|
|
70
|
-
expect(component.find('.radio').hasClass('radio-lg')).toBe(true);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
function radioButton() {
|
|
74
|
-
return component.find(RadioButton);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Radio shows the avatar when supplied 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="radio np-radio"
|
|
7
|
-
>
|
|
8
|
-
<label
|
|
9
|
-
class=""
|
|
10
|
-
>
|
|
11
|
-
<span
|
|
12
|
-
class="m-r-2 np-radio-button"
|
|
13
|
-
>
|
|
14
|
-
<input
|
|
15
|
-
class="sr-only"
|
|
16
|
-
name="name"
|
|
17
|
-
type="radio"
|
|
18
|
-
value=""
|
|
19
|
-
/>
|
|
20
|
-
<span
|
|
21
|
-
class="tw-radio-button"
|
|
22
|
-
>
|
|
23
|
-
<span
|
|
24
|
-
class="tw-radio-check"
|
|
25
|
-
/>
|
|
26
|
-
</span>
|
|
27
|
-
</span>
|
|
28
|
-
<span
|
|
29
|
-
class="np-text-body-large np-radio__text"
|
|
30
|
-
>
|
|
31
|
-
This is a label
|
|
32
|
-
</span>
|
|
33
|
-
<span
|
|
34
|
-
class="np-radio__avatar m-l-auto"
|
|
35
|
-
>
|
|
36
|
-
<div
|
|
37
|
-
class="tw-avatar tw-avatar--48 tw-avatar--initials np-text-title-body"
|
|
38
|
-
>
|
|
39
|
-
<div
|
|
40
|
-
class="tw-avatar__content"
|
|
41
|
-
>
|
|
42
|
-
HD
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
</span>
|
|
46
|
-
</label>
|
|
47
|
-
</div>
|
|
48
|
-
</div>
|
|
49
|
-
`;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '../test-utils';
|
|
2
|
-
|
|
3
|
-
import RadioGroup from '.';
|
|
4
|
-
import { Field } from '../field/Field';
|
|
5
|
-
|
|
6
|
-
describe('RadioGroup', () => {
|
|
7
|
-
it('has accessible role', () => {
|
|
8
|
-
render(
|
|
9
|
-
<RadioGroup
|
|
10
|
-
name="currency"
|
|
11
|
-
radios={[{ label: 'USD' }, { label: 'EUR' }]}
|
|
12
|
-
onChange={() => {}}
|
|
13
|
-
/>,
|
|
14
|
-
);
|
|
15
|
-
expect(screen.getByRole('radiogroup')).toBeInTheDocument();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('supports `Field` for labeling', () => {
|
|
19
|
-
render(
|
|
20
|
-
<Field label="Currency">
|
|
21
|
-
<RadioGroup
|
|
22
|
-
name="currency"
|
|
23
|
-
radios={[{ label: 'USD' }, { label: 'EUR' }]}
|
|
24
|
-
onChange={() => {}}
|
|
25
|
-
/>
|
|
26
|
-
</Field>,
|
|
27
|
-
);
|
|
28
|
-
expect(screen.getByRole('radiogroup')).toHaveAccessibleName(/^Currency/);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
|
|
4
|
-
import { Radio, RadioGroup } from '..';
|
|
5
|
-
import Avatar, { AvatarType } from '../avatar';
|
|
6
|
-
|
|
7
|
-
const props = { onChange: jest.fn(), name: 'radio-group' };
|
|
8
|
-
const avatar = <Avatar type={AvatarType.INITIALS}>HD</Avatar>;
|
|
9
|
-
|
|
10
|
-
const RADIOS = [
|
|
11
|
-
{
|
|
12
|
-
id: 'id-test-0',
|
|
13
|
-
value: 'value-test0',
|
|
14
|
-
label: 'Radio1',
|
|
15
|
-
secondary: 'secondary',
|
|
16
|
-
disabled: true,
|
|
17
|
-
avatar,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
id: 'id-test-1',
|
|
21
|
-
value: 'value-test1',
|
|
22
|
-
label: 'Radio2',
|
|
23
|
-
secondary: 'secondary',
|
|
24
|
-
disabled: false,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: 'id-test-2',
|
|
28
|
-
value: 'value-test2',
|
|
29
|
-
label: 'Radio3',
|
|
30
|
-
secondary: 'secondary',
|
|
31
|
-
disabled: false,
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
describe('RadioGroup', () => {
|
|
36
|
-
it('renders null if no radios are provided', () => {
|
|
37
|
-
expect(shallow(<RadioGroup radios={[]} {...props} />).isEmptyRender()).toBe(true);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('renders radio options', () => {
|
|
41
|
-
const component = shallow(<RadioGroup radios={RADIOS} {...props} />);
|
|
42
|
-
expect(component.find(Radio)).toHaveLength(RADIOS.length);
|
|
43
|
-
|
|
44
|
-
const { onChange, ...primitiveProps } = component.find(Radio).at(0).props();
|
|
45
|
-
expect(primitiveProps).toStrictEqual({
|
|
46
|
-
id: 'id-test-0',
|
|
47
|
-
value: 'value-test0',
|
|
48
|
-
label: 'Radio1',
|
|
49
|
-
name: 'radio-group',
|
|
50
|
-
disabled: true,
|
|
51
|
-
checked: false,
|
|
52
|
-
secondary: 'secondary',
|
|
53
|
-
avatar,
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('renders a single radio option, when radios array contains a single element', () => {
|
|
58
|
-
const component = shallow(<RadioGroup radios={RADIOS.slice(0, 1)} {...props} />);
|
|
59
|
-
expect(component.find(Radio)).toHaveLength(1);
|
|
60
|
-
|
|
61
|
-
const { onChange, ...primitiveProps } = component.find(Radio).at(0).props();
|
|
62
|
-
expect(primitiveProps).toStrictEqual({
|
|
63
|
-
id: 'id-test-0',
|
|
64
|
-
value: 'value-test0',
|
|
65
|
-
label: 'Radio1',
|
|
66
|
-
name: 'radio-group',
|
|
67
|
-
disabled: true,
|
|
68
|
-
checked: false,
|
|
69
|
-
secondary: 'secondary',
|
|
70
|
-
avatar,
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('checks specified radio', () => {
|
|
75
|
-
const component = shallow(
|
|
76
|
-
<RadioGroup radios={RADIOS} selectedValue="value-test2" {...props} />,
|
|
77
|
-
);
|
|
78
|
-
expect(component.find(Radio)).toHaveLength(RADIOS.length);
|
|
79
|
-
expect(component.find(Radio).at(2).props().checked).toBeTruthy();
|
|
80
|
-
|
|
81
|
-
expect(component.find(Radio).at(0).props().checked).toBeFalsy();
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('calls onChange with selected value', () => {
|
|
85
|
-
const component = shallow(<RadioGroup radios={RADIOS} {...props} />);
|
|
86
|
-
component.find(Radio).at(2).simulate('change', 'value-test2');
|
|
87
|
-
|
|
88
|
-
expect(props.onChange).toHaveBeenCalledWith('value-test2');
|
|
89
|
-
});
|
|
90
|
-
});
|