This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { render, unmountComponentAtNode } from "react-dom"; | |
import { act } from "react-dom/test-utils"; | |
import Hello from "./hello"; | |
let container = null; | |
// 가독성을 위해 beforeEach, afterEach는 생략합니다. | |
// 생략된 코드는 위의 Setup/Teardown 부분에 있는 예시코드와 동일합니다. | |
it("renders with or without a name", () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
export default function Hello(props) { | |
if (props.name) { | |
return <h1>Hello, {props.name}!</h1>; | |
} | |
else { | |
return <span>Hey, stranger</span>; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
act(() => { | |
// 컴포넌트를 렌더합니다. | |
}); | |
// 평가를 수행합니다. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { unmountComponentAtNode } from "react-dom"; | |
let container = null; | |
beforeEach(() => { | |
// 렌더 타겟으로 사용할 DOM 요소를 생성합니다. | |
container = document.createElement("div"); | |
document.body.appendChild(container); | |
}); | |
afterEach(() => { |
NewerOlder