Skip to content
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

Conversation

gparlakov
Copy link
Contributor

  • 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

Copy link

github-actions bot commented Jun 20, 2024

✅ 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
@gparlakov gparlakov force-pushed the initialize-campaign-applicaiton-controller-add-autospy branch from cdfd116 to e55fe2b Compare June 21, 2024 07:19
let service: SpyOf<CampaignApplicationService>

beforeEach(async () => {
service = autoSpy(CampaignApplicationService)
Copy link
Member

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

@gparlakov
Copy link
Contributor Author

gparlakov commented Jun 22, 2024 via email

@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Jun 22, 2024
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Jun 22, 2024
@sashko9807
Copy link
Member

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

const personServiceMock = {
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?

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.

@sashko9807 sashko9807 merged commit 30d2f1c into podkrepi-bg:master Jun 22, 2024
10 of 11 checks passed
gparlakov added a commit to gparlakov/podkrepi-bg-api that referenced this pull request Jun 30, 2024
- add controller using nest generator
- add tests for the initial controller methods
- add @podkrepi-bg/testing module and autoSpy exported from it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants