|
| 1 | +/** |
| 2 | + * @vitest-environment happy-dom |
| 3 | + */ |
| 4 | +import { render } from "@testing-library/svelte"; |
| 5 | +import { describe, expect, it } from "vitest"; |
| 6 | +import WithData from "../WithData.svelte"; |
| 7 | +import { CBNData } from "../data"; |
| 8 | +import Construction from "./Construction.svelte"; |
| 9 | + |
| 10 | +describe("Construction", () => { |
| 11 | + it("renders furniture prerequisites and null furniture results", () => { |
| 12 | + const data = new CBNData([ |
| 13 | + { |
| 14 | + type: "construction_group", |
| 15 | + id: "advanced_object_deconstruction", |
| 16 | + name: "Advanced Object Deconstruction", |
| 17 | + }, |
| 18 | + { |
| 19 | + type: "construction", |
| 20 | + id: "constr_remove_object_fireplace", |
| 21 | + group: "advanced_object_deconstruction", |
| 22 | + category: "OTHER", |
| 23 | + time: "90 m", |
| 24 | + required_skills: [["fabrication", 2]], |
| 25 | + pre_furniture: "f_fireplace", |
| 26 | + post_furniture: "f_null", |
| 27 | + }, |
| 28 | + { |
| 29 | + type: "furniture", |
| 30 | + id: "f_fireplace", |
| 31 | + name: "fireplace", |
| 32 | + description: "A warm test fixture.", |
| 33 | + move_cost_mod: 0, |
| 34 | + required_str: 0, |
| 35 | + }, |
| 36 | + ]); |
| 37 | + |
| 38 | + const { getByText } = render(WithData, { |
| 39 | + Component: Construction, |
| 40 | + data, |
| 41 | + construction: data.byId("construction", "constr_remove_object_fireplace"), |
| 42 | + }); |
| 43 | + |
| 44 | + expect(getByText("Requires")).toBeTruthy(); |
| 45 | + expect(getByText("fireplace")).toBeTruthy(); |
| 46 | + expect(getByText("Creates")).toBeTruthy(); |
| 47 | + expect(getByText("nothing")).toBeTruthy(); |
| 48 | + }); |
| 49 | + |
| 50 | + it("renders terrain prerequisites and furniture results without prefix inference", () => { |
| 51 | + const data = new CBNData([ |
| 52 | + { |
| 53 | + type: "construction_group", |
| 54 | + id: "build_beaded_door", |
| 55 | + name: "Build Beaded Door", |
| 56 | + }, |
| 57 | + { |
| 58 | + type: "construction", |
| 59 | + id: "constr_beaded_door", |
| 60 | + group: "build_beaded_door", |
| 61 | + category: "OTHER", |
| 62 | + time: "30 m", |
| 63 | + required_skills: [["fabrication", 1]], |
| 64 | + pre_terrain: "t_door_frame", |
| 65 | + post_furniture: "f_beaded_door", |
| 66 | + }, |
| 67 | + { |
| 68 | + type: "terrain", |
| 69 | + id: "t_door_frame", |
| 70 | + name: "door frame", |
| 71 | + description: "A test door frame.", |
| 72 | + }, |
| 73 | + { |
| 74 | + type: "furniture", |
| 75 | + id: "f_beaded_door", |
| 76 | + name: "beaded door", |
| 77 | + description: "A test beaded door.", |
| 78 | + move_cost_mod: 0, |
| 79 | + required_str: 0, |
| 80 | + }, |
| 81 | + ]); |
| 82 | + |
| 83 | + const { getByText } = render(WithData, { |
| 84 | + Component: Construction, |
| 85 | + data, |
| 86 | + construction: data.byId("construction", "constr_beaded_door"), |
| 87 | + }); |
| 88 | + |
| 89 | + expect(getByText("door frame")).toBeTruthy(); |
| 90 | + expect(getByText("beaded door")).toBeTruthy(); |
| 91 | + }); |
| 92 | +}); |
0 commit comments