@openedx/paragon 21.7.3 → 21.9.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/dist/DataTable/CollapsibleButtonGroup.js +1 -1
- package/dist/DataTable/CollapsibleButtonGroup.js.map +1 -1
- package/dist/DataTable/RowStatus.js +11 -5
- package/dist/DataTable/RowStatus.js.map +1 -1
- package/dist/DataTable/TableFilters.js +1 -1
- package/dist/DataTable/TableFilters.js.map +1 -1
- package/dist/DataTable/TableFooter.js +1 -1
- package/dist/DataTable/TableFooter.js.map +1 -1
- package/dist/DataTable/filters/CheckboxFilter.js +1 -1
- package/dist/DataTable/filters/CheckboxFilter.js.map +1 -1
- package/dist/DataTable/filters/DropdownFilter.js +1 -1
- package/dist/DataTable/filters/DropdownFilter.js.map +1 -1
- package/dist/DataTable/filters/MultiSelectDropdownFilter.js +1 -1
- package/dist/DataTable/filters/MultiSelectDropdownFilter.js.map +1 -1
- package/dist/DataTable/filters/TextFilter.js +1 -1
- package/dist/DataTable/filters/TextFilter.js.map +1 -1
- package/dist/DataTable/index.js +13 -13
- package/dist/DataTable/index.js.map +1 -1
- package/dist/Form/FormControl.js +12 -6
- package/dist/Form/FormControl.js.map +1 -1
- package/package.json +6 -2
- package/src/ActionRow/README.md +4 -2
- package/src/DataTable/CollapsibleButtonGroup.jsx +1 -1
- package/src/DataTable/RowStatus.jsx +11 -5
- package/src/DataTable/TableFilters.jsx +1 -1
- package/src/DataTable/TableFooter.jsx +1 -5
- package/src/DataTable/filters/CheckboxFilter.jsx +1 -1
- package/src/DataTable/filters/DropdownFilter.jsx +1 -1
- package/src/DataTable/filters/MultiSelectDropdownFilter.jsx +1 -1
- package/src/DataTable/filters/TextFilter.jsx +1 -1
- package/src/DataTable/index.jsx +13 -13
- package/src/DataTable/tests/DataTable.test.jsx +1 -1
- package/src/DataTable/tests/RowStatus.test.jsx +2 -2
- package/src/DataTable/tests/SmartStatus.test.jsx +2 -2
- package/src/DataTable/tests/TableActions.test.jsx +5 -4
- package/src/Form/FormControl.jsx +7 -1
- package/src/Form/form-control.mdx +142 -1
- package/src/Form/tests/FormControl.test.jsx +40 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
|
|
@@ -8,8 +8,27 @@ const ref = {
|
|
|
8
8
|
current: null,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
let unmaskedInputValue;
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line react/prop-types
|
|
14
|
+
function Component({ isClearValue }) {
|
|
15
|
+
const [inputValue, setInputValue] = useState('');
|
|
16
|
+
unmaskedInputValue = inputValue;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<FormControl
|
|
20
|
+
inputMask="+{1} (000) 000-0000"
|
|
21
|
+
value={inputValue}
|
|
22
|
+
onChange={(e) => (!isClearValue ? setInputValue(e.target.value) : null)}
|
|
23
|
+
/* eslint-disable-next-line no-underscore-dangle */
|
|
24
|
+
onAccept={(_, mask) => (isClearValue ? setInputValue(mask._unmaskedValue) : null)}
|
|
25
|
+
data-testid="form-control-with-mask"
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
11
30
|
describe('FormControl', () => {
|
|
12
|
-
it('textarea changes its height with autoResize prop',
|
|
31
|
+
it('textarea changes its height with autoResize prop', () => {
|
|
13
32
|
const useReferenceSpy = jest.spyOn(React, 'useRef').mockReturnValue(ref);
|
|
14
33
|
const onChangeFunc = jest.fn();
|
|
15
34
|
const inputText = 'new text';
|
|
@@ -26,9 +45,27 @@ describe('FormControl', () => {
|
|
|
26
45
|
expect(useReferenceSpy).toHaveBeenCalledTimes(1);
|
|
27
46
|
expect(ref.current.style.height).toBe('0px');
|
|
28
47
|
|
|
29
|
-
|
|
48
|
+
userEvent.type(textarea, inputText);
|
|
30
49
|
|
|
31
50
|
expect(onChangeFunc).toHaveBeenCalledTimes(inputText.length);
|
|
32
51
|
expect(ref.current.style.height).toEqual(`${ref.current.scrollHeight + ref.current.offsetHeight}px`);
|
|
33
52
|
});
|
|
53
|
+
|
|
54
|
+
it('should apply and accept input mask for phone numbers', () => {
|
|
55
|
+
render(<Component />);
|
|
56
|
+
|
|
57
|
+
const input = screen.getByTestId('form-control-with-mask');
|
|
58
|
+
userEvent.type(input, '5555555555');
|
|
59
|
+
expect(input.value).toBe('+1 (555) 555-5555');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should be cleared from the mask elements value', () => {
|
|
63
|
+
render(<Component isClearValue />);
|
|
64
|
+
|
|
65
|
+
const input = screen.getByTestId('form-control-with-mask');
|
|
66
|
+
userEvent.type(input, '5555555555');
|
|
67
|
+
|
|
68
|
+
expect(input.value).toBe('+1 (555) 555-5555');
|
|
69
|
+
expect(unmaskedInputValue).toBe('15555555555');
|
|
70
|
+
});
|
|
34
71
|
});
|