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
669a7e10
Commit
669a7e10
authored
6 years ago
by
Tania Fecheta
Browse files
Options
Downloads
Patches
Plain Diff
refactor(user.test.js): move the tests for isAdmin function from collection.test.js to user.test.js
parent
d7f8a406
No related branches found
No related tags found
3 merge requests
!222
Sprint #26
,
!217
Sprint #26
,
!204
Hin 1232 send correct email to new author
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/component-helper-service/src/tests/collection.test.js
+1
-23
1 addition, 23 deletions
...ges/component-helper-service/src/tests/collection.test.js
packages/component-helper-service/src/tests/user.test.js
+40
-0
40 additions, 0 deletions
packages/component-helper-service/src/tests/user.test.js
with
41 additions
and
23 deletions
packages/component-helper-service/src/tests/collection.test.js
+
1
−
23
View file @
669a7e10
...
...
@@ -5,7 +5,7 @@ const { cloneDeep } = require('lodash')
const
fixturesService
=
require
(
'
pubsweet-component-fixture-service
'
)
const
{
fixtures
,
Model
}
=
fixturesService
const
{
Collection
,
Fragment
,
User
}
=
require
(
'
../Helper
'
)
const
{
Collection
,
Fragment
}
=
require
(
'
../Helper
'
)
describe
(
'
Collection helper
'
,
()
=>
{
let
testFixtures
=
{}
...
...
@@ -231,26 +231,4 @@ describe('Collection helper', () => {
expect
(
canHEMakeRecommendation
).
toBe
(
false
)
})
})
describe
(
'
isAdmin
'
,
()
=>
{
it
(
'
should return true if user is admin
'
,
async
()
=>
{
const
{
admin
}
=
testFixtures
.
users
const
adminId
=
admin
.
id
const
UserModel
=
models
.
User
const
userHelper
=
new
User
({
UserModel
})
const
isAdmin
=
await
userHelper
.
isAdmin
(
adminId
)
expect
(
isAdmin
).
toBe
(
true
)
})
it
(
'
should return false if user is not admin
'
,
async
()
=>
{
const
{
reviewer
}
=
testFixtures
.
users
const
reviewerId
=
reviewer
.
id
const
UserModel
=
models
.
User
const
userHelper
=
new
User
({
UserModel
})
const
isAdmin
=
await
userHelper
.
isAdmin
(
reviewerId
)
expect
(
isAdmin
).
toBe
(
false
)
})
})
})
This diff is collapsed.
Click to expand it.
packages/component-helper-service/src/tests/user.test.js
0 → 100644
+
40
−
0
View file @
669a7e10
process
.
env
.
NODE_TLS_REJECT_UNAUTHORIZED
=
'
0
'
process
.
env
.
SUPPRESS_NO_CONFIG_WARNING
=
true
const
{
cloneDeep
}
=
require
(
'
lodash
'
)
const
fixturesService
=
require
(
'
pubsweet-component-fixture-service
'
)
const
{
fixtures
,
Model
}
=
fixturesService
const
{
User
}
=
require
(
'
../Helper
'
)
describe
(
'
User helper
'
,
()
=>
{
let
testFixtures
=
{}
let
models
beforeEach
(()
=>
{
testFixtures
=
cloneDeep
(
fixtures
)
models
=
Model
.
build
(
testFixtures
)
})
describe
(
'
isAdmin
'
,
()
=>
{
it
(
'
should return true if user is admin
'
,
async
()
=>
{
const
{
admin
}
=
testFixtures
.
users
const
adminId
=
admin
.
id
const
UserModel
=
models
.
User
const
userHelper
=
new
User
({
UserModel
})
const
isAdmin
=
await
userHelper
.
isAdmin
(
adminId
)
expect
(
isAdmin
).
toBe
(
true
)
})
it
(
'
should return false if user is not admin
'
,
async
()
=>
{
const
{
reviewer
}
=
testFixtures
.
users
const
reviewerId
=
reviewer
.
id
const
UserModel
=
models
.
User
const
userHelper
=
new
User
({
UserModel
})
const
isAdmin
=
await
userHelper
.
isAdmin
(
reviewerId
)
expect
(
isAdmin
).
toBe
(
false
)
})
})
})
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