Skip to content

Commit ca7b156

Browse files
committed
Fixed: CollectionType enum definition
1 parent b000b3d commit ca7b156

File tree

8 files changed

+44
-30
lines changed

8 files changed

+44
-30
lines changed

src/collections/domain/dtos/CollectionDTO.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ export interface CollectionDTO {
66
}
77

88
export enum CollectionType {
9-
RESEARCHERS,
10-
RESEARCH_PROJECTS,
11-
JOURNALS,
12-
ORGANIZATIONS_INSTITUTIONS,
13-
TEACHING_COURSES,
14-
UNCATEGORIZED,
15-
LABORATORY,
16-
RESEARCH_GROUP,
17-
DEPARTMENT
9+
RESEARCHERS = 'RESEARCHERS',
10+
RESEARCH_PROJECTS = 'RESEARCH_PROJECTS',
11+
JOURNALS = 'JOURNALS',
12+
ORGANIZATIONS_INSTITUTIONS = 'ORGANIZATIONS_INSTITUTIONS',
13+
TEACHING_COURSES = 'TEACHING_COURSES',
14+
UNCATEGORIZED = 'UNCATEGORIZED',
15+
LABORATORY = 'LABORATORY',
16+
RESEARCH_GROUP = 'RESEARCH_GROUP',
17+
DEPARTMENT = 'DEPARTMENT'
1818
}

src/collections/domain/repositories/ICollectionsRepository.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ import { Collection } from '../models/Collection'
33

44
export interface ICollectionsRepository {
55
getCollection(collectionIdOrAlias: number | string): Promise<Collection>
6-
createCollection(collectionDTO: CollectionDTO, parentCollectionId: number | string): Promise<number>
6+
createCollection(
7+
collectionDTO: CollectionDTO,
8+
parentCollectionId: number | string
9+
): Promise<number>
710
}

src/collections/domain/useCases/CreateCollection.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ export class CreateCollection implements UseCase<number> {
1313
/**
1414
* TODO
1515
*/
16-
async execute(newCollection: CollectionDTO, parentCollectionId: number | string = ROOT_COLLECTION_ALIAS): Promise<number> {
16+
async execute(
17+
newCollection: CollectionDTO,
18+
parentCollectionId: number | string = ROOT_COLLECTION_ALIAS
19+
): Promise<number> {
1720
return await this.collectionsRepository.createCollection(newCollection, parentCollectionId)
1821
}
1922
}

src/collections/infra/repositories/CollectionsRepository.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { Collection, ROOT_COLLECTION_ALIAS } from '../../domain/models/Collectio
55
import { CollectionDTO } from '../../domain/dtos/CollectionDTO'
66

77
export interface NewCollectionRequestPayload {
8-
alias: string,
9-
name: string,
10-
dataverseContacts: NewCollectionContactRequestPayload[],
8+
alias: string
9+
name: string
10+
dataverseContacts: NewCollectionContactRequestPayload[]
1111
dataverseType: string
1212
}
1313

@@ -34,9 +34,11 @@ export class CollectionsRepository extends ApiRepository implements ICollections
3434
collectionDTO: CollectionDTO,
3535
parentCollectionId: number | string = ROOT_COLLECTION_ALIAS
3636
): Promise<number> {
37-
const dataverseContacts: NewCollectionContactRequestPayload[] = collectionDTO.contacts.map((contact) => ({
38-
contactEmail: contact
39-
}))
37+
const dataverseContacts: NewCollectionContactRequestPayload[] = collectionDTO.contacts.map(
38+
(contact) => ({
39+
contactEmail: contact
40+
})
41+
)
4042

4143
const requestBody: NewCollectionRequestPayload = {
4244
alias: collectionDTO.alias,

test/integration/collections/CollectionsRepository.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ describe('CollectionsRepository', () => {
102102
})
103103

104104
test('should create collection in parent collection when parent collection is set', async () => {
105-
const actual = await sut.createCollection(createCollectionDTO(testCreateCollectionAlias2), testCollectionId)
105+
const actual = await sut.createCollection(
106+
createCollectionDTO(testCreateCollectionAlias2),
107+
testCollectionId
108+
)
106109
expect(typeof actual).toBe('number')
107110
})
108111

@@ -111,9 +114,12 @@ describe('CollectionsRepository', () => {
111114
`[404] Can't find dataverse with identifier='${TestConstants.TEST_DUMMY_COLLECTION_ID}'`
112115
)
113116
const testCreateCollectionAlias3 = 'createCollection-test-3'
114-
await expect(sut.createCollection(createCollectionDTO(testCreateCollectionAlias3), TestConstants.TEST_DUMMY_COLLECTION_ID)).rejects.toThrow(
115-
expectedError
116-
)
117+
await expect(
118+
sut.createCollection(
119+
createCollectionDTO(testCreateCollectionAlias3),
120+
TestConstants.TEST_DUMMY_COLLECTION_ID
121+
)
122+
).rejects.toThrow(expectedError)
117123
})
118124
})
119125
})

test/integration/files/DirectUploadClient.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
} from '../../testHelpers/files/filesHelper'
2323
import { FileUploadCancelError } from '../../../src/files/infra/clients/errors/FileUploadCancelError'
2424

25-
describe.skip('DirectUploadClient', () => {
25+
describe('DirectUploadClient', () => {
2626
const testCollectionAlias = 'directUploadTestCollection'
2727
let testDataset1Ids: CreatedDatasetIdentifiers
2828
let testDataset2Ids: CreatedDatasetIdentifiers

test/testHelpers/collections/collectionHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export async function setStorageDriverViaApi(
103103
}
104104
}
105105

106-
export const createCollectionDTO = (alias: string = 'test-collection'): CollectionDTO => {
106+
export const createCollectionDTO = (alias = 'test-collection'): CollectionDTO => {
107107
return {
108108
alias: alias,
109109
name: 'Test Collection',

test/unit/collections/CollectionsRepository.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('CollectionsRepository', () => {
3030
DataverseApiAuthMechanism.API_KEY,
3131
TestConstants.TEST_DUMMY_API_KEY
3232
)
33-
33+
3434
jest.clearAllMocks()
3535
})
3636

@@ -116,18 +116,20 @@ describe('CollectionsRepository', () => {
116116

117117
describe('createCollection', () => {
118118
const testNewCollection = createCollectionDTO()
119-
119+
120120
const testCreatedCollectionId = 1
121121
const testCreateCollectionResponse = {
122122
data: {
123123
status: 'OK',
124124
data: {
125-
id: testCreatedCollectionId,
125+
id: testCreatedCollectionId
126126
}
127127
}
128128
}
129129

130-
const expectedNewCollectionRequestPayloadJson = JSON.stringify(createNewCollectionRequestPayload())
130+
const expectedNewCollectionRequestPayloadJson = JSON.stringify(
131+
createNewCollectionRequestPayload()
132+
)
131133
const expectedApiEndpoint = `${TestConstants.TEST_API_URL}/dataverses/root`
132134

133135
test('should call the API with a correct request payload', async () => {
@@ -160,9 +162,7 @@ describe('CollectionsRepository', () => {
160162
jest.spyOn(axios, 'post').mockRejectedValue(TestConstants.TEST_ERROR_RESPONSE)
161163

162164
let error = undefined as unknown as WriteError
163-
await sut
164-
.createCollection(testNewCollection)
165-
.catch((e) => (error = e))
165+
await sut.createCollection(testNewCollection).catch((e) => (error = e))
166166

167167
expect(axios.post).toHaveBeenCalledWith(
168168
expectedApiEndpoint,

0 commit comments

Comments
 (0)