Skip to content

Commit

Permalink
comment fixes
Browse files Browse the repository at this point in the history
- fixed comments logic
- trying to fix directoru error
  • Loading branch information
e11sy committed Oct 22, 2023
1 parent ef2e923 commit 4e71ad0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
24 changes: 15 additions & 9 deletions src/presentation/http/router/noteList.test.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule":true,
"resolveJsonModule": true,
"strict": true,
"skipLibCheck": true,
"paths": {
"@infrastructure/*": ["infrastructure/*"],
"@presentation/*": ["presentation/*"],
"@lib/*": ["lib/*"],
"@domain/*": ["domain/*"],
"@repository/*": ["repository/*"]
"@repository/*": ["repository/*"],
"@tests/*": ["tests/*"]
},
},
"include": [
Expand Down

0 comments on commit 4e71ad0

Please sign in to comment.