Unverified Commit db5ac0ae authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

[Fast Refresh] Add additional test case (#12674)

parent cf0b1d94
...@@ -605,3 +605,80 @@ test('unterminated JSX', async () => { ...@@ -605,3 +605,80 @@ test('unterminated JSX', async () => {
await cleanup() await cleanup()
}) })
test.only('conversion to class component (1)', async () => {
const [session, cleanup] = await sandbox()
await session.write(
'Child.js',
`
export default function ClickCount() {
return <p>hello</p>
}
`
)
await session.patch(
'index.js',
`
import Child from './Child';
export default function Home() {
return (
<div>
<Child />
</div>
)
}
`
)
expect(await session.hasRedbox()).toBe(false)
expect(
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('hello')
await session.patch(
'Child.js',
`
import { Component } from 'react';
export default class ClickCount extends Component {
render() {
throw new Error()
}
}
`
)
expect(await session.hasRedbox(true)).toBe(true)
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"Child.js (5:16) @ ClickCount.render
3 | export default class ClickCount extends Component {
4 | render() {
> 5 | throw new Error()
| ^
6 | }
7 | }
8 | "
`)
await session.patch(
'Child.js',
`
import { Component } from 'react';
export default class ClickCount extends Component {
render() {
return <p>hello new</p>
}
}
`
)
expect(await session.hasRedbox()).toBe(false)
expect(
await session.evaluate(() => document.querySelector('p').textContent)
).toBe('hello new')
await cleanup()
})
Markdown is supported
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