Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nahoc committed Jul 26, 2024
1 parent c377658 commit eeb5828
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 263 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ https://www.npmjs.com/package/@risc0/ui

| Statements | Branches | Functions | Lines |
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
| ![Statements](https://img.shields.io/badge/statements-37.6%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-70.83%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-51.42%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-37.6%25-red.svg?style=flat) |
| ![Statements](https://img.shields.io/badge/statements-40.64%25-red.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-72.85%25-red.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-54.54%25-red.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-40.64%25-red.svg?style=flat) |
104 changes: 0 additions & 104 deletions alert-dialog.tsx

This file was deleted.

8 changes: 3 additions & 5 deletions alert.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ describe("Alert", () => {
test("returns default class names when no variant is provided", () => {
render(<Alert />);
const alertElement = screen.getByRole("alert");
expect(alertElement.className).toContain("relative w-full rounded-lg border px-4 py-3 text-sm");
expect(alertElement.className).toContain("bg-background text-foreground");
expect(alertElement.className).toContain("relative w-full rounded-lg border bg-background px-4 py-3 text-foreground text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:text-foreground [&>svg~*]:pl-7");
});

test("returns correct class names when destructive variant is provided", () => {
render(<Alert variant="destructive" />);
const alertElement = screen.getByRole("alert");
expect(alertElement.className).toContain("relative w-full rounded-lg border px-4 py-3 text-sm");
expect(alertElement.className).toContain("border-destructive/50 text-destructive dark:border-destructive");
expect(alertElement.className).toContain("relative w-full rounded-lg border bg-background px-4 py-3 text-foreground text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg~*]:pl-7 border-destructive/50 dark:border-destructive [&>svg]:text-destructive");
});
});

Expand All @@ -27,7 +25,7 @@ describe("AlertTitle", () => {
test("has correct default class names", () => {
render(<AlertTitle>Test Title</AlertTitle>);
const titleElement = screen.getByText("Test Title");
expect(titleElement.className).toContain("mb-1 font-medium leading-none");
expect(titleElement.className).toContain("mb-1 font-bold leading-none");
});

test("properly forwards classnames", () => {
Expand Down
10 changes: 4 additions & 6 deletions alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { type HTMLAttributes, forwardRef } from "react";
import { cn } from "./cn";

const alertVariants = cva(
"relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
"relative w-full rounded-lg border bg-background px-4 py-3 text-foreground text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
{
variants: {
variant: {
default: "bg-background text-foreground",
destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
default: "",
destructive: "border-destructive/50 dark:border-destructive [&>svg]:text-destructive",
},
},
defaultVariants: {
Expand All @@ -24,9 +24,7 @@ const Alert = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement> & Varian
);

const AlertTitle = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLHeadingElement>>(
({ className, ...rest }, ref) => (
<h3 ref={ref} className={cn("mb-1 font-medium leading-none", className)} {...rest} />
),
({ className, ...rest }, ref) => <h3 ref={ref} className={cn("mb-1 font-bold leading-none", className)} {...rest} />,
);

const AlertDescription = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLParagraphElement>>(
Expand Down
2 changes: 1 addition & 1 deletion badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { HTMLAttributes } from "react";
import { cn } from "./cn";

const badgeVariants = cva(
"inline-flex items-center rounded-md border px-2.5 py-0.5 font-semibold text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
"inline-flex items-center rounded-md border px-2.5 py-0.5 font-bold text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
{
variants: {
variant: {
Expand Down
2 changes: 1 addition & 1 deletion breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const BreadcrumbPage = forwardRef<HTMLLIElement, ComponentPropsWithoutRef<"li">>
role="link"
aria-disabled="true"
aria-current="page"
className={cn("font-normal text-foreground", className)}
className={cn("text-foreground", className)}
{...props}
/>
</li>
Expand Down
2 changes: 1 addition & 1 deletion button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type ButtonHTMLAttributes, type ReactElement, cloneElement, forwardRef
import { cn } from "./cn";

const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md font-medium text-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
"inline-flex items-center justify-center whitespace-nowrap rounded-md font-bold text-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
Expand Down
4 changes: 2 additions & 2 deletions card.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ describe("CardTitle", () => {
test("applies correct classes", () => {
render(<CardTitle />);
const cardTitleElement = screen.getByRole("heading");
expect(cardTitleElement).toHaveClass("font-semibold leading-none");
expect(cardTitleElement).toHaveClass("font-bold leading-none");
});

test("correctly applies additional classes", () => {
const additionalClass = "additional-class";
render(<CardTitle className={additionalClass} />);
const cardTitleElement = screen.getByRole("heading");
expect(cardTitleElement).toHaveClass("font-semibold leading-none", additionalClass);
expect(cardTitleElement).toHaveClass("font-bold leading-none", additionalClass);
});

test("correctly applies additional props", () => {
Expand Down
2 changes: 1 addition & 1 deletion card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const CardHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(({
));

const CardTitle = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLHeadingElement>>(
({ className, ...rest }, ref) => <h2 ref={ref} className={cn("font-semibold leading-none", className)} {...rest} />,
({ className, ...rest }, ref) => <h2 ref={ref} className={cn("font-bold leading-none", className)} {...rest} />,
);

const CardDescription = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLParagraphElement>>(
Expand Down
8 changes: 3 additions & 5 deletions chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ const ChartTooltipContent = forwardRef<
: itemConfig?.label;

if (labelFormatter) {
return <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>;
return <div className={labelClassName}>{labelFormatter(value, payload)}</div>;
}

if (!value) {
return null;
}

return <div className={cn("font-medium", labelClassName)}>{value}</div>;
return <div className={cn(labelClassName)}>{value}</div>;
}, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);

if (!active || !payload?.length) {
Expand Down Expand Up @@ -219,9 +219,7 @@ const ChartTooltipContent = forwardRef<
<span className="text-muted-foreground">{itemConfig?.label || item.name}</span>
</div>
{item.value && (
<span className="font-medium font-mono text-foreground tabular-nums">
{item.value.toLocaleString()}
</span>
<span className="font-mono text-foreground tabular-nums">{item.value.toLocaleString()}</span>
)}
</div>
</>
Expand Down
4 changes: 2 additions & 2 deletions command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const CommandDialog = ({ children, ...rest }: CommandDialogProps) => {
return (
<Dialog {...rest}>
<DialogContent className="overflow-hidden p-0">
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
{children}
</Command>
</DialogContent>
Expand Down Expand Up @@ -76,7 +76,7 @@ const CommandGroup = forwardRef<
<CommandPrimitive.Group
ref={ref}
className={cn(
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs",
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:text-xs",
className,
)}
{...rest}
Expand Down
2 changes: 1 addition & 1 deletion dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const DialogTitle = forwardRef<
<DialogPrimitive.Title
data-testid="dialog-title"
ref={ref}
className={cn("font-semibold text-lg leading-none", className)}
className={cn("font-bold text-lg leading-none", className)}
{...rest}
/>
));
Expand Down
2 changes: 1 addition & 1 deletion drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const DrawerTitle = forwardRef<
>(({ className, ...props }, ref) => (
<DrawerPrimitive.Title
ref={ref}
className={cn("font-semibold text-lg leading-none tracking-tight", className)}
className={cn("font-bold text-lg leading-none tracking-tight", className)}
{...props}
/>
));
Expand Down
2 changes: 1 addition & 1 deletion dropdown-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const DropdownMenuLabel = forwardRef<
>(({ className, inset, ...rest }, ref) => (
<DropdownMenuPrimitive.Label
ref={ref}
className={cn("px-2 py-1.5 font-semibold text-sm", inset && "pl-8", className)}
className={cn("px-2 py-1.5 font-bold text-sm", inset && "pl-8", className)}
{...rest}
/>
));
Expand Down
2 changes: 1 addition & 1 deletion form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const FormMessage = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLParagrap
<p
ref={ref}
id={formMessageId}
className={cn("animate-head-shake font-medium text-destructive text-xs", className)}
className={cn("animate-head-shake text-destructive text-xs", className)}
{...rest}
>
{body}
Expand Down
2 changes: 1 addition & 1 deletion input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
<input
type={type}
className={cn(
"peer flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors file:border-0 file:bg-transparent file:font-medium file:text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60",
"peer flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors file:border-0 file:bg-transparent file:text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60",
startIcon && "pl-9",
endIcon && "pr-9",
className,
Expand Down
2 changes: 1 addition & 1 deletion label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Label = forwardRef<ElementRef<typeof LabelPrimitive.Root>, ComponentPropsW
ref={ref}
data-testid="label"
className={cn(
"font-medium text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
"font-bold text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
className,
)}
{...rest}
Expand Down
Loading

0 comments on commit eeb5828

Please sign in to comment.