Skip to content

Commit

Permalink
feat(ui): WIP add unit tests for drawer | tg / rd | #28
Browse files Browse the repository at this point in the history
preparing storybook unit tests
  • Loading branch information
rDziuba-t-systems committed May 10, 2024
1 parent eaf2cd4 commit 2d04ccc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 27 deletions.
5 changes: 0 additions & 5 deletions packages/ui/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import type { JestConfigWithTsJest } from "ts-jest"
const jestConfig: JestConfigWithTsJest = {
preset: "ts-jest",
testEnvironment: "jsdom",
globals: {
"ts-jest": {
tsconfig: "tsconfig.json", // Path to your TypeScript config file
},
},
moduleNameMapper: {
// Handle module aliases (if used in your TypeScript configuration)
"^@pixelshades/utils/(.*)$": "<rootDir>/../utils/src/$1",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/ui/drawer/drawer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const meta: Meta<DrawerPropsAndCustomArgs> = {
title: "Components/UI/Drawer",
decorators: (Story) => (
<div className={"dark relative h-full w-full font-sans"}>
<Drawer.Trigger>
<Drawer.Trigger defaultOpen={true}>
<Button variant="outline">open drawer</Button>
<Story />
</Drawer.Trigger>
Expand Down
23 changes: 3 additions & 20 deletions packages/ui/src/components/ui/drawer/drawer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
import { composeStory } from "@storybook/react"
import "@testing-library/jest-dom"
import { render } from "@testing-library/react"
// import * as DrawerUtils from "./drawer"
// import { Drawer, type DrawerProps } from "./drawer"
import { render, screen } from "@testing-library/react"
import Meta, { Default } from "./drawer.stories"

const DrawerDefault = composeStory(Default, Meta) // default placement is "right"

describe("DrawerRoot", () => {
it("should return the correct markup for placement='right'", () => {
// const spy = jest.spyOn(DrawerUtils, "DrawerRoot")

it("should return the correct markup for placement='right'", async () => {
render(<DrawerDefault />)
expect(true).toBeFalsy()

// expect(spy).toBeCalled()

/*render(<FormError />)
const buttonElement = screen.getByRole("button", {
name: "Submit",
})
fireEvent.click(buttonElement)
const isFormValid = screen.getByLabelText("invalid-form")
expect(isFormValid).toBeInTheDocument()*/
expect(screen.getByRole("dialog")).toBeInTheDocument()
})
})
2 changes: 1 addition & 1 deletion packages/ui/src/components/ui/drawer/drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface DrawerProps extends ModalOverlayProps, VariantProps<typeof draw
placement?: Placement
}

export const DrawerRoot = ({ placement, children, className, ...props }: DrawerProps) => {
const DrawerRoot = ({ placement, children, className, ...props }: DrawerProps) => {
return (
<Modal
className={drawerVariants({
Expand Down

0 comments on commit 2d04ccc

Please sign in to comment.