-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1abeec9
commit 522c692
Showing
7 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
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
12 changes: 12 additions & 0 deletions
12
api/src/evaluation/infrastructure/repositories/answer-job-repository.js
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,12 @@ | ||
import { AnswerJob } from '../../../quest/domain/models/AnwserJob.js'; | ||
import { JobRepository } from '../../../shared/infrastructure/repositories/jobs/job-repository.js'; | ||
|
||
class AnswerJobRepository extends JobRepository { | ||
constructor() { | ||
super({ | ||
name: AnswerJob.name, | ||
}); | ||
} | ||
} | ||
|
||
export const answerJobRepository = new AnswerJobRepository(); |
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,15 @@ | ||
import { JobController, JobGroup } from '../../../shared/application/jobs/job-controller.js'; | ||
import { AnswerJob } from '../../domain/models/AnwserJob.js'; | ||
import { usecases } from '../../domain/usecases/index.js'; | ||
|
||
export class AnswerJobController extends JobController { | ||
constructor() { | ||
super(AnswerJob.name, { jobGroup: JobGroup.FAST }); | ||
} | ||
|
||
async handle({ data }) { | ||
const { userId } = data; | ||
|
||
return usecases.rewardUser({ userId }); | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
api/tests/quest/unit/application/answer-job-controller_test.js
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,21 @@ | ||
import { AnswerJobController } from '../../../../src/quest/application/jobs/answer-job-controller.js'; | ||
import { AnswerJob } from '../../../../src/quest/domain/models/AnwserJob.js'; | ||
import { usecases } from '../../../../src/quest/domain/usecases/index.js'; | ||
import { JobGroup } from '../../../../src/shared/application/jobs/job-controller.js'; | ||
import { expect, sinon } from '../../../test-helper.js'; | ||
|
||
describe('Unit | Application | Jobs | AnswerJobController', function () { | ||
it('setup the job controller configuration', async function () { | ||
const jobController = new AnswerJobController(); | ||
expect(jobController.jobName).to.equal(AnswerJob.name); | ||
expect(jobController.jobGroup).to.equal(JobGroup.FAST); | ||
}); | ||
|
||
it('triggers rewarding', async function () { | ||
sinon.stub(usecases, 'rewardUser').resolves(); | ||
const userId = Symbol('data'); | ||
const jobController = new AnswerJobController(); | ||
await jobController.handle({ data: userId }); | ||
expect(usecases.rewardUser).to.have.been.calledWith({ userId }); | ||
}); | ||
}); |