@@ -1408,7 +1408,8 @@ describe('DatasetsRepository', () => {
14081408
14091409 expect ( actual ) . toBeUndefined ( )
14101410
1411- // TODO:ME - Once we get linked dataset collections use case assert that the collection exists
1411+ const linkedCollections = await sut . getDatasetLinkedCollections ( testDatasetIds . numericId )
1412+ expect ( linkedCollections [ 0 ] . alias ) . toBe ( testCollectionAlias )
14121413 } )
14131414
14141415 test ( 'should return error when dataset does not exist' , async ( ) => {
@@ -1438,11 +1439,16 @@ describe('DatasetsRepository', () => {
14381439
14391440 test ( 'should unlink a dataset from a collection' , async ( ) => {
14401441 await sut . linkDataset ( testDatasetIds . numericId , testCollectionAlias )
1442+ const linkedCollections = await sut . getDatasetLinkedCollections ( testDatasetIds . numericId )
1443+ expect ( linkedCollections [ 0 ] . alias ) . toBe ( testCollectionAlias )
1444+
14411445 const actual = await sut . unlinkDataset ( testDatasetIds . numericId , testCollectionAlias )
14421446
14431447 expect ( actual ) . toBeUndefined ( )
1444-
1445- // TODO:ME - Once we get linked dataset collections use case assert that the collection exists
1448+ const updatedLinkedCollections = await sut . getDatasetLinkedCollections (
1449+ testDatasetIds . numericId
1450+ )
1451+ expect ( updatedLinkedCollections . length ) . toBe ( 0 )
14461452 } )
14471453
14481454 test ( 'should return error when dataset does not exist' , async ( ) => {
@@ -1461,4 +1467,38 @@ describe('DatasetsRepository', () => {
14611467 ) . rejects . toThrow ( )
14621468 } )
14631469 } )
1470+
1471+ describe ( 'getDatasetLinkedCollections' , ( ) => {
1472+ let testDatasetIds : CreatedDatasetIdentifiers
1473+ const testCollectionAlias = 'testGetLinkedCollections'
1474+
1475+ beforeAll ( async ( ) => {
1476+ testDatasetIds = await createDataset . execute ( TestConstants . TEST_NEW_DATASET_DTO )
1477+ await createCollectionViaApi ( testCollectionAlias )
1478+ } )
1479+
1480+ afterAll ( async ( ) => {
1481+ await deletePublishedDatasetViaApi ( testDatasetIds . persistentId )
1482+ await deleteCollectionViaApi ( testCollectionAlias )
1483+ } )
1484+
1485+ test ( 'should return empty array when no collections are linked' , async ( ) => {
1486+ const linkedCollections = await sut . getDatasetLinkedCollections ( testDatasetIds . numericId )
1487+
1488+ expect ( linkedCollections . length ) . toBe ( 0 )
1489+ } )
1490+
1491+ test ( 'should return linked collections for a dataset' , async ( ) => {
1492+ await sut . linkDataset ( testDatasetIds . numericId , testCollectionAlias )
1493+
1494+ const linkedCollections = await sut . getDatasetLinkedCollections ( testDatasetIds . numericId )
1495+
1496+ expect ( linkedCollections . length ) . toBe ( 1 )
1497+ expect ( linkedCollections [ 0 ] . alias ) . toBe ( testCollectionAlias )
1498+ } )
1499+
1500+ test ( 'should return error when dataset does not exist' , async ( ) => {
1501+ await expect ( sut . getDatasetLinkedCollections ( nonExistentTestDatasetId ) ) . rejects . toThrow ( )
1502+ } )
1503+ } )
14641504} )
0 commit comments