-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from gavrylenkoIvan/dev
Increase test coverage, fix global filter
- Loading branch information
Showing
26 changed files
with
448 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { createMock } from '@golevelup/ts-jest'; | ||
import { ExecutionContext } from '@nestjs/common'; | ||
import { ROUTE_ARGS_METADATA } from '@nestjs/common/constants'; | ||
import { TelegrafExecutionContext } from 'nestjs-telegraf'; | ||
import { User } from 'src/core/entities'; | ||
|
||
import { ReqUser } from '../profile.decorator'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
function getParamDecoratorFactory(decorator: Function) { | ||
class Test { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
public test(@decorator() value) {} | ||
} | ||
|
||
const args = Reflect.getMetadata(ROUTE_ARGS_METADATA, Test, 'test'); | ||
return args[Object.keys(args)[0]].factory; | ||
} | ||
|
||
describe('ReqUser', () => { | ||
it('should return the user from the request', () => { | ||
const user = createMock<User>({ | ||
id: 1, | ||
}); | ||
|
||
jest.spyOn(TelegrafExecutionContext, 'create').mockReturnValue( | ||
createMock<TelegrafExecutionContext>({ | ||
switchToHttp: () => ({ | ||
getRequest: () => ({ user }), | ||
}), | ||
}), | ||
); | ||
|
||
const factory = getParamDecoratorFactory(ReqUser); | ||
const result = factory(null, createMock<ExecutionContext>()); | ||
|
||
expect(result).toEqual(user); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
4ddb8b7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
team-ua-compodoc – ./
team-ua-compodoc-git-master-gavrylenkoivan.vercel.app
team-ua-compodoc-gavrylenkoivan.vercel.app
team-ua-compodoc.vercel.app