@@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react-native';
33import { AlertCircle , FileX } from 'lucide-react-native' ;
44import React from 'react' ;
55
6- import { Button } from '@/components/ui/button' ;
6+ import { Button , ButtonText } from '@/components/ui/button' ;
77
88import ZeroState from '../common/zero-state' ;
99
@@ -36,4 +36,75 @@ describe('ZeroState', () => {
3636 expect ( screen . getByText ( 'Connection failed' ) ) . toBeTruthy ( ) ;
3737 expect ( screen . getByText ( 'Check your internet connection' ) ) . toBeTruthy ( ) ;
3838 } ) ;
39+
40+ it ( 'applies custom View className' , ( ) => {
41+ const { getByTestId } = render (
42+ < ZeroState viewClassName = "custom-view-class bg-red-100" />
43+ ) ;
44+
45+ const zeroStateContainer = getByTestId ( 'zero-state' ) ;
46+ expect ( zeroStateContainer . parent ) . toBeTruthy ( ) ;
47+ } ) ;
48+
49+ it ( 'applies custom Center className' , ( ) => {
50+ const { getByTestId } = render (
51+ < ZeroState centerClassName = "custom-center-class bg-blue-100" />
52+ ) ;
53+
54+ const zeroStateElement = getByTestId ( 'zero-state' ) ;
55+ expect ( zeroStateElement ) . toBeTruthy ( ) ;
56+ } ) ;
57+
58+ it ( 'combines centerClassName with additional className' , ( ) => {
59+ const { getByTestId } = render (
60+ < ZeroState
61+ centerClassName = "custom-center-class"
62+ className = "additional-class"
63+ />
64+ ) ;
65+
66+ const zeroStateElement = getByTestId ( 'zero-state' ) ;
67+ expect ( zeroStateElement ) . toBeTruthy ( ) ;
68+ } ) ;
69+
70+ it ( 'renders with children' , ( ) => {
71+ render (
72+ < ZeroState >
73+ < Button onPress = { ( ) => { } } >
74+ < ButtonText > Retry</ ButtonText >
75+ </ Button >
76+ </ ZeroState >
77+ ) ;
78+
79+ expect ( screen . getByText ( 'Retry' ) ) . toBeTruthy ( ) ;
80+ } ) ;
81+
82+ it ( 'uses error state defaults when isError is true' , ( ) => {
83+ render ( < ZeroState isError /> ) ;
84+
85+ expect ( screen . getByText ( 'An error occurred' ) ) . toBeTruthy ( ) ;
86+ expect ( screen . getByText ( 'Please try again later' ) ) . toBeTruthy ( ) ;
87+ } ) ;
88+
89+ it ( 'overrides error state defaults with custom text' , ( ) => {
90+ render (
91+ < ZeroState
92+ isError
93+ heading = "Custom error title"
94+ description = "Custom error description"
95+ />
96+ ) ;
97+
98+ expect ( screen . getByText ( 'Custom error title' ) ) . toBeTruthy ( ) ;
99+ expect ( screen . getByText ( 'Custom error description' ) ) . toBeTruthy ( ) ;
100+ } ) ;
101+
102+ it ( 'applies default classNames when not provided' , ( ) => {
103+ const { getByTestId } = render ( < ZeroState /> ) ;
104+
105+ const zeroStateElement = getByTestId ( 'zero-state' ) ;
106+ expect ( zeroStateElement ) . toBeTruthy ( ) ;
107+ // The default centerClassName should be applied
108+ expect ( zeroStateElement . parent ) . toBeTruthy ( ) ;
109+ } ) ;
39110} ) ;
0 commit comments