11import { render , screen } from "@testing-library/react" ;
22import type { FC } from "react" ;
33import { describe , expect , it } from "vitest" ;
4+ import { Flowbite , type CustomFlowbiteTheme } from "../Flowbite" ;
45import type { TimelineProps } from "./Timeline" ;
56import { Timeline } from "./Timeline" ;
67
@@ -19,6 +20,26 @@ describe("Components / Timeline", () => {
1920 expect ( timelinePoint ( ) ) . toBeInTheDocument ( ) ;
2021 expect ( timelinePoint ( ) . childNodes [ 0 ] ) . toContainHTML ( "svg" ) ;
2122 } ) ;
23+
24+ it ( "should use `horizontal` classes of content if provided" , ( ) => {
25+ render (
26+ < Flowbite theme = { { theme } } >
27+ < TestTimelineNoIcon horizontal = { true } />
28+ </ Flowbite > ,
29+ ) ;
30+
31+ expect ( timelineContent ( ) ) . toHaveClass ( horizontalContentClass ) ;
32+ } ) ;
33+
34+ it ( "should not use `vertical` classes of content if provided" , ( ) => {
35+ render (
36+ < Flowbite theme = { { theme } } >
37+ < TestTimelineNoIcon horizontal = { true } />
38+ </ Flowbite > ,
39+ ) ;
40+
41+ expect ( timelineContent ( ) ) . not . toHaveClass ( verticalContentClass ) ;
42+ } ) ;
2243 } ) ;
2344 describe ( "Rendering vertical mode" , ( ) => {
2445 it ( "should have margin-top when do not icon" , ( ) => {
@@ -34,6 +55,47 @@ describe("Components / Timeline", () => {
3455 expect ( timelinePoint ( ) ) . toBeInTheDocument ( ) ;
3556 expect ( timelinePoint ( ) . childNodes [ 0 ] ) . toContainHTML ( "svg" ) ;
3657 } ) ;
58+
59+ it ( "should use `vertical` classes of content if provided" , ( ) => {
60+ render (
61+ < Flowbite theme = { { theme } } >
62+ < TestTimelineNoIcon />
63+ </ Flowbite > ,
64+ ) ;
65+
66+ expect ( timelineContent ( ) ) . toHaveClass ( verticalContentClass ) ;
67+ } ) ;
68+
69+ it ( "should not use `horizontal` classes of content if provided" , ( ) => {
70+ render (
71+ < Flowbite theme = { { theme } } >
72+ < TestTimelineNoIcon />
73+ </ Flowbite > ,
74+ ) ;
75+
76+ expect ( timelineContent ( ) ) . not . toHaveClass ( horizontalContentClass ) ;
77+ } ) ;
78+ } ) ;
79+ describe ( "Theme" , ( ) => {
80+ it ( "should use `base` classes of content in horizontal mode" , ( ) => {
81+ render (
82+ < Flowbite theme = { { theme } } >
83+ < TestTimelineNoIcon horizontal = { true } />
84+ </ Flowbite > ,
85+ ) ;
86+
87+ expect ( timelineContent ( ) ) . toHaveClass ( baseContentClass ) ;
88+ } ) ;
89+
90+ it ( "should use `base` classes of content in vertical mode" , ( ) => {
91+ render (
92+ < Flowbite theme = { { theme } } >
93+ < TestTimelineNoIcon />
94+ </ Flowbite > ,
95+ ) ;
96+
97+ expect ( timelineContent ( ) ) . toHaveClass ( baseContentClass ) ;
98+ } ) ;
3799 } ) ;
38100} ) ;
39101
@@ -92,3 +154,22 @@ const IconSVG = () => (
92154) ;
93155
94156const timelinePoint = ( ) => screen . getByTestId ( "timeline-point" ) ;
157+ const timelineContent = ( ) => screen . getByTestId ( "timeline-content" ) ;
158+
159+ const baseContentClass = "dummy-base-content" ;
160+ const verticalContentClass = "dummy-vertical-content" ;
161+ const horizontalContentClass = "dummy-horizontal-content" ;
162+
163+ const theme : CustomFlowbiteTheme = {
164+ timeline : {
165+ item : {
166+ content : {
167+ root : {
168+ base : baseContentClass ,
169+ vertical : verticalContentClass ,
170+ horizontal : horizontalContentClass ,
171+ } ,
172+ } ,
173+ } ,
174+ } ,
175+ } ;
0 commit comments