@wise/dynamic-flow-client-internal 3.13.1-experimental-renderers-7a8a51a → 3.13.1-experimental-renderers-w-tests-97b4727
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.
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { screen } from '@testing-library/react';
|
|
14
|
+
import { RadioInputRendererComponent } from '@wise/dynamic-flow-renderers/src/SelectInputRenderer/RadioInputRendererComponent';
|
|
15
|
+
import '@testing-library/jest-dom';
|
|
16
|
+
import { renderWithProviders } from '../../test-utils/rtl-utils';
|
|
17
|
+
describe('RadioInputRendererComponent', function () {
|
|
18
|
+
var getProps = function () { return ({
|
|
19
|
+
type: 'input-select',
|
|
20
|
+
id: 'id',
|
|
21
|
+
children: [],
|
|
22
|
+
description: 'description',
|
|
23
|
+
autoComplete: 'off',
|
|
24
|
+
required: false,
|
|
25
|
+
disabled: false,
|
|
26
|
+
error: 'error',
|
|
27
|
+
help: 'help',
|
|
28
|
+
label: 'label',
|
|
29
|
+
options: [
|
|
30
|
+
{
|
|
31
|
+
title: 'Option A',
|
|
32
|
+
disabled: false,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'Option B',
|
|
36
|
+
disabled: false,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
selectedIndex: null,
|
|
40
|
+
onSelect: jest.fn(),
|
|
41
|
+
onFocus: jest.fn(),
|
|
42
|
+
onBlur: jest.fn(),
|
|
43
|
+
}); };
|
|
44
|
+
describe('When the value is updated from outside the UI component', function () {
|
|
45
|
+
it('should update the selected value', function () {
|
|
46
|
+
var props = getProps();
|
|
47
|
+
var rerender = renderWithProviders(_jsx(RadioInputRendererComponent, __assign({}, props))).rerender;
|
|
48
|
+
expect(screen.getByLabelText('Option A')).not.toBeChecked();
|
|
49
|
+
expect(screen.getByLabelText('Option B')).not.toBeChecked();
|
|
50
|
+
rerender(_jsx(RadioInputRendererComponent, __assign({}, props, { selectedIndex: 1 })));
|
|
51
|
+
expect(screen.getByLabelText('Option B')).toBeChecked();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
describe('When the options are updated (e.g. refresh-on-change)', function () {
|
|
55
|
+
it('should update the options', function () {
|
|
56
|
+
var props = __assign(__assign({}, getProps()), { selectedIndex: 1 });
|
|
57
|
+
var rerender = renderWithProviders(_jsx(RadioInputRendererComponent, __assign({}, props))).rerender;
|
|
58
|
+
expect(screen.getByLabelText('Option B')).toBeChecked();
|
|
59
|
+
var updatedProps = __assign(__assign({}, props), { options: [
|
|
60
|
+
{
|
|
61
|
+
title: 'Option A',
|
|
62
|
+
disabled: false,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: 'Option NEW',
|
|
66
|
+
disabled: false,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
title: 'Option B',
|
|
70
|
+
disabled: false,
|
|
71
|
+
},
|
|
72
|
+
] });
|
|
73
|
+
rerender(_jsx(RadioInputRendererComponent, __assign({}, updatedProps)));
|
|
74
|
+
expect(screen.getByLabelText('Option NEW')).toBeChecked();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { dateStringToDateOrNull, dateToDateString, numericValueOrNull, } from '@wise/dynamic-flow-renderers/src/utils/value-utils';
|
|
2
|
+
describe('numericValueOrNull', function () {
|
|
3
|
+
it('should return null if the input is not a valid number', function () {
|
|
4
|
+
expect(numericValueOrNull('abc')).toBeNull();
|
|
5
|
+
expect(numericValueOrNull('123abc')).toBeNull();
|
|
6
|
+
});
|
|
7
|
+
it('should return the input value if it is a valid number', function () {
|
|
8
|
+
expect(numericValueOrNull('123')).toBe('123');
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
describe('dateStringToDateOrNull', function () {
|
|
12
|
+
it('should return null if the input is nullish', function () {
|
|
13
|
+
expect(dateStringToDateOrNull(undefined)).toBeNull();
|
|
14
|
+
expect(dateStringToDateOrNull('')).toBeNull();
|
|
15
|
+
expect(dateStringToDateOrNull(null)).toBeNull();
|
|
16
|
+
});
|
|
17
|
+
it('should return null if the input is not a valid date', function () {
|
|
18
|
+
expect(dateStringToDateOrNull('Jan-06-2022')).toBeNull();
|
|
19
|
+
expect(dateStringToDateOrNull('Jan 06 2022')).toBeNull();
|
|
20
|
+
});
|
|
21
|
+
it('should return a Date object if the input is a valid date string', function () {
|
|
22
|
+
var date = dateStringToDateOrNull('2022-01-31');
|
|
23
|
+
expect(date === null || date === void 0 ? void 0 : date.getFullYear()).toBe(2022);
|
|
24
|
+
expect(date === null || date === void 0 ? void 0 : date.getMonth()).toBe(0);
|
|
25
|
+
expect(date === null || date === void 0 ? void 0 : date.getDate()).toBe(31);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe('dateToDateString', function () {
|
|
29
|
+
it('should return a formatted date string when passed a date', function () {
|
|
30
|
+
var date = new Date('2022-01-01');
|
|
31
|
+
expect(dateToDateString(date)).toBe('2022-01-01');
|
|
32
|
+
});
|
|
33
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client-internal",
|
|
3
|
-
"version": "3.13.1-experimental-renderers-
|
|
3
|
+
"version": "3.13.1-experimental-renderers-w-tests-97b4727",
|
|
4
4
|
"description": "Dynamic Flow web client for Wise",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.min.js",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"react-intl": "^6"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@wise/dynamic-flow-client": "3.13.1-experimental-renderers-
|
|
86
|
+
"@wise/dynamic-flow-client": "3.13.1-experimental-renderers-w-tests-97b4727"
|
|
87
87
|
},
|
|
88
88
|
"scripts": {
|
|
89
89
|
"dev": "pnpm build:visual-tests && storybook dev -p 3005",
|