mirror of
https://github.com/vector-im/element-call.git
synced 2026-10-10 23:25:52 +00:00
With this change, views now read every reactive value through `useBehavior`, as `architecture.md` already prescribes. Where a view reads a plain stream, the view model now exposes a `Behavior`.
24 lines
685 B
TypeScript
24 lines
685 B
TypeScript
/*
|
|
Copyright 2026 Element Creations Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE in the repository root for full details.
|
|
*/
|
|
|
|
import { act, renderHook } from "@testing-library/react";
|
|
import { BehaviorSubject } from "rxjs";
|
|
import { describe, expect, test } from "vitest";
|
|
|
|
import { useBehavior } from "./useBehavior";
|
|
|
|
describe("useBehavior", () => {
|
|
test("reads the current value and follows changes", () => {
|
|
const value$ = new BehaviorSubject(1);
|
|
const { result } = renderHook(() => useBehavior(value$));
|
|
expect(result.current).toBe(1);
|
|
|
|
act(() => value$.next(2));
|
|
expect(result.current).toBe(2);
|
|
});
|
|
});
|