import { makeAppObjectRepo } from "@vived/core";
import { makeMockEmulateStylusUC } from "../../Stylus";
import { MockRenderToXR } from "../../XR/Mocks/MockRenderToXR";
import { makeZSpaceEntity } from "../../zSpace";
import { MockAppHandlerEntity } from "../Mocks/MockAppHandlerEntity";
import { makeStopZSpaceUC } from "./StopZSpaceUC";
function makeTestRig() {
    const appObjectRepo = makeAppObjectRepo();
    const appObj = appObjectRepo.getOrCreate("Handler");
    const mockAppHandler = new MockAppHandlerEntity(appObj);
    const zSpaceEntity = makeZSpaceEntity(appObj);
    const mockRenderUC = new MockRenderToXR(appObj);
    const mockEmulate = makeMockEmulateStylusUC(appObjectRepo);
    const stopZSpace = makeStopZSpaceUC(appObj);
    return {
        mockAppHandler,
        stopZSpace,
        zSpaceEntity,
        mockRenderUC,
        mockEmulate,
    };
}
describe("Stop ZSpace Base Handler", () => {
    it("Registers as a handler when constructed", () => {
        const { mockAppHandler, stopZSpace } = makeTestRig();
        expect(mockAppHandler.registerRequestHandler).toHaveBeenCalledWith(stopZSpace);
    });
    it("Triggers the action for v1", () => {
        const { stopZSpace } = makeTestRig();
        stopZSpace.action = jest.fn();
        stopZSpace.handleRequest(1);
        expect(stopZSpace.action).toHaveBeenCalled();
    });
    it("Throws for an unsupported version", () => {
        const { stopZSpace } = makeTestRig();
        expect(() => stopZSpace.handleRequest(-1)).toThrowError();
    });
    it("Should stop rendering the zSpace", () => {
        const { stopZSpace, mockRenderUC } = makeTestRig();
        stopZSpace.action();
        expect(mockRenderUC.stopRenderingXR).toHaveBeenCalled();
    });
    it("Should set enabled to false", () => {
        const { stopZSpace, zSpaceEntity } = makeTestRig();
        const spy = jest.spyOn(zSpaceEntity, "enabled", "set");
        stopZSpace.action();
        expect(spy).toHaveBeenCalledWith(false);
    });
    it("Should set emulate to false", () => {
        const { stopZSpace, zSpaceEntity } = makeTestRig();
        const spy = jest.spyOn(zSpaceEntity, "emulate", "set");
        stopZSpace.action();
        expect(spy).toHaveBeenCalledWith(false);
    });
    it("Stops the mouse emulation", () => {
        const { stopZSpace, mockEmulate } = makeTestRig();
        stopZSpace.action();
        expect(mockEmulate.stopEmulating).toHaveBeenCalled();
    });
});
//# sourceMappingURL=StopZSpaceUC.test.js.map