@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.
- package/package.json +5 -2
- package/.eslintrc +0 -119
- package/.github/actions/setup/action.yml +0 -42
- package/.github/workflows/ci.yml +0 -105
- package/.github/workflows/publish.yml +0 -40
- package/.github/workflows/release.yml +0 -44
- package/.husky/pre-commit +0 -1
- package/.prettierrc +0 -8
- package/.storybook/main.js +0 -23
- package/.storybook/manager.js +0 -10
- package/.storybook/preview-head.html +0 -29
- package/.storybook/preview.js +0 -44
- package/LICENSE +0 -21
- package/babel.config.js +0 -7
- package/jest.config.js +0 -33
- package/jest.setup.js +0 -2
- package/renovate.json +0 -4
- package/rollup.config.mjs +0 -47
- package/src/Boolean/Boolean.tsx +0 -24
- package/src/Boolean/index.ts +0 -1
- package/src/Button/Button.tsx +0 -49
- package/src/Button/index.ts +0 -1
- package/src/Checkbox/Checkbox.tsx +0 -16
- package/src/Checkbox/index.ts +0 -1
- package/src/Code/Code.tsx +0 -21
- package/src/Code/index.ts +0 -1
- package/src/Container/Container.tsx +0 -111
- package/src/Container/index.ts +0 -1
- package/src/CssVarImage/CssVarImage.tsx +0 -38
- package/src/CssVarImage/index.ts +0 -1
- package/src/Divider/Divider.tsx +0 -33
- package/src/Divider/index.ts +0 -1
- package/src/EmailField/EmailField.tsx +0 -20
- package/src/EmailField/index.ts +0 -1
- package/src/Image/Image.tsx +0 -32
- package/src/Image/index.ts +0 -1
- package/src/Input/Input.tsx +0 -27
- package/src/Input/index.ts +0 -1
- package/src/Link/Link.tsx +0 -33
- package/src/Link/index.ts +0 -1
- package/src/Loader/Loader.tsx +0 -40
- package/src/Loader/index.ts +0 -1
- package/src/Logo/Logo.tsx +0 -27
- package/src/Logo/index.ts +0 -1
- package/src/NewPassword/NewPassword.tsx +0 -25
- package/src/NewPassword/index.ts +0 -1
- package/src/NumberField/NumberField.tsx +0 -20
- package/src/NumberField/index.ts +0 -1
- package/src/Password/Password.tsx +0 -20
- package/src/Password/index.ts +0 -1
- package/src/Phone/Phone.tsx +0 -22
- package/src/Phone/index.ts +0 -1
- package/src/Select/Select.tsx +0 -29
- package/src/Select/index.ts +0 -1
- package/src/Switch/Switch.tsx +0 -21
- package/src/Switch/index.ts +0 -1
- package/src/TOTPImage/TOTPImage.tsx +0 -18
- package/src/TOTPImage/index.ts +0 -1
- package/src/TOTPLink/TOTPLink.tsx +0 -16
- package/src/TOTPLink/index.ts +0 -1
- package/src/Text/Text.tsx +0 -36
- package/src/Text/index.ts +0 -1
- package/src/TextField/TextField.tsx +0 -20
- package/src/TextField/index.ts +0 -1
- package/src/Textarea/Textarea.tsx +0 -20
- package/src/Textarea/index.ts +0 -1
- package/src/icons/apple.tsx +0 -14
- package/src/icons/discord.tsx +0 -14
- package/src/icons/facebook.tsx +0 -14
- package/src/icons/fingerprint.tsx +0 -14
- package/src/icons/github.tsx +0 -14
- package/src/icons/gitlab.tsx +0 -41
- package/src/icons/google.tsx +0 -29
- package/src/icons/index.ts +0 -11
- package/src/icons/input-hidden.tsx +0 -17
- package/src/icons/input-visible.tsx +0 -17
- package/src/icons/linkedin.tsx +0 -18
- package/src/icons/microsoft.tsx +0 -41
- package/src/icons/passkey.tsx +0 -16
- package/src/icons/sso.tsx +0 -14
- package/src/index.ts +0 -25
- package/src/inputHelpers.ts +0 -41
- package/src/types.ts +0 -52
- package/src/utils.tsx +0 -69
- package/stories/Boolean.stories.jsx +0 -37
- package/stories/Button.stories.jsx +0 -71
- package/stories/Checkbox.stories.jsx +0 -29
- package/stories/Code.stories.jsx +0 -60
- package/stories/Container.stories.jsx +0 -53
- package/stories/Divider.stories.jsx +0 -23
- package/stories/EmailField.stories.jsx +0 -36
- package/stories/Image.stories.jsx +0 -16
- package/stories/Input.stories.jsx +0 -63
- package/stories/Link.stories.jsx +0 -21
- package/stories/Loader.stories.jsx +0 -34
- package/stories/Logo.stories.jsx +0 -14
- package/stories/NewPassword.stories.jsx +0 -52
- package/stories/NumberField.stories.jsx +0 -35
- package/stories/Password.stories.jsx +0 -37
- package/stories/Phone.stories.jsx +0 -61
- package/stories/Switch.stories.jsx +0 -29
- package/stories/TOTPImage.stories.jsx +0 -22
- package/stories/TOTPLink.stories.jsx +0 -20
- package/stories/Text.stories.jsx +0 -35
- package/stories/TextField.stories.jsx +0 -39
- package/stories/Textarea.stories.jsx +0 -25
- package/storybook-static/favicon.ico +0 -0
- package/test/__snapshots__/boolean.test.tsx.snap +0 -47
- package/test/__snapshots__/buttons.test.tsx.snap +0 -843
- package/test/__snapshots__/checkbox.test.tsx.snap +0 -51
- package/test/__snapshots__/code.test.tsx.snap +0 -1184
- package/test/__snapshots__/container.test.tsx.snap +0 -218
- package/test/__snapshots__/divider.test.tsx.snap +0 -73
- package/test/__snapshots__/image.test.tsx.snap +0 -62
- package/test/__snapshots__/input.test.tsx.snap +0 -80
- package/test/__snapshots__/link.test.tsx.snap +0 -120
- package/test/__snapshots__/loader.test.tsx.snap +0 -53
- package/test/__snapshots__/logo.test.tsx.snap +0 -10
- package/test/__snapshots__/newPassword.test.tsx.snap +0 -69
- package/test/__snapshots__/numeric-input.test.tsx.snap +0 -21
- package/test/__snapshots__/password.test.tsx.snap +0 -26
- package/test/__snapshots__/phone.test.tsx.snap +0 -504
- package/test/__snapshots__/switch.test.tsx.snap +0 -51
- package/test/__snapshots__/text.test.tsx.snap +0 -89
- package/test/__snapshots__/textarea.test.tsx.snap +0 -73
- package/test/__snapshots__/themeToCssVars.test.ts.snap +0 -45
- package/test/__snapshots__/totpImage.test.tsx.snap +0 -10
- package/test/__snapshots__/totpLink.test.tsx.snap +0 -13
- package/test/boolean.test.tsx +0 -28
- package/test/buttons.test.tsx +0 -66
- package/test/checkbox.test.tsx +0 -67
- package/test/code.test.tsx +0 -182
- package/test/container.test.tsx +0 -91
- package/test/divider.test.tsx +0 -50
- package/test/image.test.tsx +0 -40
- package/test/input.test.tsx +0 -82
- package/test/inputHelpers.test.tsx +0 -58
- package/test/link.test.tsx +0 -71
- package/test/loader.test.tsx +0 -25
- package/test/logo.test.tsx +0 -10
- package/test/newPassword.test.tsx +0 -132
- package/test/numeric-input.test.tsx +0 -114
- package/test/password.test.tsx +0 -55
- package/test/phone.test.tsx +0 -158
- package/test/switch.test.tsx +0 -67
- package/test/text.test.tsx +0 -60
- package/test/textarea.test.tsx +0 -64
- package/test/themeToCssVars.test.ts +0 -82
- package/test/totpImage.test.tsx +0 -10
- package/test/totpLink.test.tsx +0 -10
- package/tsconfig.json +0 -20
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Textarea rendered with className 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<descope-text-area
|
|
6
|
-
classname="className"
|
|
7
|
-
size="md"
|
|
8
|
-
/>
|
|
9
|
-
</div>
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
exports[`Textarea rendered with custom error attributes 1`] = `
|
|
13
|
-
<div>
|
|
14
|
-
<descope-text-area
|
|
15
|
-
data-errormessage-pattern-mismatch="pattern"
|
|
16
|
-
data-errormessage-value-missing="missing"
|
|
17
|
-
size="md"
|
|
18
|
-
/>
|
|
19
|
-
</div>
|
|
20
|
-
`;
|
|
21
|
-
|
|
22
|
-
exports[`Textarea rendered with custom scripts 1`] = `
|
|
23
|
-
<div>
|
|
24
|
-
<descope-text-area
|
|
25
|
-
size="md"
|
|
26
|
-
/>
|
|
27
|
-
</div>
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
exports[`Textarea rendered with default props 1`] = `
|
|
31
|
-
<div>
|
|
32
|
-
<descope-text-area
|
|
33
|
-
size="md"
|
|
34
|
-
/>
|
|
35
|
-
</div>
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
exports[`Textarea rendered with fullWidth 1`] = `
|
|
39
|
-
<div>
|
|
40
|
-
<descope-text-area
|
|
41
|
-
full-width="true"
|
|
42
|
-
size="md"
|
|
43
|
-
/>
|
|
44
|
-
</div>
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
exports[`Textarea rendered with label 1`] = `
|
|
48
|
-
<div>
|
|
49
|
-
<descope-text-area
|
|
50
|
-
label="label"
|
|
51
|
-
size="md"
|
|
52
|
-
/>
|
|
53
|
-
</div>
|
|
54
|
-
`;
|
|
55
|
-
|
|
56
|
-
exports[`Textarea rendered with label and required 1`] = `
|
|
57
|
-
<div>
|
|
58
|
-
<descope-text-area
|
|
59
|
-
label="label"
|
|
60
|
-
required="true"
|
|
61
|
-
size="md"
|
|
62
|
-
/>
|
|
63
|
-
</div>
|
|
64
|
-
`;
|
|
65
|
-
|
|
66
|
-
exports[`Textarea rendered with name 1`] = `
|
|
67
|
-
<div>
|
|
68
|
-
<descope-text-area
|
|
69
|
-
name="name"
|
|
70
|
-
size="md"
|
|
71
|
-
/>
|
|
72
|
-
</div>
|
|
73
|
-
`;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`themeToCssVars should generate the correct css vars from a given theme 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"--body1-font-family": "var(--font-family-1)",
|
|
6
|
-
"--body1-font-size": "18px",
|
|
7
|
-
"--body1-font-weight": "600",
|
|
8
|
-
"--body2-font-family": "var(--font-family-0)",
|
|
9
|
-
"--body2-font-size": "20px",
|
|
10
|
-
"--body2-font-weight": "700",
|
|
11
|
-
"--button-font-family": "var(--font-family-0)",
|
|
12
|
-
"--button-radius": "20px",
|
|
13
|
-
"--er": "0 0% 100%",
|
|
14
|
-
"--erc": "0 0% 9.803921568627452%",
|
|
15
|
-
"--font-family-0": "Arial,sans-serif",
|
|
16
|
-
"--font-family-1": "\\"Times New Roman\\",serif",
|
|
17
|
-
"--h1-font-family": "var(--font-family-0)",
|
|
18
|
-
"--h1-font-size": "8px",
|
|
19
|
-
"--h1-font-weight": "100",
|
|
20
|
-
"--h2-font-family": "var(--font-family-1)",
|
|
21
|
-
"--h2-font-size": "10px",
|
|
22
|
-
"--h2-font-weight": "200",
|
|
23
|
-
"--h3-font-family": "var(--font-family-0)",
|
|
24
|
-
"--h3-font-size": "12px",
|
|
25
|
-
"--h3-font-weight": "300",
|
|
26
|
-
"--input-border-opacity": "0",
|
|
27
|
-
"--input-font-family": "var(--font-family-1)",
|
|
28
|
-
"--input-radius": "10px",
|
|
29
|
-
"--logo-url": "url(http://any.url)",
|
|
30
|
-
"--p": "0 0% 6.666666666666667%",
|
|
31
|
-
"--pc": "0 0% 90.58823529411765%",
|
|
32
|
-
"--pf": "0 0% 5.490196078431373%",
|
|
33
|
-
"--s": "0 0% 13.333333333333334%",
|
|
34
|
-
"--sc": "0 0% 91.37254901960785%",
|
|
35
|
-
"--sf": "0 0% 10.588235294117647%",
|
|
36
|
-
"--subtitle1-font-family": "var(--font-family-1)",
|
|
37
|
-
"--subtitle1-font-size": "14px",
|
|
38
|
-
"--subtitle1-font-weight": "400",
|
|
39
|
-
"--subtitle2-font-family": "var(--font-family-0)",
|
|
40
|
-
"--subtitle2-font-size": "16px",
|
|
41
|
-
"--subtitle2-font-weight": "500",
|
|
42
|
-
"--wa": "0 0% 0%",
|
|
43
|
-
"--wac": "0 0% 90.19607843137256%",
|
|
44
|
-
}
|
|
45
|
-
`;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`TOTP Link rendered with default props 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<a
|
|
6
|
-
class="link whitespace-pre antialiased descope-link inline-block link-hover"
|
|
7
|
-
data-type="totp-link"
|
|
8
|
-
rel="noopener noreferrer"
|
|
9
|
-
>
|
|
10
|
-
TOTP Link
|
|
11
|
-
</a>
|
|
12
|
-
</div>
|
|
13
|
-
`;
|
package/test/boolean.test.tsx
DELETED
|
@@ -1,28 +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 { Boolean } from '../src';
|
|
6
|
-
|
|
7
|
-
describe('Boolean', () => {
|
|
8
|
-
it('should render checkbox', () => {
|
|
9
|
-
const { container } = render(
|
|
10
|
-
<Boolean label="some label" name="bool1" type="checkbox" />
|
|
11
|
-
);
|
|
12
|
-
expect(container).toMatchSnapshot();
|
|
13
|
-
|
|
14
|
-
const checkbox = container.querySelector('input') as HTMLInputElement;
|
|
15
|
-
expect(checkbox).toHaveAttribute('name', 'bool1');
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should render switch', () => {
|
|
19
|
-
const { container } = render(
|
|
20
|
-
<Boolean label="some label" name="bool2" type="switch" />
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
expect(container).toMatchSnapshot();
|
|
24
|
-
|
|
25
|
-
const checkbox = container.querySelector('input') as HTMLInputElement;
|
|
26
|
-
expect(checkbox).toHaveAttribute('name', 'bool2');
|
|
27
|
-
});
|
|
28
|
-
});
|
package/test/buttons.test.tsx
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Button } from '../src';
|
|
4
|
-
// eslint-disable-next-line import/no-namespace
|
|
5
|
-
import * as icons from '../src/icons';
|
|
6
|
-
|
|
7
|
-
describe('Buttons', () => {
|
|
8
|
-
describe('Button', () => {
|
|
9
|
-
it('rendered with default props', () => {
|
|
10
|
-
render(<Button>Click</Button>);
|
|
11
|
-
expect(screen.getByText('Click')).toMatchSnapshot();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('rendered with glass', () => {
|
|
15
|
-
render(<Button glass>Click</Button>);
|
|
16
|
-
expect(screen.getByText('Click')).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('rendered with font size', () => {
|
|
20
|
-
render(<Button fontSize="9xl">Click</Button>);
|
|
21
|
-
expect(screen.getByText('Click')).toMatchSnapshot();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('rendered with responsive', () => {
|
|
25
|
-
render(<Button responsive>Click</Button>);
|
|
26
|
-
expect(screen.getByText('Click')).toMatchSnapshot();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('rendered with responsive and size', () => {
|
|
30
|
-
render(
|
|
31
|
-
<Button responsive size="md">
|
|
32
|
-
Click
|
|
33
|
-
</Button>
|
|
34
|
-
);
|
|
35
|
-
expect(screen.getByText('Click')).toMatchSnapshot();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('rendered with custom props', () => {
|
|
39
|
-
render(
|
|
40
|
-
<Button data-test-1="1" data-test-2="2" size="md">
|
|
41
|
-
Click
|
|
42
|
-
</Button>
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
expect(screen.getByText('Click')).toMatchSnapshot();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe.each(Object.keys(icons))('icons', (iconName) => {
|
|
49
|
-
it(`rendered with ${iconName} text color icon`, () => {
|
|
50
|
-
render(
|
|
51
|
-
<Button startIcon={iconName} startIconColorText>
|
|
52
|
-
Click
|
|
53
|
-
</Button>
|
|
54
|
-
);
|
|
55
|
-
// eslint-disable-next-line testing-library/no-node-access
|
|
56
|
-
expect(screen.getByText('Click').parentElement).toMatchSnapshot();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it(`rendered with ${iconName} color icon`, () => {
|
|
60
|
-
render(<Button startIcon={iconName}>Click</Button>);
|
|
61
|
-
// eslint-disable-next-line testing-library/no-node-access
|
|
62
|
-
expect(screen.getByText('Click').parentElement).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
package/test/checkbox.test.tsx
DELETED
|
@@ -1,67 +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 { Checkbox } from '../src';
|
|
6
|
-
|
|
7
|
-
describe('Checkbox', () => {
|
|
8
|
-
it('should render with label', () => {
|
|
9
|
-
const { container } = render(<Checkbox label="some label" name="check" />);
|
|
10
|
-
const label = container.querySelector('label');
|
|
11
|
-
expect(label).toHaveTextContent('some label');
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should render with checkbox component', () => {
|
|
15
|
-
const { container } = render(<Checkbox name="check" />);
|
|
16
|
-
container.querySelector('input');
|
|
17
|
-
expect(container).toMatchSnapshot();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should render with value', () => {
|
|
21
|
-
const { container } = render(<Checkbox name="check" />);
|
|
22
|
-
const checkbox = container.querySelector('input') as HTMLInputElement;
|
|
23
|
-
|
|
24
|
-
expect(checkbox.checked).toBeFalsy();
|
|
25
|
-
|
|
26
|
-
checkbox.click();
|
|
27
|
-
expect(checkbox.checked).toBeTruthy();
|
|
28
|
-
|
|
29
|
-
const label = container.querySelector('label');
|
|
30
|
-
label.click();
|
|
31
|
-
expect(checkbox.checked).toBeFalsy();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should render with name', () => {
|
|
35
|
-
const { container } = render(<Checkbox name="check" />);
|
|
36
|
-
const checkbox = container.querySelector('input') as HTMLInputElement;
|
|
37
|
-
expect(checkbox).toHaveAttribute('name', 'check');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should render with required attribute', () => {
|
|
41
|
-
const onSubmit = jest.fn((e) => e.preventDefault());
|
|
42
|
-
|
|
43
|
-
const { container } = render(
|
|
44
|
-
<form onSubmit={onSubmit}>
|
|
45
|
-
<Checkbox label="some label" name="check" required />
|
|
46
|
-
<button type="submit">submit</button>
|
|
47
|
-
</form>
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const checkbox = container.querySelector('input') as HTMLInputElement;
|
|
51
|
-
expect(checkbox.required).toEqual(true);
|
|
52
|
-
|
|
53
|
-
const label = container.querySelector('label');
|
|
54
|
-
expect(label).toHaveTextContent('some label*');
|
|
55
|
-
|
|
56
|
-
container.querySelector('button').click();
|
|
57
|
-
|
|
58
|
-
expect(checkbox).not.toBeValid();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should render with size and radius', () => {
|
|
62
|
-
const { container } = render(
|
|
63
|
-
<Checkbox label="some label" name="check" required size="sm" />
|
|
64
|
-
);
|
|
65
|
-
expect(container).toMatchSnapshot();
|
|
66
|
-
});
|
|
67
|
-
});
|
package/test/code.test.tsx
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/* eslint-disable testing-library/no-node-access */
|
|
2
|
-
/* eslint-disable testing-library/no-container */
|
|
3
|
-
import { render, waitFor } from '@testing-library/react';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import userEvent from '@testing-library/user-event';
|
|
6
|
-
import { Code } from '../src';
|
|
7
|
-
|
|
8
|
-
describe.skip('Code', () => {
|
|
9
|
-
it('rendered with default props', () => {
|
|
10
|
-
const { container } = render(<Code />);
|
|
11
|
-
expect(container).toMatchSnapshot();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('rendered with label', () => {
|
|
15
|
-
const { container } = render(<Code label="label" />);
|
|
16
|
-
expect(container).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('rendered with label and required', () => {
|
|
20
|
-
const { container } = render(<Code label="label" required />);
|
|
21
|
-
expect(container).toMatchSnapshot();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('rendered with fullWidth', () => {
|
|
25
|
-
const { container } = render(<Code fullWidth />);
|
|
26
|
-
expect(container).toMatchSnapshot();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('rendered with name', () => {
|
|
30
|
-
const { container } = render(<Code name="name" />);
|
|
31
|
-
expect(container).toMatchSnapshot();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('rendered with className', () => {
|
|
35
|
-
const { container } = render(<Code className="className" />);
|
|
36
|
-
expect(container).toMatchSnapshot();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('rendered with custom error attributes', () => {
|
|
40
|
-
const { container } = render(
|
|
41
|
-
<Code
|
|
42
|
-
data-errormessage-pattern-mismatch="pattern"
|
|
43
|
-
data-errormessage-value-missing="missing"
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
expect(container).toMatchSnapshot();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('rendered with custom scripts', () => {
|
|
50
|
-
global.process.env.SSR = 'true';
|
|
51
|
-
|
|
52
|
-
const spyToString = jest.spyOn(Function.prototype, 'toString');
|
|
53
|
-
|
|
54
|
-
spyToString.mockReturnValue(
|
|
55
|
-
(() => {
|
|
56
|
-
const x = 1 + 1;
|
|
57
|
-
|
|
58
|
-
return x;
|
|
59
|
-
}).toString()
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
const { container } = render(<Code />);
|
|
63
|
-
expect(container).toMatchSnapshot();
|
|
64
|
-
|
|
65
|
-
spyToString.mockRestore();
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('helpers', () => {
|
|
69
|
-
it('cannot type non digit characters', async () => {
|
|
70
|
-
const { container } = render(<Code />);
|
|
71
|
-
|
|
72
|
-
const digits = Array.from(
|
|
73
|
-
container.querySelectorAll('input[data-id]')
|
|
74
|
-
) as HTMLInputElement[];
|
|
75
|
-
|
|
76
|
-
await userEvent.type(digits[0], 'a');
|
|
77
|
-
|
|
78
|
-
expect(digits[0].value).toBe('');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('can type digit characters', async () => {
|
|
82
|
-
const { container } = render(<Code />);
|
|
83
|
-
|
|
84
|
-
const digits = Array.from(
|
|
85
|
-
container.querySelectorAll('input[data-id]')
|
|
86
|
-
) as HTMLInputElement[];
|
|
87
|
-
|
|
88
|
-
await userEvent.type(digits[0], '1');
|
|
89
|
-
|
|
90
|
-
expect(digits[0].value).toBe('1');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('cannot paste non digit characters', async () => {
|
|
94
|
-
const { container } = render(<Code />);
|
|
95
|
-
|
|
96
|
-
const digits = Array.from(
|
|
97
|
-
container.querySelectorAll('input[data-id]')
|
|
98
|
-
) as HTMLInputElement[];
|
|
99
|
-
|
|
100
|
-
await waitFor(() => digits[0].oninput);
|
|
101
|
-
|
|
102
|
-
digits[0].value = 'a12345';
|
|
103
|
-
|
|
104
|
-
digits[0].oninput({
|
|
105
|
-
currentTarget: digits[0]
|
|
106
|
-
} as unknown as InputEvent);
|
|
107
|
-
|
|
108
|
-
for (let i = 0; i < 6; i += 1) {
|
|
109
|
-
expect(digits[i].value).toBe('');
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('can paste a number and it should fill all digits', async () => {
|
|
114
|
-
const { container } = render(<Code />);
|
|
115
|
-
|
|
116
|
-
const digits = Array.from(
|
|
117
|
-
container.querySelectorAll('input[data-id]')
|
|
118
|
-
) as HTMLInputElement[];
|
|
119
|
-
|
|
120
|
-
await waitFor(() => digits[0].oninput);
|
|
121
|
-
|
|
122
|
-
digits[0].value = '123456';
|
|
123
|
-
|
|
124
|
-
digits[0].oninput({
|
|
125
|
-
currentTarget: digits[0]
|
|
126
|
-
} as unknown as InputEvent);
|
|
127
|
-
|
|
128
|
-
for (let i = 0; i < 6; i += 1) {
|
|
129
|
-
expect(digits[i].value).toBe(`${i + 1}`);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('should sync input value with digits', async () => {
|
|
134
|
-
const { container } = render(<Code />);
|
|
135
|
-
|
|
136
|
-
const digits = Array.from(
|
|
137
|
-
container.querySelectorAll('input[data-id]')
|
|
138
|
-
) as HTMLInputElement[];
|
|
139
|
-
|
|
140
|
-
for (let i = 0; i < 6; i += 1) {
|
|
141
|
-
// eslint-disable-next-line no-await-in-loop
|
|
142
|
-
await userEvent.type(digits[i], `${i}`);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const input = container.querySelector(
|
|
146
|
-
'input[data-input]'
|
|
147
|
-
) as HTMLInputElement;
|
|
148
|
-
|
|
149
|
-
expect(input.value).toBe('012345');
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('backspace should focus previous digit', async () => {
|
|
153
|
-
const { container } = render(<Code />);
|
|
154
|
-
|
|
155
|
-
const digits = Array.from(
|
|
156
|
-
container.querySelectorAll('input[data-id]')
|
|
157
|
-
) as HTMLInputElement[];
|
|
158
|
-
|
|
159
|
-
await userEvent.click(digits[2]);
|
|
160
|
-
await userEvent.keyboard('{Backspace}');
|
|
161
|
-
|
|
162
|
-
expect(digits[1]).toHaveFocus();
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('should sync validity', async () => {
|
|
166
|
-
const { container } = render(<Code required />);
|
|
167
|
-
|
|
168
|
-
const digits = Array.from(
|
|
169
|
-
container.querySelectorAll('input[data-id]')
|
|
170
|
-
) as HTMLInputElement[];
|
|
171
|
-
|
|
172
|
-
const input = container.querySelector(
|
|
173
|
-
'input[data-input]'
|
|
174
|
-
) as HTMLInputElement;
|
|
175
|
-
|
|
176
|
-
input.setCustomValidity('error');
|
|
177
|
-
input.checkValidity();
|
|
178
|
-
|
|
179
|
-
await waitFor(() => expect(digits[0].validity.valid).toBe(false));
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
});
|
package/test/container.test.tsx
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Container } from '../src';
|
|
4
|
-
|
|
5
|
-
describe('Container', () => {
|
|
6
|
-
it('rendered with default props', () => {
|
|
7
|
-
render(<Container>Container</Container>);
|
|
8
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('rendered with width', () => {
|
|
12
|
-
render(<Container width="10">Container</Container>);
|
|
13
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('rendered with justify', () => {
|
|
17
|
-
render(<Container justify="between">Container</Container>);
|
|
18
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('rendered with paddingX', () => {
|
|
22
|
-
render(<Container paddingX="10">Container</Container>);
|
|
23
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('rendered with paddingY', () => {
|
|
27
|
-
render(<Container paddingY="10">Container</Container>);
|
|
28
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('rendered with direction', () => {
|
|
32
|
-
render(<Container direction="col">Container</Container>);
|
|
33
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
34
|
-
});
|
|
35
|
-
it('rendered with align', () => {
|
|
36
|
-
render(<Container align="end">Container</Container>);
|
|
37
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('rendered with spaceBetween when direction is "row"', () => {
|
|
41
|
-
render(
|
|
42
|
-
<Container spaceBetween="7" direction="row">
|
|
43
|
-
Container
|
|
44
|
-
</Container>
|
|
45
|
-
);
|
|
46
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('rendered with spaceBetween when direction is "col"', () => {
|
|
50
|
-
render(
|
|
51
|
-
<Container spaceBetween="7" direction="col">
|
|
52
|
-
Container
|
|
53
|
-
</Container>
|
|
54
|
-
);
|
|
55
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('rendered with borderRadius', () => {
|
|
59
|
-
render(<Container borderRadius="md">Container</Container>);
|
|
60
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
61
|
-
});
|
|
62
|
-
it('rendered with shadow', () => {
|
|
63
|
-
render(<Container shadow="md">Container</Container>);
|
|
64
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('rendered with background value from theme', () => {
|
|
68
|
-
render(<Container background="300">Container</Container>);
|
|
69
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('rendered with custom background value', () => {
|
|
73
|
-
render(<Container background="#808080">Container</Container>);
|
|
74
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('rendered with a style object', () => {
|
|
78
|
-
render(
|
|
79
|
-
<Container background="#000000" style={{ color: '#000000' }}>
|
|
80
|
-
Container
|
|
81
|
-
</Container>
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('rendered with custom classnames', () => {
|
|
88
|
-
render(<Container className="kuku">Container</Container>);
|
|
89
|
-
expect(screen.getByText('Container')).toMatchSnapshot();
|
|
90
|
-
});
|
|
91
|
-
});
|
package/test/divider.test.tsx
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Divider } from '../src';
|
|
4
|
-
|
|
5
|
-
describe('Divider', () => {
|
|
6
|
-
it('rendered with default props', () => {
|
|
7
|
-
render(<Divider>Text</Divider>);
|
|
8
|
-
expect(screen.getByText('Text')).toMatchSnapshot();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('rendered with size', () => {
|
|
12
|
-
render(<Divider size="9xl">Text</Divider>);
|
|
13
|
-
expect(screen.getByText('Text')).toMatchSnapshot();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('rendered with fontWeight', () => {
|
|
17
|
-
render(<Divider fontWeight="black">Text</Divider>);
|
|
18
|
-
expect(screen.getByText('Text')).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('rendered with fontFamily', () => {
|
|
22
|
-
render(<Divider fontFamily="mono">Text</Divider>);
|
|
23
|
-
expect(screen.getByText('Text')).toMatchSnapshot();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('rendered with italic', () => {
|
|
27
|
-
render(<Divider italic>Text</Divider>);
|
|
28
|
-
expect(screen.getByText('Text')).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('rendered with color', () => {
|
|
32
|
-
render(<Divider color="error">Text</Divider>);
|
|
33
|
-
expect(screen.getByText('Text')).toMatchSnapshot();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('rendered with custom className', () => {
|
|
37
|
-
render(<Divider className="kuku">Text</Divider>);
|
|
38
|
-
expect(screen.getByText('Text')).toMatchSnapshot();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('rendered with vertical', () => {
|
|
42
|
-
render(<Divider vertical>Text</Divider>);
|
|
43
|
-
expect(screen.getByText('Text')).toMatchSnapshot();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('rendered with typography', () => {
|
|
47
|
-
render(<Divider typography="body1">Text</Divider>);
|
|
48
|
-
expect(screen.getByText('Text')).toMatchSnapshot();
|
|
49
|
-
});
|
|
50
|
-
});
|
package/test/image.test.tsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Image } from '../src';
|
|
4
|
-
|
|
5
|
-
describe('Image', () => {
|
|
6
|
-
it('rendered with default props', () => {
|
|
7
|
-
const { container } = render(<Image />);
|
|
8
|
-
expect(container).toMatchSnapshot();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('rendered with custom classnames', () => {
|
|
12
|
-
const { container } = render(<Image className="kuku" />);
|
|
13
|
-
expect(container).toMatchSnapshot();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('rendered with height', () => {
|
|
17
|
-
const { container } = render(<Image height={20} />);
|
|
18
|
-
expect(container).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('render with width', () => {
|
|
22
|
-
const { container } = render(<Image width={20} />);
|
|
23
|
-
expect(container).toMatchSnapshot();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('render with src', () => {
|
|
27
|
-
const { container } = render(<Image src="123" />);
|
|
28
|
-
expect(container).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('rendered with alt', () => {
|
|
32
|
-
const { container } = render(<Image alt="123" />);
|
|
33
|
-
expect(container).toMatchSnapshot();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('rendered with style', () => {
|
|
37
|
-
const { container } = render(<Image style={{ color: 'red' }} />);
|
|
38
|
-
expect(container).toMatchSnapshot();
|
|
39
|
-
});
|
|
40
|
-
});
|