Something went wrong. Try again.
Starship Simulator Controls thoriumsim.com
Something went wrong. Try again.
TypeScript
at develop
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import ImpulseEnginesPlugin from "@thorium/.server/classes/Plugins/ShipSystems/ImpulseEngines";import { thoriumContext } from "@thorium/utils/.server/context";import { createMockDataContext, createMockRouter,} from "@thorium/utils/.server/createMockDataContext";import { testDataStoreProps } from "@thorium/utils/.server/db-fs/testDataStoreProps";import { describe, expect, it } from "vitest";
describe("impulse engines plugin input", () => { it("should create a new impulse engine system", async () => { await thoriumContext.run(testDataStoreProps, async () => { const dataContext = createMockDataContext(); const router = createMockRouter(dataContext); const created = await router.plugin.systems.create({ pluginId: "Test Plugin", type: "impulseEngines", name: "Test Impulse Engine", });
expect(created).toBeTruthy(); expect(created.shipSystemId).toEqual("Test Impulse Engine"); const system = dataContext.server.plugins[0].aspects.shipSystems[0]; if (!(system instanceof ImpulseEnginesPlugin)) throw new Error("Not impulse engines"); expect(system.type).toEqual("impulseEngines"); expect(system.cruisingSpeed).toEqual(1500); }); }); it("should update an impulse engine system", async () => { await thoriumContext.run(testDataStoreProps, async () => { const dataContext = createMockDataContext(); const router = createMockRouter(dataContext); await router.plugin.systems.create({ pluginId: "Test Plugin", type: "impulseEngines", name: "Test Impulse Engine", }); const system = dataContext.server.plugins[0].aspects.shipSystems[0];
await router.plugin.systems.impulse.update({ pluginId: "Test Plugin", systemId: "Test Impulse Engine", cruisingSpeed: 2000, }); if (!(system instanceof ImpulseEnginesPlugin)) throw new Error("Not impulse engines"); expect(system.cruisingSpeed).toEqual(2000);
expect(system.emergencySpeed).toEqual(2000); await router.plugin.systems.impulse.update({ pluginId: "Test Plugin", systemId: "Test Impulse Engine", emergencySpeed: 1000, }); expect(system.emergencySpeed).toEqual(1000);
expect(system.acceleration).toEqual(625); await router.plugin.systems.impulse.update({ pluginId: "Test Plugin", systemId: "Test Impulse Engine", acceleration: 10000, }); expect(system.acceleration).toEqual(10000); }); });});