@@ -691,6 +691,76 @@ describe('FilesRepository', () => {
691691 } )
692692 } )
693693
694+ describe ( 'updateFileTabularTags' , ( ) => {
695+ test ( 'should add a new file tabularTags' , async ( ) => {
696+ const datasetFiles = await sut . getDatasetFiles (
697+ testDatasetIds . persistentId ,
698+ latestDatasetVersionId ,
699+ false ,
700+ FileOrderCriteria . NAME_AZ
701+ )
702+ const tabularDatasetId = datasetFiles . files [ 3 ] . id
703+ const tag = [ 'Survey' ]
704+
705+ const actual = await sut . updateFileTabularTags ( tabularDatasetId , tag )
706+
707+ expect ( actual ) . toBeUndefined ( )
708+ } )
709+
710+ test ( 'should replace file tabular Tags to new' , async ( ) => {
711+ const datasetFiles = await sut . getDatasetFiles (
712+ testDatasetIds . persistentId ,
713+ latestDatasetVersionId ,
714+ false ,
715+ FileOrderCriteria . NAME_AZ
716+ )
717+ const tabularDatasetId = datasetFiles . files [ 3 ] . id
718+ const tag = [ 'Survey' ]
719+
720+ const actual = await sut . updateFileTabularTags ( tabularDatasetId , tag , true )
721+
722+ expect ( actual ) . toBeUndefined ( )
723+ } )
724+
725+ test ( 'should return error when file does not exist' , async ( ) => {
726+ const tag = [ 'Data' ]
727+
728+ const errorExpected = new WriteError ( `[404] File with ID ${ nonExistentFiledId } not found.` )
729+
730+ await expect ( sut . updateFileCategories ( nonExistentFiledId , tag , false ) ) . rejects . toThrow (
731+ errorExpected
732+ )
733+ } )
734+ } )
735+
736+ describe ( 'updateFileCategories' , ( ) => {
737+ test ( 'should update file categories when file exists' , async ( ) => {
738+ const categories = [ 'Data' ]
739+
740+ const actual = await sut . updateFileCategories ( testFileId , categories )
741+
742+ expect ( actual ) . toBeUndefined ( )
743+ } )
744+
745+ test ( 'should replace file categories when file exists' , async ( ) => {
746+ const categories = [ 'Data' ]
747+
748+ const actual = await sut . updateFileCategories ( testFileId , categories , true )
749+
750+ expect ( actual ) . toBeUndefined ( )
751+ } )
752+
753+ test ( 'should return error when file does not exist' , async ( ) => {
754+ const categories = [ 'Data' ]
755+
756+ const errorExpected = new WriteError ( `[404] File with ID ${ nonExistentFiledId } not found.` )
757+
758+ await expect ( sut . updateFileCategories ( nonExistentFiledId , categories , false ) ) . rejects . toThrow (
759+ errorExpected
760+ )
761+ } )
762+ } )
763+
694764 describe ( 'deleteFile' , ( ) => {
695765 let deleFileTestDatasetIds : CreatedDatasetIdentifiers
696766 const testTextFile1Name = 'test-file-1.txt'
0 commit comments