Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AdLer-Lukas committed Feb 12, 2025
2 parents 192ea3f + 4d7b2df commit 6c8d8f5
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 3 deletions.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ export default class AvatarEditorPreviewModelView {
this.scenePresenter = CoreDIContainer.get<ScenePresenterFactory>(
SCENE_TYPES.ScenePresenterFactory,
)(AvatarEditorPreviewSceneDefinition);
viewModel.avatarConfigDiff.subscribe(() => {
this.onAvatarConfigChanged();
});
viewModel.avatarConfigDiff.subscribe(this.onAvatarConfigChanged);
}
private async onAvatarConfigChanged(): Promise<void> {
this.updateAllModels("diff");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { mockDeep } from "jest-mock-extended";
import CoreDIContainer from "../../../../../Core/DependencyInjection/CoreDIContainer";
import SCENE_TYPES from "../../../../../Core/DependencyInjection/Scenes/SCENE_TYPES";
import AvatarEditorPreviewModelView from "../../../../../Core/Presentation/AvatarEditor/AvatarEditorPreview/AvatarEditorPreviewModel/AvatarEditorPreviewModelView";
import AvatarEditorPreviewModelViewModel from "../../../../../Core/Presentation/AvatarEditor/AvatarEditorPreview/AvatarEditorPreviewModel/AvatarEditorPreviewModelViewModel";
import IScenePresenter from "../../../../../Core/Presentation/Babylon/SceneManagement/IScenePresenter";
import { AbstractMesh, NullEngine, Scene } from "@babylonjs/core";

const scenePresenterMock = mockDeep<IScenePresenter>();
const scenePresenterFactoryMock = () => scenePresenterMock;
function buildSystemUnderTest(): [
AvatarEditorPreviewModelViewModel,
AvatarEditorPreviewModelView,
] {
const viewModel = new AvatarEditorPreviewModelViewModel();
const systemUnderTest = new AvatarEditorPreviewModelView(viewModel);
return [viewModel, systemUnderTest];
}

describe("AvatarEditorPreviewModelView", () => {
let systemUnderTest: AvatarEditorPreviewModelView;

beforeAll(() => {
CoreDIContainer.snapshot();
CoreDIContainer.rebind(SCENE_TYPES.ScenePresenterFactory).toConstantValue(
scenePresenterFactoryMock,
);
});
beforeEach(() => {
buildSystemUnderTest();
});

afterAll(() => {
CoreDIContainer.restore();
jest.clearAllMocks();
});

test("constructor injects scenePresenter", async () => {
scenePresenterMock.loadModel.mockResolvedValue([
new AbstractMesh("TestMesh", new Scene(new NullEngine())),
]);

const [, systemUnderTest] = buildSystemUnderTest();
expect(systemUnderTest["scenePresenter"]).toBeDefined();
});

test("constructor subscribes to viewModel.isOpen", () => {
scenePresenterMock.loadModel.mockResolvedValue([
new AbstractMesh("TestMesh", new Scene(new NullEngine())),
]);

const [viewModel, systemUnderTest] = buildSystemUnderTest();

expect(viewModel.avatarConfigDiff["subscribers"]).toStrictEqual([
systemUnderTest["onAvatarConfigChanged"],
]);
});
});

0 comments on commit 6c8d8f5

Please sign in to comment.