Skip to content

Instantly share code, notes, and snippets.

import React from "react"
import { render } from "@testing-library/react"
test("Adds number and gives result as a prop", function test() {
let result
function WrappedComponent({ sum }) {
result = sum
return null
}
const ComponentWithSum = withSum(WrappedComponent, [4, 6])
1. When the name to search is not specified, all characters are shown despite their name.
2. When searching for the name "Rick", shows all characters that contain "Rick" in its name.
3. When searching for the name "ick", shows all characters that contain "ick" in its name.
4. When searching for a name that's not part of any character's name, a message is shown to inform the user that there are no characters for their search.
5. Searching for a name should be case insensitive.
6. When the status is not specified, all characters are shown despite their status.
7. When searching for characters with status, "Alive", shows all characters that are alive.
8. When searching for characters with status, "Dead", shows all characters that are dead.
9. When searching for characters with status "Unknown", shows all characters that is not known if they're alive or dead.
10. When searching for a character with the name "Rick" and the status "Alive", all characters with the name Rick that are alive are shown.
@Jnforja
Jnforja / auth-context.js
Created May 14, 2020 17:03
Example of context and hook for authentication
import React, { useContext, useEffect, useState, useRef } from 'react';
import { login } from './login-service';
import { fetchUser as fetchUserRequest } from './fetch-user';
import { removeAccessToken } from './access-token-storage';
import styles from './auth-context.module.scss';
const AuthContext = React.createContext();
function AuthProvider({
fetchUser = fetchUserRequest,
import { add, Add } from "./Add";
import React from "react";
import { render, fireEvent, waitFor } from "@testing-library/react";
test("6 + 4 = 10", function () {
expect.assertions(1);
return expect(add(6, 4)).resolves.toBe(10);
});
test("Add component has expected fields", function () {