1
1
import { render , screen } from "@testing-library/react" ;
2
2
import type { FC } from "react" ;
3
3
import { describe , expect , it } from "vitest" ;
4
+ import { Flowbite , type CustomFlowbiteTheme } from "../Flowbite" ;
4
5
import type { TimelineProps } from "./Timeline" ;
5
6
import { Timeline } from "./Timeline" ;
6
7
@@ -19,6 +20,26 @@ describe("Components / Timeline", () => {
19
20
expect ( timelinePoint ( ) ) . toBeInTheDocument ( ) ;
20
21
expect ( timelinePoint ( ) . childNodes [ 0 ] ) . toContainHTML ( "svg" ) ;
21
22
} ) ;
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
+ } ) ;
22
43
} ) ;
23
44
describe ( "Rendering vertical mode" , ( ) => {
24
45
it ( "should have margin-top when do not icon" , ( ) => {
@@ -34,6 +55,47 @@ describe("Components / Timeline", () => {
34
55
expect ( timelinePoint ( ) ) . toBeInTheDocument ( ) ;
35
56
expect ( timelinePoint ( ) . childNodes [ 0 ] ) . toContainHTML ( "svg" ) ;
36
57
} ) ;
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
+ } ) ;
37
99
} ) ;
38
100
} ) ;
39
101
@@ -92,3 +154,22 @@ const IconSVG = () => (
92
154
) ;
93
155
94
156
const 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