@transferwise/components 0.0.0-experimental-29ce40f → 0.0.0-experimental-04e4d95
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 +524 -15
- package/build/index.js.map +1 -1
- package/build/index.mjs +524 -17
- package/build/index.mjs.map +1 -1
- package/build/main.css +5 -0
- package/build/styles/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +5 -0
- package/build/styles/main.css +5 -0
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/common/requirements.d.ts +3 -0
- package/build/types/common/requirements.d.ts.map +1 -0
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/dynamicFieldDefinitionList/DynamicFieldDefinitionList.d.ts +21 -0
- package/build/types/dynamicFieldDefinitionList/DynamicFieldDefinitionList.d.ts.map +1 -0
- package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts +12 -0
- package/build/types/dynamicFieldDefinitionList/FormattedValue/FormattedValue.d.ts.map +1 -0
- package/build/types/dynamicFieldDefinitionList/FormattedValue/index.d.ts +2 -0
- package/build/types/dynamicFieldDefinitionList/FormattedValue/index.d.ts.map +1 -0
- package/build/types/dynamicFieldDefinitionList/index.d.ts +2 -0
- package/build/types/dynamicFieldDefinitionList/index.d.ts.map +1 -0
- package/build/types/dynamicFieldDefinitionList/utils/createDefinitions.d.ts +2 -0
- package/build/types/dynamicFieldDefinitionList/utils/createDefinitions.d.ts.map +1 -0
- package/build/types/dynamicFieldDefinitionList/utils/text-format.d.ts +2 -0
- package/build/types/dynamicFieldDefinitionList/utils/text-format.d.ts.map +1 -0
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/loader/Loader.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/popover/Popover.d.ts.map +1 -1
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/stepper/deviceDetection.d.ts.map +1 -1
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.story.tsx +1 -1
- package/src/alert/Alert.tsx +2 -1
- package/src/avatar/colors/colors.ts +1 -1
- package/src/body/Body.spec.tsx +1 -1
- package/src/body/Body.story.tsx +8 -8
- package/src/checkbox/Checkbox.js +1 -1
- package/src/checkboxButton/CheckboxButton.spec.tsx +0 -1
- package/src/common/Option/Option.tsx +1 -1
- package/src/common/deviceDetection/deviceDetection.js +1 -1
- package/src/common/deviceDetection/deviceDetection.spec.js +4 -2
- package/src/common/responsivePanel/ResponsivePanel.spec.js +11 -15
- package/src/decision/Decision.spec.js +0 -1
- package/src/dimmer/Dimmer.tsx +6 -2
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.js +41 -0
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.spec.js +21 -0
- package/src/dynamicFieldDefinitionList/DynamicFieldDefinitionList.story.js +134 -0
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.css +5 -0
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.js +73 -0
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.less +4 -0
- package/src/dynamicFieldDefinitionList/FormattedValue/FormattedValue.spec.js +200 -0
- package/src/dynamicFieldDefinitionList/FormattedValue/index.js +1 -0
- package/src/dynamicFieldDefinitionList/index.js +1 -0
- package/src/dynamicFieldDefinitionList/utils/createDefinitions.js +33 -0
- package/src/dynamicFieldDefinitionList/utils/createDefinitions.spec.js +83 -0
- package/src/dynamicFieldDefinitionList/utils/text-format.js +46 -0
- package/src/dynamicFieldDefinitionList/utils/text-format.spec.js +43 -0
- package/src/index.ts +1 -0
- package/src/inlineAlert/InlineAlert.story.tsx +8 -7
- package/src/link/Link.story.tsx +16 -16
- package/src/loader/Loader.tsx +0 -1
- package/src/logo/Logo.js +2 -2
- package/src/main.css +5 -0
- package/src/main.less +1 -0
- package/src/moneyInput/MoneyInput.story.tsx +3 -3
- package/src/nudge/Nudge.spec.tsx +5 -5
- package/src/phoneNumberInput/PhoneNumberInput.tsx +2 -1
- package/src/phoneNumberInput/utils/cleanNumber/cleanNumber.ts +1 -1
- package/src/popover/Popover.tsx +2 -1
- package/src/promoCard/PromoCard.tsx +1 -1
- package/src/radioGroup/RadioGroup.spec.js +1 -1
- package/src/section/Section.story.tsx +2 -1
- package/src/segmentedControl/SegmentedControl.spec.tsx +2 -2
- package/src/select/Select.js +2 -3
- package/src/stepper/deviceDetection.js +1 -2
- package/src/stepper/deviceDetection.spec.js +8 -3
- package/src/test-utils/index.js +1 -1
- package/src/test-utils/story-config.ts +1 -1
- package/src/title/Title.spec.tsx +1 -1
- package/src/typeahead/Typeahead.spec.js +4 -2
- package/src/upload/Upload.spec.js +8 -4
- package/src/uploadInput/uploadButton/UploadButton.tsx +1 -0
package/src/link/Link.story.tsx
CHANGED
|
@@ -29,64 +29,64 @@ export const Basic = () => {
|
|
|
29
29
|
Links via <code>{'<Link />'}</code> component in all types of body copy
|
|
30
30
|
</Title>
|
|
31
31
|
<Body type={Typography.BODY_LARGE_BOLD} className="m-t-3">
|
|
32
|
-
We’re building the world
|
|
32
|
+
We’re building the world’s{' '}
|
|
33
33
|
<Link href="#" target="_blank">
|
|
34
34
|
most international account
|
|
35
35
|
</Link>
|
|
36
|
-
. We’re building the world
|
|
36
|
+
. We’re building the world’s most international account
|
|
37
37
|
</Body>
|
|
38
38
|
<Body type={Typography.BODY_LARGE} className="m-t-3">
|
|
39
|
-
We’re building the world
|
|
39
|
+
We’re building the world’s{' '}
|
|
40
40
|
<Link href="#" target="_blank">
|
|
41
41
|
most international account
|
|
42
42
|
</Link>
|
|
43
|
-
. We’re building the world
|
|
43
|
+
. We’re building the world’s most international account
|
|
44
44
|
</Body>
|
|
45
45
|
<Body type={Typography.BODY_DEFAULT_BOLD} className="m-t-3">
|
|
46
|
-
We’re building the world
|
|
46
|
+
We’re building the world’s{' '}
|
|
47
47
|
<Link href="#" target="_blank">
|
|
48
48
|
most international account
|
|
49
49
|
</Link>
|
|
50
|
-
. We’re building the world
|
|
50
|
+
. We’re building the world’s most international account
|
|
51
51
|
</Body>
|
|
52
52
|
<Body type={Typography.BODY_DEFAULT} className="m-t-3">
|
|
53
|
-
We’re building the world
|
|
53
|
+
We’re building the world’s{' '}
|
|
54
54
|
<Link href="#" target="_blank">
|
|
55
55
|
most international account
|
|
56
56
|
</Link>
|
|
57
|
-
. We’re building the world
|
|
57
|
+
. We’re building the world’s most international account
|
|
58
58
|
</Body>
|
|
59
59
|
|
|
60
60
|
<Title type={Typography.TITLE_SCREEN} className="m-t-3">
|
|
61
61
|
Links via <code>{'<a>'}</code> tag in all types of body copy
|
|
62
62
|
</Title>
|
|
63
63
|
<Body type={Typography.BODY_LARGE_BOLD} className="m-t-3">
|
|
64
|
-
We’re building the world
|
|
64
|
+
We’re building the world’s{' '}
|
|
65
65
|
<a href="#" target="_blank">
|
|
66
66
|
most international account
|
|
67
67
|
</a>
|
|
68
|
-
. We’re building the world
|
|
68
|
+
. We’re building the world’s most international account
|
|
69
69
|
</Body>
|
|
70
70
|
<Body type={Typography.BODY_LARGE} className="m-t-3">
|
|
71
|
-
We’re building the world
|
|
71
|
+
We’re building the world’s{' '}
|
|
72
72
|
<a href="#" target="_blank">
|
|
73
73
|
most international account
|
|
74
74
|
</a>
|
|
75
|
-
. We’re building the world
|
|
75
|
+
. We’re building the world’s most international account
|
|
76
76
|
</Body>
|
|
77
77
|
<Body type={Typography.BODY_DEFAULT_BOLD} className="m-t-3">
|
|
78
|
-
We’re building the world
|
|
78
|
+
We’re building the world’s{' '}
|
|
79
79
|
<a href="#" target="_blank">
|
|
80
80
|
most international account
|
|
81
81
|
</a>
|
|
82
|
-
. We’re building the world
|
|
82
|
+
. We’re building the world’s most international account
|
|
83
83
|
</Body>
|
|
84
84
|
<Body type={Typography.BODY_DEFAULT} className="m-t-3">
|
|
85
|
-
We’re building the world
|
|
85
|
+
We’re building the world’s{' '}
|
|
86
86
|
<a href="#" target="_blank">
|
|
87
87
|
most international account
|
|
88
88
|
</a>
|
|
89
|
-
. We’re building the world
|
|
89
|
+
. We’re building the world’s most international account
|
|
90
90
|
</Body>
|
|
91
91
|
</>
|
|
92
92
|
);
|
package/src/loader/Loader.tsx
CHANGED
package/src/logo/Logo.js
CHANGED
|
@@ -42,8 +42,8 @@ const Logo = ({ className, inverse, type }) => {
|
|
|
42
42
|
type === LogoType.WISE
|
|
43
43
|
? 'Wise'
|
|
44
44
|
: 'Wise Business' | (type === LogoType.WISE_PLATFORM)
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
? 'Wise Platform'
|
|
46
|
+
: 'Wise Business'
|
|
47
47
|
}
|
|
48
48
|
role="img"
|
|
49
49
|
className={classNames(className, 'np-logo')}
|
package/src/main.css
CHANGED
|
@@ -1857,6 +1857,11 @@ button.np-option {
|
|
|
1857
1857
|
transition: opacity 150ms ease-in, height 150ms ease-in 150ms;
|
|
1858
1858
|
opacity: 0;
|
|
1859
1859
|
}
|
|
1860
|
+
.formatted-value__h3-custom-alignment {
|
|
1861
|
+
margin-bottom: 16px;
|
|
1862
|
+
margin-bottom: var(--size-16);
|
|
1863
|
+
line-height: 24px;
|
|
1864
|
+
}
|
|
1860
1865
|
.emphasis {
|
|
1861
1866
|
font-weight: 600;
|
|
1862
1867
|
font-weight: var(--font-weight-semi-bold);
|
package/src/main.less
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
@import "./dimmer/Dimmer.less";
|
|
23
23
|
@import "./drawer/Drawer.less";
|
|
24
24
|
@import "./dropFade/DropFade.less";
|
|
25
|
+
@import "./dynamicFieldDefinitionList/FormattedValue/FormattedValue.less";
|
|
25
26
|
@import "./emphasis/Emphasis.less";
|
|
26
27
|
@import "./flowNavigation/animatedLabel/AnimatedLabel.less";
|
|
27
28
|
@import "./flowNavigation/backButton/BackButton.less";
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
18
|
<>
|
|
19
|
-
<label htmlFor={args.id
|
|
19
|
+
<label htmlFor={args.id}>Editable money input label</label>
|
|
20
20
|
<MoneyInput
|
|
21
21
|
{...args}
|
|
22
22
|
selectedCurrency={selectedCurrency}
|
|
@@ -160,13 +160,13 @@ export const SmallInput: Story = {
|
|
|
160
160
|
render: (args) => {
|
|
161
161
|
return (
|
|
162
162
|
<>
|
|
163
|
-
<label htmlFor={args.id
|
|
163
|
+
<label htmlFor={args.id}>Money inputs</label>
|
|
164
164
|
<MoneyInput {...args} {...SingleCurrency.args} />
|
|
165
165
|
<br />
|
|
166
166
|
<MoneyInput {...args} {...MultipleCurrencies.args} />
|
|
167
167
|
<hr />
|
|
168
168
|
<div className="has-error">
|
|
169
|
-
<label htmlFor={args.id
|
|
169
|
+
<label htmlFor={args.id}>Error states</label>
|
|
170
170
|
<MoneyInput {...args} {...SingleCurrency.args} />
|
|
171
171
|
<br />
|
|
172
172
|
<MoneyInput {...args} {...MultipleCurrencies.args} />
|
package/src/nudge/Nudge.spec.tsx
CHANGED
|
@@ -51,14 +51,14 @@ describe('Nudge', () => {
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
it('does NOT render a nudge if localStorage has been set with the id of the nudge', () => {
|
|
54
|
-
jest.spyOn(
|
|
54
|
+
jest.spyOn(Storage.prototype, 'getItem').mockReturnValue('["CAKE","TEST"]');
|
|
55
55
|
|
|
56
56
|
render(<Nudge {...defaultProps} id="TEST" persistDismissal />);
|
|
57
57
|
expect(screen.queryByText('A nudge title')).not.toBeInTheDocument();
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
it('does NOT render a nudge if localStorage has been set with the id of the nudge AND calls is previously dismissed with TRUE', () => {
|
|
61
|
-
jest.spyOn(
|
|
61
|
+
jest.spyOn(Storage.prototype, 'getItem').mockReturnValue('["CAKE","TEST"]');
|
|
62
62
|
const isPreviouslyDismissed = jest.fn();
|
|
63
63
|
|
|
64
64
|
render(
|
|
@@ -75,7 +75,7 @@ describe('Nudge', () => {
|
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
it('shows a nudge if localStorage has been set with a different id for a different nudge and calls is previously dismissed with FALSE', () => {
|
|
78
|
-
jest.spyOn(
|
|
78
|
+
jest.spyOn(Storage.prototype, 'getItem').mockReturnValue('["BANANA"]');
|
|
79
79
|
const isPreviouslyDismissed = jest.fn();
|
|
80
80
|
|
|
81
81
|
render(
|
|
@@ -92,8 +92,8 @@ describe('Nudge', () => {
|
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
it('calls local storage with updated dismissed nudges value', () => {
|
|
95
|
-
jest.spyOn(
|
|
96
|
-
const setItem = jest.spyOn(
|
|
95
|
+
jest.spyOn(Storage.prototype, 'getItem').mockReturnValue('["BANANA"]');
|
|
96
|
+
const setItem = jest.spyOn(Storage.prototype, 'setItem');
|
|
97
97
|
|
|
98
98
|
render(<Nudge {...defaultProps} id="TEST" persistDismissal />);
|
|
99
99
|
expect(screen.getByText('A nudge title')).toBeInTheDocument();
|
|
@@ -110,7 +110,8 @@ const PhoneNumberInput = ({
|
|
|
110
110
|
|
|
111
111
|
useEffect(() => {
|
|
112
112
|
if (broadcastedValue === null) {
|
|
113
|
-
|
|
113
|
+
setBroadcastedValue(internalValue);
|
|
114
|
+
return;
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
const internalPhoneNumber = `${internalValue.prefix ?? ''}${internalValue.suffix}`;
|
package/src/popover/Popover.tsx
CHANGED
|
@@ -38,8 +38,9 @@ function resolvePlacement(preferredPlacement: PopoverPreferredPlacement) {
|
|
|
38
38
|
case 'bottom-left':
|
|
39
39
|
case 'bottom-right':
|
|
40
40
|
return 'bottom';
|
|
41
|
+
default:
|
|
42
|
+
return preferredPlacement;
|
|
41
43
|
}
|
|
42
|
-
return preferredPlacement;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
export default function Popover({
|
|
@@ -298,7 +298,7 @@ const PromoCard: FunctionComponent<PromoCardProps> = forwardRef(
|
|
|
298
298
|
...commonProps,
|
|
299
299
|
'aria-checked':
|
|
300
300
|
type === 'radio' ? value === state : type === 'checkbox' ? checked : undefined,
|
|
301
|
-
'aria-describedby': `${componentId}-title
|
|
301
|
+
'aria-describedby': `${componentId}-title`,
|
|
302
302
|
'aria-disabled': isDisabled,
|
|
303
303
|
'data-value': value ?? undefined,
|
|
304
304
|
role: type === 'checkbox' || type === 'radio' ? type : undefined,
|
|
@@ -34,7 +34,7 @@ const RADIOS = [
|
|
|
34
34
|
|
|
35
35
|
describe('RadioGroup', () => {
|
|
36
36
|
it('renders null if no radios are provided', () => {
|
|
37
|
-
expect(shallow(<RadioGroup radios={[]} {...props} />).
|
|
37
|
+
expect(shallow(<RadioGroup radios={[]} {...props} />).isEmptyRender()).toBe(true);
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
it('renders radio options', () => {
|
|
@@ -96,7 +96,7 @@ describe('SegmentedControl', () => {
|
|
|
96
96
|
|
|
97
97
|
// new function is created on every render
|
|
98
98
|
const onChange = () => {
|
|
99
|
-
onChangeCallCount
|
|
99
|
+
onChangeCallCount += 1;
|
|
100
100
|
simulateRerender({});
|
|
101
101
|
};
|
|
102
102
|
|
|
@@ -118,7 +118,7 @@ describe('SegmentedControl', () => {
|
|
|
118
118
|
|
|
119
119
|
// a new onChange function is created on every render
|
|
120
120
|
const onChange = () => {
|
|
121
|
-
onChangeCallCount
|
|
121
|
+
onChangeCallCount += 1;
|
|
122
122
|
simulateRerender({});
|
|
123
123
|
};
|
|
124
124
|
|
package/src/select/Select.js
CHANGED
|
@@ -246,8 +246,8 @@ export default function Select({
|
|
|
246
246
|
};
|
|
247
247
|
|
|
248
248
|
function selectKeyboardFocusedOption() {
|
|
249
|
-
if (keyboardFocusedOptionIndex != null) {
|
|
250
|
-
|
|
249
|
+
if (keyboardFocusedOptionIndex != null && selectableOptions.length > 0) {
|
|
250
|
+
selectOption(selectableOptions[keyboardFocusedOptionIndex]);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
|
|
@@ -511,7 +511,6 @@ export default function Select({
|
|
|
511
511
|
disabled={disabled}
|
|
512
512
|
aria-controls={listboxId}
|
|
513
513
|
aria-expanded={open}
|
|
514
|
-
aria-autocomplete="none"
|
|
515
514
|
onClick={handleOnClick}
|
|
516
515
|
{...buttonProps}
|
|
517
516
|
>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
function supportsTouchEvents() {
|
|
2
2
|
const onTouchStartIsDefined = typeof window !== 'undefined' && window.ontouchstart !== undefined;
|
|
3
|
-
// eslint-disable-next-line compat/compat
|
|
4
3
|
const maxTouchPointsIsDefined = typeof navigator !== 'undefined' && navigator.maxTouchPoints;
|
|
5
4
|
const documentTouchIsDefined =
|
|
6
5
|
typeof window !== 'undefined' &&
|
|
@@ -21,7 +20,7 @@ function userAgentSuggestsTouchDevice() {
|
|
|
21
20
|
'bada',
|
|
22
21
|
];
|
|
23
22
|
const matchString = sampleTouchDevices.map((device) => `(${device})`).join('|');
|
|
24
|
-
const regex = new RegExp(matchString, '
|
|
23
|
+
const regex = new RegExp(matchString, 'gi');
|
|
25
24
|
return typeof navigator !== 'undefined' && !!navigator.userAgent.match(regex);
|
|
26
25
|
}
|
|
27
26
|
// Important: this is not fool-proof! It gives false positives and negatives, and will be outdated.
|
|
@@ -2,12 +2,17 @@ import { isTouchDevice } from './deviceDetection';
|
|
|
2
2
|
|
|
3
3
|
describe('Device detection', () => {
|
|
4
4
|
function fakeUserAgent(userAgent) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(navigator, 'userAgent', {
|
|
6
|
+
value: userAgent,
|
|
7
|
+
configurable: true,
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
function fakeMaxTouchPoints(maxTouchPoints) {
|
|
10
|
-
|
|
12
|
+
Object.defineProperty(navigator, 'maxTouchPoints', {
|
|
13
|
+
value: maxTouchPoints,
|
|
14
|
+
configurable: true,
|
|
15
|
+
});
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
// We don't test DocumentTouch api as it's basically impossible to test :(
|
package/src/test-utils/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import en from '../i18n/en.json';
|
|
|
13
13
|
*/
|
|
14
14
|
function customRender(ui, { locale = DEFAULT_LOCALE, messages = en, ...renderOptions } = {}) {
|
|
15
15
|
// eslint-disable-next-line react/prop-types
|
|
16
|
-
|
|
16
|
+
const Wrapper = ({ children }) => {
|
|
17
17
|
return <Provider i18n={{ locale, messages }}>{children}</Provider>;
|
|
18
18
|
};
|
|
19
19
|
return render(ui, { wrapper: Wrapper, ...renderOptions });
|
|
@@ -30,7 +30,7 @@ interface StoryConfig {
|
|
|
30
30
|
|
|
31
31
|
const getViewportWidth = (viewport: (typeof viewports)[keyof typeof viewports]) => {
|
|
32
32
|
if (viewport.styles && typeof viewport.styles === 'object') {
|
|
33
|
-
return parseInt(viewport.styles.width);
|
|
33
|
+
return Number.parseInt(viewport.styles.width, 10);
|
|
34
34
|
}
|
|
35
35
|
throw new Error('Unknown viewport styles');
|
|
36
36
|
};
|
package/src/title/Title.spec.tsx
CHANGED
|
@@ -34,7 +34,7 @@ describe('Title', () => {
|
|
|
34
34
|
|
|
35
35
|
it('handles unsupported typography type', () => {
|
|
36
36
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
37
|
-
// @ts-
|
|
37
|
+
// @ts-expect-error
|
|
38
38
|
render(<Title type={Typography.BODY_LARGE_BOLD}>Test</Title>);
|
|
39
39
|
const copy = screen.getByText('Test');
|
|
40
40
|
expect(copy).toBeInTheDocument();
|
|
@@ -314,7 +314,9 @@ describe('Typeahead', () => {
|
|
|
314
314
|
let selectedOption;
|
|
315
315
|
|
|
316
316
|
component.setProps({
|
|
317
|
-
onChange: (selections) =>
|
|
317
|
+
onChange: (selections) => {
|
|
318
|
+
selectedOption = selections[0];
|
|
319
|
+
},
|
|
318
320
|
options: options,
|
|
319
321
|
});
|
|
320
322
|
|
|
@@ -340,7 +342,7 @@ describe('Typeahead', () => {
|
|
|
340
342
|
it('renders all options', () => {
|
|
341
343
|
const options = option().map((optNode) => optNode.text());
|
|
342
344
|
expect(options).toHaveLength(props.options.length);
|
|
343
|
-
expect(options.every((label, i) => label === props.options[i].label));
|
|
345
|
+
expect(options.every((label, i) => label === props.options[i].label)).toBe(true);
|
|
344
346
|
});
|
|
345
347
|
|
|
346
348
|
it('does not render new option if showNewEntry is false', () => {
|
|
@@ -8,7 +8,7 @@ import Upload from '.';
|
|
|
8
8
|
|
|
9
9
|
jest.useFakeTimers();
|
|
10
10
|
jest.mock('./utils/postData', () => ({
|
|
11
|
-
postData:
|
|
11
|
+
postData: async () => 'ServerResponse',
|
|
12
12
|
}));
|
|
13
13
|
|
|
14
14
|
jest.mock('./utils/asyncFileRead');
|
|
@@ -88,7 +88,7 @@ describe('Upload', () => {
|
|
|
88
88
|
let component;
|
|
89
89
|
beforeEach(() => {
|
|
90
90
|
component = shallow(<Upload {...props} />).dive();
|
|
91
|
-
asyncFileRead.mockImplementation(
|
|
91
|
+
asyncFileRead.mockImplementation(async () => 'a value');
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
afterEach(() => {
|
|
@@ -183,7 +183,9 @@ describe('Upload', () => {
|
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
it('step ProcessingStep is called with error props', async () => {
|
|
186
|
-
asyncFileRead.mockImplementation(
|
|
186
|
+
asyncFileRead.mockImplementation(async () => {
|
|
187
|
+
throw 'An error';
|
|
188
|
+
});
|
|
187
189
|
|
|
188
190
|
await component.instance().fileDropped(TEST_FILE);
|
|
189
191
|
jest.advanceTimersByTime(props.animationDelay);
|
|
@@ -230,7 +232,9 @@ describe('Upload', () => {
|
|
|
230
232
|
it('step CompleteStep is called with error props', async () => {
|
|
231
233
|
component = mount(<Upload {...props} />);
|
|
232
234
|
const upload = component.children();
|
|
233
|
-
asyncFileRead.mockImplementation(
|
|
235
|
+
asyncFileRead.mockImplementation(async () => {
|
|
236
|
+
throw 'An error';
|
|
237
|
+
});
|
|
234
238
|
|
|
235
239
|
await upload.instance().fileDropped(TEST_FILE);
|
|
236
240
|
jest.advanceTimersByTime(props.animationDelay + ANIMATION_DELAY);
|
|
@@ -225,6 +225,7 @@ const UploadButton = ({
|
|
|
225
225
|
data-testid={TEST_IDS.uploadInput}
|
|
226
226
|
onChange={filesSelected}
|
|
227
227
|
/>
|
|
228
|
+
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
|
228
229
|
<label
|
|
229
230
|
htmlFor={id}
|
|
230
231
|
className={classNames('btn', 'np-upload-accent', 'np-upload-button', {
|