diff --git a/src/api/public/notes/notes.controller.ts b/src/api/public/notes/notes.controller.ts index 42d218c13..e7739529b 100644 --- a/src/api/public/notes/notes.controller.ts +++ b/src/api/public/notes/notes.controller.ts @@ -176,7 +176,7 @@ export class NotesController { if (!this.permissionsService.mayRead(req.user, note)) { throw new UnauthorizedException('Reading note denied!'); } - return await this.noteService.getNoteContentByNote(note); + return await this.noteService.getNoteContent(note); } catch (e) { if (e instanceof NotInDBError) { throw new NotFoundException(e.message); diff --git a/src/notes/notes.service.spec.ts b/src/notes/notes.service.spec.ts index 91b89162a..18a02dba5 100644 --- a/src/notes/notes.service.spec.ts +++ b/src/notes/notes.service.spec.ts @@ -180,7 +180,7 @@ describe('NotesService', () => { }); }); - describe('getNoteContentByNote', () => { + describe('getNoteContent', () => { it('works', async () => { const content = 'testContent'; jest @@ -189,7 +189,7 @@ describe('NotesService', () => { const newNote = await service.createNote(content); const revisions = await newNote.revisions; jest.spyOn(revisionRepo, 'findOne').mockResolvedValueOnce(revisions[0]); - service.getNoteContentByNote(newNote).then((result) => { + service.getNoteContent(newNote).then((result) => { expect(result).toEqual(content); }); }); @@ -575,22 +575,6 @@ describe('NotesService', () => { }); }); - describe('getNoteContentByIdOrAlias', () => { - it('works', async () => { - const content = 'testContent'; - jest - .spyOn(noteRepo, 'save') - .mockImplementation(async (note: Note): Promise => note); - const newNote = await service.createNote(content); - const revisions = await newNote.revisions; - jest.spyOn(noteRepo, 'findOne').mockResolvedValueOnce(newNote); - jest.spyOn(revisionRepo, 'findOne').mockResolvedValueOnce(revisions[0]); - service.getNoteContentByIdOrAlias('noteThatExists').then((result) => { - expect(result).toEqual(content); - }); - }); - }); - describe('toTagList', () => { it('works', async () => { const note = {} as Note; diff --git a/src/notes/notes.service.ts b/src/notes/notes.service.ts index 09bdbe3d9..5b99e6f78 100644 --- a/src/notes/notes.service.ts +++ b/src/notes/notes.service.ts @@ -112,7 +112,7 @@ export class NotesService { * @param {Note} note - the note to use * @return {string} the content of the note */ - async getNoteContentByNote(note: Note): Promise { + async getNoteContent(note: Note): Promise { return (await this.getLatestRevision(note)).content; } @@ -266,17 +266,6 @@ export class NotesService { return await this.noteRepository.save(note); } - /** - * @async - * Get the current content of the note by either their id or alias. - * @param {string} noteIdOrAlias - the notes id or alias - * @return {string} the content of the note - */ - async getNoteContentByIdOrAlias(noteIdOrAlias: string): Promise { - const note = await this.getNoteByIdOrAlias(noteIdOrAlias); - return this.getNoteContentByNote(note); - } - /** * @async * Calculate the updateUser (for the NoteDto) for a Note. @@ -360,7 +349,7 @@ export class NotesService { */ async toNoteDto(note: Note): Promise { return { - content: await this.getNoteContentByNote(note), + content: await this.getNoteContent(note), metadata: await this.toNoteMetadataDto(note), editedByAtPosition: [], }; diff --git a/test/public-api/notes.e2e-spec.ts b/test/public-api/notes.e2e-spec.ts index 97aa31705..f201f3d67 100644 --- a/test/public-api/notes.e2e-spec.ts +++ b/test/public-api/notes.e2e-spec.ts @@ -74,7 +74,7 @@ describe('Notes', () => { .expect(201); expect(response.body.metadata?.id).toBeDefined(); expect( - await notesService.getNoteContentByNote( + await notesService.getNoteContent( await notesService.getNoteByIdOrAlias(response.body.metadata.id), ), ).toEqual(content); @@ -109,7 +109,7 @@ describe('Notes', () => { .expect(201); expect(response.body.metadata?.id).toBeDefined(); return expect( - await notesService.getNoteContentByNote( + await notesService.getNoteContent( await notesService.getNoteByIdOrAlias(response.body.metadata?.id), ), ).toEqual(content); @@ -150,7 +150,7 @@ describe('Notes', () => { .send(changedContent) .expect(200); await expect( - await notesService.getNoteContentByNote( + await notesService.getNoteContent( await notesService.getNoteByIdOrAlias('test4'), ), ).toEqual(changedContent);