diff --git a/src/presentation/http/router/note.test.ts b/src/presentation/http/router/note.test.ts index b0b49a4a..732accb1 100644 --- a/src/presentation/http/router/note.test.ts +++ b/src/presentation/http/router/note.test.ts @@ -564,10 +564,6 @@ describe('Note API', () => { id: parentNote.publicId, content: parentNote.content, }, - { - id: childNote.publicId, - content: childNote.content, - }, ], }); }); @@ -632,10 +628,6 @@ describe('Note API', () => { id: parentNote.publicId, content: parentNote.content, }, - { - id: childNote.publicId, - content: childNote.content, - }, ], }); }); @@ -688,15 +680,11 @@ describe('Note API', () => { id: parentNote.publicId, content: parentNote.content, }, - { - id: childNote.publicId, - content: childNote.content, - }, ], }); }); - test('Returns one note in case where there is no relation exist for the note with status 200', async () => { + test('Returns no note in case where there is no relation exist for the note with status 200', async () => { /** Create test user */ const user = await global.db.insertUser(); @@ -725,12 +713,7 @@ describe('Note API', () => { expect(response?.statusCode).toBe(200); expect(response?.json()).toMatchObject({ - parents: [ - { - id: note.publicId, - content: note.content, - }, - ], + parents: [], }); }); }); diff --git a/src/repository/storage/postgres/orm/sequelize/noteRelations.ts b/src/repository/storage/postgres/orm/sequelize/noteRelations.ts index 54476308..8031c9d1 100644 --- a/src/repository/storage/postgres/orm/sequelize/noteRelations.ts +++ b/src/repository/storage/postgres/orm/sequelize/noteRelations.ts @@ -240,13 +240,8 @@ export default class NoteRelationsSequelizeStorage { }); // eslint-disable-next-line @typescript-eslint/naming-convention - const output = (result as { note_id: number; parent_id: number }[])?.map(note => note.parent_id) ?? []; + parentNotes = (result as { note_id: number; parent_id: number }[])?.map(note => note.parent_id) ?? []; - if (output.find(note => (note == noteId)) == undefined) { - parentNotes = [noteId, ...output]; - } else { - parentNotes = output; - } parentNotes.reverse(); } catch { console.log(`something wrong happened with sql query`);