mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-04 22:58:29 +08:00
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
/**
|
|
* @jest-environment jsdom
|
|
*/
|
|
import { QuestInfoController } from "../controllers/QuestInfoController";
|
|
import { undo_manager } from "../../core/undo/UndoManager";
|
|
import { QuestInfoView } from "./QuestInfoView";
|
|
import { Episode } from "../../core/data_formats/parsing/quest/Episode";
|
|
import {
|
|
create_area_store,
|
|
create_quest_editor_store,
|
|
} from "../../../test/src/quest_editor/stores/store_creation";
|
|
import { create_new_quest } from "../stores/quest_creation";
|
|
|
|
test("Renders correctly without a current quest.", () => {
|
|
const view = new QuestInfoView(new QuestInfoController(create_quest_editor_store()));
|
|
|
|
expect(view.element).toMatchSnapshot('should render a "No quest loaded." view');
|
|
});
|
|
|
|
test("Renders correctly with a current quest.", async () => {
|
|
const area_store = create_area_store();
|
|
const store = create_quest_editor_store();
|
|
const view = new QuestInfoView(new QuestInfoController(store));
|
|
|
|
await store.set_quest(create_new_quest(area_store, Episode.I));
|
|
|
|
expect(view.element).toMatchSnapshot("should render property inputs");
|
|
});
|
|
|
|
test("When the view's element is focused the store's undo stack should become the current stack.", () => {
|
|
const store = create_quest_editor_store();
|
|
const view = new QuestInfoView(new QuestInfoController(store));
|
|
|
|
undo_manager.make_noop_current();
|
|
|
|
view.element.focus();
|
|
|
|
expect(undo_manager.current.val).toBe(store.undo);
|
|
});
|