"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@vived/core");
const core_2 = require("@vived/core");
const StylusEntity_1 = require("../Entity/StylusEntity");
const StylusIsInUsePM_1 = require("./StylusIsInUsePM");
function makeTestRig() {
    const appObjects = (0, core_1.makeAppObjectRepo)();
    const registerSingletonSpy = jest.spyOn(appObjects, "registerSingleton");
    const stylusAO = appObjects.getOrCreate("Stylus");
    const stylusEntity = (0, StylusEntity_1.makeStylusEntity)(stylusAO);
    const pm = (0, StylusIsInUsePM_1.makeStylusIsInUsePM)(stylusAO);
    return { pm, stylusEntity, registerSingletonSpy, appObjects };
}
describe("Stylus is in use", () => {
    it("Initializes the VM", () => {
        const { pm } = makeTestRig();
        const lastVM = pm.lastVM;
        expect(lastVM).toEqual(false);
    });
    it("Updates is in use to true if the stylus has moved", () => {
        const { pm, stylusEntity } = makeTestRig();
        stylusEntity.transform.worldPosition = core_2.Vector3.One();
        stylusEntity.transform.worldRotation = new core_2.Quaternion(1, 1, 1, 1);
        const lastVM = pm.lastVM;
        expect(lastVM).toEqual(true);
    });
    it("Updates is in use back to false", () => {
        const { pm, stylusEntity } = makeTestRig();
        stylusEntity.transform.worldPosition = core_2.Vector3.One();
        stylusEntity.transform.worldRotation = new core_2.Quaternion(1, 1, 1, 1);
        stylusEntity.transform.worldPosition = core_2.Vector3.Zero();
        stylusEntity.transform.worldRotation = core_2.Quaternion.Identity();
        const lastVM = pm.lastVM;
        expect(lastVM).toEqual(false);
    });
    it("Registers as a singleton", () => {
        const { pm, registerSingletonSpy } = makeTestRig();
        expect(registerSingletonSpy).toHaveBeenCalledWith(pm);
    });
    it("Gets the singleton", () => {
        const { pm, appObjects } = makeTestRig();
        expect(StylusIsInUsePM_1.StylusIsInUsePM.get(appObjects)).toEqual(pm);
    });
});
//# sourceMappingURL=StylusIsInUsePM.test.js.map