@@ -1388,4 +1388,77 @@ describe('DatasetsRepository', () => {
13881388 await expect ( sut . deleteDatasetDraft ( nonExistentTestDatasetId ) ) . rejects . toThrow ( expectedError )
13891389 } )
13901390 } )
1391+
1392+ describe ( 'linkDataset' , ( ) => {
1393+ let testDatasetIds : CreatedDatasetIdentifiers
1394+ const testCollectionAlias = 'testLinkDatasetCollection'
1395+
1396+ beforeAll ( async ( ) => {
1397+ testDatasetIds = await createDataset . execute ( TestConstants . TEST_NEW_DATASET_DTO )
1398+ await createCollectionViaApi ( testCollectionAlias )
1399+ } )
1400+
1401+ afterAll ( async ( ) => {
1402+ await deletePublishedDatasetViaApi ( testDatasetIds . persistentId )
1403+ await deleteCollectionViaApi ( testCollectionAlias )
1404+ } )
1405+
1406+ test ( 'should link a dataset to another collection' , async ( ) => {
1407+ const actual = await sut . linkDataset ( testDatasetIds . numericId , testCollectionAlias )
1408+
1409+ expect ( actual ) . toBeUndefined ( )
1410+
1411+ // TODO:ME - Once we get linked dataset collections use case assert that the collection exists
1412+ } )
1413+
1414+ test ( 'should return error when dataset does not exist' , async ( ) => {
1415+ await expect ( sut . linkDataset ( nonExistentTestDatasetId , testCollectionAlias ) ) . rejects . toThrow ( )
1416+ } )
1417+
1418+ test ( 'should return error when collection does not exist' , async ( ) => {
1419+ await expect (
1420+ sut . linkDataset ( testDatasetIds . numericId , 'nonExistentCollectionAlias' )
1421+ ) . rejects . toThrow ( )
1422+ } )
1423+ } )
1424+
1425+ describe ( 'unlinkDataset' , ( ) => {
1426+ let testDatasetIds : CreatedDatasetIdentifiers
1427+ const testCollectionAlias = 'testUnlinkDatasetCollection'
1428+
1429+ beforeAll ( async ( ) => {
1430+ testDatasetIds = await createDataset . execute ( TestConstants . TEST_NEW_DATASET_DTO )
1431+ await createCollectionViaApi ( testCollectionAlias )
1432+ } )
1433+
1434+ afterAll ( async ( ) => {
1435+ await deletePublishedDatasetViaApi ( testDatasetIds . persistentId )
1436+ await deleteCollectionViaApi ( testCollectionAlias )
1437+ } )
1438+
1439+ test ( 'should unlink a dataset from a collection' , async ( ) => {
1440+ await sut . linkDataset ( testDatasetIds . numericId , testCollectionAlias )
1441+ const actual = await sut . unlinkDataset ( testDatasetIds . numericId , testCollectionAlias )
1442+
1443+ expect ( actual ) . toBeUndefined ( )
1444+
1445+ // TODO:ME - Once we get linked dataset collections use case assert that the collection exists
1446+ } )
1447+
1448+ test ( 'should return error when dataset does not exist' , async ( ) => {
1449+ await expect ( sut . linkDataset ( nonExistentTestDatasetId , testCollectionAlias ) ) . rejects . toThrow ( )
1450+ } )
1451+
1452+ test ( 'should return error when collection does not exist' , async ( ) => {
1453+ await expect (
1454+ sut . linkDataset ( testDatasetIds . numericId , 'nonExistentCollectionAlias' )
1455+ ) . rejects . toThrow ( )
1456+ } )
1457+
1458+ test ( 'should return error when dataset is not linked to the collection' , async ( ) => {
1459+ await expect (
1460+ sut . unlinkDataset ( testDatasetIds . numericId , testCollectionAlias )
1461+ ) . rejects . toThrow ( )
1462+ } )
1463+ } )
13911464} )
0 commit comments