@@ -2,6 +2,7 @@ import { DatasetCard } from '@/sections/collection/collection-items-panel/items-
22import { DatasetItemTypePreviewMother } from '@tests/component/dataset/domain/models/DatasetItemTypePreviewMother'
33import { DateHelper } from '@/shared/helpers/DateHelper'
44import styles from '@/sections/collection/collection-items-panel/items-list/dataset-card/DatasetCard.module.scss'
5+ import { Route } from '@/sections/Route.enum'
56
67describe ( 'DatasetCard' , ( ) => {
78 it ( 'should render the card' , ( ) => {
@@ -55,4 +56,32 @@ describe('DatasetCard', () => {
5556 . parent ( )
5657 . should ( 'have.class' , styles [ 'deaccesioned' ] )
5758 } )
59+
60+ describe ( 'Parent Collection Link' , ( ) => {
61+ it ( 'should render it if parentCollectionAlias is not the one where the dataset card is being shown' , ( ) => {
62+ const dataset = DatasetItemTypePreviewMother . create ( {
63+ parentCollectionAlias : 'parent-collection-alias' ,
64+ parentCollectionName : 'Parent Collection Name'
65+ } )
66+ cy . customMount (
67+ < DatasetCard datasetPreview = { dataset } parentCollectionAlias = "another-collection-alias" />
68+ )
69+
70+ cy . findByText ( 'Parent Collection Name' )
71+ . should ( 'exist' )
72+ . should ( 'have.attr' , 'href' , `${ Route . COLLECTIONS_BASE } /parent-collection-alias` )
73+ } )
74+
75+ it ( 'should not render it if parentCollectionAlias is the same as the one where the dataset card is being shown' , ( ) => {
76+ const dataset = DatasetItemTypePreviewMother . create ( {
77+ parentCollectionAlias : 'parent-collection-alias' ,
78+ parentCollectionName : 'Parent Collection Name'
79+ } )
80+ cy . customMount (
81+ < DatasetCard datasetPreview = { dataset } parentCollectionAlias = "parent-collection-alias" />
82+ )
83+
84+ cy . findByText ( 'Parent Collection Name' ) . should ( 'not.exist' )
85+ } )
86+ } )
5887} )
0 commit comments