reshaped 3.8.0-canary.2 → 3.8.0-canary.3

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 (26) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/bundle.js +9 -9
  3. package/dist/components/Actionable/Actionable.js +16 -3
  4. package/dist/components/Actionable/Actionable.types.d.ts +15 -3
  5. package/dist/components/Actionable/tests/Actionable.stories.d.ts +13 -1
  6. package/dist/components/Actionable/tests/Actionable.stories.js +127 -7
  7. package/dist/components/Button/Button.js +2 -2
  8. package/dist/components/Button/Button.types.d.ts +1 -1
  9. package/dist/components/Button/tests/Button.test.stories.d.ts +1 -0
  10. package/dist/components/Button/tests/Button.test.stories.js +23 -0
  11. package/dist/components/Card/Card.d.ts +1 -1
  12. package/dist/components/Card/tests/Card.stories.d.ts +1 -1
  13. package/dist/components/Card/tests/Card.test.stories.d.ts +1 -1
  14. package/dist/components/Link/Link.d.ts +1 -1
  15. package/dist/components/Link/Link.js +2 -2
  16. package/dist/components/Link/Link.types.d.ts +1 -1
  17. package/dist/components/Link/tests/Link.stories.d.ts +1 -1
  18. package/dist/components/Link/tests/Link.test.stories.d.ts +2 -1
  19. package/dist/components/Link/tests/Link.test.stories.js +9 -0
  20. package/dist/components/MenuItem/MenuItem.js +2 -2
  21. package/dist/components/MenuItem/MenuItem.types.d.ts +1 -1
  22. package/dist/components/MenuItem/tests/MenuItem.test.stories.d.ts +1 -0
  23. package/dist/components/MenuItem/tests/MenuItem.test.stories.js +16 -0
  24. package/package.json +2 -2
  25. package/dist/components/Actionable/tests/Actionable.test.stories.d.ts +0 -32
  26. package/dist/components/Actionable/tests/Actionable.test.stories.js +0 -130
@@ -1,130 +0,0 @@
1
- import { userEvent, expect, fn } from "storybook/test";
2
- import Actionable from "../index.js";
3
- export default {
4
- title: "Utility components/Actionable/tests",
5
- component: Actionable,
6
- parameters: {
7
- iframe: {
8
- url: "https://reshaped.so/docs/utilities/actionable",
9
- },
10
- chromatic: { disableSnapshot: true },
11
- },
12
- };
13
- export const children = {
14
- name: "children",
15
- render: () => <Actionable>Trigger</Actionable>,
16
- play: async ({ canvas }) => {
17
- const el = canvas.getByText("Trigger");
18
- expect(el).toBeInTheDocument();
19
- expect(el.tagName).toBe("SPAN");
20
- },
21
- };
22
- export const href = {
23
- name: "href",
24
- render: () => <Actionable href="https://reshaped.so">Trigger</Actionable>,
25
- play: async ({ canvas }) => {
26
- const el = canvas.getByRole("link");
27
- expect(el).toHaveAttribute("href", "https://reshaped.so");
28
- },
29
- };
30
- export const attributesHref = {
31
- name: "attributes.href",
32
- render: () => <Actionable attributes={{ href: "https://reshaped.so" }}>Trigger</Actionable>,
33
- play: async ({ canvas }) => {
34
- const el = canvas.getByRole("link");
35
- expect(el).toHaveAttribute("href", "https://reshaped.so");
36
- },
37
- };
38
- export const onClick = {
39
- name: "onClick",
40
- args: {
41
- handleClick: fn(),
42
- },
43
- render: (args) => <Actionable onClick={args.handleClick}>Trigger</Actionable>,
44
- play: async ({ canvas, args }) => {
45
- const { handleClick } = args;
46
- const el = canvas.getAllByRole("button")[0];
47
- await userEvent.click(el);
48
- expect(el).toHaveAttribute("type", "button");
49
- expect(handleClick).toHaveBeenCalledTimes(1);
50
- expect(handleClick).toHaveBeenCalledWith(expect.objectContaining({ target: el }));
51
- },
52
- };
53
- export const hrefOnClick = {
54
- name: "href + onClick",
55
- args: {
56
- handleClick: fn(),
57
- },
58
- render: (args) => (<Actionable onClick={(e) => {
59
- e.preventDefault();
60
- args.handleClick(e);
61
- }} href="https://reshaped.so">
62
- Trigger
63
- </Actionable>),
64
- play: async ({ canvas, args }) => {
65
- const { handleClick } = args;
66
- const el = canvas.getByRole("link");
67
- await userEvent.click(el);
68
- expect(el).toHaveAttribute("href", "https://reshaped.so");
69
- expect(handleClick).toHaveBeenCalledTimes(1);
70
- expect(handleClick).toHaveBeenCalledWith(expect.objectContaining({ target: el }));
71
- },
72
- };
73
- export const as = {
74
- name: "as",
75
- render: () => (<Actionable onClick={() => { }} as="span">
76
- Trigger
77
- </Actionable>),
78
- play: ({ canvas }) => {
79
- const el = canvas.getAllByRole("button")[0];
80
- expect(el.tagName).toBe("SPAN");
81
- },
82
- };
83
- export const type = {
84
- name: "type",
85
- args: {
86
- handleSubmit: fn(),
87
- },
88
- render: (args) => (<form onSubmit={(e) => {
89
- e.preventDefault();
90
- args.handleSubmit();
91
- }}>
92
- <Actionable onClick={() => { }} type="submit">
93
- Trigger
94
- </Actionable>
95
- </form>),
96
- play: async ({ canvas, args }) => {
97
- const button = canvas.getAllByRole("button")[0];
98
- await userEvent.click(button);
99
- expect(args.handleSubmit).toHaveBeenCalledTimes(1);
100
- },
101
- };
102
- export const stopPropagation = {
103
- name: "stopPropagation",
104
- args: {
105
- handleParentClick: fn(),
106
- },
107
- render: (args) => (<div onClick={args.handleParentClick}>
108
- <Actionable stopPropagation onClick={() => { }}>
109
- Trigger
110
- </Actionable>
111
- </div>),
112
- play: async ({ canvas, args }) => {
113
- const button = canvas.getAllByRole("button")[0];
114
- await userEvent.click(button);
115
- expect(args.handleParentClick).not.toHaveBeenCalled();
116
- },
117
- };
118
- export const className = {
119
- name: "className, attributes",
120
- render: () => (<div data-testid="root">
121
- <Actionable className="test-classname" attributes={{ id: "test-id" }}>
122
- Trigger
123
- </Actionable>
124
- </div>),
125
- play: async ({ canvas }) => {
126
- const root = canvas.getByTestId("root").firstChild;
127
- expect(root).toHaveClass("test-classname");
128
- expect(root).toHaveAttribute("id", "test-id");
129
- },
130
- };