@@ -534,41 +534,6 @@ describe('FilesRepository', () => {
534534 } )
535535 } )
536536
537- describe ( 'updateFileMetadata' , ( ) => {
538- test ( 'should return error when file does not exist' , async ( ) => {
539- const testFileMetadata = {
540- description : 'My description bbb.' ,
541- categories : [ 'Data' ] ,
542- restrict : false
543- }
544- const errorExpected = new WriteError ( `[400] Error attempting get the requested data file.` )
545-
546- await expect ( sut . updateFileMetadata ( nonExistentFiledId , testFileMetadata ) ) . rejects . toThrow (
547- errorExpected
548- )
549- } )
550-
551- test ( 'should update file metadata when file exists' , async ( ) => {
552- const getDatasetFilesResponse = await sut . getDatasetFiles (
553- testDatasetIds . numericId ,
554- latestDatasetVersionId ,
555- false ,
556- FileOrderCriteria . NAME_AZ
557- )
558-
559- const fileId = getDatasetFilesResponse . files [ 0 ] . id
560- const testFileMetadata = {
561- description : 'My description bbb.' ,
562- categories : [ 'Data' ] ,
563- restrict : false
564- }
565-
566- const actual = await sut . updateFileMetadata ( fileId , testFileMetadata )
567-
568- expect ( actual ) . toBeUndefined ( )
569- } )
570- } )
571-
572537 describe ( 'getFileCitation' , ( ) => {
573538 test ( 'should return citation when file exists' , async ( ) => {
574539 const actualFileCitation = await sut . getFileCitation (
@@ -682,6 +647,43 @@ describe('FilesRepository', () => {
682647 } )
683648 } )
684649
650+ describe ( 'updateFileMetadata' , ( ) => {
651+ test ( 'should update file metadata when file exists' , async ( ) => {
652+ const testFileMetadata = {
653+ description : 'My description test.' ,
654+ categories : [ 'Data' ] ,
655+ restrict : false
656+ }
657+
658+ const actual = await sut . updateFileMetadata ( testFileId , testFileMetadata )
659+
660+ expect ( actual ) . toBeUndefined ( )
661+
662+ const fileInfo : FileModel = ( await sut . getFile (
663+ testFileId ,
664+ DatasetNotNumberedVersion . LATEST ,
665+ false
666+ ) ) as FileModel
667+
668+ expect ( fileInfo . description ) . toBe ( testFileMetadata . description )
669+ expect ( fileInfo . categories ) . toEqual ( testFileMetadata . categories )
670+ expect ( fileInfo . restricted ) . toBe ( testFileMetadata . restrict )
671+ } )
672+
673+ test ( 'should return error when file does not exist' , async ( ) => {
674+ const testFileMetadata = {
675+ description : 'My description test.' ,
676+ categories : [ 'Data' ] ,
677+ restrict : false
678+ }
679+ const errorExpected = new WriteError ( `[400] Error attempting get the requested data file.` )
680+
681+ await expect ( sut . updateFileMetadata ( nonExistentFiledId , testFileMetadata ) ) . rejects . toThrow (
682+ errorExpected
683+ )
684+ } )
685+ } )
686+
685687 describe ( 'deleteFile' , ( ) => {
686688 let deleFileTestDatasetIds : CreatedDatasetIdentifiers
687689 const testTextFile1Name = 'test-file-1.txt'
@@ -889,42 +891,4 @@ describe('FilesRepository', () => {
889891 await expect ( setFileToRestricted ( nonExistentFiledId ) ) . rejects . toThrow ( expectedError )
890892 } )
891893 } )
892-
893- describe ( 'updateFileMetadata' , ( ) => {
894- test ( 'should return error when file does not exist' , async ( ) => {
895- const nonExistentFiledId = 4000
896- const testFileMetadata = {
897- description : 'My description bbb.' ,
898- categories : [ 'Data' ] ,
899- restrict : false
900- }
901- const errorExpected = new WriteError ( `[400] Error attempting get the requested data file.` )
902-
903- await expect ( sut . updateFileMetadata ( nonExistentFiledId , testFileMetadata ) ) . rejects . toThrow (
904- errorExpected
905- )
906- } )
907-
908- test ( 'should update file metadata when file exists' , async ( ) => {
909- const getDatasetFilesResponse = await sut . getDatasetFiles (
910- testDatasetIds . numericId ,
911- latestDatasetVersionId ,
912- false ,
913- FileOrderCriteria . NAME_AZ
914- )
915-
916- console . log ( 'fileInfo' , getDatasetFilesResponse )
917-
918- const fileId = getDatasetFilesResponse . files [ 0 ] . id
919- const testFileMetadata = {
920- description : 'My description bbb.' ,
921- categories : [ 'Data' ] ,
922- restrict : false
923- }
924-
925- const actual = await sut . updateFileMetadata ( fileId , testFileMetadata )
926-
927- expect ( actual ) . toBeUndefined ( )
928- } )
929- } )
930894} )
0 commit comments