aotds-docks/src/routes/editor/page.test.js

28 lines
825 B
JavaScript
Raw Normal View History

2023-04-16 15:52:36 +00:00
import { render, fireEvent } from "@testing-library/svelte";
2023-04-14 18:29:20 +00:00
import "@testing-library/jest-dom";
2023-04-16 15:52:36 +00:00
import { tick } from "svelte";
2023-04-14 18:29:20 +00:00
import Page from "./+page.svelte";
2023-04-16 15:52:36 +00:00
import { createApi } from "$lib/store/api.ts";
2023-04-14 18:29:20 +00:00
test("we have a page", () => {
const { getByText } = render(Page);
expect(getByText("propulsion")).toBeInTheDocument();
});
2023-04-16 15:52:36 +00:00
test("we can pass a store", async () => {
const context = new Map();
const api = createApi();
context.set("api", api);
api.dispatch.updateIdentification({ shipClass: "Bonobo" });
2023-04-21 15:17:28 +00:00
const { getByLabelText } = render(Page, { context });
2023-04-16 15:52:36 +00:00
2023-04-21 15:17:28 +00:00
const classInput = getByLabelText("ship class");
2023-04-16 15:52:36 +00:00
await fireEvent.input(classInput, { target: { value: "Tarzan" } });
expect(classInput.value).toEqual("Tarzan");
expect(api.getState().identification.shipClass).toBe("Tarzan");
});