"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const Stylus_1 = require("../../Stylus");
const MockRenderToXR_1 = require("../../XR/Mocks/MockRenderToXR");
const zSpace_1 = require("../../zSpace");
const MockAppHandlerEntity_1 = require("../Mocks/MockAppHandlerEntity");
const StopZSpaceUC_1 = require("./StopZSpaceUC");
function makeTestRig() {
    const appObjectRepo = (0, core_1.makeAppObjectRepo)();
    const appObj = appObjectRepo.getOrCreate("Handler");
    const mockAppHandler = new MockAppHandlerEntity_1.MockAppHandlerEntity(appObj);
    const zSpaceEntity = (0, zSpace_1.makeZSpaceEntity)(appObj);
    const mockRenderUC = new MockRenderToXR_1.MockRenderToXR(appObj);
    const mockEmulate = (0, Stylus_1.makeMockEmulateStylusUC)(appObjectRepo);
    const stopZSpace = (0, StopZSpaceUC_1.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