mirror of
https://github.com/vector-im/element-web.git
synced 2025-12-25 11:11:31 +01:00
* Remove vm related code from element-web/src * Add and export view model code from package * Update imports * Rewrite vm tests using vitest * Add github action to run vm tests * Fix lint errors * Mvoe tests over to jest * Try fixing code coverage * Second attempt at fixing code coverage
24 lines
603 B
TypeScript
24 lines
603 B
TypeScript
/*
|
|
Copyright 2025 New Vector Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { type ViewModel } from "./ViewModel";
|
|
|
|
/**
|
|
* A mock view model that returns a static snapshot passed in the constructor, with no updates.
|
|
*/
|
|
export class MockViewModel<T> implements ViewModel<T> {
|
|
public constructor(private snapshot: T) {}
|
|
|
|
public getSnapshot = (): T => {
|
|
return this.snapshot;
|
|
};
|
|
|
|
public subscribe(listener: () => void): () => void {
|
|
return () => undefined;
|
|
}
|
|
}
|