diff --git a/tests/AspectRatioColumns.test.svelte b/tests/AspectRatioColumns.test.svelte deleted file mode 100644 index ec03527a..00000000 --- a/tests/AspectRatioColumns.test.svelte +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - 2x1 - - - 2x1 - - - diff --git a/tests/Column/Column.test.svelte b/tests/Column/Column.test.svelte new file mode 100644 index 00000000..9c12aa05 --- /dev/null +++ b/tests/Column/Column.test.svelte @@ -0,0 +1,32 @@ + + + +
Column Content
+
diff --git a/tests/Column/Column.test.ts b/tests/Column/Column.test.ts new file mode 100644 index 00000000..99c1ac13 --- /dev/null +++ b/tests/Column/Column.test.ts @@ -0,0 +1,114 @@ +import { render, screen } from "@testing-library/svelte"; +import Column from "./Column.test.svelte"; + +describe("Column", () => { + it("should render with default props", () => { + render(Column); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass("bx--col"); + }); + + it("should render with custom element when as is true", () => { + render(Column, { props: { as: true } }); + const column = screen.getByTestId("content").parentElement!; + expect(column.tagName).toBe("DIV"); + }); + + describe("Gutter modifiers", () => { + it("should remove all gutters", () => { + render(Column, { props: { noGutter: true } }); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass("bx--no-gutter"); + }); + + it("should remove left gutter", () => { + render(Column, { props: { noGutterLeft: true } }); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass("bx--no-gutter--left"); + }); + + it("should remove right gutter", () => { + render(Column, { props: { noGutterRight: true } }); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass("bx--no-gutter--right"); + }); + }); + + it("should add padding", () => { + render(Column, { props: { padding: true } }); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass("bx--col-padding"); + }); + + describe("Aspect ratio", () => { + const ratios = ["2x1", "16x9", "9x16", "1x2", "4x3", "3x4", "1x1"] as const; + + ratios.forEach((ratio) => { + it(`should apply ${ratio} aspect ratio`, () => { + render(Column, { + props: { aspectRatio: ratio }, + }); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass( + `bx--aspect-ratio`, + `bx--aspect-ratio--${ratio}`, + ); + }); + }); + }); + + describe("Breakpoints", () => { + const breakpoints = ["sm", "md", "lg", "xlg", "max"] as const; + + breakpoints.forEach((bp) => { + it(`should handle boolean ${bp} breakpoint`, () => { + render(Column, { + props: { [bp]: true }, + }); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass(`bx--col-${bp}`); + }); + + it(`should handle numeric ${bp} breakpoint`, () => { + render(Column, { + props: { [bp]: 4 }, + }); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass(`bx--col-${bp}-4`); + }); + + it(`should handle object ${bp} breakpoint with span`, () => { + render(Column, { + props: { [bp]: { span: 4, offset: 2 } }, + }); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass(`bx--col-${bp}-4`, `bx--offset-${bp}-2`); + }); + + it(`should handle object ${bp} breakpoint with boolean span`, () => { + render(Column, { + props: { [bp]: { span: true, offset: 2 } }, + }); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass(`bx--col-${bp}`, `bx--offset-${bp}-2`); + }); + }); + }); + + it("should combine multiple breakpoint classes", () => { + render(Column, { + props: { + sm: 4, + md: { span: 6, offset: 2 }, + lg: true, + }, + }); + const column = screen.getByTestId("content").parentElement!; + expect(column).toHaveClass( + "bx--col-sm-4", + "bx--col-md-6", + "bx--offset-md-2", + "bx--col-lg", + ); + }); +}); diff --git a/tests/OffsetColumns.test.svelte b/tests/OffsetColumns.test.svelte deleted file mode 100644 index 3873576d..00000000 --- a/tests/OffsetColumns.test.svelte +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - Offset 3 - - - Offset 2 - - - Offset 1 - - - Offset 0 - - -