Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xpub-faraday
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
xpub
xpub-faraday
Commits
79225893
Commit
79225893
authored
6 years ago
by
Sebastian Mihalache
Browse files
Options
Downloads
Patches
Plain Diff
fix(fragmentHelper): write unit tests for getReviewers
parent
290bb6fc
No related branches found
No related tags found
2 merge requests
!136
Sprint 22 features (updates)
,
!126
Hin 1046
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/component-helper-service/src/services/Fragment.js
+1
-0
1 addition, 0 deletions
packages/component-helper-service/src/services/Fragment.js
packages/component-helper-service/src/tests/fragment.test.js
+100
-9
100 additions, 9 deletions
packages/component-helper-service/src/tests/fragment.test.js
with
101 additions
and
9 deletions
packages/component-helper-service/src/services/Fragment.js
+
1
−
0
View file @
79225893
...
@@ -92,6 +92,7 @@ class Fragment {
...
@@ -92,6 +92,7 @@ class Fragment {
getInvitations
({
isAccepted
=
true
,
role
=
'
reviewer
'
,
type
})
{
getInvitations
({
isAccepted
=
true
,
role
=
'
reviewer
'
,
type
})
{
const
{
fragment
:
{
invitations
=
[],
recommendations
=
[]
}
}
=
this
const
{
fragment
:
{
invitations
=
[],
recommendations
=
[]
}
}
=
this
let
filteredInvitations
=
isAccepted
let
filteredInvitations
=
isAccepted
?
invitations
.
filter
(
?
invitations
.
filter
(
inv
=>
inv
.
role
===
role
&&
inv
.
hasAnswer
&&
inv
.
isAccepted
,
inv
=>
inv
.
role
===
role
&&
inv
.
hasAnswer
&&
inv
.
isAccepted
,
...
...
This diff is collapsed.
Click to expand it.
packages/component-helper-service/src/tests/fragment.test.js
+
100
−
9
View file @
79225893
...
@@ -3,7 +3,9 @@ process.env.SUPPRESS_NO_CONFIG_WARNING = true
...
@@ -3,7 +3,9 @@ process.env.SUPPRESS_NO_CONFIG_WARNING = true
const
{
cloneDeep
}
=
require
(
'
lodash
'
)
const
{
cloneDeep
}
=
require
(
'
lodash
'
)
const
fixturesService
=
require
(
'
pubsweet-component-fixture-service
'
)
const
fixturesService
=
require
(
'
pubsweet-component-fixture-service
'
)
const
Chance
=
require
(
'
chance
'
)
const
chance
=
new
Chance
()
const
{
fixtures
}
=
fixturesService
const
{
fixtures
}
=
fixturesService
const
{
Fragment
}
=
require
(
'
../Helper
'
)
const
{
Fragment
}
=
require
(
'
../Helper
'
)
...
@@ -13,17 +15,106 @@ describe('Fragment helper', () => {
...
@@ -13,17 +15,106 @@ describe('Fragment helper', () => {
testFixtures
=
cloneDeep
(
fixtures
)
testFixtures
=
cloneDeep
(
fixtures
)
})
})
it
(
'
hasReviewReport - should return true if the fragment has a review report
'
,
()
=>
{
describe
(
'
hasReviewReport
'
,
()
=>
{
const
{
fragment
}
=
testFixtures
.
fragments
it
(
'
should return true if the fragment has a review report
'
,
()
=>
{
const
fragmentHelper
=
new
Fragment
({
fragment
})
const
{
fragment
}
=
testFixtures
.
fragments
const
fragmentHelper
=
new
Fragment
({
fragment
})
expect
(
fragmentHelper
.
hasReviewReport
()).
toBeTruthy
()
expect
(
fragmentHelper
.
hasReviewReport
()).
toBeTruthy
()
})
it
(
'
should return false if the fragment does not have a review report
'
,
()
=>
{
const
{
fragment
}
=
testFixtures
.
fragments
fragment
.
recommendations
=
[]
const
fragmentHelper
=
new
Fragment
({
fragment
})
expect
(
fragmentHelper
.
hasReviewReport
()).
toBeFalsy
()
})
})
})
it
(
'
hasReviewReport - should return false if the fragment does not have a review report
'
,
()
=>
{
const
{
fragment
}
=
testFixtures
.
fragments
fragment
.
recommendations
=
[]
const
fragmentHelper
=
new
Fragment
({
fragment
})
expect
(
fragmentHelper
.
hasReviewReport
()).
toBeFalsy
()
describe
(
'
getInvitations
'
,
()
=>
{
it
(
'
should return accepted invitations if type is accepted
'
,
()
=>
{
const
{
fragment
}
=
testFixtures
.
fragments
const
acceptedReviewerId
=
chance
.
guid
()
const
submittedReviewerId
=
chance
.
guid
()
fragment
.
invitations
.
push
(
{
id
:
chance
.
guid
(),
role
:
'
reviewer
'
,
hasAnswer
:
true
,
isAccepted
:
true
,
userId
:
acceptedReviewerId
,
invitedOn
:
chance
.
timestamp
(),
respondedOn
:
chance
.
timestamp
(),
type
:
'
invitation
'
,
},
{
id
:
chance
.
guid
(),
role
:
'
reviewer
'
,
hasAnswer
:
true
,
isAccepted
:
true
,
userId
:
submittedReviewerId
,
invitedOn
:
chance
.
timestamp
(),
respondedOn
:
chance
.
timestamp
(),
type
:
'
invitation
'
,
},
)
fragment
.
recommendations
.
push
(
{
recommendation
:
'
publish
'
,
recommendationType
:
'
review
'
,
comments
:
[
{
content
:
chance
.
paragraph
(),
public
:
chance
.
bool
(),
files
:
[
{
id
:
chance
.
guid
(),
name
:
'
file.pdf
'
,
size
:
chance
.
natural
(),
},
],
},
],
id
:
chance
.
guid
(),
userId
:
submittedReviewerId
,
createdOn
:
chance
.
timestamp
(),
updatedOn
:
chance
.
timestamp
(),
submittedOn
:
chance
.
timestamp
(),
},
{
recommendation
:
'
publish
'
,
recommendationType
:
'
review
'
,
comments
:
[
{
content
:
chance
.
paragraph
(),
public
:
chance
.
bool
(),
files
:
[
{
id
:
chance
.
guid
(),
name
:
'
file.pdf
'
,
size
:
chance
.
natural
(),
},
],
},
],
id
:
chance
.
guid
(),
userId
:
acceptedReviewerId
,
createdOn
:
chance
.
timestamp
(),
updatedOn
:
chance
.
timestamp
(),
// submittedOn: chance.timestamp(),
},
)
const
fragmentHelper
=
new
Fragment
({
fragment
})
const
acceptedInvitations
=
fragmentHelper
.
getInvitations
({
isAccepted
:
true
,
type
:
'
accepted
'
,
})
console
.
log
(
acceptedInvitations
)
})
})
})
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment