-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(app-generic): add test for add job use case to check the injected queue service #3941
Conversation
@@ -0,0 +1,77 @@ | |||
import { Test } from '@nestjs/testing'; | |||
import { ExecutionDetailsRepository, JobRepository } from '@novu/dal'; | |||
import { UserSession } from '@novu/testing'; |
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.
there are some unused imports and variables ;)
it('should instantiate properly the use case', async () => { | ||
const queueService = useCase.getQueueService(); | ||
|
||
expect(queueService.DEFAULT_ATTEMPTS).toEqual(3); | ||
expect(queueService.name).toEqual('standard'); | ||
const { bullMqService } = queueService; | ||
expect(bullMqService).toBeDefined(); | ||
expect(await bullMqService.getRunningStatus()).toEqual({ | ||
queueIsPaused: false, | ||
queueName: 'standard', | ||
workerIsRunning: undefined, | ||
workerName: undefined, | ||
}); | ||
}); |
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.
You've created the test for the AddJob use-case but just checking if the queue is instantiated properly? 🤔
is something missing here?
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.
I am trying to validate that the queueName used by the BullMqService is the right one for the intentions of AddJob. I am facing problems with the DI on the MemoryDB PR and I am going back and forth from next
to that PR to double check I am doing the changes properly.
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.
If you are facing problems with DI typically it's because few provider instances have the same interface. If that's still a problem maybe you should use the "named" injections.
public getQueueService(): QueueService { | ||
return this.queueService; | ||
} |
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.
you don't need to expose it this way, in the test you can do (useCase as any).queueService
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.
Changed the visibility to public readonly as I consider bad advise with hacking the type away as I mentioned in previous PRs.
2d7b22e
to
9b98b29
Compare
What change does this PR introduce?
Adds unit test for AddJob use case.
Why was this change needed?
To validate the QueueService injection in the MemoryDB PR for validation.
Other information (Screenshots)