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
{ | |
"@context": [ | |
"http://www.w3.org/ns/anno.jsonld", | |
"http://iiif.io/api/presentation/3/context.json" | |
], | |
"type": "Manifest", | |
"id": "http://localhost:3333/concern/generic_works/9019s2443/manifest", | |
"label": "Generic Bunny", | |
"metadata": [ | |
{ |
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
// https://testing-library.com/docs/example-react-router | |
import React from "react"; | |
import { Router } from "react-router-dom"; | |
import { render } from "@testing-library/react"; | |
import { createMemoryHistory } from "history"; | |
// test utils file | |
function renderWithRouter( | |
ui, |
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 { withRouter } from "react-router"; | |
import ScreenHeader from "../../components/UI/ScreenHeader"; | |
import Error from "../../components/UI/Error"; | |
import Loading from "../../components/UI/Loading"; | |
import { useQuery } from "@apollo/react-hooks"; | |
import { GET_PROJECT } from "../../components/Project/project.query"; | |
const ScreensProject = ({ match }) => { | |
const { id } = match.params; |
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
// Component example | |
// ContentWrapper.jsx | |
import React from "react"; | |
import Main from "./Main"; | |
import { withRouter } from "react-router-dom"; | |
const ContentWrapper = ({ children, match }) => ( | |
<Main> | |
<p>Match id: {match.params.id}</p> | |
{children} |
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
// Very simplified version of a component | |
import React from "react" | |
import { Helmet } from "react-helmet" | |
import { useStaticQuery, graphql } from "gatsby" | |
import ogImage from "../images/og-image.png" | |
export default function SEO() { | |
return ( |
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
/** | |
* Testing Library utility function to wrap tested component in React Hook Form | |
* @param {ReactElement} ui A React component | |
* @param objectParameters | |
* @param {Object} objectParameters.defaultValues Initial form values to pass into | |
* React Hook Form, which you can then assert against | |
*/ | |
export function renderWithReactHookForm( | |
ui, | |
{ defaultValues = {} } = {} |
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 { screen } from "@testing-library/react"; | |
import { renderWithReactHookForm } from "./services/testing-helpers"; | |
import UIFormRelatedURL from "./RelatedURL"; | |
const props = { | |
name: "relatedUrl", | |
label: "Related URL", | |
}; |
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 { Router } from "react-router-dom"; | |
import { render } from "@testing-library/react"; | |
import { useForm, FormProvider } from "react-hook-form"; | |
/** | |
* Testing Library utility function to wrap tested component in React Hook Form | |
* @param {ReactElement} ui A React component | |
* @param objectParameters | |
* @param {Object} objectParameters.defaultValues Initial form values to pass into |
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
/** | |
* Higher order helper function which wraps a component w/ React Hook Form | |
* @param {React Component} WrappedComponent to pass into | |
* @param {*} restProps any other remaining props | |
* @returns {React Component} | |
*/ | |
export function withReactHookForm(WrappedComponent, restProps) { | |
const HOC = () => { | |
const methods = useForm(); |
OlderNewer