@descope/flow-components 2.0.39 → 2.0.40

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.
Files changed (151) hide show
  1. package/package.json +5 -2
  2. package/.eslintrc +0 -119
  3. package/.github/actions/setup/action.yml +0 -42
  4. package/.github/workflows/ci.yml +0 -105
  5. package/.github/workflows/publish.yml +0 -40
  6. package/.github/workflows/release.yml +0 -44
  7. package/.husky/pre-commit +0 -1
  8. package/.prettierrc +0 -8
  9. package/.storybook/main.js +0 -23
  10. package/.storybook/manager.js +0 -10
  11. package/.storybook/preview-head.html +0 -29
  12. package/.storybook/preview.js +0 -44
  13. package/LICENSE +0 -21
  14. package/babel.config.js +0 -7
  15. package/jest.config.js +0 -33
  16. package/jest.setup.js +0 -2
  17. package/renovate.json +0 -4
  18. package/rollup.config.mjs +0 -47
  19. package/src/Boolean/Boolean.tsx +0 -24
  20. package/src/Boolean/index.ts +0 -1
  21. package/src/Button/Button.tsx +0 -49
  22. package/src/Button/index.ts +0 -1
  23. package/src/Checkbox/Checkbox.tsx +0 -16
  24. package/src/Checkbox/index.ts +0 -1
  25. package/src/Code/Code.tsx +0 -21
  26. package/src/Code/index.ts +0 -1
  27. package/src/Container/Container.tsx +0 -111
  28. package/src/Container/index.ts +0 -1
  29. package/src/CssVarImage/CssVarImage.tsx +0 -38
  30. package/src/CssVarImage/index.ts +0 -1
  31. package/src/Divider/Divider.tsx +0 -33
  32. package/src/Divider/index.ts +0 -1
  33. package/src/EmailField/EmailField.tsx +0 -20
  34. package/src/EmailField/index.ts +0 -1
  35. package/src/Image/Image.tsx +0 -32
  36. package/src/Image/index.ts +0 -1
  37. package/src/Input/Input.tsx +0 -27
  38. package/src/Input/index.ts +0 -1
  39. package/src/Link/Link.tsx +0 -33
  40. package/src/Link/index.ts +0 -1
  41. package/src/Loader/Loader.tsx +0 -40
  42. package/src/Loader/index.ts +0 -1
  43. package/src/Logo/Logo.tsx +0 -27
  44. package/src/Logo/index.ts +0 -1
  45. package/src/NewPassword/NewPassword.tsx +0 -25
  46. package/src/NewPassword/index.ts +0 -1
  47. package/src/NumberField/NumberField.tsx +0 -20
  48. package/src/NumberField/index.ts +0 -1
  49. package/src/Password/Password.tsx +0 -20
  50. package/src/Password/index.ts +0 -1
  51. package/src/Phone/Phone.tsx +0 -22
  52. package/src/Phone/index.ts +0 -1
  53. package/src/Select/Select.tsx +0 -29
  54. package/src/Select/index.ts +0 -1
  55. package/src/Switch/Switch.tsx +0 -21
  56. package/src/Switch/index.ts +0 -1
  57. package/src/TOTPImage/TOTPImage.tsx +0 -18
  58. package/src/TOTPImage/index.ts +0 -1
  59. package/src/TOTPLink/TOTPLink.tsx +0 -16
  60. package/src/TOTPLink/index.ts +0 -1
  61. package/src/Text/Text.tsx +0 -36
  62. package/src/Text/index.ts +0 -1
  63. package/src/TextField/TextField.tsx +0 -20
  64. package/src/TextField/index.ts +0 -1
  65. package/src/Textarea/Textarea.tsx +0 -20
  66. package/src/Textarea/index.ts +0 -1
  67. package/src/icons/apple.tsx +0 -14
  68. package/src/icons/discord.tsx +0 -14
  69. package/src/icons/facebook.tsx +0 -14
  70. package/src/icons/fingerprint.tsx +0 -14
  71. package/src/icons/github.tsx +0 -14
  72. package/src/icons/gitlab.tsx +0 -41
  73. package/src/icons/google.tsx +0 -29
  74. package/src/icons/index.ts +0 -11
  75. package/src/icons/input-hidden.tsx +0 -17
  76. package/src/icons/input-visible.tsx +0 -17
  77. package/src/icons/linkedin.tsx +0 -18
  78. package/src/icons/microsoft.tsx +0 -41
  79. package/src/icons/passkey.tsx +0 -16
  80. package/src/icons/sso.tsx +0 -14
  81. package/src/index.ts +0 -25
  82. package/src/inputHelpers.ts +0 -41
  83. package/src/types.ts +0 -52
  84. package/src/utils.tsx +0 -69
  85. package/stories/Boolean.stories.jsx +0 -37
  86. package/stories/Button.stories.jsx +0 -71
  87. package/stories/Checkbox.stories.jsx +0 -29
  88. package/stories/Code.stories.jsx +0 -60
  89. package/stories/Container.stories.jsx +0 -53
  90. package/stories/Divider.stories.jsx +0 -23
  91. package/stories/EmailField.stories.jsx +0 -36
  92. package/stories/Image.stories.jsx +0 -16
  93. package/stories/Input.stories.jsx +0 -63
  94. package/stories/Link.stories.jsx +0 -21
  95. package/stories/Loader.stories.jsx +0 -34
  96. package/stories/Logo.stories.jsx +0 -14
  97. package/stories/NewPassword.stories.jsx +0 -52
  98. package/stories/NumberField.stories.jsx +0 -35
  99. package/stories/Password.stories.jsx +0 -37
  100. package/stories/Phone.stories.jsx +0 -61
  101. package/stories/Switch.stories.jsx +0 -29
  102. package/stories/TOTPImage.stories.jsx +0 -22
  103. package/stories/TOTPLink.stories.jsx +0 -20
  104. package/stories/Text.stories.jsx +0 -35
  105. package/stories/TextField.stories.jsx +0 -39
  106. package/stories/Textarea.stories.jsx +0 -25
  107. package/storybook-static/favicon.ico +0 -0
  108. package/test/__snapshots__/boolean.test.tsx.snap +0 -47
  109. package/test/__snapshots__/buttons.test.tsx.snap +0 -843
  110. package/test/__snapshots__/checkbox.test.tsx.snap +0 -51
  111. package/test/__snapshots__/code.test.tsx.snap +0 -1184
  112. package/test/__snapshots__/container.test.tsx.snap +0 -218
  113. package/test/__snapshots__/divider.test.tsx.snap +0 -73
  114. package/test/__snapshots__/image.test.tsx.snap +0 -62
  115. package/test/__snapshots__/input.test.tsx.snap +0 -80
  116. package/test/__snapshots__/link.test.tsx.snap +0 -120
  117. package/test/__snapshots__/loader.test.tsx.snap +0 -53
  118. package/test/__snapshots__/logo.test.tsx.snap +0 -10
  119. package/test/__snapshots__/newPassword.test.tsx.snap +0 -69
  120. package/test/__snapshots__/numeric-input.test.tsx.snap +0 -21
  121. package/test/__snapshots__/password.test.tsx.snap +0 -26
  122. package/test/__snapshots__/phone.test.tsx.snap +0 -504
  123. package/test/__snapshots__/switch.test.tsx.snap +0 -51
  124. package/test/__snapshots__/text.test.tsx.snap +0 -89
  125. package/test/__snapshots__/textarea.test.tsx.snap +0 -73
  126. package/test/__snapshots__/themeToCssVars.test.ts.snap +0 -45
  127. package/test/__snapshots__/totpImage.test.tsx.snap +0 -10
  128. package/test/__snapshots__/totpLink.test.tsx.snap +0 -13
  129. package/test/boolean.test.tsx +0 -28
  130. package/test/buttons.test.tsx +0 -66
  131. package/test/checkbox.test.tsx +0 -67
  132. package/test/code.test.tsx +0 -182
  133. package/test/container.test.tsx +0 -91
  134. package/test/divider.test.tsx +0 -50
  135. package/test/image.test.tsx +0 -40
  136. package/test/input.test.tsx +0 -82
  137. package/test/inputHelpers.test.tsx +0 -58
  138. package/test/link.test.tsx +0 -71
  139. package/test/loader.test.tsx +0 -25
  140. package/test/logo.test.tsx +0 -10
  141. package/test/newPassword.test.tsx +0 -132
  142. package/test/numeric-input.test.tsx +0 -114
  143. package/test/password.test.tsx +0 -55
  144. package/test/phone.test.tsx +0 -158
  145. package/test/switch.test.tsx +0 -67
  146. package/test/text.test.tsx +0 -60
  147. package/test/textarea.test.tsx +0 -64
  148. package/test/themeToCssVars.test.ts +0 -82
  149. package/test/totpImage.test.tsx +0 -10
  150. package/test/totpLink.test.tsx +0 -10
  151. package/tsconfig.json +0 -20
@@ -1,82 +0,0 @@
1
- /* eslint-disable testing-library/no-container */
2
- /* eslint-disable testing-library/no-node-access */
3
- import { render } from '@testing-library/react';
4
- import React from 'react';
5
- import { Input } from '../src';
6
-
7
- describe('Input', () => {
8
- it('rendered with default props', () => {
9
- const { container } = render(<Input />);
10
- expect(container).toMatchSnapshot();
11
- });
12
-
13
- it('rendered with label', () => {
14
- const { container } = render(<Input label="label" />);
15
- expect(container).toMatchSnapshot();
16
- });
17
-
18
- it('rendered with label and required', () => {
19
- const { container } = render(<Input label="label" required />);
20
- expect(container).toMatchSnapshot();
21
- });
22
-
23
- it('rendered with fullWidth', () => {
24
- const { container } = render(<Input fullWidth />);
25
- expect(container).toMatchSnapshot();
26
- });
27
-
28
- it('rendered with name', () => {
29
- const { container } = render(<Input name="name" />);
30
- expect(container).toMatchSnapshot();
31
- });
32
-
33
- it('rendered with className', () => {
34
- const { container } = render(<Input className="className" />);
35
- expect(container).toMatchSnapshot();
36
- });
37
-
38
- it('rendered with custom error attributes', () => {
39
- const { container } = render(
40
- <Input
41
- data-errormessage-pattern-mismatch="pattern"
42
- data-errormessage-value-missing="missing"
43
- />
44
- );
45
- expect(container).toMatchSnapshot();
46
- });
47
-
48
- it.skip('should apply render single icon', () => {
49
- const { container } = render(<Input endIcons={['github']} />);
50
- const icon = container.querySelector('[data-icon]') as HTMLElement;
51
- expect(icon).toBeInTheDocument();
52
- });
53
-
54
- it.skip('should apply render multiple icon', () => {
55
- const { container } = render(<Input endIcons={['github', 'discord']} />);
56
- const icon = container.querySelectorAll('[data-icon]');
57
- const discordIcon = container.querySelector('[data-icon="discord"]');
58
- const githubIcon = container.querySelector('[data-icon="github"]');
59
- expect(icon).toHaveLength(2);
60
- expect(discordIcon).toBeInTheDocument();
61
- expect(githubIcon).toBeInTheDocument();
62
- });
63
-
64
- it('rendered with custom scripts', () => {
65
- global.process.env.SSR = 'true';
66
-
67
- const spyToString = jest.spyOn(Function.prototype, 'toString');
68
-
69
- spyToString.mockReturnValue(
70
- (() => {
71
- const x = 1 + 1;
72
-
73
- return x;
74
- }).toString()
75
- );
76
-
77
- const { container } = render(<Input />);
78
- expect(container).toMatchSnapshot();
79
-
80
- spyToString.mockRestore();
81
- });
82
- });
@@ -1,58 +0,0 @@
1
- import { render } from '@testing-library/react';
2
- import React from 'react';
3
- import { handleCustomValidationMessages } from '../src/inputHelpers';
4
-
5
- const Input = (props) => (
6
- <div>
7
- <input {...props} className="descope-input" />
8
- </div>
9
- );
10
-
11
- describe('inputHelpers', () => {
12
- describe('handleCustomValidationMessages', () => {
13
- describe('required', () => {
14
- it('should report correct error message when checking validity', () => {
15
- const { container } = render(
16
- <Input required data-errormessage-value-missing="missing" />
17
- );
18
- handleCustomValidationMessages.bind(container)();
19
-
20
- // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
21
- const inputEle = container.querySelector('input');
22
- const spy = jest.spyOn(inputEle, 'setCustomValidity');
23
- inputEle.checkValidity();
24
-
25
- expect(spy).toHaveBeenCalledWith('missing');
26
- });
27
- });
28
-
29
- describe('pattern', () => {
30
- it('should report correct error message when checking validity', () => {
31
- const { container } = render(
32
- <Input
33
- pattern="\\d{6}"
34
- data-errormessage-pattern-mismatch="pattern"
35
- />
36
- );
37
- handleCustomValidationMessages.bind(container)();
38
-
39
- // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
40
- const inputEle = container.querySelector('input');
41
- inputEle.value = '1';
42
- const spy = jest.spyOn(inputEle, 'setCustomValidity');
43
- inputEle.checkValidity();
44
-
45
- expect(spy).toHaveBeenCalledWith('pattern');
46
- });
47
-
48
- it('should not throw if not bound', () => {
49
- handleCustomValidationMessages();
50
- });
51
-
52
- it('should not throw if no input found', () => {
53
- const { container } = render(<div />);
54
- handleCustomValidationMessages.bind(container)();
55
- });
56
- });
57
- });
58
- });
@@ -1,71 +0,0 @@
1
- /* eslint-disable jsx-a11y/anchor-is-valid */
2
- import { render, screen } from '@testing-library/react';
3
- import React from 'react';
4
- import { Link } from '../src';
5
-
6
- describe('Link', () => {
7
- it('rendered with default props', () => {
8
- render(<Link>Link</Link>);
9
- expect(screen.getByText('Link')).toMatchSnapshot();
10
- });
11
-
12
- it('rendered with size', () => {
13
- render(<Link size="9xl">Link</Link>);
14
- expect(screen.getByText('Link')).toMatchSnapshot();
15
- });
16
-
17
- it('rendered with fontWeight', () => {
18
- render(<Link fontWeight="black">Link</Link>);
19
- expect(screen.getByText('Link')).toMatchSnapshot();
20
- });
21
-
22
- it('rendered with fontFamily', () => {
23
- render(<Link fontFamily="mono">Link</Link>);
24
- expect(screen.getByText('Link')).toMatchSnapshot();
25
- });
26
-
27
- it('rendered with align', () => {
28
- render(<Link align="end">Link</Link>);
29
- expect(screen.getByText('Link')).toMatchSnapshot();
30
- });
31
-
32
- it('rendered with italic', () => {
33
- render(<Link italic>Link</Link>);
34
- expect(screen.getByText('Link')).toMatchSnapshot();
35
- });
36
-
37
- it('rendered with fullWidth', () => {
38
- render(<Link fullWidth>Link</Link>);
39
- expect(screen.getByText('Link')).toMatchSnapshot();
40
- });
41
-
42
- it('rendered with color', () => {
43
- render(<Link color="primary">Link</Link>);
44
- expect(screen.getByText('Link')).toMatchSnapshot();
45
- });
46
-
47
- it('rendered without hover', () => {
48
- render(<Link hover={false}>Link</Link>);
49
- expect(screen.getByText('Link')).toMatchSnapshot();
50
- });
51
-
52
- it('rendered with href', () => {
53
- render(<Link href="http://a.com">Link</Link>);
54
- expect(screen.getByText('Link')).toMatchSnapshot();
55
- });
56
-
57
- it('rendered with target', () => {
58
- render(<Link target="_blank">Link</Link>);
59
- expect(screen.getByText('Link')).toMatchSnapshot();
60
- });
61
-
62
- it('rendered with custom className', () => {
63
- render(<Link className="kuku">Link</Link>);
64
- expect(screen.getByText('Link')).toMatchSnapshot();
65
- });
66
-
67
- it('rendered with custom typography', () => {
68
- render(<Link typography="body1">Link</Link>);
69
- expect(screen.getByText('Link')).toMatchSnapshot();
70
- });
71
- });
@@ -1,25 +0,0 @@
1
- import { render } from '@testing-library/react';
2
- import React from 'react';
3
- import { Loader } from '../src';
4
-
5
- describe('Logo', () => {
6
- it('rendered with default props', () => {
7
- const { container } = render(<Loader />);
8
- expect(container).toMatchSnapshot();
9
- });
10
-
11
- it('rendered with color prop', () => {
12
- const { container } = render(<Loader color="secondary" />);
13
- expect(container).toMatchSnapshot();
14
- });
15
-
16
- it('rendered with size prop', () => {
17
- const { container } = render(<Loader size="xs" />);
18
- expect(container).toMatchSnapshot();
19
- });
20
-
21
- it('rendered with variant prop', () => {
22
- const { container } = render(<Loader variant="radial" />);
23
- expect(container).toMatchSnapshot();
24
- });
25
- });
@@ -1,10 +0,0 @@
1
- import { render } from '@testing-library/react';
2
- import React from 'react';
3
- import { Logo } from '../src';
4
-
5
- describe('Logo', () => {
6
- it('rendered with default props', () => {
7
- const { container } = render(<Logo />);
8
- expect(container).toMatchSnapshot();
9
- });
10
- });
@@ -1,132 +0,0 @@
1
- /* eslint-disable testing-library/no-container */
2
- /* eslint-disable testing-library/no-node-access */
3
- import { fireEvent, render } from '@testing-library/react';
4
- import React from 'react';
5
- import { NewPassword } from '../src';
6
-
7
- const defaultProps = {
8
- passwordInputProps: { label: 'Password', placeholder: 'enter password' },
9
- confirmInputProps: {
10
- label: 'Confirm Password',
11
- placeholder: 'confirm password'
12
- },
13
- isConfirm: false
14
- };
15
-
16
- describe.skip('Password Confirm', () => {
17
- it('should render a single input with default props', () => {
18
- const { container } = render(<NewPassword {...defaultProps} />);
19
- expect(container).toMatchSnapshot();
20
- expect(container.querySelectorAll('input')).toHaveLength(1);
21
- });
22
-
23
- it('should render with confirmation input', () => {
24
- const { container } = render(<NewPassword {...defaultProps} isConfirm />);
25
- expect(container).toMatchSnapshot();
26
- });
27
-
28
- it('should render with type password', () => {
29
- const { container } = render(<NewPassword {...defaultProps} />);
30
- const input = container.querySelector('input');
31
- expect(input).toHaveAttribute('type', 'password');
32
- });
33
-
34
- it('should toggle validation error on value mismatch', () => {
35
- const { container } = render(
36
- <form>
37
- <NewPassword {...defaultProps} isConfirm />
38
- <button type="submit">submit</button>
39
- </form>
40
- );
41
-
42
- const source = container.querySelector('input[data-testid="primary"]');
43
- const target = container.querySelector('input[data-testid="secondary"]');
44
-
45
- expect(
46
- container.querySelector('input[data-testid="secondary"][pattern]')
47
- ).not.toBeInTheDocument();
48
-
49
- fireEvent.change(source, { target: { value: 'mismatch' } });
50
- fireEvent.keyUp(source);
51
-
52
- fireEvent.change(target, { target: { value: 'password' } });
53
- fireEvent.keyUp(target);
54
-
55
- expect(
56
- container.querySelector('[data-testid="secondary"][pattern="mismatch"]')
57
- ).toBeInTheDocument();
58
-
59
- expect(target).toBeInvalid();
60
- });
61
-
62
- it('should clean pattern', () => {
63
- const { container } = render(
64
- <form>
65
- <NewPassword {...defaultProps} isConfirm />
66
- <button type="submit">submit</button>
67
- </form>
68
- );
69
-
70
- const source = container.querySelector('input[data-testid="primary"]');
71
- const target = container.querySelector('input[data-testid="secondary"]');
72
-
73
- fireEvent.change(source, { target: { value: 'mismatch' } });
74
- fireEvent.keyUp(source);
75
-
76
- fireEvent.change(target, { target: { value: 'password' } });
77
- fireEvent.keyUp(target);
78
-
79
- expect(
80
- container.querySelector('[data-testid="secondary"][pattern="mismatch"]')
81
- ).toBeInTheDocument();
82
-
83
- fireEvent.change(source, { target: { value: '' } });
84
- fireEvent.keyUp(source);
85
-
86
- expect(
87
- container.querySelector('[data-testid="secondary"]')
88
- ).not.toHaveAttribute('pattern');
89
- });
90
-
91
- it('should render with custom scripts', () => {
92
- global.process.env.SSR = 'true';
93
-
94
- const spyToString = jest.spyOn(Function.prototype, 'toString');
95
-
96
- spyToString.mockReturnValue(
97
- (() => {
98
- const x = 1 + 1;
99
- return x;
100
- }).toString()
101
- );
102
-
103
- const { container } = render(<NewPassword {...defaultProps} />);
104
- expect(container).toMatchSnapshot();
105
-
106
- spyToString.mockRestore();
107
- });
108
-
109
- it('should escape regexp', () => {
110
- const onSubmit = jest.fn((e) => e.preventDefault());
111
-
112
- const { container } = render(
113
- <form onSubmit={onSubmit}>
114
- <NewPassword {...defaultProps} isConfirm />
115
- <button type="submit">submit</button>
116
- </form>
117
- );
118
-
119
- const source = container.querySelector('input[data-testid="primary"]');
120
- const target = container.querySelector('input[data-testid="secondary"]');
121
-
122
- fireEvent.change(source, { target: { value: 'q1#w%2e&3*R$' } });
123
- fireEvent.keyUp(source);
124
-
125
- fireEvent.change(target, { target: { value: 'q1#w%2e&3*R$' } });
126
- fireEvent.keyUp(target);
127
-
128
- fireEvent.click(container.querySelector('button'));
129
-
130
- expect(container.querySelector('[data-testid="secondary"]')).toBeValid();
131
- });
132
- });
@@ -1,114 +0,0 @@
1
- /* eslint-disable testing-library/no-container */
2
- /* eslint-disable testing-library/no-node-access */
3
- import { fireEvent, render } from '@testing-library/react';
4
- import React from 'react';
5
- import { Input } from '../src';
6
-
7
- describe.skip('Number Input', () => {
8
- it('should render with default props', () => {
9
- const { container } = render(<Input type="number" />);
10
- expect(container).toMatchSnapshot();
11
- });
12
-
13
- it('should render with type number', () => {
14
- const { container } = render(<Input type="number" />);
15
- const input = container.querySelector('input');
16
- expect(input).toHaveAttribute('type', 'number');
17
- });
18
-
19
- it('should allow number input', () => {
20
- const { container } = render(<Input type="number" />);
21
- const input = container.querySelector('input');
22
-
23
- fireEvent.change(input, { target: { value: 123 } });
24
- expect(input.value).toEqual('123');
25
- });
26
-
27
- it('should not allow exponential symbol in number input', () => {
28
- const { container } = render(<Input type="number" />);
29
- const input = container.querySelector('input');
30
-
31
- const preventDefaultSpy = jest.spyOn(Event.prototype, 'preventDefault');
32
-
33
- input.dispatchEvent(new KeyboardEvent('keypress', { key: 'e' }));
34
- expect(input.value).toEqual('');
35
- expect(preventDefaultSpy).toHaveBeenCalledTimes(1);
36
-
37
- input.dispatchEvent(new KeyboardEvent('keypress', { key: 'E' }));
38
- expect(input.value).toEqual('');
39
- expect(preventDefaultSpy).toHaveBeenCalledTimes(2);
40
- });
41
-
42
- it('should allow minus symbol in number input', () => {
43
- const { container } = render(<Input type="number" />);
44
- const input = container.querySelector('input');
45
-
46
- fireEvent.change(input, { target: { value: -1 } });
47
- expect(input.value).toEqual('-1');
48
- });
49
-
50
- it('should not have change value when only minus symbol is submitted', () => {
51
- const { container } = render(<Input type="number" />);
52
- const input = container.querySelector('input');
53
-
54
- fireEvent.change(input, { target: { value: '-' } });
55
- expect(input.value).toEqual('');
56
- });
57
-
58
- it('should not allow float value by default', () => {
59
- const onSubmit = jest.fn((e) => e.preventDefault());
60
-
61
- const { container } = render(
62
- <form onSubmit={onSubmit}>
63
- <Input type="number" />
64
- <button type="submit">submit</button>
65
- </form>
66
- );
67
- const input = container.querySelector('input');
68
-
69
- expect(input).not.toHaveAttribute('step', 'any');
70
-
71
- fireEvent.change(input, { target: { value: 3.2 } });
72
-
73
- fireEvent.click(container.querySelector('button[type="submit"]'));
74
- expect(input).not.toBeValid();
75
- });
76
-
77
- it('should allow float value', () => {
78
- const onSubmit = jest.fn((e) => e.preventDefault());
79
-
80
- const { container } = render(
81
- <form onSubmit={onSubmit}>
82
- <Input type="number" step="any" />
83
- <button type="submit">submit</button>
84
- </form>
85
- );
86
- const input = container.querySelector('input');
87
-
88
- expect(input).toHaveAttribute('step', 'any');
89
-
90
- fireEvent.change(input, { target: { value: 3.2 } });
91
- expect(input.value).toEqual('3.2');
92
-
93
- fireEvent.click(container.querySelector('button[type="submit"]'));
94
- expect(input).toBeValid();
95
- });
96
-
97
- it('rendered with custom scripts', () => {
98
- global.process.env.SSR = 'true';
99
-
100
- const spyToString = jest.spyOn(Function.prototype, 'toString');
101
-
102
- spyToString.mockReturnValue(
103
- (() => {
104
- const x = 1 + 1;
105
- return x;
106
- }).toString()
107
- );
108
-
109
- const { container } = render(<Input type="number" />);
110
- expect(container).toMatchSnapshot();
111
-
112
- spyToString.mockRestore();
113
- });
114
- });
@@ -1,55 +0,0 @@
1
- /* eslint-disable testing-library/no-container */
2
- /* eslint-disable testing-library/no-node-access */
3
- import { fireEvent, render } from '@testing-library/react';
4
- import React from 'react';
5
- import { PasswordField } from '../src';
6
-
7
- describe.skip('Password', () => {
8
- it('should render with default props', () => {
9
- const { container } = render(<PasswordField />);
10
- expect(container).toMatchSnapshot();
11
- });
12
-
13
- it('should render with toggle on/off icons', () => {
14
- const { container } = render(
15
- <PasswordField endIcons={['inputVisible', 'inputHidden']} />
16
- );
17
- expect(container).toMatchSnapshot();
18
- });
19
-
20
- it('should render with type password', () => {
21
- const { container } = render(<PasswordField />);
22
- const input = container.querySelector('input');
23
- expect(input).toHaveAttribute('type', 'password');
24
- });
25
-
26
- it('should toggle password visibility', () => {
27
- const { container } = render(<PasswordField />);
28
- const input = container.querySelector('input');
29
- const svg = container.querySelector('svg');
30
-
31
- fireEvent.click(svg);
32
- expect(input).toHaveAttribute('type', 'text');
33
-
34
- fireEvent.click(svg);
35
- expect(input).toHaveAttribute('type', 'password');
36
- });
37
-
38
- it('rendered with custom scripts', () => {
39
- global.process.env.SSR = 'true';
40
-
41
- const spyToString = jest.spyOn(Function.prototype, 'toString');
42
-
43
- spyToString.mockReturnValue(
44
- (() => {
45
- const x = 1 + 1;
46
- return x;
47
- }).toString()
48
- );
49
-
50
- const { container } = render(<PasswordField />);
51
- expect(container).toMatchSnapshot();
52
-
53
- spyToString.mockRestore();
54
- });
55
- });