Open History to see the last commit
1import { renderToStaticMarkup } from "react-dom/server";
2import { describe, expect, it } from "vitest";
3
4import {
5 SidebarMenuAction,
6 SidebarMenuButton,
7 SidebarMenuSubButton,
8 SidebarProvider,
9} from "./sidebar";
10
11function renderSidebarButton(className?: string) {
12 return renderToStaticMarkup(
13 <SidebarProvider>
14 <SidebarMenuButton className={className}>Projects</SidebarMenuButton>
15 </SidebarProvider>,
16 );
17}
18
19describe("sidebar interactive cursors", () => {
20 it("uses a pointer cursor for menu buttons by default", () => {
21 const html = renderSidebarButton();
22
23 expect(html).toContain('data-slot="sidebar-menu-button"');
24 expect(html).toContain("cursor-pointer");
25 });
26
27 it("lets project drag handles override the default pointer cursor", () => {
28 const html = renderSidebarButton("cursor-grab");
29
30 expect(html).toContain("cursor-grab");
31 expect(html).not.toContain("cursor-pointer");
32 });
33
34 it("uses a pointer cursor for menu actions", () => {
35 const html = renderToStaticMarkup(
36 <SidebarMenuAction aria-label="Create thread">
37 <span>+</span>
38 </SidebarMenuAction>,
39 );
40
41 expect(html).toContain('data-slot="sidebar-menu-action"');
42 expect(html).toContain("cursor-pointer");
43 });
44
45 it("uses a pointer cursor for submenu buttons", () => {
46 const html = renderToStaticMarkup(
47 <SidebarMenuSubButton render={<button type="button" />}>Show more</SidebarMenuSubButton>,
48 );
49
50 expect(html).toContain('data-slot="sidebar-menu-sub-button"');
51 expect(html).toContain("cursor-pointer");
52 });
53});