Skip to content

Commit

Permalink
Merge branch 'auth-method-for-tests' of https://github.com/codex-team…
Browse files Browse the repository at this point in the history
…/notes.api into auth-method-for-tests
  • Loading branch information
iamgabrielsoft committed Jan 10, 2024
2 parents d5b2249 + 023a509 commit 7c98390
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/presentation/http/router/noteList.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
<<<<<<< HEAD

Check failure on line 1 in src/presentation/http/router/noteList.test.ts

View workflow job for this annotation

GitHub Actions / Run yarn build

Merge conflict marker encountered.
import userSessions from '@tests/test-data/user-sessions.json';
=======

Check failure on line 3 in src/presentation/http/router/noteList.test.ts

View workflow job for this annotation

GitHub Actions / Run yarn build

Merge conflict marker encountered.
// import type AuthSession from '@domain/entities/authSession';
import userSessions from '@tests/test-data/userSessions.json';
>>>>>>> 023a509cd58ac661142c392596df8e9a10c65342

Check failure on line 6 in src/presentation/http/router/noteList.test.ts

View workflow job for this annotation

GitHub Actions / Run yarn build

Merge conflict marker encountered.
import { describe, test, expect, beforeAll } from 'vitest';


/**
* Access token that will be used for Authorization header
*/
let accessToken = '';

<<<<<<< HEAD

Check failure on line 14 in src/presentation/http/router/noteList.test.ts

View workflow job for this annotation

GitHub Actions / Run yarn build

Merge conflict marker encountered.
=======

Check failure on line 15 in src/presentation/http/router/noteList.test.ts

View workflow job for this annotation

GitHub Actions / Run yarn build

Merge conflict marker encountered.

>>>>>>> 023a509cd58ac661142c392596df8e9a10c65342

Check failure on line 17 in src/presentation/http/router/noteList.test.ts

View workflow job for this annotation

GitHub Actions / Run yarn build

Merge conflict marker encountered.
describe('NoteList API', () => {
beforeAll(() => {
/**
* userId for authorization
*/
<<<<<<< HEAD

Check failure on line 23 in src/presentation/http/router/noteList.test.ts

View workflow job for this annotation

GitHub Actions / Run yarn build

Merge conflict marker encountered.
const userId = userSessions[0]['user_id'];

accessToken = global.auth(userId);
=======

Check failure on line 27 in src/presentation/http/router/noteList.test.ts

View workflow job for this annotation

GitHub Actions / Run yarn build

Merge conflict marker encountered.
const id = userSessions[0]['user_id'];

accessToken = global.auth(id);
>>>>>>> 023a509cd58ac661142c392596df8e9a10c65342

Check failure on line 31 in src/presentation/http/router/noteList.test.ts

View workflow job for this annotation

GitHub Actions / Run yarn build

Merge conflict marker encountered.
});

describe('GET /notes?page', () => {
Expand Down
12 changes: 12 additions & 0 deletions src/tests/utils/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ declare global {
* Globally exposed method for creating accessToken using id
* Is accessed as 'global.server' in tests
*
<<<<<<< HEAD
* @param userId - id of the user that will be considered the author of the request
* @returns accessToken for authorization
*/
Expand All @@ -45,6 +46,12 @@ declare global {
*/
query: (sql: string) => Promise<unknown>;
};
=======

Check failure on line 49 in src/tests/utils/setup.ts

View workflow job for this annotation

GitHub Actions / Run yarn build

Merge conflict marker encountered.
* @param id - id for making accessToken
* @returns accessToken for authorization
*/
function auth(id: number) : string;
>>>>>>> 023a509cd58ac661142c392596df8e9a10c65342
}

/**
Expand All @@ -70,6 +77,7 @@ beforeAll(async () => {
await insertData(orm);

global.api = api;
<<<<<<< HEAD

global.auth = (userId: number) => {
return domainServices.authService.signAccessToken({ id : userId });
Expand All @@ -79,6 +87,10 @@ beforeAll(async () => {
query: async (sqlString: string) => {
return await orm.connection.query(sqlString);
},
=======
global.auth = (id: number) => {
return domainServices.authService.signAccessToken({ id : id });
>>>>>>> 023a509cd58ac661142c392596df8e9a10c65342
};
}, TIMEOUT);

Expand Down

0 comments on commit 7c98390

Please sign in to comment.