Skip to content

Commit bba1993

Browse files
committed
fix: update collectionId to Uppercase
1 parent c3f76f8 commit bba1993

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

docs/useCases.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,11 +2810,11 @@ Returns all [Guestbook](../src/guestbooks/domain/models/Guestbook.ts) entries av
28102810
##### Example call:
28112811

28122812
```typescript
2813-
import { getGuestbooksBycollectionId } from '@iqss/dataverse-client-javascript'
2813+
import { getGuestbooksByCollectionId } from '@iqss/dataverse-client-javascript'
28142814

28152815
const collectionIdOrAlias = 'root'
28162816

2817-
getGuestbooksBycollectionId.execute(collectionIdOrAlias).then((guestbooks: Guestbook[]) => {
2817+
getGuestbooksByCollectionId.execute(collectionIdOrAlias).then((guestbooks: Guestbook[]) => {
28182818
/* ... */
28192819
})
28202820
```

src/guestbooks/domain/repositories/IGuestbooksRepository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface IGuestbooksRepository {
77
guestbook: CreateGuestbookDTO
88
): Promise<void>
99
getGuestbook(guestbookId: number): Promise<Guestbook>
10-
getGuestbooksBycollectionId(collectionIdOrAlias: number | string): Promise<Guestbook[]>
10+
getGuestbooksByCollectionId(collectionIdOrAlias: number | string): Promise<Guestbook[]>
1111
setGuestbookEnabled(
1212
collectionIdOrAlias: number | string,
1313
guestbookId: number,

src/guestbooks/domain/useCases/GetGuestbooksByCollectionId.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ export class GetGuestbooksByCollectionId implements UseCase<Guestbook[]> {
1212
* @returns {Promise<Guestbook[]>}
1313
*/
1414
async execute(collectionIdOrAlias: number | string): Promise<Guestbook[]> {
15-
return await this.guestbooksRepository.getGuestbooksBycollectionId(collectionIdOrAlias)
15+
return await this.guestbooksRepository.getGuestbooksByCollectionId(collectionIdOrAlias)
1616
}
1717
}

src/guestbooks/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ const guestbooksRepository = new GuestbooksRepository()
88

99
const createGuestbook = new CreateGuestbook(guestbooksRepository)
1010
const getGuestbook = new GetGuestbook(guestbooksRepository)
11-
const getGuestbooksBycollectionId = new GetGuestbooksByCollectionId(guestbooksRepository)
11+
const getGuestbooksByCollectionId = new GetGuestbooksByCollectionId(guestbooksRepository)
1212
const setGuestbookEnabled = new SetGuestbookEnabled(guestbooksRepository)
1313

14-
export { createGuestbook, getGuestbook, getGuestbooksBycollectionId, setGuestbookEnabled }
14+
export { createGuestbook, getGuestbook, getGuestbooksByCollectionId, setGuestbookEnabled }
1515

1616
export {
1717
CreateGuestbookDTO,

src/guestbooks/infra/repositories/GuestbooksRepository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class GuestbooksRepository extends ApiRepository implements IGuestbooksRe
3131
})
3232
}
3333

34-
public async getGuestbooksBycollectionId(
34+
public async getGuestbooksByCollectionId(
3535
collectionIdOrAlias: number | string
3636
): Promise<Guestbook[]> {
3737
return this.doGet(

test/integration/guestbooks/GuestbooksRepository.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,22 @@ describe('GuestbooksRepository', () => {
8585
})
8686
})
8787

88-
describe('getGuestbooksBycollectionId', () => {
88+
describe('getGuestbooksByCollectionId', () => {
8989
test('should list guestbooks for collection', async () => {
9090
await sut.createGuestbook(testCollectionId, createGuestbookDTO)
91-
const actual = await sut.getGuestbooksBycollectionId(testCollectionId)
91+
const actual = await sut.getGuestbooksByCollectionId(testCollectionId)
9292
expect(actual.length).toBeGreaterThan(0)
9393
createdGuestbookId = actual[0].id as number
9494
})
9595

9696
test('should list guestbooks for collection by collection alias', async () => {
9797
await sut.createGuestbook(testCollectionAlias, createGuestbookDTO)
98-
const actual = await sut.getGuestbooksBycollectionId(testCollectionAlias)
98+
const actual = await sut.getGuestbooksByCollectionId(testCollectionAlias)
9999
expect(actual.length).toBeGreaterThan(0)
100100
})
101101

102102
test('should return error when collection does not exist', async () => {
103-
await expect(sut.getGuestbooksBycollectionId(999999)).rejects.toThrow(ReadError)
103+
await expect(sut.getGuestbooksByCollectionId(999999)).rejects.toThrow(ReadError)
104104
})
105105
})
106106

test/unit/guestbooks/GetGuestbooksByCollectionId.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ describe('GetGuestbooksByCollectionId', () => {
2222

2323
test('should return guestbooks for collection', async () => {
2424
const repository: IGuestbooksRepository = {} as IGuestbooksRepository
25-
repository.getGuestbooksBycollectionId = jest.fn().mockResolvedValue(guestbooks)
25+
repository.getGuestbooksByCollectionId = jest.fn().mockResolvedValue(guestbooks)
2626

2727
const sut = new GetGuestbooksByCollectionId(repository)
2828
const actual = await sut.execute(collectionId)
2929

30-
expect(repository.getGuestbooksBycollectionId).toHaveBeenCalledWith(collectionId)
30+
expect(repository.getGuestbooksByCollectionId).toHaveBeenCalledWith(collectionId)
3131
expect(actual).toEqual(guestbooks)
3232
})
3333

3434
test('should throw ReadError when repository fails', async () => {
3535
const repository: IGuestbooksRepository = {} as IGuestbooksRepository
36-
repository.getGuestbooksBycollectionId = jest.fn().mockRejectedValue(new ReadError())
36+
repository.getGuestbooksByCollectionId = jest.fn().mockRejectedValue(new ReadError())
3737
const sut = new GetGuestbooksByCollectionId(repository)
3838

3939
await expect(sut.execute(collectionId)).rejects.toThrow(ReadError)

0 commit comments

Comments
 (0)