From 4e71ad0608fa1975de5dd82136bd5afb39d9dfdd Mon Sep 17 00:00:00 2001 From: e11sy Date: Mon, 23 Oct 2023 02:49:42 +0300 Subject: [PATCH] comment fixes - fixed comments logic - trying to fix directoru error --- src/presentation/http/router/noteList.test.ts | 24 ++++++++++++------- tsconfig.json | 5 ++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/presentation/http/router/noteList.test.ts b/src/presentation/http/router/noteList.test.ts index 79a19afb..8dc6752a 100644 --- a/src/presentation/http/router/noteList.test.ts +++ b/src/presentation/http/router/noteList.test.ts @@ -1,5 +1,5 @@ +import userSessions from '@test/test-data/userSessions.json'; import { describe, test, expect } from 'vitest'; -import userSessions from 'tests/test-data/userSessions.json'; const refresh_token = userSessions[0]['refresh_tocken']; const access_token = await global.api?.fakeRequest({ @@ -8,17 +8,18 @@ const access_token = await global.api?.fakeRequest({ }); describe('NoteList API', () => { - describe('GET notes?page', () => { + describe('GET /notes?page', () => { test('Returns noteList with specified lenght (not for last page)', async () => { const expectedStatus = 200; const portionSize = 30; + const pageNumber = 1; const response = await global.api?.fakeRequest({ method: 'GET', headers: { authorization: `Bearer ${access_token}`, }, - url: '/notes/&page=1', + url: `/notes/&page=${pageNumber}`, }); expect(response?.statusCode).toBe(expectedStatus); @@ -31,13 +32,14 @@ describe('NoteList API', () => { test('Returns noteList with specified lenght (for last page)', async () => { const expectedStatus = 200; const portionSize = 20; + const pageNumber = 2; const response = await global.api?.fakeRequest({ method: 'GET', headers: { authorization: `Bearer ${access_token}`, }, - url: '/notes/&page=2', + url: `/notes/&page=${pageNumber}`, }); expect(response?.statusCode).toBe(expectedStatus); @@ -47,15 +49,16 @@ describe('NoteList API', () => { expect(body).toHaveLength(portionSize); }); - test('Returns noteList with no items if page*portionSize > numberOfNotes', async () => { + test('Returns noteList with no items if it has no notes', async () => { const expectedStatus = 200; + const pageNumber = 3; const response = await global.api?.fakeRequest({ method: 'GET', headers: { authorization: `Bearer ${access_token}`, }, - url: '/notes/&page=3', + url: `/notes/&page=${pageNumber}`, }); expect(response?.statusCode).toBe(expectedStatus); @@ -68,27 +71,30 @@ describe('NoteList API', () => { test('Returns 400 when page < 0', async () => { const expextedStatus = 400; + const pageNumber = 0; + const response = await global.api?.fakeRequest({ method: 'GET', headers: { authorization: `Bearer ${access_token}`, }, - url: '/notes/&page=0', + url: `/notes/&page=${pageNumber}`, }); expect(response?.statusCode).toBe(expextedStatus); }); - test('Returns 400 when page > 0', async () => { + test('Returns 400 when page is too large', async () => { const expextedStatus = 400; + const pageNumber = 31; const response = await global.api?.fakeRequest({ method: 'GET', headers: { authorization: `Bearer ${access_token}`, }, - url: '/notes/&page=31', + url: `/notes/&page=${pageNumber}`, }); expect(response?.statusCode).toBe(expextedStatus); diff --git a/tsconfig.json b/tsconfig.json index 93e90d57..407fef84 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - "resolveJsonModule":true, + "resolveJsonModule": true, "strict": true, "skipLibCheck": true, "paths": { @@ -15,7 +15,8 @@ "@presentation/*": ["presentation/*"], "@lib/*": ["lib/*"], "@domain/*": ["domain/*"], - "@repository/*": ["repository/*"] + "@repository/*": ["repository/*"], + "@tests/*": ["tests/*"] }, }, "include": [