Skip to content
Snippets Groups Projects
Commit da9a54a6 authored by Tania Fecheta's avatar Tania Fecheta
Browse files

test(canHeMakeAnotherRecommendation): add unit tests for canHEMakeAnotherRecommendation

parent eaadaee0
No related branches found
No related tags found
3 merge requests!176Sprint 24,!171Sprint 24,!157fix(fragmentRecommendation): allow HE to make another recommendation on the same…
......@@ -15,6 +15,8 @@ const { recommendations: configRecommendations } = config
const acceptedReviewerId = chance.guid()
const submittedReviewerId1 = chance.guid()
const submittedReviewerId2 = chance.guid()
const handlingEditorId = chance.guid()
const editorInChiefId = chance.guid()
const fragment = {
invitations: [
{
......@@ -281,4 +283,93 @@ describe('Fragment helper', () => {
}
})
})
describe('canHEMakeAnotherRecommendation', () => {
it('should return true when He makes a recommendation after EIC decision was to return to HE', async () => {
testFragment.recommendations = [
{
recommendation: 'publish',
recommendationType: 'editorRecommendation',
comments: [
{
content: chance.paragraph(),
public: true,
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: handlingEditorId,
createdOn: 1542361074012,
updatedOn: chance.timestamp(),
},
{
recommendation: 'return-to-handling-editor',
recommendationType: 'editorRecommendation',
comments: [
{
content: chance.paragraph(),
public: true,
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: editorInChiefId,
createdOn: 1542361115749,
updatedOn: chance.timestamp(),
},
]
const currentUserRecommendations = testFragment.recommendations.filter(
r => r.userId === handlingEditorId,
)
const fragmentHelper = new Fragment({ fragment: testFragment })
const canHEMakeAnotherRecommendation = await fragmentHelper.canHEMakeAnotherRecommendation(
currentUserRecommendations,
)
expect(canHEMakeAnotherRecommendation).toBe(true)
})
it('should return false when He makes another recommendation', async () => {
testFragment.recommendations = [
{
recommendation: 'publish',
recommendationType: 'editorRecommendation',
comments: [
{
content: chance.paragraph(),
public: true,
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: handlingEditorId,
createdOn: 1542361074012,
updatedOn: chance.timestamp(),
},
]
const currentUserRecommendations = testFragment.recommendations.filter(
r => r.userId === handlingEditorId,
)
const fragmentHelper = new Fragment({ fragment: testFragment })
const canHEMakeAnotherRecommendation = await fragmentHelper.canHEMakeAnotherRecommendation(
currentUserRecommendations,
)
expect(canHEMakeAnotherRecommendation).toBe(false)
})
})
})
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment