File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
packages/devextreme/js/__internal/grids/new/card_view/content_view/content/card Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -107,15 +107,30 @@ describe('Card Header', () => {
107107 } ) ;
108108} ) ;
109109
110- describe ( 'Image ' , ( ) => {
111- it ( 'should render the image correctly ' , ( ) => {
110+ describe ( 'Cover ' , ( ) => {
111+ it ( 'should be rendered ' , ( ) => {
112112 const container = document . createElement ( 'div' ) ;
113113 // @ts -expect-error
114114 render ( < Card { ...props } /> , container ) ;
115115
116116 const image = container . querySelector ( 'img' ) ;
117117 expect ( image ) . not . toBeNull ( ) ;
118118 } ) ;
119+
120+ it ( 'should be rendered if imageExpr is not defined but template is defined' , ( ) => {
121+ const container = document . createElement ( 'div' ) ;
122+ const localProps = {
123+ ...props ,
124+ cover : {
125+ template : ( ) => < img className = 'myTemplate' /> ,
126+ } ,
127+ } ;
128+
129+ // @ts -expect-error
130+ render ( < Card { ...localProps } /> , container ) ;
131+
132+ expect ( container . querySelector ( '.myTemplate' ) ) . toBeTruthy ( ) ;
133+ } ) ;
119134} ) ;
120135
121136describe ( 'Field Template' , ( ) => {
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ export class Card extends Component<CardProps> {
144144 [ CLASSES . selectCard ] : ! ! card . isSelected ,
145145 } ) ;
146146
147- const hasCover = ! ! cover ?. imageExpr ;
147+ const hasCover = ! ! cover ?. imageExpr || ! ! cover ?. template ;
148148
149149 const imageSrc = cover ?. imageExpr ?.( this . props . card . data ) ;
150150 const alt = cover ?. altExpr ?.( this . props . card . data ) ;
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export class Cover extends Component<CoverProps> {
2828
2929 const containerClasses = combineClasses ( {
3030 [ CLASSES . cover ] : true ,
31- [ CLASSES . noImage ] : ! src ,
31+ [ CLASSES . noImage ] : ! src && ! Template ,
3232 } ) ;
3333
3434 return (
You can’t perform that action at this time.
0 commit comments