@@ -55,6 +55,9 @@ describe('ListViewComponent', () => {
5555 listView : {
5656 fields : [ ] ,
5757 } ,
58+ detailView : {
59+ fields : [ ] ,
60+ } ,
5861 } ,
5962 } ,
6063 } ) ) as any ;
@@ -128,6 +131,59 @@ describe('ListViewComponent', () => {
128131 expect ( navSpy ) . toHaveBeenCalledWith ( 'res1' ) ;
129132 } ) ;
130133
134+ it ( 'should not navigate when detailView is not defined' , ( ) => {
135+ const newFixture = TestBed . createComponent ( ListViewComponent ) ;
136+ const newComponent = newFixture . componentInstance ;
137+
138+ newComponent . context = ( ( ) => ( {
139+ resourceDefinition : {
140+ plural : 'clusters' ,
141+ kind : 'Cluster' ,
142+ group : 'core.k8s.io' ,
143+ ui : {
144+ listView : {
145+ fields : [ ] ,
146+ } ,
147+ } ,
148+ } ,
149+ } ) ) as any ;
150+
151+ const resource = { metadata : { name : 'res1' } } ;
152+ const navSpy = jest . fn ( ) ;
153+ newComponent . LuigiClient = ( ( ) => ( {
154+ linkManager : ( ) => ( {
155+ navigate : navSpy ,
156+ } ) ,
157+ } ) ) as any ;
158+
159+ newComponent . navigateToResource ( resource as any ) ;
160+ expect ( navSpy ) . not . toHaveBeenCalled ( ) ;
161+ } ) ;
162+
163+ it ( 'should not navigate when ui is not defined' , ( ) => {
164+ const newFixture = TestBed . createComponent ( ListViewComponent ) ;
165+ const newComponent = newFixture . componentInstance ;
166+
167+ newComponent . context = ( ( ) => ( {
168+ resourceDefinition : {
169+ plural : 'clusters' ,
170+ kind : 'Cluster' ,
171+ group : 'core.k8s.io' ,
172+ } ,
173+ } ) ) as any ;
174+
175+ const resource = { metadata : { name : 'res1' } } ;
176+ const navSpy = jest . fn ( ) ;
177+ newComponent . LuigiClient = ( ( ) => ( {
178+ linkManager : ( ) => ( {
179+ navigate : navSpy ,
180+ } ) ,
181+ } ) ) as any ;
182+
183+ newComponent . navigateToResource ( resource as any ) ;
184+ expect ( navSpy ) . not . toHaveBeenCalled ( ) ;
185+ } ) ;
186+
131187 it ( 'should open create resource modal' , ( ) => {
132188 const openSpy = jest . fn ( ) ;
133189 ( component as any ) . createModal = ( ) => ( { open : openSpy } ) ;
0 commit comments