File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed
Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 1+ import { render , screen , within } from '@testing-library/react-native' ;
2+ import React from 'react' ;
3+
4+ import { colors } from '@/ui' ;
5+
6+ import { Colors } from './colors' ;
7+
8+ describe ( 'Colors component' , ( ) => {
9+ it ( 'should render the Title component' , ( ) => {
10+ render ( < Colors /> ) ;
11+ expect ( screen . getByText ( 'Colors' ) ) . toBeTruthy ( ) ;
12+ } ) ;
13+
14+ it ( 'should render Color components for each color group' , ( ) => {
15+ render ( < Colors /> ) ;
16+ const colorNames = Object . keys ( colors ) as ( keyof typeof colors ) [ ] ;
17+
18+ colorNames . forEach ( ( name : keyof typeof colors ) => {
19+ if ( typeof colors [ name ] !== 'string' ) {
20+ const colorTextLabel = screen . getByText ( name . toUpperCase ( ) ) ;
21+ expect ( colorTextLabel ) . toBeTruthy ( ) ;
22+ const list = screen . getByTestId ( `color-list-${ name } ` ) ;
23+
24+ Object . entries ( colors [ name ] ) . forEach ( ( [ color ] ) => {
25+ within ( list ) . getByText ( color ) ;
26+ } ) ;
27+ }
28+ } ) ;
29+ } ) ;
30+ } ) ;
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ const Color = ({ name }: { name: ColorName }) => {
2222 return null ;
2323 }
2424 return (
25- < View className = "pt-2" >
25+ < View className = "pt-2" testID = { `color-list- ${ name } ` } >
2626 < Text className = "font-medium" > { name . toUpperCase ( ) } </ Text >
2727 < View className = "flex-row flex-wrap content-between justify-around " >
2828 { Object . entries ( colors [ name ] ) . map ( ( [ key , value ] ) => {
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { useColorScheme } from 'nativewind';
77
88import colors from '@/ui/colors' ;
99
10- const DarkTheme : Theme = {
10+ export const DarkTheme : Theme = {
1111 ..._DarkTheme ,
1212 colors : {
1313 ..._DarkTheme . colors ,
@@ -19,7 +19,7 @@ const DarkTheme: Theme = {
1919 } ,
2020} ;
2121
22- const LightTheme : Theme = {
22+ export const LightTheme : Theme = {
2323 ...DefaultTheme ,
2424 colors : {
2525 ...DefaultTheme . colors ,
You can’t perform that action at this time.
0 commit comments