@@ -145,7 +145,7 @@ describe('MetadataContainerComponent', () => {
145145 } ) ;
146146
147147 const mockBitstreamDataService = jasmine . createSpyObj ( 'BitstreamDataService' , {
148- findAllByItemAndBundleName : jasmine . createSpy ( 'findAllByItemAndBundleName ' )
148+ findShowableBitstreamsByItem : jasmine . createSpy ( 'findShowableBitstreamsByItem ' )
149149 } ) ;
150150
151151 beforeEach ( async ( ) => {
@@ -172,7 +172,10 @@ describe('MetadataContainerComponent', () => {
172172 component = fixture . componentInstance ;
173173 component . item = testItem ;
174174 component . box = boxMetadata ;
175- mockBitstreamDataService . findAllByItemAndBundleName . and . returnValue ( createSuccessfulRemoteDataObject$ ( createPaginatedList ( [ ] ) ) ) ;
175+
176+ mockBitstreamDataService . findShowableBitstreamsByItem . and . returnValue (
177+ createSuccessfulRemoteDataObject$ ( createPaginatedList ( [ ] ) )
178+ ) ;
176179 } ) ;
177180
178181 describe ( 'When field rendering type is not structured' , ( ) => {
@@ -283,15 +286,15 @@ describe('MetadataContainerComponent', () => {
283286 describe ( 'and item has bitstream' , ( ) => {
284287
285288 beforeEach ( ( ) => {
286- mockBitstreamDataService . findAllByItemAndBundleName . and . returnValue ( createSuccessfulRemoteDataObject$ ( createPaginatedList ( [ bitstream1 ] ) ) ) ;
289+ mockBitstreamDataService . findShowableBitstreamsByItem . and . returnValue ( createSuccessfulRemoteDataObject$ ( createPaginatedList ( [ bitstream1 ] ) ) ) ;
287290 fixture . detectChanges ( ) ;
288291 } ) ;
289292
290293 it ( 'should create' , ( ) => {
291294 expect ( component ) . toBeTruthy ( ) ;
292295 } ) ;
293296
294- it ( 'should not render metadata ' , ( done ) => {
297+ it ( 'should render metadata ' , ( done ) => {
295298 const spanValueFound = fixture . debugElement . queryAll ( By . css ( '.test-style-label' ) ) ;
296299 expect ( spanValueFound . length ) . toBe ( 1 ) ;
297300
@@ -301,6 +304,35 @@ describe('MetadataContainerComponent', () => {
301304 } ) ;
302305 } ) ;
303306
307+ describe ( 'and bitstream has metadata' , ( ) => {
308+ beforeEach ( ( ) => {
309+ component . field . bitstream . metadataField = 'metadataFieldTest' ;
310+ component . field . bitstream . metadataValue = 'metadataValueTest' ;
311+ fixture . detectChanges ( ) ;
312+ } ) ;
313+
314+ it ( 'should use the metadata in filters' , ( ) => {
315+ expect ( mockBitstreamDataService . findShowableBitstreamsByItem ) . toHaveBeenCalledWith (
316+ testItem . uuid ,
317+ bitstreamField . bitstream . bundle ,
318+ [ { metadataName : 'metadataFieldTest' , metadataValue : 'metadataValueTest' } ]
319+ ) ;
320+ } ) ;
321+ } ) ;
322+
323+ describe ( 'and bitstream doesnt have metadataValue' , ( ) => {
324+ beforeEach ( ( ) => {
325+ component . field . bitstream . metadataValue = undefined ;
326+ fixture . detectChanges ( ) ;
327+ } ) ;
328+
329+ it ( 'should use empty array in filters' , ( ) => {
330+ expect ( mockBitstreamDataService . findShowableBitstreamsByItem ) . toHaveBeenCalledWith (
331+ testItem . uuid ,
332+ bitstreamField . bitstream . bundle ,
333+ [ ] // <--- empty array of filters
334+ ) ;
335+ } ) ;
336+ } ) ;
304337 } ) ;
305- } )
306- ;
338+ } ) ;
0 commit comments