From e0605dc823725e1511a7bc58cf947872ef4663b3 Mon Sep 17 00:00:00 2001 From: e11sy Date: Wed, 24 Jul 2024 17:44:38 +0300 Subject: [PATCH] test improved --- src/presentation/http/router/note.test.ts | 19 ++++++++++------- src/presentation/http/router/note.ts | 2 +- src/presentation/http/schema/History.ts | 26 ++++++++++++----------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/presentation/http/router/note.test.ts b/src/presentation/http/router/note.test.ts index af99f2ed..6de9e590 100644 --- a/src/presentation/http/router/note.test.ts +++ b/src/presentation/http/router/note.test.ts @@ -717,6 +717,14 @@ describe('Note API', () => { expect(response?.json().message).toStrictEqual(expectedMessage); }); + // test.each + // + // + // + // + // + // + test.todo('Returns 400 when parentId has incorrect characters and length'); }); @@ -1882,23 +1890,18 @@ describe('Note API', () => { if (expectedMessage !== null) { expect(response?.json()).toStrictEqual({ message: expectedMessage }); } else { - expect(response?.json().noteHistoryMeta).toMatchObject([ + expect(response?.json().noteHistoryMeta).toStrictEqual([ /** * First history record created automatically on note insertion */ { - id: '1', - noteId: note.publicId, + id: 1, userId: creator.id, - content: note.content, - tools: note.tools, }, { id: history.id, - noteId: history.noteId, userId: history.userId, - content: history.content, - tools: history.tools, + createdAt: history.createdAt, }, ]); } diff --git a/src/presentation/http/router/note.ts b/src/presentation/http/router/note.ts index adde2ed2..6de6b09d 100644 --- a/src/presentation/http/router/note.ts +++ b/src/presentation/http/router/note.ts @@ -678,7 +678,7 @@ const NoteRouter: FastifyPluginCallback = (fastify, opts, don noteHistoryMeta: { type: 'array', items: { - $ref: 'HistoryMetaSchema#', + $ref: 'HistoryMetaSchema', }, }, }, diff --git a/src/presentation/http/schema/History.ts b/src/presentation/http/schema/History.ts index 7dc91c7e..63cd5d87 100644 --- a/src/presentation/http/schema/History.ts +++ b/src/presentation/http/schema/History.ts @@ -70,17 +70,19 @@ export const HistoryMetaSchema = { 'userId', 'createdAt', ], - id: { - description: 'unique note hisotry record identifier', - type: 'number', - }, - userId: { - description: 'unique user identifier', - type: 'number', - }, - createdAt: { - description: 'time, when note history record was created', - type: 'string', - format: 'date-time', + properties: { + id: { + description: 'unique note hisotry record identifier', + type: 'number', + }, + userId: { + description: 'unique user identifier', + type: 'number', + }, + createdAt: { + description: 'time, when note history record was created', + type: 'string', + format: 'date-time', + }, }, };