add a test

docks66-json-schema
Yanick Champoux 2023-04-16 11:52:36 -04:00
parent 948fe96e0a
commit 88c08a8b79
1 changed files with 19 additions and 1 deletions

View File

@ -1,9 +1,27 @@
import { render, fireEvent, screen, getByText } from "@testing-library/svelte";
import { render, fireEvent } from "@testing-library/svelte";
import "@testing-library/jest-dom";
import { tick } from "svelte";
import Page from "./+page.svelte";
import { createApi } from "$lib/store/api.ts";
test("we have a page", () => {
const { getByText } = render(Page);
expect(getByText("propulsion")).toBeInTheDocument();
});
test("we can pass a store", async () => {
const context = new Map();
const api = createApi();
context.set("api", api);
api.dispatch.updateIdentification({ shipClass: "Bonobo" });
const { getByPlaceholderText } = render(Page, { context });
const classInput = getByPlaceholderText("ship class");
await fireEvent.input(classInput, { target: { value: "Tarzan" } });
expect(classInput.value).toEqual("Tarzan");
expect(api.getState().identification.shipClass).toBe("Tarzan");
});