Skip to content

Commit c949dc5

Browse files
committed
fix: test .
1 parent 5c73311 commit c949dc5

File tree

1 file changed

+11
-77
lines changed

1 file changed

+11
-77
lines changed

test/integration/files/FilesRepository.test.ts

Lines changed: 11 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe('FilesRepository', () => {
170170
test('should return error when dataset does not exist', async () => {
171171
const nonExistentTestDatasetId = 100
172172
const errorExpected: ReadError = new ReadError(
173-
`[404] Dataset with ID ${nonExistentTestDatasetId} not found`
173+
`[404] Dataset with ID ${nonExistentTestDatasetId} not found.`
174174
)
175175

176176
await expect(
@@ -398,7 +398,7 @@ describe('FilesRepository', () => {
398398
})
399399

400400
test('should return error when file does not exist', async () => {
401-
const expectedError = new ReadError(`[404] File with ID ${nonExistentFiledId} not found`)
401+
const expectedError = new ReadError(`[404] File with ID ${nonExistentFiledId} not found.`)
402402

403403
await expect(sut.getFileDownloadCount(nonExistentFiledId)).rejects.toThrow(expectedError)
404404
})
@@ -421,7 +421,7 @@ describe('FilesRepository', () => {
421421
})
422422

423423
test('should return error when file does not exist', async () => {
424-
const errorExpected = new ReadError(`[404] File with ID ${nonExistentFiledId} not found`)
424+
const errorExpected = new ReadError(`[404] File with ID ${nonExistentFiledId} not found.`)
425425

426426
await expect(sut.getFileUserPermissions(nonExistentFiledId)).rejects.toThrow(errorExpected)
427427
})
@@ -496,7 +496,7 @@ describe('FilesRepository', () => {
496496
})
497497

498498
test('should return error when file does not exist', async () => {
499-
const expectedError = new ReadError(`[404] File with ID ${nonExistentFiledId} not found`)
499+
const expectedError = new ReadError(`[404] File with ID ${nonExistentFiledId} not found.`)
500500

501501
await expect(
502502
sut.getFile(nonExistentFiledId, DatasetNotNumberedVersion.LATEST, false)
@@ -527,7 +527,7 @@ describe('FilesRepository', () => {
527527
test('should return error when file does not exist', async () => {
528528
const nonExistentFiledPersistentId = 'nonExistentFiledPersistentId'
529529
const expectedError = new ReadError(
530-
`[404] Datafile with Persistent ID ${nonExistentFiledPersistentId} not found`
530+
`[404] Datafile with Persistent ID ${nonExistentFiledPersistentId} not found.`
531531
)
532532

533533
await expect(
@@ -571,7 +571,7 @@ describe('FilesRepository', () => {
571571
})
572572

573573
test('should return error when file does not exist', async () => {
574-
const errorExpected = new ReadError(`[404] File with ID ${nonExistentFiledId} not found`)
574+
const errorExpected = new ReadError(`[404] File with ID ${nonExistentFiledId} not found.`)
575575

576576
await expect(
577577
sut.getFileCitation(nonExistentFiledId, DatasetNotNumberedVersion.LATEST, false)
@@ -653,6 +653,8 @@ describe('FilesRepository', () => {
653653
const testFileMetadata = {
654654
description: 'My description test.',
655655
categories: ['Data'],
656+
label: 'myfile.txt',
657+
directoryLabel: 'mydir',
656658
restrict: false
657659
}
658660

@@ -668,6 +670,8 @@ describe('FilesRepository', () => {
668670

669671
expect(fileInfo.description).toBe(testFileMetadata.description)
670672
expect(fileInfo.categories).toEqual(testFileMetadata.categories)
673+
expect(fileInfo.name).toBe(testFileMetadata.label)
674+
expect(fileInfo.directoryLabel).toBe(testFileMetadata.directoryLabel)
671675
expect(fileInfo.restricted).toBe(testFileMetadata.restrict)
672676
})
673677

@@ -685,76 +689,6 @@ describe('FilesRepository', () => {
685689
})
686690
})
687691

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

830764
test('should return error when file does not exist', async () => {
831-
const expectedError = new WriteError(`[404] File with ID ${nonExistentFiledId} not found`)
765+
const expectedError = new WriteError(`[404] File with ID ${nonExistentFiledId} not found.`)
832766

833767
await expect(sut.deleteFile(nonExistentFiledId)).rejects.toThrow(expectedError)
834768
})

0 commit comments

Comments
 (0)