@madie/madie-design-system 1.2.85 → 1.2.87
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/components/MadieDeleteDialog/MadieDeleteDialog.stories.js +30 -1
- package/components/MadieDeleteDialog/index.jsx +14 -3
- package/components/MadieTooltip/MadieTooltip.stories.js +7 -7
- package/components/MadieTooltip/index.jsx +34 -39
- package/components/TextField/index.jsx +2 -2
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +85 -85
- package/dist/react/index.js.LICENSE.txt +1 -17
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/styles/components/_text.scss +3 -3
- package/test/components/MadieDeleteDialog.test.js +46 -6
- package/test/components/TextField.test.js +20 -54
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ body {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
p {
|
|
24
|
-
margin-bottom:
|
|
24
|
+
margin-bottom: 8px;
|
|
25
25
|
|
|
26
26
|
&.lead {
|
|
27
27
|
color: $lead-color;
|
|
@@ -31,8 +31,8 @@ p {
|
|
|
31
31
|
|
|
32
32
|
& ~ ul,
|
|
33
33
|
& ~ ol {
|
|
34
|
-
margin-bottom:
|
|
35
|
-
margin-top: -
|
|
34
|
+
margin-bottom: 8px;
|
|
35
|
+
margin-top: -3px;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -2,7 +2,7 @@ import "@testing-library/jest-dom";
|
|
|
2
2
|
import { describe, expect, test } from "@jest/globals";
|
|
3
3
|
import MadieDeleteDialog from "../../components/MadieDeleteDialog/index";
|
|
4
4
|
import { act } from "react-dom/test-utils";
|
|
5
|
-
import { render, fireEvent, waitFor } from "@testing-library/react";
|
|
5
|
+
import { render, fireEvent, waitFor, screen } from "@testing-library/react";
|
|
6
6
|
|
|
7
7
|
import React, { useState } from "react";
|
|
8
8
|
|
|
@@ -140,7 +140,7 @@ describe("MadieDeleteDialog", () => {
|
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
test("Dialog shows alternate text", async () => {
|
|
144
144
|
const { getByTestId, queryByText } = render(
|
|
145
145
|
<MadieDeleteDialog
|
|
146
146
|
open={true}
|
|
@@ -150,7 +150,7 @@ describe("MadieDeleteDialog", () => {
|
|
|
150
150
|
dialogTitle="Remove Element"
|
|
151
151
|
alternateText="Remove"
|
|
152
152
|
name="element"
|
|
153
|
-
|
|
153
|
+
/>
|
|
154
154
|
);
|
|
155
155
|
|
|
156
156
|
const deleteDialog = await getByTestId("delete-dialog");
|
|
@@ -158,12 +158,52 @@ describe("MadieDeleteDialog", () => {
|
|
|
158
158
|
await waitFor(() => {
|
|
159
159
|
expect(
|
|
160
160
|
deleteDialog.textContent.includes(
|
|
161
|
-
"Are you sure you want to remove element?"
|
|
162
|
-
)
|
|
161
|
+
"Are you sure you want to remove element?"
|
|
162
|
+
)
|
|
163
163
|
).toBeTruthy();
|
|
164
164
|
expect(
|
|
165
|
-
queryByText("This Action cannot be undone.")
|
|
165
|
+
queryByText("This Action cannot be undone.")
|
|
166
166
|
).not.toBeInTheDocument();
|
|
167
167
|
});
|
|
168
168
|
});
|
|
169
|
+
|
|
170
|
+
test("Dialog shows custom dialog", async () => {
|
|
171
|
+
const { getByTestId, queryByText } = render(
|
|
172
|
+
<MadieDeleteDialog
|
|
173
|
+
open={true}
|
|
174
|
+
onClose={() => setDialogOpen(false)}
|
|
175
|
+
onContinue={() => setDialogOpen(false)}
|
|
176
|
+
hideWarning={true}
|
|
177
|
+
dialogTitle="Delete Item"
|
|
178
|
+
customDialogBody={<span>Custom Dialog</span>}
|
|
179
|
+
name="Test Item"
|
|
180
|
+
/>
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const deleteDialog = await getByTestId("delete-dialog");
|
|
184
|
+
expect(deleteDialog).toBeInTheDocument();
|
|
185
|
+
await waitFor(() => {
|
|
186
|
+
expect(screen.getByText("Custom Dialog")).toBeInTheDocument();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test("renders '?' only if statement is not provided", async () => {
|
|
191
|
+
const { getByTestId, queryByText } = render(
|
|
192
|
+
<MadieDeleteDialog
|
|
193
|
+
open={true}
|
|
194
|
+
onClose={() => setDialogOpen(false)}
|
|
195
|
+
onContinue={() => setDialogOpen(false)}
|
|
196
|
+
hideWarning={true}
|
|
197
|
+
dialogTitle="Delete Item"
|
|
198
|
+
statement={true}
|
|
199
|
+
name="Test Item"
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
const deleteDialog = await getByTestId("delete-dialog");
|
|
204
|
+
expect(deleteDialog).toBeInTheDocument();
|
|
205
|
+
await waitFor(() => {
|
|
206
|
+
expect(screen.queryByText("?")).not.toBeInTheDocument();
|
|
207
|
+
});
|
|
208
|
+
});
|
|
169
209
|
});
|
|
@@ -4,9 +4,7 @@ import { describe, expect, test } from "@jest/globals";
|
|
|
4
4
|
import TextField from "../../components/TextField/index";
|
|
5
5
|
import { act, Simulate } from "react-dom/test-utils";
|
|
6
6
|
import {
|
|
7
|
-
findByTestId,
|
|
8
7
|
render,
|
|
9
|
-
fireEvent,
|
|
10
8
|
screen,
|
|
11
9
|
} from "@testing-library/react";
|
|
12
10
|
import userEvent from "@testing-library/user-event";
|
|
@@ -107,59 +105,27 @@ describe("TextField", () => {
|
|
|
107
105
|
});
|
|
108
106
|
|
|
109
107
|
test("tooltip text renders, can be seen and removed.", async () => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// click and escape
|
|
128
|
-
act(() => {
|
|
129
|
-
fireEvent.click(tooltipTrigger);
|
|
130
|
-
});
|
|
131
|
-
expect(getByText("tooltip text")).toBeInTheDocument();
|
|
132
|
-
act(() => {
|
|
133
|
-
fireEvent.keyDown(getByText(/tooltip text/i), {
|
|
134
|
-
key: "Escape",
|
|
135
|
-
code: "Escape",
|
|
136
|
-
keyCode: 27,
|
|
137
|
-
charCode: 27,
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
expect(getByTestId("testName-tooltip")).toHaveClass("hidden");
|
|
141
|
-
|
|
142
|
-
// enter and leave
|
|
143
|
-
act(() => {
|
|
144
|
-
fireEvent.mouseEnter(getByTestId("testName-tooltip-button"));
|
|
145
|
-
});
|
|
146
|
-
expect(getByTestId("testName-tooltip")).not.toHaveClass("hidden");
|
|
147
|
-
act(() => {
|
|
148
|
-
fireEvent.mouseLeave(getByTestId("testName-tooltip-button"));
|
|
149
|
-
});
|
|
150
|
-
expect(getByTestId("testName-tooltip")).toHaveClass("hidden");
|
|
151
|
-
|
|
152
|
-
// focus, blur
|
|
153
|
-
act(() => {
|
|
154
|
-
fireEvent.focus(getByTestId("testName-tooltip-button"));
|
|
155
|
-
});
|
|
156
|
-
expect(getByTestId("testName-tooltip")).not.toHaveClass("hidden");
|
|
157
|
-
|
|
158
|
-
act(() => {
|
|
159
|
-
fireEvent.blur(getByTestId("testName-tooltip-button"));
|
|
160
|
-
});
|
|
161
|
-
expect(getByTestId("testName-tooltip")).toHaveClass("hidden");
|
|
108
|
+
const { findByTestId } = render(
|
|
109
|
+
<TextField
|
|
110
|
+
placeholder="test Name"
|
|
111
|
+
helperText="helper text"
|
|
112
|
+
label="test Name"
|
|
113
|
+
id="testName"
|
|
114
|
+
tooltipText="tooltip text"
|
|
115
|
+
inputProps={{ "data-testid": "test-name-input" }}
|
|
116
|
+
data-testid="test-name-text-field"
|
|
117
|
+
size="small"
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
const tooltipTrigger = await findByTestId(
|
|
121
|
+
"testName-tooltip"
|
|
122
|
+
);
|
|
123
|
+
act(() => {
|
|
124
|
+
userEvent.hover(tooltipTrigger);
|
|
162
125
|
});
|
|
126
|
+
|
|
127
|
+
const tooltip = await screen.findByRole('tooltip');
|
|
128
|
+
expect(tooltip).toHaveTextContent('tooltip text');
|
|
163
129
|
});
|
|
164
130
|
|
|
165
131
|
test("Textfield has different color for label", async () => {
|