Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pubsweet
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
Giorgio Sironi
pubsweet
Commits
472ca55b
Commit
472ca55b
authored
7 years ago
by
Jure
Browse files
Options
Downloads
Patches
Plain Diff
Revert "Wrap Authorize children to avoid errors when there is more than a single element"
This reverts commit
3b578dbc
parent
9debb4e5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/helpers/Authorize.jsx
+1
-1
1 addition, 1 deletion
src/helpers/Authorize.jsx
test/helpers/Authorize.test.jsx
+4
-6
4 additions, 6 deletions
test/helpers/Authorize.test.jsx
with
5 additions
and
7 deletions
src/helpers/Authorize.jsx
+
1
−
1
View file @
472ca55b
...
@@ -41,7 +41,7 @@ export class Authorize extends React.Component {
...
@@ -41,7 +41,7 @@ export class Authorize extends React.Component {
render
()
{
render
()
{
return
this
.
state
.
authorized
return
this
.
state
.
authorized
?
<
div
>
{
this
.
props
.
children
}
</
div
>
?
this
.
props
.
children
:
this
.
props
.
unauthorized
||
null
:
this
.
props
.
unauthorized
||
null
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
test/helpers/Authorize.test.jsx
+
4
−
6
View file @
472ca55b
...
@@ -8,8 +8,7 @@ global.PUBSWEET_COMPONENTS = []
...
@@ -8,8 +8,7 @@ global.PUBSWEET_COMPONENTS = []
function
makeWrapper
(
props
=
{})
{
function
makeWrapper
(
props
=
{})
{
return
shallow
(
return
shallow
(
<
Authorize
currentUser
=
{
{
id
:
'
user1
'
}
}
{
...
props
}
>
<
Authorize
currentUser
=
{
{
id
:
'
user1
'
}
}
{
...
props
}
>
<
span
className
=
"secret"
/>
<
div
/>
<
span
className
=
"sibling"
/>
</
Authorize
>,
</
Authorize
>,
)
)
}
}
...
@@ -45,12 +44,11 @@ describe('<Authorize/>', () => {
...
@@ -45,12 +44,11 @@ describe('<Authorize/>', () => {
})
})
it
(
'
optionally shows alternative content when not authorized
'
,
async
()
=>
{
it
(
'
optionally shows alternative content when not authorized
'
,
async
()
=>
{
const
wrapper
=
makeWrapper
({
authsome
,
unauthorized
:
<
span
className
=
"message"
/>
})
const
wrapper
=
makeWrapper
({
authsome
,
unauthorized
:
<
span
/>
})
resolveMode
(
false
)
resolveMode
(
false
)
await
modePromise
await
modePromise
expect
(
wrapper
.
find
(
'
.secret
'
)).
toHaveLength
(
0
)
expect
(
wrapper
.
type
()).
toBe
(
'
span
'
)
expect
(
wrapper
.
find
(
'
.message
'
)).
toHaveLength
(
1
)
})
})
it
(
'
is empty when authsome throws
'
,
async
()
=>
{
it
(
'
is empty when authsome throws
'
,
async
()
=>
{
...
@@ -74,7 +72,7 @@ describe('<Authorize/>', () => {
...
@@ -74,7 +72,7 @@ describe('<Authorize/>', () => {
resolveMode
(
true
)
resolveMode
(
true
)
await
modePromise
await
modePromise
expect
(
wrapper
.
find
(
'
.secret
'
)).
toHaveLength
(
1
)
expect
(
wrapper
.
type
()).
toBe
(
'
div
'
)
})
})
it
(
'
rechecks auth when props change
'
,
()
=>
{
it
(
'
rechecks auth when props change
'
,
()
=>
{
...
...
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