-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Client metadata draft. * Equipping the remote clients too. * Fix: remote one is readonly. * More JSdoc. * Add fallback empty object to parseMeta(). * Rev: no metadata schema and no parsing: getData() and setData() accept type argument instead. * Ref: getRemoteClients() return type. * Logging metadata by default and fallback object values for getters. * Example: message count metadata with constraints. * Fallback coverage from RemoteClient::getData(). * Marking getData() returns as partial to emphasize that it's an empty object initially. * Update src/action.ts
- Loading branch information
Showing
11 changed files
with
141 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { RemoteSocket } from "socket.io"; | ||
import { describe, expect, test } from "vitest"; | ||
import { getRemoteClients } from "./remote-client"; | ||
|
||
describe("RemoteClient", () => { | ||
describe("getRemoteClients()", () => { | ||
const socketsMock = [ | ||
{ id: "ONE", rooms: new Set(["room1"]), data: { name: "TEST" } }, | ||
{ id: "TWO", rooms: new Set(["room2"]) }, | ||
]; | ||
|
||
test("should map RemoteSockets to RemoteClients", () => { | ||
const clients = getRemoteClients(socketsMock as RemoteSocket<any, any>[]); | ||
expect(clients).toEqual([ | ||
{ | ||
id: "ONE", | ||
rooms: ["room1"], | ||
getData: expect.any(Function), | ||
}, | ||
{ | ||
id: "TWO", | ||
rooms: ["room2"], | ||
getData: expect.any(Function), | ||
}, | ||
]); | ||
|
||
// getData: | ||
expect(clients[0].getData()).toEqual({ name: "TEST" }); | ||
expect(clients[1].getData()).toEqual({}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters