-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: init campaign application controller #647
feature: init campaign application controller #647
Conversation
✅ Tests will run for this PR. Once they succeed it can be merged. |
- add controller using nest generator - add tests for the initial controller methods - add @podkrepi-bg/testing module and autoSpy exported from it
cdfd116
to
e55fe2b
Compare
let service: SpyOf<CampaignApplicationService> | ||
|
||
beforeEach(async () => { | ||
service = autoSpy(CampaignApplicationService) |
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.
How is autoSpy different, than module.get<CampaignApplicationService>(CampaignApplicationService)
?
Seems redundant to me.
Docs in NestJS also shows similar way to mock the Service classes link
AutoSpy walks the prototype and creates a spy (jest.fn) and the test.get is
a dependency injection tool (i.e. resolve and give me an isnstance for this
token).
Autospy essentially does this
https://github.com/podkrepi-bg/api/blob/39e39a856d2de27b9b6944ff9382a65dafd25249/apps/api/src/campaign/campaign.controller.spec.ts#L34
The docs seem to talk about mocking but not show a mechanism to mock
instances. Or did I miss something?
What do you feel is the overlap here?
…On Sat, Jun 22, 2024, 2:10 PM Aleksandar Petkov ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
apps/api/src/campaign-application/campaign-application.controller.spec.ts
<#647 (comment)>:
> @@ -0,0 +1,71 @@
+import { Test, TestingModule } from ***@***.***/testing'
+import { CampaignApplicationController } from './campaign-application.controller'
+import { CampaignApplicationService } from './campaign-application.service'
+import { SpyOf, autoSpy } from ***@***.***/testing'
+
+describe('CampaignApplicationController', () => {
+ let controller: CampaignApplicationController
+ let service: SpyOf<CampaignApplicationService>
+
+ beforeEach(async () => {
+ service = autoSpy(CampaignApplicationService)
How is autoSpy different, than
module.get<CampaignApplicationService>(CampaignApplicationService)?
Seems redundant to me.
Docs in NestJS also shows similar way to mock the Service classes link
<https://docs.nestjs.com/fundamentals/testing#testing-utilities>
—
Reply to this email directly, view it on GitHub
<#647 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2SEV6YTKP6KCWZLHMZTBTZIVLSFAVCNFSM6AAAAABJULSIQ6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCMZTGY4TQNBYG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I was rather curious, because I have not seen this practice before, and probably got a bit confused, by the implementation. Though I admit I should've put a bit more thought at what autoSpy does, before bothering you explaining it to me. Sorry for that. |
- add controller using nest generator - add tests for the initial controller methods - add @podkrepi-bg/testing module and autoSpy exported from it
New endpoints
campaign-application/create
campaign-application/find-all
campaign-application/find-one
campaign-application/update