@scrippsproduct/networks-ui-library 1.1.8 → 1.1.10-alpha.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/{Form.module-Cd8qH2rj.mjs → Form.module-CarfWK5T.mjs} +1 -1
- package/dist/ResultsTable.module-wcNUQEKe.mjs +14 -0
- package/dist/_commonjsHelpers-DaMA6jEr.mjs +8 -0
- package/dist/assets/ResultsTable.css +1 -1
- package/dist/assets/ScheduleLayout.css +1 -1
- package/dist/{chevron-left-DRvpaLmK.mjs → chevron-left-D0UjbrKw.mjs} +1 -1
- package/dist/{chevron-right-C8yCnmfx.mjs → chevron-right-0ZF3LruR.mjs} +1 -1
- package/dist/components/ActionButton/ActionButton.test.js +209 -0
- package/dist/components/AdBlock/AdBlock.test.js +286 -0
- package/dist/components/AdjustableTwoColumnGrid/AdjustableTwoColumnGrid.test.js +295 -0
- package/dist/components/AirDateFormatter/AirDateFormatter.test.js +192 -0
- package/dist/components/AnchorTag/AnchorTag.test.js +463 -0
- package/dist/components/BCVideoPlayer/BCVideoPlayer.test.js +295 -0
- package/dist/components/BasicGridModule/BasicGridModule.js +41 -37
- package/dist/components/BasicGridModule/BasicGridModule.test.js +227 -0
- package/dist/components/Button/Button.test.js +434 -0
- package/dist/components/Carousel/Carousel.js +2 -2
- package/dist/components/Carousel/Carousel.test.js +705 -0
- package/dist/components/CarouselSlide/CarouselSlide.test.js +378 -0
- package/dist/components/CarouselSlide/slide-layouts/TwoColumn/TwoColumnSlide.js +1 -1
- package/dist/components/CastInfoLayout/CastInfoLayout.test.js +294 -0
- package/dist/components/ChannelSearch/ChannelSearch.test.js +565 -0
- package/dist/components/ChoicesItem/ChoicesItem.test.js +428 -0
- package/dist/components/Concat/Concat.js +1 -1
- package/dist/components/Concat/Concat.test.js +115 -0
- package/dist/components/CtaBlock/CtaBlock.js +1 -1
- package/dist/components/CtaBlock/CtaBlock.test.js +226 -0
- package/dist/components/CustomDataList/CustomDataList.js +4 -4
- package/dist/components/CustomSelect/CustomSelect.js +86 -86
- package/dist/components/CustomSelect/CustomSelect.test.js +313 -0
- package/dist/components/DateNavigation/DateNavigation.js +10 -10
- package/dist/components/DateNavigation/DateNavigation.test.js +370 -0
- package/dist/components/DatePicker/DatePicker.js +1 -1
- package/dist/components/DeviceAndPlatformLists/DeviceAndPlatformLists.test.js +288 -0
- package/dist/components/DrawerNavigation/DrawerNavigation.test.js +316 -0
- package/dist/components/EqualSizeFlexRow/EqualSizeFlexRow.test.js +337 -0
- package/dist/components/EqualSizeGrid/EqualSizeGrid.test.js +358 -0
- package/dist/components/ErrorHandler/ErrorHandler.js +2 -2
- package/dist/components/ErrorHandler/ErrorHandler.test.js +158 -0
- package/dist/components/FeaturedList/FeaturedList.test.js +353 -0
- package/dist/components/Figure/Figure.js +1 -1
- package/dist/components/Figure/Figure.test.js +198 -0
- package/dist/components/FindUs/FindUs.test.js +499 -0
- package/dist/components/FooterNavigation/FooterNavigation.test.js +310 -0
- package/dist/components/GenericList/GenericList.js +1 -1
- package/dist/components/GenericList/GenericList.test.js +288 -0
- package/dist/components/GetAirdateWrapper/GetAirdateWrapper.test.js +689 -0
- package/dist/components/GradientButton/GradientButton.d.ts +1 -1
- package/dist/components/GradientButton/GradientButton.js +33 -31
- package/dist/components/GradientButton/GradientButton.test.js +457 -0
- package/dist/components/GridList/GridList.test.js +371 -0
- package/dist/components/ImageCard/ImageCard.test.js +668 -0
- package/dist/components/ImageCard/ImageCardCore.js +28 -28
- package/dist/components/ImageCard/ImageCardCore.test.js +577 -0
- package/dist/components/ImageReplacementAnchor/ImageReplacementAnchor.test.js +379 -0
- package/dist/components/InfoPanel/InfoPanel.js +1 -1
- package/dist/components/InlineNavigation/InlineNavigation.test.js +149 -0
- package/dist/components/Input/Input.js +1 -1
- package/dist/components/Input/Input.test.js +263 -0
- package/dist/components/InstructionsList/InstructionsList.js +11 -11
- package/dist/components/InstructionsList/InstructionsList.test.js +181 -0
- package/dist/components/LogoListItem/LogoListItem.test.js +303 -0
- package/dist/components/LogoNavigation/LogoNavigation.test.js +352 -0
- package/dist/components/ModalContainer/ModalContainer.js +2 -2
- package/dist/components/NavList/NavList.test.js +332 -0
- package/dist/components/Overlay/Overlay.js +24 -23
- package/dist/components/Overlay/Overlay.test.js +198 -0
- package/dist/components/PageHero/PageHero.test.js +241 -0
- package/dist/components/PageHero/page-hero-layouts/IONShow/IONShowHero.js +1 -1
- package/dist/components/ProgramAirdate/ProgramAirdate.js +1 -1
- package/dist/components/ProgramAirdate/ProgramAirdate.test.js +414 -0
- package/dist/components/PromotionBlock/PromotionBlock.test.js +208 -0
- package/dist/components/PromotionsRowBlock/PromotionsRowBlock.test.js +221 -0
- package/dist/components/PromotionsRowModule/PromotionsRowModule.test.js +349 -0
- package/dist/components/RescanInstructions/RescanInstructions.test.js +218 -0
- package/dist/components/ResponsiveImage/ResponsiveImage.test.js +264 -0
- package/dist/components/ResultsTable/ResultsTable.js +9 -2
- package/dist/components/ResultsTable/ResultsTable.test.js +402 -0
- package/dist/components/ResultsTableBody/ResultsTableBody.js +1 -1
- package/dist/components/ResultsTableBody/ResultsTableBody.test.js +445 -0
- package/dist/components/ResultsTableHeader/ResultsTableHeader.js +37 -15
- package/dist/components/ResultsTableHeader/ResultsTableHeader.test.js +275 -0
- package/dist/components/ScheduleLayout/ScheduleContext.js +654 -626
- package/dist/components/ScheduleLayout/ScheduleLayout.js +1 -1
- package/dist/components/ScheduleLayout/useScheduleContext.js +5 -10
- package/dist/components/ScheduleList/ScheduleList.js +1 -1
- package/dist/components/SectionedContent/SectionedContent.js +1 -1
- package/dist/components/SectionedContent/SectionedContent.test.js +341 -0
- package/dist/components/Select/Select.js +24 -24
- package/dist/components/Select/Select.test.js +367 -0
- package/dist/components/ShowAboutContent/ShowAboutContent.js +1 -1
- package/dist/components/ShowAboutContent/ShowAboutContent.test.js +535 -0
- package/dist/components/ShowAboutLayout/ShowAboutLayout.test.js +570 -0
- package/dist/components/SocialLinks/SocialLinks.js +1 -1
- package/dist/components/StringList/StringList.js +1 -1
- package/dist/components/StringList/StringList.test.js +311 -0
- package/dist/components/TabContent/TabContent.js +1 -1
- package/dist/components/TabContent/TabContent.test.js +274 -0
- package/dist/components/TabNavigation/TabNavigation.js +21 -21
- package/dist/components/TabNavigation/TabNavigation.test.js +535 -0
- package/dist/components/TabbedContent/TabbedContent.test.js +654 -0
- package/dist/components/TextArea/TextArea.js +1 -1
- package/dist/components/UpcomingList/UpcomingList.test.js +471 -0
- package/dist/{index-VjANCDXC.mjs → index-06PEPfBQ.mjs} +1 -1
- package/dist/index-BUN4jQ3m.mjs +3098 -0
- package/dist/index-BVxBrkZB.mjs +3 -0
- package/dist/{index-DC2JJV3a.mjs → index-D3kkcgee.mjs} +1 -1
- package/dist/{index-C-kn9Zhn.mjs → index-DzfYkULW.mjs} +2 -1
- package/dist/magic-string.es-uPKorP4O.mjs +663 -0
- package/dist/matchers-35e4d3bd-BBPNTlen.mjs +2404 -0
- package/dist/react.esm-DLSrfVwM.mjs +23410 -0
- package/dist/test/setupTests.d.ts +1 -0
- package/dist/test/setupTests.js +55 -0
- package/dist/{triangle-PcCcGXjr.mjs → triangle-C4z906Wf.mjs} +1 -1
- package/dist/useScheduleContext-D7FdzNxe.mjs +17 -0
- package/dist/utils/analytics.js +1 -1
- package/dist/utils/getOnNowProgram.js +10 -10
- package/dist/{x-C-QzJ-qD.mjs → x-Ck9Vk5Fo.mjs} +1 -1
- package/package.json +4 -1
- package/dist/ResultsTable.module-1zxhXaem.mjs +0 -14
- package/dist/_commonjsHelpers-C6fGbg64.mjs +0 -6
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { v as u, d as c, b as v, i as l, r as s, g as t, s as i } from "../../react.esm-DLSrfVwM.mjs";
|
|
3
|
+
import { u as g } from "../../index-BUN4jQ3m.mjs";
|
|
4
|
+
import { NavList as o } from "./NavList.js";
|
|
5
|
+
u.mock("../AnchorTag", () => ({
|
|
6
|
+
default: ({
|
|
7
|
+
classname: r,
|
|
8
|
+
clickHandler: e,
|
|
9
|
+
href: n,
|
|
10
|
+
image: h,
|
|
11
|
+
label: d,
|
|
12
|
+
type: m
|
|
13
|
+
}) => /* @__PURE__ */ a(
|
|
14
|
+
"a",
|
|
15
|
+
{
|
|
16
|
+
className: r,
|
|
17
|
+
"data-href": n,
|
|
18
|
+
"data-image": h ? JSON.stringify({ src: h.url, alt: h.altText }) : void 0,
|
|
19
|
+
"data-label": d,
|
|
20
|
+
"data-testid": "anchor-tag",
|
|
21
|
+
"data-type": m,
|
|
22
|
+
onClick: e || void 0,
|
|
23
|
+
children: d
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
}));
|
|
27
|
+
u.mock("../../utils/helpers", () => ({
|
|
28
|
+
slugify: (r) => r.toLowerCase().replace(/\s+/g, "-")
|
|
29
|
+
}));
|
|
30
|
+
u.mock("./NavList.module.scss", () => ({
|
|
31
|
+
default: {
|
|
32
|
+
"nav-list": "nav-list",
|
|
33
|
+
"nav-list__item": "nav-list__item"
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
36
|
+
c("NavList", () => {
|
|
37
|
+
const r = [
|
|
38
|
+
{ href: "/link1", label: "Link 1", type: "internal-link" },
|
|
39
|
+
{ href: "/link2", label: "Link 2", type: "internal-link" },
|
|
40
|
+
{ href: "/link3", label: "Link 3", type: "external-link" }
|
|
41
|
+
];
|
|
42
|
+
v(() => {
|
|
43
|
+
u.clearAllMocks();
|
|
44
|
+
}), c("Basic Rendering", () => {
|
|
45
|
+
l("should render without crashing", () => {
|
|
46
|
+
s(/* @__PURE__ */ a(o, {})), t(document.body).toBeTruthy();
|
|
47
|
+
}), l("should render as div wrapper by default", () => {
|
|
48
|
+
const { container: e } = s(/* @__PURE__ */ a(o, {})), n = e.querySelector("div");
|
|
49
|
+
t(n).toBeInTheDocument();
|
|
50
|
+
}), l("should render as nav wrapper when useNavWrapper is true", () => {
|
|
51
|
+
s(/* @__PURE__ */ a(o, { useNavWrapper: !0 }));
|
|
52
|
+
const e = i.getByRole("navigation");
|
|
53
|
+
t(e).toBeInTheDocument();
|
|
54
|
+
}), l("should render ul element", () => {
|
|
55
|
+
s(/* @__PURE__ */ a(o, { links: r }));
|
|
56
|
+
const e = document.querySelector("ul");
|
|
57
|
+
t(e).toBeInTheDocument();
|
|
58
|
+
}), l("should apply nav-list class to ul", () => {
|
|
59
|
+
s(/* @__PURE__ */ a(o, { links: r }));
|
|
60
|
+
const e = document.querySelector("ul");
|
|
61
|
+
t(e).toHaveClass("nav-list");
|
|
62
|
+
});
|
|
63
|
+
}), c("Title Rendering", () => {
|
|
64
|
+
l("should render title when provided", () => {
|
|
65
|
+
s(/* @__PURE__ */ a(o, { title: "Navigation Menu" })), t(i.getByText("Navigation Menu")).toBeInTheDocument();
|
|
66
|
+
}), l("should not render title when empty string", () => {
|
|
67
|
+
const { container: e } = s(/* @__PURE__ */ a(o, { title: "" })), n = e.querySelector("h2");
|
|
68
|
+
t(n).not.toBeInTheDocument();
|
|
69
|
+
}), l("should not render title when undefined", () => {
|
|
70
|
+
const { container: e } = s(/* @__PURE__ */ a(o, {})), n = e.querySelector("h2");
|
|
71
|
+
t(n).not.toBeInTheDocument();
|
|
72
|
+
}), l("should apply h4 class to title", () => {
|
|
73
|
+
s(/* @__PURE__ */ a(o, { title: "Navigation Menu" }));
|
|
74
|
+
const e = i.getByText("Navigation Menu");
|
|
75
|
+
t(e).toHaveClass("h4");
|
|
76
|
+
}), l("should create slugified id for title", () => {
|
|
77
|
+
s(/* @__PURE__ */ a(o, { title: "Navigation Menu" }));
|
|
78
|
+
const e = i.getByText("Navigation Menu");
|
|
79
|
+
t(e).toHaveAttribute("id", "navigation-menu");
|
|
80
|
+
}), l("should not have id when title is empty", () => {
|
|
81
|
+
const { container: e } = s(/* @__PURE__ */ a(o, { links: r, title: "" })), n = e.querySelector("h2");
|
|
82
|
+
t(n).not.toBeInTheDocument();
|
|
83
|
+
});
|
|
84
|
+
}), c("Nav Wrapper Mode", () => {
|
|
85
|
+
l("should set aria-labelledby when title is provided", () => {
|
|
86
|
+
s(/* @__PURE__ */ a(o, { useNavWrapper: !0, title: "Main Navigation" }));
|
|
87
|
+
const e = i.getByRole("navigation");
|
|
88
|
+
t(e).toHaveAttribute("aria-labelledby", "main-navigation");
|
|
89
|
+
}), l("should not set aria-labelledby when title is empty", () => {
|
|
90
|
+
s(/* @__PURE__ */ a(o, { useNavWrapper: !0, title: "" }));
|
|
91
|
+
const e = i.getByRole("navigation");
|
|
92
|
+
t(e).toHaveAttribute("aria-labelledby", "");
|
|
93
|
+
}), l("should apply classname to nav wrapper", () => {
|
|
94
|
+
s(/* @__PURE__ */ a(o, { useNavWrapper: !0, classname: "custom-nav" }));
|
|
95
|
+
const e = i.getByRole("navigation");
|
|
96
|
+
t(e).toHaveClass("custom-nav");
|
|
97
|
+
});
|
|
98
|
+
}), c("Div Wrapper Mode", () => {
|
|
99
|
+
l("should apply classname to div wrapper", () => {
|
|
100
|
+
const { container: e } = s(/* @__PURE__ */ a(o, { classname: "custom-nav" })), n = e.querySelector("div.custom-nav");
|
|
101
|
+
t(n).toBeInTheDocument();
|
|
102
|
+
}), l("should not have aria-labelledby in div mode", () => {
|
|
103
|
+
const { container: e } = s(/* @__PURE__ */ a(o, { title: "Menu" })), n = e.querySelector("div");
|
|
104
|
+
t(n).not.toHaveAttribute("aria-labelledby");
|
|
105
|
+
});
|
|
106
|
+
}), c("Links Rendering", () => {
|
|
107
|
+
l("should render all provided links", () => {
|
|
108
|
+
s(/* @__PURE__ */ a(o, { links: r }));
|
|
109
|
+
const e = i.getAllByTestId("anchor-tag");
|
|
110
|
+
t(e).toHaveLength(3);
|
|
111
|
+
}), l("should render empty list when no links provided", () => {
|
|
112
|
+
s(/* @__PURE__ */ a(o, {}));
|
|
113
|
+
const e = document.querySelector("ul");
|
|
114
|
+
t(e == null ? void 0 : e.children).toHaveLength(0);
|
|
115
|
+
}), l("should render empty list when links is empty array", () => {
|
|
116
|
+
s(/* @__PURE__ */ a(o, { links: [] }));
|
|
117
|
+
const e = document.querySelector("ul");
|
|
118
|
+
t(e == null ? void 0 : e.children).toHaveLength(0);
|
|
119
|
+
}), l("should render li elements for each link", () => {
|
|
120
|
+
s(/* @__PURE__ */ a(o, { links: r }));
|
|
121
|
+
const e = document.querySelectorAll("li");
|
|
122
|
+
t(e).toHaveLength(3);
|
|
123
|
+
}), l("should apply nav-list__item class to each li", () => {
|
|
124
|
+
s(/* @__PURE__ */ a(o, { links: r })), document.querySelectorAll("li").forEach((n) => {
|
|
125
|
+
t(n).toHaveClass("nav-list__item");
|
|
126
|
+
});
|
|
127
|
+
}), l("should pass correct href to AnchorTag", () => {
|
|
128
|
+
s(/* @__PURE__ */ a(o, { links: r }));
|
|
129
|
+
const e = i.getAllByTestId("anchor-tag");
|
|
130
|
+
t(e[0]).toHaveAttribute("data-href", "/link1"), t(e[1]).toHaveAttribute("data-href", "/link2"), t(e[2]).toHaveAttribute("data-href", "/link3");
|
|
131
|
+
}), l("should pass correct label to AnchorTag", () => {
|
|
132
|
+
s(/* @__PURE__ */ a(o, { links: r }));
|
|
133
|
+
const e = i.getAllByTestId("anchor-tag");
|
|
134
|
+
t(e[0]).toHaveAttribute("data-label", "Link 1"), t(e[1]).toHaveAttribute("data-label", "Link 2"), t(e[2]).toHaveAttribute("data-label", "Link 3");
|
|
135
|
+
}), l("should pass correct type to AnchorTag", () => {
|
|
136
|
+
s(/* @__PURE__ */ a(o, { links: r }));
|
|
137
|
+
const e = i.getAllByTestId("anchor-tag");
|
|
138
|
+
t(e[0]).toHaveAttribute("data-type", "internal-link"), t(e[1]).toHaveAttribute("data-type", "internal-link"), t(e[2]).toHaveAttribute("data-type", "external-link");
|
|
139
|
+
});
|
|
140
|
+
}), c("Link Images", () => {
|
|
141
|
+
l("should pass image to AnchorTag when provided", () => {
|
|
142
|
+
s(/* @__PURE__ */ a(o, { links: [
|
|
143
|
+
{
|
|
144
|
+
href: "/link1",
|
|
145
|
+
label: "Link 1",
|
|
146
|
+
type: "internal-link",
|
|
147
|
+
image: { url: "/image.jpg", altText: "Image", aspectRatio: 1 }
|
|
148
|
+
}
|
|
149
|
+
] }));
|
|
150
|
+
const n = i.getByTestId("anchor-tag");
|
|
151
|
+
t(n).toHaveAttribute("data-image");
|
|
152
|
+
const h = n.getAttribute("data-image");
|
|
153
|
+
if (t(h).toBeTruthy(), h) {
|
|
154
|
+
const d = JSON.parse(h);
|
|
155
|
+
t(d.src).toBe("/image.jpg"), t(d.alt).toBe("Image");
|
|
156
|
+
}
|
|
157
|
+
}), l("should pass null for image when not provided", () => {
|
|
158
|
+
s(/* @__PURE__ */ a(o, { links: r })), i.getAllByTestId("anchor-tag").forEach((n) => {
|
|
159
|
+
t(n).not.toHaveAttribute("data-image");
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}), c("Link Classnames", () => {
|
|
163
|
+
l("should include custom classname in AnchorTag when link has classname", () => {
|
|
164
|
+
s(/* @__PURE__ */ a(o, { classname: "nav", links: [
|
|
165
|
+
{
|
|
166
|
+
href: "/link1",
|
|
167
|
+
label: "Link 1",
|
|
168
|
+
type: "internal-link",
|
|
169
|
+
classname: "custom-link"
|
|
170
|
+
}
|
|
171
|
+
] }));
|
|
172
|
+
const n = i.getByTestId("anchor-tag");
|
|
173
|
+
t(n.className).toContain("custom-link");
|
|
174
|
+
}), l("should apply base classname pattern to AnchorTag", () => {
|
|
175
|
+
s(/* @__PURE__ */ a(o, { classname: "nav", links: r })), i.getAllByTestId("anchor-tag").forEach((n) => {
|
|
176
|
+
t(n.className).toContain("nav__nav-link");
|
|
177
|
+
});
|
|
178
|
+
}), l("should combine classname with li elements", () => {
|
|
179
|
+
s(/* @__PURE__ */ a(o, { classname: "custom", links: r })), document.querySelectorAll("li").forEach((n) => {
|
|
180
|
+
t(n.className).toContain("custom__nav-item");
|
|
181
|
+
});
|
|
182
|
+
}), l("should combine classname with ul element", () => {
|
|
183
|
+
s(/* @__PURE__ */ a(o, { classname: "custom", links: r }));
|
|
184
|
+
const e = document.querySelector("ul");
|
|
185
|
+
t(e == null ? void 0 : e.className).toContain("custom__nav-list");
|
|
186
|
+
});
|
|
187
|
+
}), c("Toggle Handler", () => {
|
|
188
|
+
l("should pass toggleHandler to AnchorTag components", async () => {
|
|
189
|
+
const e = g.setup(), n = u.fn();
|
|
190
|
+
s(/* @__PURE__ */ a(o, { links: r, toggleHandler: n }));
|
|
191
|
+
const h = i.getAllByTestId("anchor-tag");
|
|
192
|
+
await e.click(h[0]), t(n).toHaveBeenCalledTimes(1);
|
|
193
|
+
}), l("should not pass handler when toggleHandler is null", () => {
|
|
194
|
+
s(/* @__PURE__ */ a(o, { links: r, toggleHandler: null })), i.getAllByTestId("anchor-tag").forEach((n) => {
|
|
195
|
+
t(n).not.toHaveAttribute("onclick");
|
|
196
|
+
});
|
|
197
|
+
}), l("should call toggleHandler for each link click", async () => {
|
|
198
|
+
const e = g.setup(), n = u.fn();
|
|
199
|
+
s(/* @__PURE__ */ a(o, { links: r, toggleHandler: n }));
|
|
200
|
+
const h = i.getAllByTestId("anchor-tag");
|
|
201
|
+
await e.click(h[0]), await e.click(h[1]), await e.click(h[2]), t(n).toHaveBeenCalledTimes(3);
|
|
202
|
+
}), l("should pass undefined when toggleHandler is not provided", () => {
|
|
203
|
+
s(/* @__PURE__ */ a(o, { links: r })), i.getAllByTestId("anchor-tag").forEach((n) => {
|
|
204
|
+
t(n).not.toHaveAttribute("onclick");
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}), c("Default Props", () => {
|
|
208
|
+
l("should use empty string for title by default", () => {
|
|
209
|
+
const { container: e } = s(/* @__PURE__ */ a(o, {})), n = e.querySelector("h2");
|
|
210
|
+
t(n).not.toBeInTheDocument();
|
|
211
|
+
}), l("should use empty array for links by default", () => {
|
|
212
|
+
s(/* @__PURE__ */ a(o, {}));
|
|
213
|
+
const e = document.querySelector("ul");
|
|
214
|
+
t(e == null ? void 0 : e.children).toHaveLength(0);
|
|
215
|
+
}), l("should use empty string for classname by default", () => {
|
|
216
|
+
const { container: e } = s(/* @__PURE__ */ a(o, {})), n = e.firstChild;
|
|
217
|
+
t(n.className).toBe("");
|
|
218
|
+
}), l("should use false for useNavWrapper by default", () => {
|
|
219
|
+
const { container: e } = s(/* @__PURE__ */ a(o, {})), n = e.querySelector("nav");
|
|
220
|
+
t(n).not.toBeInTheDocument();
|
|
221
|
+
}), l("should use null for toggleHandler by default", () => {
|
|
222
|
+
s(/* @__PURE__ */ a(o, { links: r })), i.getAllByTestId("anchor-tag").forEach((n) => {
|
|
223
|
+
t(n).not.toHaveAttribute("onclick");
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}), c("List Item Keys", () => {
|
|
227
|
+
l("should generate unique keys for list items", () => {
|
|
228
|
+
s(/* @__PURE__ */ a(o, { classname: "nav", links: r }));
|
|
229
|
+
const e = document.querySelectorAll("li");
|
|
230
|
+
t(e).toHaveLength(r.length);
|
|
231
|
+
});
|
|
232
|
+
}), c("Edge Cases", () => {
|
|
233
|
+
l("should handle single link", () => {
|
|
234
|
+
s(/* @__PURE__ */ a(o, { links: [
|
|
235
|
+
{ href: "/single", label: "Single Link", type: "internal-link" }
|
|
236
|
+
] }));
|
|
237
|
+
const n = i.getAllByTestId("anchor-tag");
|
|
238
|
+
t(n).toHaveLength(1);
|
|
239
|
+
}), l("should handle very long title", () => {
|
|
240
|
+
const e = "This is a very long navigation menu title that should still render correctly";
|
|
241
|
+
s(/* @__PURE__ */ a(o, { title: e })), t(i.getByText(e)).toBeInTheDocument();
|
|
242
|
+
}), l("should handle special characters in title", () => {
|
|
243
|
+
const e = "Navigation & Menu (2024)";
|
|
244
|
+
s(/* @__PURE__ */ a(o, { title: e })), t(i.getByText(e)).toBeInTheDocument();
|
|
245
|
+
}), l("should handle links with minimal properties", () => {
|
|
246
|
+
s(/* @__PURE__ */ a(o, { links: [
|
|
247
|
+
{ href: "/link", label: "Link", type: "internal-link" }
|
|
248
|
+
] }));
|
|
249
|
+
const n = i.getByTestId("anchor-tag");
|
|
250
|
+
t(n).toBeInTheDocument();
|
|
251
|
+
}), l("should handle multiple classnames on links", () => {
|
|
252
|
+
s(/* @__PURE__ */ a(o, { classname: "nav", links: [
|
|
253
|
+
{
|
|
254
|
+
href: "/link1",
|
|
255
|
+
label: "Link 1",
|
|
256
|
+
type: "internal-link",
|
|
257
|
+
classname: "class1 class2 class3"
|
|
258
|
+
}
|
|
259
|
+
] }));
|
|
260
|
+
const n = i.getByTestId("anchor-tag");
|
|
261
|
+
t(n.className).toContain("class1 class2 class3");
|
|
262
|
+
}), l("should handle empty classname prop", () => {
|
|
263
|
+
s(/* @__PURE__ */ a(o, { classname: "", links: r }));
|
|
264
|
+
const e = document.querySelector("ul");
|
|
265
|
+
t(e == null ? void 0 : e.className).toContain("__nav-list");
|
|
266
|
+
});
|
|
267
|
+
}), c("Integration", () => {
|
|
268
|
+
l("should render complete navigation with title and links", () => {
|
|
269
|
+
s(
|
|
270
|
+
/* @__PURE__ */ a(
|
|
271
|
+
o,
|
|
272
|
+
{
|
|
273
|
+
useNavWrapper: !0,
|
|
274
|
+
classname: "main-nav",
|
|
275
|
+
links: r,
|
|
276
|
+
title: "Main Menu"
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
), t(i.getByText("Main Menu")).toBeInTheDocument(), t(i.getByRole("navigation")).toBeInTheDocument(), t(i.getAllByTestId("anchor-tag")).toHaveLength(3);
|
|
280
|
+
}), l("should render with all optional props", () => {
|
|
281
|
+
const e = u.fn();
|
|
282
|
+
s(
|
|
283
|
+
/* @__PURE__ */ a(
|
|
284
|
+
o,
|
|
285
|
+
{
|
|
286
|
+
useNavWrapper: !0,
|
|
287
|
+
classname: "full-nav",
|
|
288
|
+
links: [
|
|
289
|
+
{
|
|
290
|
+
href: "/link1",
|
|
291
|
+
label: "Link 1",
|
|
292
|
+
type: "internal-link",
|
|
293
|
+
image: { url: "/img1.jpg", altText: "Image 1", aspectRatio: 1 },
|
|
294
|
+
classname: "special-link"
|
|
295
|
+
}
|
|
296
|
+
],
|
|
297
|
+
title: "Complete Navigation",
|
|
298
|
+
toggleHandler: e
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
), t(i.getByText("Complete Navigation")).toBeInTheDocument(), t(i.getByRole("navigation")).toHaveClass("full-nav"), t(i.getByTestId("anchor-tag")).toBeInTheDocument();
|
|
302
|
+
}), l("should maintain structure with empty links", () => {
|
|
303
|
+
s(
|
|
304
|
+
/* @__PURE__ */ a(
|
|
305
|
+
o,
|
|
306
|
+
{
|
|
307
|
+
useNavWrapper: !0,
|
|
308
|
+
classname: "empty-nav",
|
|
309
|
+
links: [],
|
|
310
|
+
title: "Empty Menu"
|
|
311
|
+
}
|
|
312
|
+
)
|
|
313
|
+
), t(i.getByText("Empty Menu")).toBeInTheDocument(), t(i.getByRole("navigation")).toBeInTheDocument();
|
|
314
|
+
const e = document.querySelector("ul");
|
|
315
|
+
t(e).toBeInTheDocument(), t(e == null ? void 0 : e.children).toHaveLength(0);
|
|
316
|
+
});
|
|
317
|
+
}), c("Accessibility", () => {
|
|
318
|
+
l("should have proper heading hierarchy", () => {
|
|
319
|
+
s(/* @__PURE__ */ a(o, { title: "Navigation" }));
|
|
320
|
+
const e = i.getByRole("heading", { level: 2 });
|
|
321
|
+
t(e).toBeInTheDocument();
|
|
322
|
+
}), l("should connect nav to heading with aria-labelledby", () => {
|
|
323
|
+
s(/* @__PURE__ */ a(o, { useNavWrapper: !0, title: "Main Menu" }));
|
|
324
|
+
const e = i.getByRole("navigation"), n = i.getByText("Main Menu");
|
|
325
|
+
t(e).toHaveAttribute("aria-labelledby", n.id);
|
|
326
|
+
}), l("should have accessible list structure", () => {
|
|
327
|
+
s(/* @__PURE__ */ a(o, { useNavWrapper: !0, links: r }));
|
|
328
|
+
const n = i.getByRole("navigation").querySelector("ul");
|
|
329
|
+
t(n).toBeInTheDocument();
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
import { r as i } from "../../index-
|
|
1
|
+
import { jsx as l, Fragment as s } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as a } from "react";
|
|
3
|
+
import { r as i } from "../../index-DzfYkULW.mjs";
|
|
4
4
|
import '../../assets/Overlay.css';const v = "_overlay_itsaf_1", d = {
|
|
5
5
|
overlay: v
|
|
6
6
|
};
|
|
@@ -8,29 +8,30 @@ function p({
|
|
|
8
8
|
appendToElement: r,
|
|
9
9
|
state: o = "entering"
|
|
10
10
|
}) {
|
|
11
|
-
(() => {
|
|
11
|
+
return (() => {
|
|
12
12
|
if (!document.querySelector("#overlay")) {
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const e = document.createElement("div");
|
|
14
|
+
e.setAttribute("id", "overlay"), e.setAttribute("class", `${d.overlay} overlay`), e.setAttribute("data-state", "entering"), r ? r.append(e) : document.body.appendChild(e);
|
|
15
15
|
}
|
|
16
|
-
})()
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
})(), a(() => {
|
|
17
|
+
const t = setInterval(() => {
|
|
18
|
+
const e = document.querySelector("#overlay");
|
|
19
|
+
if (e) {
|
|
20
|
+
const c = () => {
|
|
21
|
+
const n = new CustomEvent("scripps:overlay:closed");
|
|
22
|
+
document.dispatchEvent(n), e.setAttribute("data-state", "exiting"), setTimeout(() => {
|
|
23
|
+
e.remove();
|
|
24
|
+
}, 200);
|
|
25
|
+
};
|
|
26
|
+
clearInterval(t), e.addEventListener("click", c);
|
|
27
|
+
}
|
|
28
|
+
}, 100);
|
|
29
|
+
return () => clearInterval(t);
|
|
30
|
+
}, []), a(() => {
|
|
31
|
+
var t;
|
|
32
|
+
(t = document.querySelector("#overlay")) == null || t.setAttribute("data-state", o);
|
|
32
33
|
}, [o]), i.createPortal(
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
+
/* @__PURE__ */ l(s, {}),
|
|
34
35
|
document.getElementById("overlay")
|
|
35
36
|
);
|
|
36
37
|
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { v as a, d, b as u, a as y, i as s, r as l, g as t, w as m } from "../../react.esm-DLSrfVwM.mjs";
|
|
3
|
+
import { Overlay as o } from "./Overlay.js";
|
|
4
|
+
a.mock("./Overlay.module.scss", () => ({
|
|
5
|
+
default: {
|
|
6
|
+
overlay: "overlay-module"
|
|
7
|
+
}
|
|
8
|
+
}));
|
|
9
|
+
d("Overlay", () => {
|
|
10
|
+
u(() => {
|
|
11
|
+
document.body.innerHTML = "", a.clearAllMocks();
|
|
12
|
+
}), y(() => {
|
|
13
|
+
a.clearAllTimers(), document.body.innerHTML = "";
|
|
14
|
+
}), d("Portal Element Creation", () => {
|
|
15
|
+
s("should create overlay element in body by default", () => {
|
|
16
|
+
l(/* @__PURE__ */ n(o, {}));
|
|
17
|
+
const e = document.querySelector("#overlay");
|
|
18
|
+
t(e).toBeInTheDocument(), t(document.body.contains(e)).toBe(!0);
|
|
19
|
+
}), s("should create overlay element with correct id", () => {
|
|
20
|
+
l(/* @__PURE__ */ n(o, {}));
|
|
21
|
+
const e = document.getElementById("overlay");
|
|
22
|
+
t(e).toBeInTheDocument();
|
|
23
|
+
}), s("should apply overlay class to element", () => {
|
|
24
|
+
l(/* @__PURE__ */ n(o, {}));
|
|
25
|
+
const e = document.getElementById("overlay");
|
|
26
|
+
t(e).toHaveClass("overlay");
|
|
27
|
+
}), s("should apply SCSS module class to element", () => {
|
|
28
|
+
l(/* @__PURE__ */ n(o, {}));
|
|
29
|
+
const e = document.getElementById("overlay");
|
|
30
|
+
t(e).toHaveClass("overlay-module");
|
|
31
|
+
}), s("should set initial data-state to entering", () => {
|
|
32
|
+
l(/* @__PURE__ */ n(o, {}));
|
|
33
|
+
const e = document.getElementById("overlay");
|
|
34
|
+
t(e).toHaveAttribute("data-state", "entering");
|
|
35
|
+
}), s("should not create duplicate overlay if one exists", () => {
|
|
36
|
+
l(/* @__PURE__ */ n(o, {})), l(/* @__PURE__ */ n(o, {}));
|
|
37
|
+
const e = document.querySelectorAll("#overlay");
|
|
38
|
+
t(e).toHaveLength(1);
|
|
39
|
+
});
|
|
40
|
+
}), d("Append to Custom Element", () => {
|
|
41
|
+
s("should append to custom element when provided", () => {
|
|
42
|
+
const e = document.createElement("div");
|
|
43
|
+
e.id = "custom-container", document.body.appendChild(e), l(/* @__PURE__ */ n(o, { appendToElement: e }));
|
|
44
|
+
const r = document.getElementById("overlay");
|
|
45
|
+
t(r).toBeInTheDocument(), t(e.contains(r)).toBe(!0);
|
|
46
|
+
}), s("should not append to body when custom element provided", () => {
|
|
47
|
+
const e = document.createElement("div");
|
|
48
|
+
e.id = "custom-container", document.body.appendChild(e), l(/* @__PURE__ */ n(o, { appendToElement: e }));
|
|
49
|
+
const r = document.getElementById("overlay");
|
|
50
|
+
t(r == null ? void 0 : r.parentElement).toBe(e), t(document.body.children).toContain(e);
|
|
51
|
+
});
|
|
52
|
+
}), d("State Management", () => {
|
|
53
|
+
s("should set data-state to entering by default", () => {
|
|
54
|
+
l(/* @__PURE__ */ n(o, {}));
|
|
55
|
+
const e = document.getElementById("overlay");
|
|
56
|
+
t(e).toHaveAttribute("data-state", "entering");
|
|
57
|
+
}), s("should update data-state when state prop changes to entered", async () => {
|
|
58
|
+
const { rerender: e } = l(/* @__PURE__ */ n(o, { state: "entering" }));
|
|
59
|
+
e(/* @__PURE__ */ n(o, { state: "entered" })), await m(() => {
|
|
60
|
+
const r = document.getElementById("overlay");
|
|
61
|
+
t(r).toHaveAttribute("data-state", "entered");
|
|
62
|
+
});
|
|
63
|
+
}), s("should update data-state when state prop changes to exiting", async () => {
|
|
64
|
+
const { rerender: e } = l(/* @__PURE__ */ n(o, { state: "entering" }));
|
|
65
|
+
e(/* @__PURE__ */ n(o, { state: "exiting" })), await m(() => {
|
|
66
|
+
const r = document.getElementById("overlay");
|
|
67
|
+
t(r).toHaveAttribute("data-state", "exiting");
|
|
68
|
+
});
|
|
69
|
+
}), s("should update data-state when state prop changes to exited", async () => {
|
|
70
|
+
const { rerender: e } = l(/* @__PURE__ */ n(o, { state: "entering" }));
|
|
71
|
+
e(/* @__PURE__ */ n(o, { state: "exited" })), await m(() => {
|
|
72
|
+
const r = document.getElementById("overlay");
|
|
73
|
+
t(r).toHaveAttribute("data-state", "exited");
|
|
74
|
+
});
|
|
75
|
+
}), s("should handle multiple state transitions", async () => {
|
|
76
|
+
const { rerender: e } = l(/* @__PURE__ */ n(o, { state: "entering" }));
|
|
77
|
+
e(/* @__PURE__ */ n(o, { state: "entered" })), await m(() => {
|
|
78
|
+
t(document.getElementById("overlay")).toHaveAttribute("data-state", "entered");
|
|
79
|
+
}), e(/* @__PURE__ */ n(o, { state: "exiting" })), await m(() => {
|
|
80
|
+
t(document.getElementById("overlay")).toHaveAttribute("data-state", "exiting");
|
|
81
|
+
}), e(/* @__PURE__ */ n(o, { state: "exited" })), await m(() => {
|
|
82
|
+
t(document.getElementById("overlay")).toHaveAttribute("data-state", "exited");
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}), d("Click Handler", () => {
|
|
86
|
+
s("should attach click event listener to overlay", async () => {
|
|
87
|
+
a.useFakeTimers(), l(/* @__PURE__ */ n(o, {})), a.advanceTimersByTime(100);
|
|
88
|
+
const e = document.getElementById("overlay");
|
|
89
|
+
t(e).toBeInTheDocument(), a.useRealTimers();
|
|
90
|
+
}), s("should dispatch custom event on click", async () => {
|
|
91
|
+
a.useFakeTimers();
|
|
92
|
+
const e = a.fn();
|
|
93
|
+
document.addEventListener("scripps:overlay:closed", e), l(/* @__PURE__ */ n(o, {})), a.advanceTimersByTime(100);
|
|
94
|
+
const r = document.getElementById("overlay");
|
|
95
|
+
t(r).toBeInTheDocument(), r && r.click(), t(e).toHaveBeenCalledTimes(1), document.removeEventListener("scripps:overlay:closed", e), a.useRealTimers();
|
|
96
|
+
}), s("should set data-state to exiting on click", async () => {
|
|
97
|
+
a.useFakeTimers(), l(/* @__PURE__ */ n(o, {})), a.advanceTimersByTime(100);
|
|
98
|
+
const e = document.getElementById("overlay");
|
|
99
|
+
t(e).toBeInTheDocument(), e && e.click(), t(e).toHaveAttribute("data-state", "exiting"), a.useRealTimers();
|
|
100
|
+
}), s("should remove overlay element after 200ms delay", async () => {
|
|
101
|
+
a.useFakeTimers(), l(/* @__PURE__ */ n(o, {})), a.advanceTimersByTime(100);
|
|
102
|
+
const e = document.getElementById("overlay");
|
|
103
|
+
t(e).toBeInTheDocument(), e && e.click(), t(document.getElementById("overlay")).toBeInTheDocument(), a.advanceTimersByTime(200), t(document.getElementById("overlay")).not.toBeInTheDocument(), a.useRealTimers();
|
|
104
|
+
});
|
|
105
|
+
}), d("Interval Management", () => {
|
|
106
|
+
s("should clear interval after overlay element is found", async () => {
|
|
107
|
+
a.useFakeTimers();
|
|
108
|
+
const e = a.spyOn(global, "clearInterval");
|
|
109
|
+
l(/* @__PURE__ */ n(o, {})), a.advanceTimersByTime(100), t(e).toHaveBeenCalled(), e.mockRestore(), a.useRealTimers();
|
|
110
|
+
}), s("should continue checking if overlay not immediately available", async () => {
|
|
111
|
+
a.useFakeTimers(), l(/* @__PURE__ */ n(o, {})), a.advanceTimersByTime(100), t(document.getElementById("overlay")).toBeInTheDocument(), a.useRealTimers();
|
|
112
|
+
});
|
|
113
|
+
}), d("Custom Event", () => {
|
|
114
|
+
s("should dispatch CustomEvent with correct type", async () => {
|
|
115
|
+
a.useFakeTimers();
|
|
116
|
+
const e = a.fn((c) => {
|
|
117
|
+
t(c.type).toBe("scripps:overlay:closed"), t(c instanceof CustomEvent).toBe(!0);
|
|
118
|
+
});
|
|
119
|
+
document.addEventListener("scripps:overlay:closed", e), l(/* @__PURE__ */ n(o, {})), a.advanceTimersByTime(100);
|
|
120
|
+
const r = document.getElementById("overlay");
|
|
121
|
+
r && r.click(), t(e).toHaveBeenCalled(), document.removeEventListener("scripps:overlay:closed", e), a.useRealTimers();
|
|
122
|
+
}), s("should be catchable by document event listener", async () => {
|
|
123
|
+
a.useFakeTimers();
|
|
124
|
+
let e = !1;
|
|
125
|
+
const r = () => {
|
|
126
|
+
e = !0;
|
|
127
|
+
};
|
|
128
|
+
document.addEventListener("scripps:overlay:closed", r), l(/* @__PURE__ */ n(o, {})), a.advanceTimersByTime(100);
|
|
129
|
+
const c = document.getElementById("overlay");
|
|
130
|
+
c && c.click(), t(e).toBe(!0), document.removeEventListener("scripps:overlay:closed", r), a.useRealTimers();
|
|
131
|
+
});
|
|
132
|
+
}), d("Portal Rendering", () => {
|
|
133
|
+
s("should render empty portal", () => {
|
|
134
|
+
const { container: e } = l(/* @__PURE__ */ n(o, {}));
|
|
135
|
+
t(e.innerHTML).toBe("");
|
|
136
|
+
}), s("should render portal to overlay element", () => {
|
|
137
|
+
l(/* @__PURE__ */ n(o, {}));
|
|
138
|
+
const e = document.getElementById("overlay");
|
|
139
|
+
t(e).toBeInTheDocument(), t(e == null ? void 0 : e.tagName).toBe("DIV");
|
|
140
|
+
}), s("should portal content be empty", () => {
|
|
141
|
+
l(/* @__PURE__ */ n(o, {}));
|
|
142
|
+
const e = document.getElementById("overlay");
|
|
143
|
+
t(e == null ? void 0 : e.innerHTML).toBe("");
|
|
144
|
+
});
|
|
145
|
+
}), d("Edge Cases", () => {
|
|
146
|
+
s("should handle undefined appendToElement gracefully", () => {
|
|
147
|
+
l(/* @__PURE__ */ n(o, { appendToElement: void 0 }));
|
|
148
|
+
const e = document.getElementById("overlay");
|
|
149
|
+
t(e).toBeInTheDocument(), t(document.body.contains(e)).toBe(!0);
|
|
150
|
+
}), s("should handle rapid state changes", async () => {
|
|
151
|
+
const { rerender: e } = l(/* @__PURE__ */ n(o, { state: "entering" }));
|
|
152
|
+
e(/* @__PURE__ */ n(o, { state: "entered" })), e(/* @__PURE__ */ n(o, { state: "exiting" })), e(/* @__PURE__ */ n(o, { state: "exited" })), e(/* @__PURE__ */ n(o, { state: "entering" })), await m(() => {
|
|
153
|
+
const r = document.getElementById("overlay");
|
|
154
|
+
t(r).toHaveAttribute("data-state", "entering");
|
|
155
|
+
});
|
|
156
|
+
}), s("should handle click before interval completes", async () => {
|
|
157
|
+
a.useFakeTimers(), l(/* @__PURE__ */ n(o, {}));
|
|
158
|
+
const e = document.getElementById("overlay");
|
|
159
|
+
t(e).toBeInTheDocument();
|
|
160
|
+
const r = new MouseEvent("click", { bubbles: !0 });
|
|
161
|
+
e == null || e.dispatchEvent(r), t(document.getElementById("overlay")).toBeInTheDocument(), a.useRealTimers();
|
|
162
|
+
}), s("should handle removal of overlay element externally", async () => {
|
|
163
|
+
a.useFakeTimers(), l(/* @__PURE__ */ n(o, {})), a.advanceTimersByTime(100);
|
|
164
|
+
const e = document.getElementById("overlay");
|
|
165
|
+
t(e).toBeInTheDocument(), e == null || e.remove(), t(document.getElementById("overlay")).not.toBeInTheDocument(), a.useRealTimers();
|
|
166
|
+
});
|
|
167
|
+
}), d("Multiple Overlays", () => {
|
|
168
|
+
s("should not create multiple overlay elements", () => {
|
|
169
|
+
l(/* @__PURE__ */ n(o, {})), l(/* @__PURE__ */ n(o, {})), l(/* @__PURE__ */ n(o, {}));
|
|
170
|
+
const e = document.querySelectorAll("#overlay");
|
|
171
|
+
t(e).toHaveLength(1);
|
|
172
|
+
}), s("should reuse existing overlay element", () => {
|
|
173
|
+
const { container: e } = l(/* @__PURE__ */ n(o, { state: "entering" })), r = document.getElementById("overlay"), { container: c } = l(/* @__PURE__ */ n(o, { state: "entered" })), i = document.getElementById("overlay");
|
|
174
|
+
t(r).toBe(i), t(e.innerHTML).toBe(""), t(c.innerHTML).toBe("");
|
|
175
|
+
});
|
|
176
|
+
}), d("Cleanup", () => {
|
|
177
|
+
s("should properly clean up when component unmounts", async () => {
|
|
178
|
+
a.useFakeTimers();
|
|
179
|
+
const { unmount: e } = l(/* @__PURE__ */ n(o, {}));
|
|
180
|
+
a.advanceTimersByTime(100), t(document.getElementById("overlay")).toBeInTheDocument(), e(), t(document.getElementById("overlay")).toBeInTheDocument(), a.useRealTimers();
|
|
181
|
+
});
|
|
182
|
+
}), d("Integration", () => {
|
|
183
|
+
s("should handle complete lifecycle", async () => {
|
|
184
|
+
a.useFakeTimers();
|
|
185
|
+
const e = a.fn();
|
|
186
|
+
document.addEventListener("scripps:overlay:closed", e);
|
|
187
|
+
const { rerender: r } = l(/* @__PURE__ */ n(o, { state: "entering" }));
|
|
188
|
+
a.advanceTimersByTime(100), t(document.getElementById("overlay")).toHaveAttribute("data-state", "entering"), r(/* @__PURE__ */ n(o, { state: "entered" })), t(document.getElementById("overlay")).toHaveAttribute("data-state", "entered");
|
|
189
|
+
const c = document.getElementById("overlay");
|
|
190
|
+
c && c.click(), t(c).toHaveAttribute("data-state", "exiting"), t(e).toHaveBeenCalled(), a.advanceTimersByTime(200), t(document.getElementById("overlay")).not.toBeInTheDocument(), document.removeEventListener("scripps:overlay:closed", e), a.useRealTimers();
|
|
191
|
+
}), s("should work with custom append element and state changes", async () => {
|
|
192
|
+
const e = document.createElement("div");
|
|
193
|
+
e.id = "custom-container", document.body.appendChild(e);
|
|
194
|
+
const { rerender: r } = l(/* @__PURE__ */ n(o, { appendToElement: e, state: "entering" }));
|
|
195
|
+
t(e.contains(document.getElementById("overlay"))).toBe(!0), r(/* @__PURE__ */ n(o, { appendToElement: e, state: "entered" })), t(document.getElementById("overlay")).toHaveAttribute("data-state", "entered"), t(e.contains(document.getElementById("overlay"))).toBe(!0);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
});
|