import { makeAppObjectRepo } from "@vived/core";
import { Quaternion, Vector3 } from "@vived/core";
import { makeStoredView, StoredView } from "./StoredView";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const rootAO = appObjects.getOrCreate(StoredView.type);
    const storedView = makeStoredView(rootAO);
    const observer = jest.fn();
    storedView.addChangeObserver(observer);
    return { storedView, observer, appObjects };
}
describe("Scene Root Entity", () => {
    it("Sets the position", () => {
        const { storedView, observer } = makeTestRig();
        expect(storedView.position).toEqual(Vector3.Zero());
        observer.mockClear();
        storedView.position = new Vector3(1, 2, 3);
        expect(observer).toHaveBeenCalled();
        expect(storedView.position).toEqual(new Vector3(1, 2, 3));
        observer.mockClear();
        storedView.position = new Vector3(1, 2, 3);
        expect(observer).not.toHaveBeenCalled();
    });
    it("Sets the rotation", () => {
        const { storedView, observer } = makeTestRig();
        expect(storedView.rotation).toEqual(Quaternion.Identity());
        observer.mockClear();
        storedView.rotation = new Quaternion(1, 1, 1, 1);
        expect(observer).toHaveBeenCalled();
        expect(storedView.rotation).toEqual(new Quaternion(1, 1, 1, 1));
        observer.mockClear();
        storedView.rotation = new Quaternion(1, 1, 1, 1);
        expect(observer).not.toHaveBeenCalled();
    });
    it("Sets the scale", () => {
        const { storedView, observer } = makeTestRig();
        expect(storedView.scale).toEqual(1);
        observer.mockClear();
        storedView.scale = 2;
        expect(observer).toHaveBeenCalled();
        expect(storedView.scale).toEqual(2);
        observer.mockClear();
        storedView.scale = 2;
        expect(observer).not.toHaveBeenCalled();
    });
    it("Sets has stored view", () => {
        const { storedView, observer } = makeTestRig();
        expect(storedView.hasStoredView).toEqual(false);
        observer.mockClear();
        storedView.hasStoredView = true;
        expect(observer).toHaveBeenCalled();
        expect(storedView.hasStoredView).toEqual(true);
        observer.mockClear();
        storedView.hasStoredView = true;
        expect(observer).not.toHaveBeenCalled();
    });
});
//# sourceMappingURL=StoredView.test.js.map