import { makeAppObjectRepo } from "@vived/core";
import { ChannelModelObject, makeChannelModelObject, } from "./ChannelModelObject";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const appObj = appObjects.getOrCreate("ob1j");
    const modelObject = makeChannelModelObject(appObj);
    const observer = jest.fn();
    modelObject.addChangeObserver(observer);
    return { modelObject, observer, appObj, appObjects };
}
describe("Channel Model Object", () => {
    it("Sets the scene object", () => {
        const { modelObject, appObj } = makeTestRig();
        expect(modelObject.appObject).toEqual(appObj);
    });
    it("Adds itself to the App Object", () => {
        const { modelObject, appObj } = makeTestRig();
        expect(appObj.hasComponent(ChannelModelObject.type)).toEqual(true);
        expect(appObj.getComponent(ChannelModelObject.type)).toEqual(modelObject);
    });
    it("Removes itself from the App Object when disposed", () => {
        const { modelObject, appObj } = makeTestRig();
        modelObject.dispose();
        expect(appObj.hasComponent(ChannelModelObject.type)).toEqual(false);
    });
    it("Gets the array of sub meshes", () => {
        const { modelObject, observer } = makeTestRig();
        expect(modelObject.subMeshPaths).toEqual([]);
        modelObject.subMeshPaths = [`modelObject/path/1`];
        expect(modelObject.subMeshPaths).toEqual([`modelObject/path/1`]);
        expect(observer).toHaveBeenCalledTimes(1);
    });
    it("Get by ID", () => {
        const { modelObject, appObjects } = makeTestRig();
        expect(ChannelModelObject.get("ob1j", appObjects)).toEqual(modelObject);
    });
    it("Gets the id from the app object", () => {
        const { modelObject } = makeTestRig();
        expect(modelObject.id).toEqual("ob1j");
    });
    it("Notifies when the label changes", () => {
        const { modelObject, observer } = makeTestRig();
        modelObject.label.custom = "a label";
        modelObject.label.custom = "a label";
        modelObject.label.custom = "a label";
        expect(observer).toHaveBeenCalledTimes(1);
    });
    it("Notifies when the tags are set", () => {
        const { modelObject, observer } = makeTestRig();
        expect(modelObject.tags).toEqual([]);
        modelObject.tags = ["tag1", "tag2"];
        expect(observer).toHaveBeenCalledTimes(1);
        expect(modelObject.tags).toEqual(["tag1", "tag2"]);
    });
});
//# sourceMappingURL=ChannelModelObject.test.js.map