diff --git a/tests/Truncate.test.svelte b/tests/Truncate.test.svelte
deleted file mode 100644
index 64f4049e..00000000
--- a/tests/Truncate.test.svelte
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- Carbon Components Svelte is a Svelte component library that implements the
- Carbon Design System, an open source design system by IBM.
-
-
-
- Carbon Components Svelte is a Svelte component library that implements the
- Carbon Design System, an open source design system by IBM.
-
-
-
- Carbon Components Svelte is a Svelte component library that implements the
- Carbon Design System, an open source design system by IBM.
-
-
- Carbon Components Svelte is a Svelte component library that implements the
- Carbon Design System, an open source design system by IBM.
-
diff --git a/tests/Truncate/Truncate.test.svelte b/tests/Truncate/Truncate.test.svelte
new file mode 100644
index 00000000..d9aee792
--- /dev/null
+++ b/tests/Truncate/Truncate.test.svelte
@@ -0,0 +1,11 @@
+
+
+
+ {text}
+
diff --git a/tests/Truncate/Truncate.test.ts b/tests/Truncate/Truncate.test.ts
new file mode 100644
index 00000000..b5f7b758
--- /dev/null
+++ b/tests/Truncate/Truncate.test.ts
@@ -0,0 +1,90 @@
+import { render, screen } from "@testing-library/svelte";
+import Truncate from "./Truncate.test.svelte";
+import TruncateAction from "./TruncateAction.test.svelte";
+
+describe("Truncate", () => {
+ describe("component", () => {
+ test.each([
+ ["end", "bx--text-truncate--end"],
+ ["front", "bx--text-truncate--front"],
+ ] as const)("should support %s clamp", (clamp, expectedClass) => {
+ render(Truncate, { props: { clamp } });
+
+ const element = screen.getByText(/This is a long text/);
+ expect(element).toHaveClass(expectedClass);
+ });
+
+ it("should render text content", () => {
+ const text = "Custom text content";
+ render(Truncate, { props: { text } });
+
+ expect(screen.getByText(text)).toBeInTheDocument();
+ });
+
+ it("should render as paragraph element", () => {
+ render(Truncate);
+
+ const element = screen.getByText(/This is a long text/);
+ expect(element.tagName).toBe("P");
+ });
+
+ it("should default to end clamp", () => {
+ render(Truncate);
+
+ const element = screen.getByText(/This is a long text/);
+ expect(element).toHaveClass("bx--text-truncate--end");
+ });
+ });
+
+ describe("action", () => {
+ test.each([
+ ["end", "bx--text-truncate--end"],
+ ["front", "bx--text-truncate--front"],
+ ] as const)("should support %s clamp", (clamp, expectedClass) => {
+ render(TruncateAction, { props: { clamp } });
+
+ const element = screen.getByText(/This is a long text/);
+ expect(element).toHaveClass(expectedClass);
+ });
+
+ test.each([
+ ["h1", "H1"],
+ ["h2", "H2"],
+ ["h3", "H3"],
+ ["h4", "H4"],
+ ["p", "P"],
+ ["span", "SPAN"],
+ ] as const)("should work with %s element", (elementType, expectedTag) => {
+ render(TruncateAction, { props: { element: elementType } });
+
+ const element = screen.getByText(/This is a long text/);
+ expect(element.tagName).toBe(expectedTag);
+ expect(element).toHaveClass("bx--text-truncate--end");
+ });
+
+ it("should preserve existing classes", () => {
+ render(TruncateAction, {
+ props: {
+ element: "p",
+ text: "Test",
+ },
+ });
+
+ const element = screen.getByText("Test");
+ element.classList.add("custom-class");
+
+ // Trigger update
+ element.dispatchEvent(new Event("update"));
+
+ expect(element).toHaveClass("custom-class");
+ expect(element).toHaveClass("bx--text-truncate--end");
+ });
+
+ it("should default to end clamp", () => {
+ render(TruncateAction);
+
+ const element = screen.getByText(/This is a long text/);
+ expect(element).toHaveClass("bx--text-truncate--end");
+ });
+ });
+});
diff --git a/tests/Truncate/TruncateAction.test.svelte b/tests/Truncate/TruncateAction.test.svelte
new file mode 100644
index 00000000..fe2d8b50
--- /dev/null
+++ b/tests/Truncate/TruncateAction.test.svelte
@@ -0,0 +1,22 @@
+
+
+{#if element === "h1"}
+ {text}
+{:else if element === "h2"}
+ {text}
+{:else if element === "h3"}
+ {text}
+{:else if element === "h4"}
+ {text}
+{:else if element === "span"}
+ {text}
+{:else}
+ {text}
+{/if}