File size: 469 Bytes
2f49513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { renderHook, act } from "@testing-library/react";
import useChatHistory from "../useChatHistory";

describe("useChatHistory", () => {
  test("should add chat entries", () => {
    const { result } = renderHook(() => useChatHistory());

    act(() => {
      result.current.add("Hello", "us");
    });

    expect(result.current.entries).toHaveLength(1);
    expect(result.current.entries[0]).toEqual({
      text: "Hello",
      author: "us",
    });
  });
});