This file contains hidden or 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"; | |
// Can not really write good unit tests | |
// Every test should start with a mock of the API call to fetch the `book` | |
export default function BookDetail() { | |
const [isDeleteClicked, setDeleteClicked] = React.useState(false); | |
const { state: book, fetchBook, deleteBook } = React.useContext(BookContext); | |
const bookUrl = utils.buildBookUrlFromUri(); | |
React.useEffect(() => { |
This file contains hidden or 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 SmartBookDetail() { | |
const [isDeleteClicked, setDeleteClicked] = React.useState(false); | |
const { state: book, fetchBook, deleteBook } = React.useContext(BookContext); | |
const bookUrl = utils.buildBookUrlFromUri(); | |
React.useEffect(() => { | |
fetchBook(bookUrl); | |
}, []); |
This file contains hidden or 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"; | |
// Same level of complexity for integration tests | |
export default function SetupBookDetail() { | |
const { state: book, fetchBook, deleteBook } = React.useContext(BookContext); | |
const bookUrl = utils.buildBookUrlFromUri(); | |
React.useEffect(() => { | |
fetchBook(bookUrl); | |
}, []); |
OlderNewer