import { Angle, makeAppObjectRepo } from "@vived/core";
import { makeCameraEntity } from "./CameraEntity";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const cameraAo = appObjects.getOrCreate("CameraAO");
    const camera = makeCameraEntity(cameraAo);
    const observer = jest.fn();
    camera.addChangeObserver(observer);
    return {
        camera,
        observer,
    };
}
describe("Camera Entity Test", () => {
    it("NearClip changes notifies", () => {
        const { camera, observer } = makeTestRig();
        camera.nearClip = 0.02;
        observer.mockClear();
        camera.nearClip = 0.03;
        expect(observer).toHaveBeenCalled();
    });
    it("NearClip does not notify when nothing changes", () => {
        const { camera, observer } = makeTestRig();
        camera.nearClip = 0.02;
        observer.mockClear();
        camera.nearClip = 0.02;
        expect(observer).not.toHaveBeenCalled();
    });
    it("FarClip changes notifies", () => {
        const { camera, observer } = makeTestRig();
        camera.farClip = 0.02;
        observer.mockClear();
        camera.farClip = 0.03;
        expect(observer).toHaveBeenCalled();
    });
    it("FarClip does not notify when nothing changes", () => {
        const { camera, observer } = makeTestRig();
        camera.farClip = 0.02;
        observer.mockClear();
        camera.farClip = 0.02;
        expect(observer).not.toHaveBeenCalled();
    });
    it("notifies when transform notifies", () => {
        const { camera, observer } = makeTestRig();
        observer.mockClear();
        camera.transform.notifyOnChange();
        expect(observer).toHaveBeenCalled();
    });
    it("notifies when angle changes", () => {
        const { camera, observer } = makeTestRig();
        camera.fov = Angle.FromRadians(0);
        observer.mockClear();
        camera.fov = Angle.FromRadians(1);
        expect(observer).toHaveBeenCalled();
        expect(camera.fov.radians).toEqual(1);
    });
    it("does not notify when no angle changes", () => {
        const { camera, observer } = makeTestRig();
        camera.fov = Angle.FromRadians(0);
        observer.mockClear();
        camera.fov = Angle.FromRadians(0);
        expect(observer).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=CameraEntity.test.js.map