Skip to content

Commit ed49e60

Browse files
update (note parents): only include the parents note without the main note
1 parent aa93ee2 commit ed49e60

2 files changed

Lines changed: 3 additions & 25 deletions

File tree

src/presentation/http/router/note.test.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,6 @@ describe('Note API', () => {
564564
id: parentNote.publicId,
565565
content: parentNote.content,
566566
},
567-
{
568-
id: childNote.publicId,
569-
content: childNote.content,
570-
},
571567
],
572568
});
573569
});
@@ -632,10 +628,6 @@ describe('Note API', () => {
632628
id: parentNote.publicId,
633629
content: parentNote.content,
634630
},
635-
{
636-
id: childNote.publicId,
637-
content: childNote.content,
638-
},
639631
],
640632
});
641633
});
@@ -688,15 +680,11 @@ describe('Note API', () => {
688680
id: parentNote.publicId,
689681
content: parentNote.content,
690682
},
691-
{
692-
id: childNote.publicId,
693-
content: childNote.content,
694-
},
695683
],
696684
});
697685
});
698686

699-
test('Returns one note in case where there is no relation exist for the note with status 200', async () => {
687+
test('Returns no note in case where there is no relation exist for the note with status 200', async () => {
700688
/** Create test user */
701689
const user = await global.db.insertUser();
702690

@@ -725,12 +713,7 @@ describe('Note API', () => {
725713
expect(response?.statusCode).toBe(200);
726714

727715
expect(response?.json()).toMatchObject({
728-
parents: [
729-
{
730-
id: note.publicId,
731-
content: note.content,
732-
},
733-
],
716+
parents: [],
734717
});
735718
});
736719
});

src/repository/storage/postgres/orm/sequelize/noteRelations.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,8 @@ export default class NoteRelationsSequelizeStorage {
240240
});
241241

242242
// eslint-disable-next-line @typescript-eslint/naming-convention
243-
const output = (result as { note_id: number; parent_id: number }[])?.map(note => note.parent_id) ?? [];
243+
parentNotes = (result as { note_id: number; parent_id: number }[])?.map(note => note.parent_id) ?? [];
244244

245-
if (output.find(note => (note == noteId)) == undefined) {
246-
parentNotes = [noteId, ...output];
247-
} else {
248-
parentNotes = output;
249-
}
250245
parentNotes.reverse();
251246
} catch {
252247
console.log(`something wrong happened with sql query`);

0 commit comments

Comments
 (0)