Skip to content

Commit

Permalink
chore(tests): rename variable
Browse files Browse the repository at this point in the history
- renamed variable from id to userId
- typo fixed
  • Loading branch information
e11sy committed Nov 5, 2023
1 parent 0a998e8 commit a149b00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ File `src/tests/utils/setup.ts` does necessary preparations to make in possible
Test data lies in `src/tests/test-data/` directory. If you are missing some data for your tests, fill free to modify existing files or add new ones. Just remember to support relations between data that is usually provided by foreign key mechanism.

## Authorization in test
Use `global.auth(id)` for getting accessToken, which you can use in:
Use `global.auth(userId)` for getting accessToken, which you can use in:
```
headers: {
authorization: `Bearer ${accessToken}`
}
```
in your fake rewuests
in your fake requests

## Writing tests
Please, locate a test file near the file that it tests. Make sure test file name is the same as tested file name, but with `.test` suffix.
Expand Down
8 changes: 4 additions & 4 deletions src/tests/utils/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ declare global {
* Globally exposed method for creating accessToken using id
* Is accessed as 'global.server' in tests
*
* @param id - id for making accessToken
* @param userId - id of the user that will be considered the author of the request
* @returns accessToken for authorization
*/
function auth(id: number) : string;
function auth(userId: number) : string;
}

/**
Expand All @@ -59,8 +59,8 @@ beforeAll(async () => {
await insertData(orm);

global.api = api;
global.auth = (id: number) => {
return domainServices.authService.signAccessToken({ id : id });
global.auth = (userId: number) => {
return domainServices.authService.signAccessToken({ id : userId });
};
}, TIMEOUT);

Expand Down

0 comments on commit a149b00

Please sign in to comment.