tests first batch

This commit is contained in:
Timo K
2025-11-13 11:35:37 +01:00
parent c7f50b53f5
commit 0115242a2b
10 changed files with 98 additions and 198 deletions

View File

@@ -6,7 +6,7 @@ Please see LICENSE in the repository root for full details.
*/
import { describe, expect, it } from "vitest";
import { BehaviorSubject, combineLatest, timer } from "rxjs";
import { BehaviorSubject, combineLatest, of, Subject } from "rxjs";
import { logger } from "matrix-js-sdk/lib/logger";
import {
@@ -60,19 +60,6 @@ describe("Epoch", () => {
});
});
});
it("obs", () => {
const nothing = Symbol("nothing");
const scope = new ObservableScope();
const sb$ = new BehaviorSubject("initial");
const su$ = new BehaviorSubject(undefined);
expect(sb$.value).toBe("initial");
expect(su$.value).toBe(undefined);
expect(su$.value === nothing).toBe(false);
const a$ = timer(10);
scope.behavior(a$, undefined);
});
it("diamonds emits in a predictable order", () => {
const sb$ = new BehaviorSubject("initial");
@@ -97,4 +84,21 @@ describe("Epoch", () => {
sb$.next("updated");
sb$.next("ANOTERUPDATE");
});
it("behavior test", () => {
const scope = new ObservableScope();
const s$ = new Subject();
const behavior$ = scope.behavior(s$, 0);
behavior$.subscribe((value) => {
logger.log(`Received value: ${value}`);
});
s$.next(1);
s$.next(2);
s$.next(3);
s$.next(3);
s$.next(3);
s$.next(3);
s$.next(3);
s$.complete();
});
});