Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
Septias committed Dec 11, 2024
1 parent ace1104 commit 6f3b6e9
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions backend/message.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createProcessor } from "./message";
import type { Message } from "../types/message";
import { ReceivedStatusUpdate } from "@webxdc/types";

// a little helper to let us track messages for testing purposes
function track(): [() => Message[], (message: Message) => void] {
Expand All @@ -19,7 +20,7 @@ test("distribute to self", () => {
const processor = createProcessor(onMessage);
const client0 = processor.createClient("3001");

const client0Heard: UpdateDescr[] = [];
const client0Heard: ReceivedStatusUpdate<any>[] = [];

client0.connect((updates) => {
client0Heard.push(...updates);
Expand Down Expand Up @@ -58,8 +59,8 @@ test("distribute to self and other", () => {
const client0 = processor.createClient("3001");
const client1 = processor.createClient("3002");

const client0Heard: UpdateDescr[] = [];
const client1Heard: UpdateDescr[] = [];
const client0Heard: ReceivedStatusUpdate<any>[] = [];
const client1Heard: ReceivedStatusUpdate<any>[] = [];

client0.connect((updates) => {
client0Heard.push(...updates);
Expand Down Expand Up @@ -125,8 +126,8 @@ test("setUpdateListener serial should skip older", () => {
const client0 = processor.createClient("3001");
const client1 = processor.createClient("3002");

const client0Heard: UpdateDescr[] = [];
const client1Heard: UpdateDescr[] = [];
const client0Heard: ReceivedStatusUpdate<any>[] = [];
const client1Heard: ReceivedStatusUpdate<any>[] = [];

client0.connect((updates) => {
client0Heard.push(...updates);
Expand Down Expand Up @@ -155,8 +156,8 @@ test("other starts listening later", () => {
const client0 = processor.createClient("3001");
const client1 = processor.createClient("3002");

const client0Heard: UpdateDescr[] = [];
const client1Heard: UpdateDescr[] = [];
const client0Heard: ReceivedStatusUpdate<any>[] = [];
const client1Heard: ReceivedStatusUpdate<any>[] = [];

client0.connect((updates) => {
client0Heard.push(...updates);
Expand Down Expand Up @@ -229,8 +230,8 @@ test("client is created later and needs to catch up", () => {
const processor = createProcessor();
const client0 = processor.createClient("3001");

const client0Heard: UpdateDescr[] = [];
const client1Heard: UpdateDescr[] = [];
const client0Heard: ReceivedStatusUpdate<any>[] = [];
const client1Heard: ReceivedStatusUpdate<any>[] = [];

client0.connect((updates) => {
client0Heard.push(...updates);
Expand Down Expand Up @@ -269,8 +270,8 @@ test("other starts listening later but is partially caught up", () => {
const client0 = processor.createClient("3001");
const client1 = processor.createClient("3002");

const client0Heard: UpdateDescr[] = [];
const client1Heard: UpdateDescr[] = [];
const client0Heard: ReceivedStatusUpdate<any>[] = [];
const client1Heard: ReceivedStatusUpdate<any>[] = [];

client0.connect((updates) => {
client0Heard.push(...updates);
Expand Down Expand Up @@ -456,8 +457,8 @@ test("connect with clear means we get no catchup if no new updates", () => {
const processor = createProcessor();
const client0 = processor.createClient("3001");

const client0Heard: (UpdateDescr | string)[] = [];
const client1Heard: (UpdateDescr | string)[] = [];
const client0Heard: (ReceivedStatusUpdate<any> | string)[] = [];
const client1Heard: (ReceivedStatusUpdate<any> | string)[] = [];

client0.connect(
(updates) => {
Expand Down Expand Up @@ -514,8 +515,8 @@ test("connect with clear means catchup only with updates after clear", () => {
const processor = createProcessor(onMessage);
const client0 = processor.createClient("3001");

const client0Heard: (UpdateDescr | string)[] = [];
const client1Heard: (UpdateDescr | string)[] = [];
const client0Heard: (ReceivedStatusUpdate<any> | string)[] = [];
const client1Heard: (ReceivedStatusUpdate<any> | string)[] = [];

client0.connect(
(updates) => {
Expand Down Expand Up @@ -623,8 +624,8 @@ test("distribute to self and other, but other was disconnected", () => {
const client0 = processor.createClient("3001");
const client1 = processor.createClient("3002");

const client0Heard: UpdateDescr[] = [];
const client1Heard: UpdateDescr[] = [];
const client0Heard: ReceivedStatusUpdate<any>[] = [];
const client1Heard: ReceivedStatusUpdate<any>[] = [];

client0.connect((updates) => {
client0Heard.push(...updates);
Expand Down

0 comments on commit 6f3b6e9

Please sign in to comment.