|
1
|
import React from "react" |
|
2
|
import { beforeEach, describe, expect, test, vi } from "vitest" |
|
3
|
import { render } from "@testing-library/react" |
|
4
|
|
|
5
|
// mock components |
|
6
|
vi.mock("@/components/CopyButton", () => ({ |
|
7
|
CopyButton: ({ children }: { children: React.ReactNode }) => ( |
|
8
|
<div data-testid="copy-button">{children}</div> |
|
9
|
), |
|
10
|
})) |
|
11
|
|
|
12
|
import { InlineCode } from "../../InlineCode" |
|
13
|
|
|
14
|
describe("rendering", () => { |
|
15
|
test("renders default variant", () => { |
|
16
|
const { container } = render(<InlineCode>Test</InlineCode>) |
|
17
|
const code = container.querySelector("code") |
|
18
|
expect(code).toBeInTheDocument() |
|
19
|
expect(code).toHaveTextContent("Test") |
|
20
|
expect(code).toHaveClass( |
|
21
|
"bg-medusa-tag-neutral-bg group-hover:bg-medusa-tag-neutral-bg-hover group-active:bg-medusa-bg-subtle-pressed group-focus:bg-medusa-bg-subtle-pressed border-medusa-tag-neutral-border" |
|
22
|
) |
|
23
|
}) |
|
24
|
|
|
25
|
test("renders grey-bg variant", () => { |
|
26
|
const { container } = render( |
|
27
|
<InlineCode variant="grey-bg">Test</InlineCode> |
|
28
|
) |
|
29
|
const code = container.querySelector("code") |
|
30
|
expect(code).toBeInTheDocument() |
|
31
|
expect(code).toHaveTextContent("Test") |
|
32
|
expect(code).toHaveClass( |
|
33
|
"bg-medusa-bg-switch-off group-hover:bg-medusa-bg-switch-off-hover group-active:bg-medusa-bg-switch-off-hover group-focus:bg-medusa-switch-off-hover border-medusa-border-strong" |
|
34
|
) |
|
35
|
}) |
|
36
|
}) |