From 4f334d272c967684779985810cf3818141ec18a2 Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Tue, 17 Dec 2024 16:49:38 -0300 Subject: [PATCH 1/5] feat: tailwind variants upgrade --- .changeset/stupid-pants-perform.md | 84 + .npmrc | 3 +- apps/docs/package.json | 10 +- package.json | 17 +- .../accordion/__tests__/accordion.test.tsx | 11 +- packages/components/accordion/package.json | 3 +- packages/components/alert/package.json | 3 +- .../__tests__/autocomplete.test.tsx | 6 + packages/components/autocomplete/package.json | 4 +- packages/components/avatar/package.json | 3 +- packages/components/badge/package.json | 3 +- packages/components/breadcrumbs/package.json | 3 +- packages/components/button/package.json | 3 +- packages/components/calendar/package.json | 3 +- packages/components/card/package.json | 3 +- packages/components/checkbox/package.json | 3 +- packages/components/chip/package.json | 3 +- .../components/code/__tests__/code.test.tsx | 7 + packages/components/code/package.json | 4 +- packages/components/date-input/package.json | 3 +- .../__tests__/date-picker.test.tsx | 25 +- packages/components/date-picker/package.json | 3 +- packages/components/divider/package.json | 3 +- .../drawer/__tests__/drawer.test.tsx | 9 +- packages/components/drawer/package.json | 4 +- .../dropdown/__tests__/dropdown.test.tsx | 116 +- packages/components/dropdown/package.json | 3 +- packages/components/form/package.json | 3 +- packages/components/image/package.json | 3 +- packages/components/input-otp/package.json | 3 +- packages/components/input/package.json | 3 +- .../components/kbd/__tests__/kbd.test.tsx | 7 + packages/components/kbd/package.json | 4 +- packages/components/link/package.json | 3 +- packages/components/listbox/package.json | 3 +- packages/components/menu/package.json | 3 +- .../components/modal/__tests__/modal.test.tsx | 8 +- packages/components/modal/package.json | 4 +- .../navbar/__tests__/navbar.test.tsx | 10 +- packages/components/navbar/package.json | 4 +- .../pagination/__tests__/pagination.test.tsx | 7 + packages/components/pagination/package.json | 4 +- .../popover/__tests__/popover.test.tsx | 9 +- packages/components/popover/package.json | 4 +- packages/components/progress/package.json | 3 +- packages/components/radio/package.json | 4 +- packages/components/ripple/package.json | 3 +- .../components/scroll-shadow/package.json | 3 +- .../select/__tests__/select.test.tsx | 114 +- packages/components/select/package.json | 4 +- packages/components/skeleton/package.json | 3 +- packages/components/slider/package.json | 3 +- packages/components/snippet/package.json | 3 +- .../spacer/__tests__/spacer.test.tsx | 7 + packages/components/spacer/package.json | 4 +- packages/components/spinner/package.json | 3 +- packages/components/switch/package.json | 3 +- packages/components/table/package.json | 3 +- .../components/tabs/__tests__/tabs.test.tsx | 9 +- packages/components/tabs/package.json | 3 +- .../tooltip/__tests__/tooltip.test.tsx | 9 +- packages/components/tooltip/package.json | 1 + packages/components/user/package.json | 3 +- packages/core/react/package.json | 3 +- packages/core/system-rsc/package.json | 2 +- packages/core/system/package.json | 3 +- packages/core/theme/package.json | 10 +- packages/core/theme/src/utils/types.ts | 2 +- .../use-aria-accordion-item/package.json | 2 +- .../hooks/use-aria-accordion/package.json | 2 +- packages/hooks/use-aria-button/package.json | 2 +- packages/hooks/use-aria-link/package.json | 2 +- .../hooks/use-aria-modal-overlay/package.json | 3 +- .../hooks/use-aria-multiselect/package.json | 3 +- packages/hooks/use-callback-ref/package.json | 2 +- packages/hooks/use-clipboard/package.json | 2 +- .../use-data-scroll-overflow/package.json | 2 +- packages/hooks/use-disclosure/package.json | 2 +- packages/hooks/use-draggable/package.json | 2 +- packages/hooks/use-image/package.json | 2 +- .../hooks/use-infinite-scroll/package.json | 2 +- .../use-intersection-observer/package.json | 2 +- packages/hooks/use-is-mobile/package.json | 2 +- packages/hooks/use-is-mounted/package.json | 2 +- packages/hooks/use-measure/package.json | 2 +- packages/hooks/use-pagination/package.json | 2 +- packages/hooks/use-real-shape/package.json | 2 +- packages/hooks/use-ref-state/package.json | 2 +- packages/hooks/use-resize/package.json | 2 +- .../hooks/use-safe-layout-effect/package.json | 2 +- .../hooks/use-scroll-position/package.json | 2 +- packages/hooks/use-ssr/package.json | 2 +- packages/hooks/use-theme/package.json | 2 +- packages/hooks/use-update-effect/package.json | 2 +- packages/storybook/package.json | 3 +- packages/utilities/aria-utils/package.json | 3 +- packages/utilities/framer-utils/package.json | 3 +- .../utilities/react-rsc-utils/package.json | 2 +- packages/utilities/react-utils/package.json | 2 +- packages/utilities/shared-icons/package.json | 2 +- packages/utilities/test-utils/src/index.ts | 1 + packages/utilities/test-utils/src/spy.ts | 17 + plop/component/package.json.hbs | 3 +- plop/hook/package.json.hbs | 2 +- pnpm-lock.yaml | 4634 +++++++++-------- scripts/setup-test.ts | 6 + 106 files changed, 2899 insertions(+), 2462 deletions(-) create mode 100644 .changeset/stupid-pants-perform.md create mode 100644 packages/utilities/test-utils/src/spy.ts diff --git a/.changeset/stupid-pants-perform.md b/.changeset/stupid-pants-perform.md new file mode 100644 index 0000000000..3c52fead19 --- /dev/null +++ b/.changeset/stupid-pants-perform.md @@ -0,0 +1,84 @@ +--- +"@nextui-org/use-intersection-observer": patch +"@nextui-org/use-data-scroll-overflow": patch +"@nextui-org/use-aria-accordion-item": patch +"@nextui-org/use-aria-modal-overlay": patch +"@nextui-org/use-safe-layout-effect": patch +"@nextui-org/use-aria-multiselect": patch +"@nextui-org/use-infinite-scroll": patch +"@nextui-org/use-scroll-position": patch +"@nextui-org/react-rsc-utils": patch +"@nextui-org/scroll-shadow": patch +"@nextui-org/use-aria-accordion": patch +"@nextui-org/autocomplete": patch +"@nextui-org/use-update-effect": patch +"@nextui-org/breadcrumbs": patch +"@nextui-org/date-picker": patch +"@nextui-org/use-callback-ref": patch +"@nextui-org/framer-utils": patch +"@nextui-org/shared-icons": patch +"@nextui-org/date-input": patch +"@nextui-org/pagination": patch +"@nextui-org/use-aria-button": patch +"@nextui-org/react-utils": patch +"@nextui-org/accordion": patch +"@nextui-org/input-otp": patch +"@nextui-org/use-disclosure": patch +"@nextui-org/use-is-mounted": patch +"@nextui-org/use-pagination": patch +"@nextui-org/use-real-shape": patch +"@nextui-org/aria-utils": patch +"@nextui-org/test-utils": patch +"@nextui-org/calendar": patch +"@nextui-org/checkbox": patch +"@nextui-org/dropdown": patch +"@nextui-org/progress": patch +"@nextui-org/skeleton": patch +"@nextui-org/use-aria-link": patch +"@nextui-org/use-clipboard": patch +"@nextui-org/use-draggable": patch +"@nextui-org/use-is-mobile": patch +"@nextui-org/use-ref-state": patch +"@nextui-org/divider": patch +"@nextui-org/listbox": patch +"@nextui-org/popover": patch +"@nextui-org/snippet": patch +"@nextui-org/spinner": patch +"@nextui-org/tooltip": patch +"@nextui-org/avatar": patch +"@nextui-org/button": patch +"@nextui-org/drawer": patch +"@nextui-org/navbar": patch +"@nextui-org/ripple": patch +"@nextui-org/select": patch +"@nextui-org/slider": patch +"@nextui-org/spacer": patch +"@nextui-org/switch": patch +"@nextui-org/use-measure": patch +"@nextui-org/alert": patch +"@nextui-org/badge": patch +"@nextui-org/image": patch +"@nextui-org/input": patch +"@nextui-org/modal": patch +"@nextui-org/radio": patch +"@nextui-org/table": patch +"@nextui-org/use-resize": patch +"@nextui-org/card": patch +"@nextui-org/chip": patch +"@nextui-org/code": patch +"@nextui-org/form": patch +"@nextui-org/link": patch +"@nextui-org/menu": patch +"@nextui-org/tabs": patch +"@nextui-org/user": patch +"@nextui-org/system-rsc": patch +"@nextui-org/use-image": patch +"@nextui-org/use-theme": patch +"@nextui-org/kbd": patch +"@nextui-org/use-ssr": patch +"@nextui-org/system": patch +"@nextui-org/react": patch +"@nextui-org/theme": patch +--- + +Tailwind variants upgraded to the latest version, classnames adjusted, tests fixed diff --git a/.npmrc b/.npmrc index 1d46cebd7c..6337693e2a 100644 --- a/.npmrc +++ b/.npmrc @@ -3,4 +3,5 @@ enable-pre-post-scripts=true public-hoist-pattern[]=*tailwind-variants* public-hoist-pattern[]=*framer-motion* public-hoist-pattern[]=*@react-aria/interactions* -public-hoist-pattern[]=*@nextui-org/theme* \ No newline at end of file +public-hoist-pattern[]=*@nextui-org/theme* +public-hoist-pattern[]=*flat* \ No newline at end of file diff --git a/apps/docs/package.json b/apps/docs/package.json index f051f18fcc..80c8af3611 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -75,8 +75,8 @@ "posthog-js": "1.197.0", "prism-react-renderer": "^1.2.1", "querystring": "^0.2.1", - "react": "18.2.0", - "react-dom": "18.2.0", + "react": "18.3.0", + "react-dom": "18.3.0", "react-hook-form": "^7.51.3", "react-icons": "^4.10.1", "react-live": "^4.1.8", @@ -123,8 +123,8 @@ "algoliasearch": "^4.10.3", "autoprefixer": "10.4.20", "dotenv": "^16.0.1", - "esbuild-plugin-raw": "0.1.8", "eslint-config-next": "15.0.3", + "esbuild-plugin-raw": "0.1.8", "markdown-toc": "^1.2.0", "mdx-bundler": "10.0.3", "next-sitemap": "4.2.3", @@ -138,8 +138,8 @@ }, "pnpm": { "overrides": { - "react": "18.2.0", - "react-dom": "18.2.0" + "react": "18.3.0", + "react-dom": "18.3.0" } } } diff --git a/package.json b/package.json index aedb782009..604150ebc7 100644 --- a/package.json +++ b/package.json @@ -62,10 +62,10 @@ "@babel/preset-env": "^7.14.5", "@babel/preset-react": "^7.14.5", "@babel/preset-typescript": "^7.14.5", - "@changesets/cli": "2.27.10", "@changesets/changelog-github": "0.5.0", - "@changesets/get-release-plan": "4.0.5", + "@changesets/cli": "2.27.10", "@changesets/get-github-info": "0.6.0", + "@changesets/get-release-plan": "4.0.5", "@changesets/types": "6.0.0", "@commitlint/cli": "^17.2.0", "@commitlint/config-conventional": "^17.2.0", @@ -127,14 +127,13 @@ "prettier": "^2.2.1", "prettier-eslint": "^12.0.0", "prettier-eslint-cli": "^5.0.1", - "react": "^18.0.0", - "react-dom": "^18.0.0", + "react": "^18.3.0", "rimraf": "^3.0.2", "shelljs": "^0.8.4", - "tsup": "6.4.0", - "tsx": "^3.8.2", + "tsup": "8.3.5", + "tsx": "^4.19.2", "turbo": "1.6.3", - "typescript": "^4.9.5", + "typescript": "^5.5.0", "webpack": "^5.53.0", "webpack-bundle-analyzer": "^4.4.2", "webpack-cli": "^3.3.11", @@ -142,8 +141,8 @@ }, "pnpm": { "overrides": { - "react": "18.2.0", - "react-dom": "18.2.0", + "react": "18.3.0", + "react-dom": "18.3.0", "@changesets/get-github-info": "0.6.0" } }, diff --git a/packages/components/accordion/__tests__/accordion.test.tsx b/packages/components/accordion/__tests__/accordion.test.tsx index 8a4d78df7e..72f3fca8f2 100644 --- a/packages/components/accordion/__tests__/accordion.test.tsx +++ b/packages/components/accordion/__tests__/accordion.test.tsx @@ -1,15 +1,12 @@ +import "@testing-library/jest-dom"; import * as React from "react"; import {act, render} from "@testing-library/react"; -import {focus} from "@nextui-org/test-utils"; +import {focus, shouldIgnoreReactWarning, spy} from "@nextui-org/test-utils"; import userEvent, {UserEvent} from "@testing-library/user-event"; import {Input} from "@nextui-org/input"; import {Accordion, AccordionItem} from "../src"; -// e.g. console.error Warning: Function components cannot be given refs. -// Attempts to access this ref will fail. Did you mean to use React.forwardRef()? -const spy = jest.spyOn(console, "error").mockImplementation(() => {}); - describe("Accordion", () => { let user: UserEvent; @@ -30,6 +27,10 @@ describe("Accordion", () => { expect(() => wrapper.unmount()).not.toThrow(); + if (shouldIgnoreReactWarning(spy)) { + return; + } + expect(spy).toHaveBeenCalledTimes(0); }); diff --git a/packages/components/accordion/package.json b/packages/components/accordion/package.json index 38f618dfab..0a2b5326dc 100644 --- a/packages/components/accordion/package.json +++ b/packages/components/accordion/package.json @@ -72,8 +72,7 @@ "@nextui-org/test-utils": "workspace:*", "framer-motion": "11.9.0", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/alert/package.json b/packages/components/alert/package.json index c8155bc059..68c2b3cbeb 100644 --- a/packages/components/alert/package.json +++ b/packages/components/alert/package.json @@ -55,8 +55,7 @@ "@nextui-org/system": "workspace:*", "@nextui-org/theme": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/autocomplete/__tests__/autocomplete.test.tsx b/packages/components/autocomplete/__tests__/autocomplete.test.tsx index 55a050d64c..3ed7ab17cd 100644 --- a/packages/components/autocomplete/__tests__/autocomplete.test.tsx +++ b/packages/components/autocomplete/__tests__/autocomplete.test.tsx @@ -2,6 +2,7 @@ import "@testing-library/jest-dom"; import * as React from "react"; import {within, render, renderHook, act} from "@testing-library/react"; import userEvent, {UserEvent} from "@testing-library/user-event"; +import {spy, shouldIgnoreReactWarning} from "@nextui-org/test-utils"; import {useForm} from "react-hook-form"; import {Form} from "@nextui-org/form"; @@ -88,6 +89,11 @@ describe("Autocomplete", () => { it("should render correctly", () => { const wrapper = render(); + if (shouldIgnoreReactWarning(spy)) { + return; + } + + expect(spy).toHaveBeenCalledTimes(0); expect(() => wrapper.unmount()).not.toThrow(); }); diff --git a/packages/components/autocomplete/package.json b/packages/components/autocomplete/package.json index cb748b3855..b961b8fd19 100644 --- a/packages/components/autocomplete/package.json +++ b/packages/components/autocomplete/package.json @@ -68,14 +68,14 @@ "@nextui-org/avatar": "workspace:*", "@nextui-org/chip": "workspace:*", "@nextui-org/stories-utils": "workspace:*", + "@nextui-org/test-utils": "workspace:*", "@nextui-org/system": "workspace:*", "@nextui-org/theme": "workspace:*", "@nextui-org/use-infinite-scroll": "workspace:*", "@react-stately/data": "3.12.0", "clean-package": "2.2.0", "framer-motion": "11.9.0", - "react": "^18.0.0", - "react-dom": "^18.0.0", + "react": "18.3.0", "react-hook-form": "^7.51.3" }, "clean-package": "../../../clean-package.config.json" diff --git a/packages/components/avatar/package.json b/packages/components/avatar/package.json index 34f2d245c1..383631f5d4 100644 --- a/packages/components/avatar/package.json +++ b/packages/components/avatar/package.json @@ -53,8 +53,7 @@ "@nextui-org/shared-icons": "workspace:*", "@nextui-org/test-utils": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/badge/package.json b/packages/components/badge/package.json index 00fdb3fc23..d278e47805 100644 --- a/packages/components/badge/package.json +++ b/packages/components/badge/package.json @@ -50,8 +50,7 @@ "@nextui-org/shared-icons": "workspace:*", "@nextui-org/switch": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/breadcrumbs/package.json b/packages/components/breadcrumbs/package.json index 66ecd9ae1a..93392bc359 100644 --- a/packages/components/breadcrumbs/package.json +++ b/packages/components/breadcrumbs/package.json @@ -56,8 +56,7 @@ "@nextui-org/tooltip": "workspace:*", "@nextui-org/button": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/button/package.json b/packages/components/button/package.json index 1b8d940ca6..4bcdc7d0d9 100644 --- a/packages/components/button/package.json +++ b/packages/components/button/package.json @@ -59,8 +59,7 @@ "@nextui-org/shared-icons": "workspace:*", "framer-motion": "11.9.0", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/calendar/package.json b/packages/components/calendar/package.json index b6dd595dbe..a1ca4250e9 100644 --- a/packages/components/calendar/package.json +++ b/packages/components/calendar/package.json @@ -70,8 +70,7 @@ "@nextui-org/test-utils": "workspace:*", "framer-motion": "11.9.0", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } diff --git a/packages/components/card/package.json b/packages/components/card/package.json index a7ad58f473..1202690302 100644 --- a/packages/components/card/package.json +++ b/packages/components/card/package.json @@ -61,8 +61,7 @@ "@nextui-org/image": "workspace:*", "framer-motion": "11.9.0", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/checkbox/package.json b/packages/components/checkbox/package.json index 509cac6c9c..df37eb5ebc 100644 --- a/packages/components/checkbox/package.json +++ b/packages/components/checkbox/package.json @@ -63,8 +63,7 @@ "@nextui-org/theme": "workspace:*", "@nextui-org/user": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0", + "react": "18.3.0", "react-hook-form": "^7.51.3" }, "clean-package": "../../../clean-package.config.json" diff --git a/packages/components/chip/package.json b/packages/components/chip/package.json index e43e08b89b..ffd5a342fb 100644 --- a/packages/components/chip/package.json +++ b/packages/components/chip/package.json @@ -53,8 +53,7 @@ "@nextui-org/system": "workspace:*", "@nextui-org/avatar": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/code/__tests__/code.test.tsx b/packages/components/code/__tests__/code.test.tsx index 58afd21346..b7dcce0ad9 100644 --- a/packages/components/code/__tests__/code.test.tsx +++ b/packages/components/code/__tests__/code.test.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import {render} from "@testing-library/react"; +import {spy, shouldIgnoreReactWarning} from "@nextui-org/test-utils"; import {Code} from "../src"; @@ -8,6 +9,12 @@ describe("Code", () => { const wrapper = render(); expect(() => wrapper.unmount()).not.toThrow(); + + if (shouldIgnoreReactWarning(spy)) { + return; + } + + expect(spy).toHaveBeenCalledTimes(0); }); it("ref should be forwarded", () => { diff --git a/packages/components/code/package.json b/packages/components/code/package.json index b3681b9a45..44ac732a5d 100644 --- a/packages/components/code/package.json +++ b/packages/components/code/package.json @@ -45,9 +45,9 @@ }, "devDependencies": { "@nextui-org/theme": "workspace:*", + "@nextui-org/test-utils": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/date-input/package.json b/packages/components/date-input/package.json index b93da09a42..affc14200d 100644 --- a/packages/components/date-input/package.json +++ b/packages/components/date-input/package.json @@ -57,8 +57,7 @@ "@nextui-org/shared-icons": "workspace:*", "@nextui-org/test-utils": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } diff --git a/packages/components/date-picker/__tests__/date-picker.test.tsx b/packages/components/date-picker/__tests__/date-picker.test.tsx index 461aa8be3f..7f7bb3cca3 100644 --- a/packages/components/date-picker/__tests__/date-picker.test.tsx +++ b/packages/components/date-picker/__tests__/date-picker.test.tsx @@ -1,7 +1,13 @@ /* eslint-disable jsx-a11y/no-autofocus */ import * as React from "react"; import {render, act, fireEvent, waitFor, within} from "@testing-library/react"; -import {pointerMap, triggerPress} from "@nextui-org/test-utils"; +import { + errorSpy, + pointerMap, + shouldIgnoreReactWarning, + triggerPress, + warnSpy, +} from "@nextui-org/test-utils"; import userEvent from "@testing-library/user-event"; import {CalendarDate, CalendarDateTime} from "@internationalized/date"; import {NextUIProvider} from "@nextui-org/system"; @@ -66,6 +72,7 @@ describe("DatePicker", () => { user = userEvent.setup({delay: null, pointerMap}); jest.useFakeTimers(); }); + afterEach(() => { act(() => { jest.runAllTimers(); @@ -435,8 +442,6 @@ describe("DatePicker", () => { describe("Calendar popover", function () { it("should emit onChange when selecting a date in the calendar in controlled mode", function () { let onChange = jest.fn(); - const consoleWarnSpy = jest.spyOn(console, "warn").mockImplementation(() => {}); - const consoleErrorSpy = jest.spyOn(console, "error").mockImplementation(() => {}); let {getByRole, getAllByRole, queryByLabelText} = render( { expect(onChange).toHaveBeenCalledWith(new CalendarDate(2019, 2, 4)); expect(getTextValue(combobox)).toBe("2/3/2019"); // controlled - expect(consoleWarnSpy).not.toHaveBeenCalled(); - expect(consoleErrorSpy).not.toHaveBeenCalled(); - consoleWarnSpy.mockRestore(); - consoleErrorSpy.mockRestore(); + if (!shouldIgnoreReactWarning(warnSpy)) { + expect(warnSpy).not.toHaveBeenCalled(); + } + + if (!shouldIgnoreReactWarning(errorSpy)) { + expect(errorSpy).not.toHaveBeenCalled(); + } + + warnSpy.mockRestore(); + errorSpy.mockRestore(); }); it("should emit onChange when selecting a date in the calendar in uncontrolled mode", function () { diff --git a/packages/components/date-picker/package.json b/packages/components/date-picker/package.json index 10dbe6f3a1..be258f58b6 100644 --- a/packages/components/date-picker/package.json +++ b/packages/components/date-picker/package.json @@ -67,8 +67,7 @@ "@nextui-org/theme": "workspace:*", "framer-motion": "11.9.0", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } diff --git a/packages/components/divider/package.json b/packages/components/divider/package.json index 969a18b94b..05c8db870f 100644 --- a/packages/components/divider/package.json +++ b/packages/components/divider/package.json @@ -47,8 +47,7 @@ "devDependencies": { "@nextui-org/theme": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/drawer/__tests__/drawer.test.tsx b/packages/components/drawer/__tests__/drawer.test.tsx index 85178372c5..c6e1ad8865 100644 --- a/packages/components/drawer/__tests__/drawer.test.tsx +++ b/packages/components/drawer/__tests__/drawer.test.tsx @@ -2,11 +2,9 @@ import "@testing-library/jest-dom"; import * as React from "react"; import {render, fireEvent} from "@testing-library/react"; import userEvent from "@testing-library/user-event"; +import {spy, shouldIgnoreReactWarning} from "@nextui-org/test-utils"; import {Drawer, DrawerContent, DrawerHeader, DrawerBody, DrawerFooter} from "../src"; -// e.g. console.error Warning: Function components cannot be given refs. -// Attempts to access this ref will fail. Did you mean to use React.forwardRef()? -const spy = jest.spyOn(console, "error").mockImplementation(() => {}); describe("Drawer", () => { afterEach(() => { @@ -25,6 +23,11 @@ describe("Drawer", () => { ); expect(() => wrapper.unmount()).not.toThrow(); + + if (shouldIgnoreReactWarning(spy)) { + return; + } + expect(spy).toHaveBeenCalledTimes(0); }); diff --git a/packages/components/drawer/package.json b/packages/components/drawer/package.json index e6220349fd..7044074aa2 100644 --- a/packages/components/drawer/package.json +++ b/packages/components/drawer/package.json @@ -58,10 +58,10 @@ "@nextui-org/switch": "workspace:*", "@nextui-org/shared-icons": "workspace:*", "@nextui-org/use-disclosure": "workspace:*", + "@nextui-org/test-utils": "workspace:*", "react-lorem-component": "0.13.0", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } diff --git a/packages/components/dropdown/__tests__/dropdown.test.tsx b/packages/components/dropdown/__tests__/dropdown.test.tsx index 370d5ca718..532205bfe9 100644 --- a/packages/components/dropdown/__tests__/dropdown.test.tsx +++ b/packages/components/dropdown/__tests__/dropdown.test.tsx @@ -2,17 +2,13 @@ import * as React from "react"; import {act, render, fireEvent} from "@testing-library/react"; import {Button} from "@nextui-org/button"; import userEvent, {UserEvent} from "@testing-library/user-event"; -import {keyCodes} from "@nextui-org/test-utils"; +import {keyCodes, shouldIgnoreReactWarning, spy} from "@nextui-org/test-utils"; import {User} from "@nextui-org/user"; import {Image} from "@nextui-org/image"; import {Avatar} from "@nextui-org/avatar"; import {Dropdown, DropdownTrigger, DropdownMenu, DropdownItem, DropdownSection} from "../src"; -// e.g. console.error Warning: Function components cannot be given refs. -// Attempts to access this ref will fail. Did you mean to use React.forwardRef()? -const spy = jest.spyOn(console, "error").mockImplementation(() => {}); - describe("Dropdown", () => { let user: UserEvent; @@ -25,7 +21,7 @@ describe("Dropdown", () => { it("should render correctly (static)", () => { const wrapper = render( - + @@ -52,7 +48,7 @@ describe("Dropdown", () => { ]; const wrapper = render( - + @@ -67,7 +63,7 @@ describe("Dropdown", () => { it("should render correctly with section (static)", () => { const wrapper = render( - + @@ -106,7 +102,7 @@ describe("Dropdown", () => { ]; const wrapper = render( - + @@ -130,7 +126,7 @@ describe("Dropdown", () => { it("should not throw any error when clicking button", async () => { const wrapper = render( - + @@ -149,7 +145,14 @@ describe("Dropdown", () => { expect(triggerButton).toBeTruthy(); - await user.click(triggerButton); + await act(async () => { + await user.click(triggerButton); + }); + + if (shouldIgnoreReactWarning(spy)) { + return; + } + expect(spy).toHaveBeenCalledTimes(0); let menu = wrapper.queryByRole("menu"); @@ -186,7 +189,9 @@ describe("Dropdown", () => { expect(onOpenChange).toHaveBeenCalledTimes(0); - await user.click(triggerButton); + await act(async () => { + await user.click(triggerButton); + }); expect(onOpenChange).toHaveBeenCalledTimes(1); @@ -201,7 +206,9 @@ describe("Dropdown", () => { expect(menuItems.length).toBe(4); - await user.click(menuItems[1]); + await act(async () => { + await user.click(menuItems[1]); + }); expect(onSelectionChange).toHaveBeenCalledTimes(1); expect(onOpenChange).toHaveBeenCalled(); @@ -236,7 +243,9 @@ describe("Dropdown", () => { expect(onOpenChange).toHaveBeenCalledTimes(0); - await user.click(triggerButton); + await act(async () => { + await user.click(triggerButton); + }); expect(onOpenChange).toHaveBeenCalledTimes(1); @@ -251,7 +260,9 @@ describe("Dropdown", () => { expect(menuItems.length).toBe(4); - await user.click(menuItems[0]); + await act(async () => { + await user.click(menuItems[0]); + }); expect(onSelectionChange).toHaveBeenCalledTimes(1); expect(onOpenChange).toHaveBeenCalled(); @@ -362,7 +373,7 @@ describe("Dropdown", () => { it("should not open on disabled button", async () => { const wrapper = render( - + @@ -543,7 +560,7 @@ describe("Dropdown", () => { - + @@ -565,29 +582,26 @@ describe("Dropdown", () => { expect(dropdown).toBeVisible(); expect(dropdown2).toBeVisible(); - // open the dropdown listbox by clicking dropdown button in the first dropdown - await user.click(dropdown); + // Wrap click events in act() + await act(async () => { + await user.click(dropdown); + }); - // assert that the first dropdown listbox is open expect(dropdown).toHaveAttribute("aria-expanded", "true"); - - // assert that the second dropdown listbox is close expect(dropdown2).toHaveAttribute("aria-expanded", "false"); - // close the dropdown listbox by clicking the second dropdown - await user.click(dropdown2); + await act(async () => { + await user.click(dropdown2); + }); - // assert that the first dropdown listbox is closed expect(dropdown).toHaveAttribute("aria-expanded", "false"); - - // assert that the second dropdown listbox is open expect(dropdown2).toHaveAttribute("aria-expanded", "true"); }); describe("Keyboard interactions", () => { it("should focus on the first item on keyDown (Enter)", async () => { const wrapper = render( - + @@ -625,7 +639,7 @@ describe("Dropdown", () => { it("should focus on the first item on keyDown (Space)", async () => { const wrapper = render( - + @@ -665,7 +679,7 @@ describe("Dropdown", () => { const logSpy = jest.spyOn(console, "log").mockImplementation(() => {}); const wrapper = render( - + @@ -708,7 +722,9 @@ describe("Dropdown", () => { expect(menuItems[0]).toHaveFocus(); - await user.keyboard("[Enter]"); + await act(async () => { + await user.keyboard("[Enter]"); + }); expect(logSpy).toHaveBeenCalledWith("ENTER"); @@ -719,7 +735,7 @@ describe("Dropdown", () => { const logSpy = jest.spyOn(console, "log").mockImplementation(() => {}); const wrapper = render( - + @@ -762,7 +778,9 @@ describe("Dropdown", () => { expect(menuItems[0]).toHaveFocus(); - await user.keyboard("[Space]"); + await act(async () => { + await user.keyboard("[Space]"); + }); expect(logSpy).toHaveBeenCalledWith("SPACE"); @@ -787,16 +805,24 @@ describe("Dropdown", () => { let triggerButton = wrapper.getByTestId("trigger-test"); - await user.click(triggerButton); + await act(async () => { + await user.click(triggerButton); + }); expect(onOpenChange).toHaveBeenCalledTimes(1); let menuItems = wrapper.getAllByRole("menuitem"); - await user.click(menuItems[0]); + await act(async () => { + await user.click(menuItems[0]); + }); + expect(onOpenChange).toHaveBeenCalledTimes(1); - await user.click(menuItems[1]); + await act(async () => { + await user.click(menuItems[1]); + }); + expect(onOpenChange).toHaveBeenCalledTimes(2); }); @@ -829,12 +855,18 @@ describe("Dropdown", () => { let triggerButton = wrapper.getByTestId("trigger-test"); - await user.click(triggerButton); + await act(async () => { + await user.click(triggerButton); + }); + expect(onOpenChange).toHaveBeenCalledTimes(1); let menuItems = wrapper.getAllByRole("menuitem"); - await user.click(menuItems[0]); + await act(async () => { + await user.click(menuItems[0]); + }); + expect(onOpenChange).toHaveBeenCalledTimes(2); }); }); diff --git a/packages/components/dropdown/package.json b/packages/components/dropdown/package.json index 438ba56dcd..8626aac713 100644 --- a/packages/components/dropdown/package.json +++ b/packages/components/dropdown/package.json @@ -64,8 +64,7 @@ "@nextui-org/user": "workspace:*", "clean-package": "2.2.0", "framer-motion": "11.9.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } diff --git a/packages/components/form/package.json b/packages/components/form/package.json index 62efe653c2..ab6b3a299c 100644 --- a/packages/components/form/package.json +++ b/packages/components/form/package.json @@ -52,8 +52,7 @@ "devDependencies": { "@nextui-org/button": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } diff --git a/packages/components/image/package.json b/packages/components/image/package.json index 9aa34457bf..d010b87c3f 100644 --- a/packages/components/image/package.json +++ b/packages/components/image/package.json @@ -48,8 +48,7 @@ "@nextui-org/theme": "workspace:*", "@nextui-org/system": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/input-otp/package.json b/packages/components/input-otp/package.json index fe884b6a73..3e1f04b07c 100644 --- a/packages/components/input-otp/package.json +++ b/packages/components/input-otp/package.json @@ -56,8 +56,7 @@ "@nextui-org/system": "workspace:*", "@nextui-org/button": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0", + "react": "18.3.0", "react-hook-form": "^7.51.3" }, "clean-package": "../../../clean-package.config.json" diff --git a/packages/components/input/package.json b/packages/components/input/package.json index 5ad2742260..4a5b92826d 100644 --- a/packages/components/input/package.json +++ b/packages/components/input/package.json @@ -58,8 +58,7 @@ "@nextui-org/system": "workspace:*", "@nextui-org/theme": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0", + "react": "18.3.0", "react-hook-form": "^7.51.3" }, "clean-package": "../../../clean-package.config.json" diff --git a/packages/components/kbd/__tests__/kbd.test.tsx b/packages/components/kbd/__tests__/kbd.test.tsx index a4b38b593c..e6a5a6ab15 100644 --- a/packages/components/kbd/__tests__/kbd.test.tsx +++ b/packages/components/kbd/__tests__/kbd.test.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import {render} from "@testing-library/react"; +import {spy, shouldIgnoreReactWarning} from "@nextui-org/test-utils"; import {Kbd} from "../src"; @@ -8,6 +9,12 @@ describe("Kbd", () => { const wrapper = render(); expect(() => wrapper.unmount()).not.toThrow(); + + if (shouldIgnoreReactWarning(spy)) { + return; + } + + expect(spy).toHaveBeenCalledTimes(0); }); it("ref should be forwarded", () => { diff --git a/packages/components/kbd/package.json b/packages/components/kbd/package.json index febbd03f4a..ea08c64e32 100644 --- a/packages/components/kbd/package.json +++ b/packages/components/kbd/package.json @@ -46,9 +46,9 @@ }, "devDependencies": { "@nextui-org/theme": "workspace:*", + "@nextui-org/test-utils": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/link/package.json b/packages/components/link/package.json index 3ae8b33a50..68b00f7316 100644 --- a/packages/components/link/package.json +++ b/packages/components/link/package.json @@ -53,8 +53,7 @@ "@nextui-org/theme": "workspace:*", "@nextui-org/system": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/listbox/package.json b/packages/components/listbox/package.json index ca524e8412..8b824f021c 100644 --- a/packages/components/listbox/package.json +++ b/packages/components/listbox/package.json @@ -63,8 +63,7 @@ "@nextui-org/system": "workspace:*", "@nextui-org/theme": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/menu/package.json b/packages/components/menu/package.json index 909a8158c7..2c1542427d 100644 --- a/packages/components/menu/package.json +++ b/packages/components/menu/package.json @@ -60,8 +60,7 @@ "@nextui-org/test-utils": "workspace:*", "clean-package": "2.2.0", "@nextui-org/shared-icons": "workspace:*", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/modal/__tests__/modal.test.tsx b/packages/components/modal/__tests__/modal.test.tsx index 3e73ec156f..9ee1b8fbed 100644 --- a/packages/components/modal/__tests__/modal.test.tsx +++ b/packages/components/modal/__tests__/modal.test.tsx @@ -1,14 +1,11 @@ import "@testing-library/jest-dom"; import * as React from "react"; import {render, fireEvent} from "@testing-library/react"; +import {shouldIgnoreReactWarning, spy} from "@nextui-org/test-utils"; import userEvent from "@testing-library/user-event"; import {Modal, ModalContent, ModalBody, ModalHeader, ModalFooter, useDraggable} from "../src"; -// e.g. console.error Warning: Function components cannot be given refs. -// Attempts to access this ref will fail. Did you mean to use React.forwardRef()? -const spy = jest.spyOn(console, "error").mockImplementation(() => {}); - const ModalDraggable = ({canOverflow = false, isDisabled = false}) => { const targetRef = React.useRef(null); @@ -43,6 +40,9 @@ describe("Modal", () => { expect(() => wrapper.unmount()).not.toThrow(); + if (shouldIgnoreReactWarning(spy)) { + return; + } expect(spy).toHaveBeenCalledTimes(0); }); diff --git a/packages/components/modal/package.json b/packages/components/modal/package.json index 97aa18aa41..0106459f99 100644 --- a/packages/components/modal/package.json +++ b/packages/components/modal/package.json @@ -66,11 +66,11 @@ "@nextui-org/button": "workspace:*", "@nextui-org/link": "workspace:*", "@nextui-org/switch": "workspace:*", + "@nextui-org/test-utils": "workspace:*", "react-lorem-component": "0.13.0", "framer-motion": "11.9.0", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/navbar/__tests__/navbar.test.tsx b/packages/components/navbar/__tests__/navbar.test.tsx index d2d9c4355c..0aedf91f15 100644 --- a/packages/components/navbar/__tests__/navbar.test.tsx +++ b/packages/components/navbar/__tests__/navbar.test.tsx @@ -1,6 +1,7 @@ import * as React from "react"; import {render} from "@testing-library/react"; import userEvent, {UserEvent} from "@testing-library/user-event"; +import {spy, shouldIgnoreReactWarning} from "@nextui-org/test-utils"; import { Navbar, @@ -14,10 +15,6 @@ import { window.scrollTo = jest.fn(); -// e.g. console.error Warning: Function components cannot be given refs. -// Attempts to access this ref will fail. Did you mean to use React.forwardRef()? -const spy = jest.spyOn(console, "error").mockImplementation(() => {}); - describe("Navbar", () => { let user: UserEvent; @@ -28,6 +25,7 @@ describe("Navbar", () => { afterEach(() => { jest.clearAllMocks(); }); + it("should render correctly", () => { const wrapper = render(); @@ -94,6 +92,10 @@ describe("Navbar", () => { await user.click(toggle); + if (shouldIgnoreReactWarning(spy)) { + return; + } + expect(spy).toHaveBeenCalledTimes(0); }); diff --git a/packages/components/navbar/package.json b/packages/components/navbar/package.json index bd585d78b5..621f2176ad 100644 --- a/packages/components/navbar/package.json +++ b/packages/components/navbar/package.json @@ -62,12 +62,12 @@ "@nextui-org/dropdown": "workspace:*", "@nextui-org/input": "workspace:*", "@nextui-org/link": "workspace:*", + "@nextui-org/test-utils": "workspace:*", "@nextui-org/shared-icons": "workspace:*", "framer-motion": "11.9.0", "react-lorem-component": "0.13.0", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/pagination/__tests__/pagination.test.tsx b/packages/components/pagination/__tests__/pagination.test.tsx index 71db770711..055d433fef 100644 --- a/packages/components/pagination/__tests__/pagination.test.tsx +++ b/packages/components/pagination/__tests__/pagination.test.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import {render} from "@testing-library/react"; +import {spy, shouldIgnoreReactWarning} from "@nextui-org/test-utils"; import {Pagination} from "../src"; @@ -8,6 +9,12 @@ describe("Pagination", () => { const wrapper = render(); expect(() => wrapper.unmount()).not.toThrow(); + + if (shouldIgnoreReactWarning(spy)) { + return; + } + + expect(spy).toHaveBeenCalledTimes(0); }); it("ref should be forwarded", () => { diff --git a/packages/components/pagination/package.json b/packages/components/pagination/package.json index 997a6c4df2..34ca549efe 100644 --- a/packages/components/pagination/package.json +++ b/packages/components/pagination/package.json @@ -54,9 +54,9 @@ "devDependencies": { "@nextui-org/theme": "workspace:*", "@nextui-org/system": "workspace:*", + "@nextui-org/test-utils": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/popover/__tests__/popover.test.tsx b/packages/components/popover/__tests__/popover.test.tsx index affe4d0dbf..04b30b53d7 100644 --- a/packages/components/popover/__tests__/popover.test.tsx +++ b/packages/components/popover/__tests__/popover.test.tsx @@ -2,14 +2,11 @@ import * as React from "react"; import {render, fireEvent, act} from "@testing-library/react"; import userEvent, {UserEvent} from "@testing-library/user-event"; import {Button} from "@nextui-org/button"; +import {spy, shouldIgnoreReactWarning} from "@nextui-org/test-utils"; import {Popover, PopoverContent, PopoverTrigger} from "../src"; import {Select, SelectItem} from "../../select/src"; -// e.g. console.error Warning: Function components cannot be given refs. -// Attempts to access this ref will fail. Did you mean to use React.forwardRef()? -const spy = jest.spyOn(console, "error").mockImplementation(() => {}); - describe("Popover", () => { let user: UserEvent; @@ -52,7 +49,9 @@ describe("Popover", () => { // open popover await user.click(trigger); - expect(spy).toHaveBeenCalledTimes(0); + if (!shouldIgnoreReactWarning(spy)) { + expect(spy).toHaveBeenCalledTimes(0); + } }); it("ref should be forwarded", () => { diff --git a/packages/components/popover/package.json b/packages/components/popover/package.json index 47e33a6a58..3490c1bb68 100644 --- a/packages/components/popover/package.json +++ b/packages/components/popover/package.json @@ -63,10 +63,10 @@ "@nextui-org/input": "workspace:*", "@nextui-org/system": "workspace:*", "@nextui-org/theme": "workspace:*", + "@nextui-org/test-utils": "workspace:*", "clean-package": "2.2.0", "framer-motion": "11.9.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } diff --git a/packages/components/progress/package.json b/packages/components/progress/package.json index b23d4f9c77..2367176145 100644 --- a/packages/components/progress/package.json +++ b/packages/components/progress/package.json @@ -54,8 +54,7 @@ "@nextui-org/card": "workspace:*", "@nextui-org/chip": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/radio/package.json b/packages/components/radio/package.json index 02844b4059..a8b842784d 100644 --- a/packages/components/radio/package.json +++ b/packages/components/radio/package.json @@ -56,9 +56,9 @@ "@nextui-org/theme": "workspace:*", "@nextui-org/system": "workspace:*", "@nextui-org/button": "workspace:*", + "@nextui-org/test-utils": "workspace:*", "clean-package": "2.2.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } diff --git a/packages/components/ripple/package.json b/packages/components/ripple/package.json index bc16bfcad0..a951fac4e7 100644 --- a/packages/components/ripple/package.json +++ b/packages/components/ripple/package.json @@ -50,8 +50,7 @@ "@nextui-org/system": "workspace:*", "clean-package": "2.2.0", "framer-motion": "11.9.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/scroll-shadow/package.json b/packages/components/scroll-shadow/package.json index 5210dbd69e..6cac6543ee 100644 --- a/packages/components/scroll-shadow/package.json +++ b/packages/components/scroll-shadow/package.json @@ -49,8 +49,7 @@ "@nextui-org/system": "workspace:*", "clean-package": "2.2.0", "react-lorem-component": "0.13.0", - "react": "^18.0.0", - "react-dom": "^18.0.0" + "react": "18.3.0" }, "clean-package": "../../../clean-package.config.json" } \ No newline at end of file diff --git a/packages/components/select/__tests__/select.test.tsx b/packages/components/select/__tests__/select.test.tsx index 13b90369a4..a7ba4c8883 100644 --- a/packages/components/select/__tests__/select.test.tsx +++ b/packages/components/select/__tests__/select.test.tsx @@ -1,8 +1,10 @@ import type {SelectProps} from "../src"; +import "@testing-library/jest-dom"; import * as React from "react"; -import {act, render, renderHook, waitFor} from "@testing-library/react"; +import {render, renderHook, waitFor, act} from "@testing-library/react"; import userEvent, {UserEvent} from "@testing-library/user-event"; +import {spy, shouldIgnoreReactWarning} from "@nextui-org/test-utils"; import {useForm} from "react-hook-form"; import {Form} from "@nextui-org/form"; @@ -58,15 +60,24 @@ describe("Select", () => { user = userEvent.setup(); }); + afterEach(() => { + jest.clearAllMocks(); + }); + it("should render correctly", () => { const wrapper = render( - Penguin Zebra Shark , ); + if (shouldIgnoreReactWarning(spy)) { + return; + } + + expect(spy).toHaveBeenCalledTimes(0); expect(() => wrapper.unmount()).not.toThrow(); }); @@ -74,7 +85,7 @@ describe("Select", () => { const ref = React.createRef(); render( - Penguin Zebra Shark @@ -85,7 +96,12 @@ describe("Select", () => { it("should render correctly (dynamic)", () => { const wrapper = render( - {(item) => {item.label}} , ); @@ -95,7 +111,7 @@ describe("Select", () => { it("should render correctly with section (static)", () => { const wrapper = render( - Penguin @@ -111,7 +127,12 @@ describe("Select", () => { it("should render correctly with section (dynamic)", () => { const wrapper = render( - {(section) => ( aria-label={section.title} @@ -133,6 +154,7 @@ describe("Select", () => { const wrapper = render( { expect(listboxItems.length).toBe(3); - await user.click(listboxItems[1]); - await user.click(listboxItems[2]); + await act(async () => { + await user.click(listboxItems[1]); + await user.click(listboxItems[2]); + }); expect(onSelectionChange).toHaveBeenCalledTimes(2); }); @@ -199,6 +225,7 @@ describe("Select", () => { return ( { Modal header { const wrapper = render( { const onSelectionChangeId = jest.fn(); const wrapperWithId = render( { it("should display selected items as comma-separated string inside the select", async () => { const wrapper = render( + - Penguin @@ -536,6 +585,7 @@ describe("Select", () => { it("should display placeholder text when unselected", async () => { const wrapper = render( { }} > + { const wrapper = render( { render( { expect(select).not.toHaveAttribute("aria-describedby"); await user.click(getByTestId("button")); + expect(select).toHaveAttribute("aria-describedby"); expect(document.getElementById(select.getAttribute("aria-describedby")!)).toHaveTextContent( "Invalid value", @@ -833,6 +896,7 @@ describe("Select", () => { it("should not open dropdown when hideEmptyContent is true", async () => { const wrapper = render( { const wrapper = render(
- {options.map((o) => ( {o} @@ -928,7 +999,13 @@ describe("Select virtualization tests", () => { const wrapper = render(
- {options.map((o) => ( {o} @@ -973,6 +1050,7 @@ describe("Select virtualization tests", () => { const wrapper = render(
{ wrapper = render(
{ const {getByTestId} = render(