Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
4bec4cc6
Unverified
Commit
4bec4cc6
authored
May 08, 2018
by
Tim Neutkens
Committed by
GitHub
May 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test stateful component style update (#4309)
parent
76f5e979
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
10 deletions
+68
-10
style-stateful-component.js
test/integration/basic/pages/hmr/style-stateful-component.js
+20
-0
style.js
test/integration/basic/pages/hmr/style.js
+13
-10
hmr.js
test/integration/basic/test/hmr.js
+35
-0
No files found.
test/integration/basic/pages/hmr/style-stateful-component.js
0 → 100644
View file @
4bec4cc6
import
React
,
{
Component
}
from
'react'
export
default
class
StyleStateFul
extends
Component
{
render
()
{
return
(
<
React
.
Fragment
>
<
div
className
=
'hmr-style-page'
>
<
p
>
This
is
the
style
page
.
<
style
jsx
>
{
`
p {
font-size: 100px;
}
`
}
<
/style
>
<
/p
>
<
/div
>
<
/React.Fragment
>
)
}
}
test/integration/basic/pages/hmr/style.js
View file @
4bec4cc6
import
React
from
'react'
export
default
()
=>
{
export
default
()
=>
{
return
(
return
(
<>
' '
<
div
className
=
'hmr-style-page'
>
<
React
.
Fragment
>
<
p
>
<
div
className
=
'hmr-style-page'
>
This
is
the
style
page
.
<
p
>
<
style
jsx
>
{
`
This
is
the
style
page
.
p {
<
style
jsx
>
{
`
font-size: 100px;
p {
}
font-size: 100px;
`
}
<
/style
>
}
<
/p
>
`
}
<
/style
>
<
/div>' '</
>
<
/p
>
<
/div
>
<
/React.Fragment
>
)
)
}
}
test/integration/basic/test/hmr.js
View file @
4bec4cc6
...
@@ -133,6 +133,41 @@ export default (context, render) => {
...
@@ -133,6 +133,41 @@ export default (context, render) => {
browser
.
close
()
browser
.
close
()
})
})
// Added because of a regression in react-hot-loader, see issues: #4246 #4273
// Also: https://github.com/zeit/styled-jsx/issues/425
it
(
'should update styles in a stateful component correctly'
,
async
()
=>
{
const
browser
=
await
webdriver
(
context
.
appPort
,
'/hmr/style-stateful-component'
)
const
pTag
=
await
browser
.
elementByCss
(
'.hmr-style-page p'
)
const
initialFontSize
=
await
pTag
.
getComputedCss
(
'font-size'
)
expect
(
initialFontSize
).
toBe
(
'100px'
)
const
pagePath
=
join
(
__dirname
,
'../'
,
'pages'
,
'hmr'
,
'style-stateful-component.js'
)
const
originalContent
=
readFileSync
(
pagePath
,
'utf8'
)
const
editedContent
=
originalContent
.
replace
(
'100px'
,
'200px'
)
// Change the page
writeFileSync
(
pagePath
,
editedContent
,
'utf8'
)
// wait for 5 seconds
await
waitFor
(
5000
)
try
{
// Check whether the this page has reloaded or not.
const
editedPTag
=
await
browser
.
elementByCss
(
'.hmr-style-page p'
)
const
editedFontSize
=
await
editedPTag
.
getComputedCss
(
'font-size'
)
expect
(
editedFontSize
).
toBe
(
'200px'
)
}
finally
{
// Finally is used so that we revert the content back to the original regardless of the test outcome
// restore the about page content.
writeFileSync
(
pagePath
,
originalContent
,
'utf8'
)
}
browser
.
close
()
})
})
})
})
})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment