Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
tailuge committed Dec 27, 2024
1 parent f87ca1f commit 0dcfd0d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/network/client/nchanmessagerelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MessageRelay } from "./messagerelay"

export class NchanMessageRelay<T> implements MessageRelay<T> {

private websockets: Map<string, WebSocket> = new Map()
private readonly websockets: Map<string, WebSocket> = new Map()

constructor(private readonly baseURL: string) { }

Expand Down
28 changes: 28 additions & 0 deletions test/server/messagerelay.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import "mocha"
import { expect } from "chai"
import { InMemoryMessageRelay } from "../mocks/inmemorymessagerelay"
import { MessageRelay } from "../../src/network/client/messagerelay"

const jestConsole = console

beforeEach(() => {
global.console = require("console")
})

afterEach(() => {
global.console = jestConsole
})

describe("Lobby", () => {
const relay: MessageRelay<string> = new InMemoryMessageRelay<string>()

it("validate subscriber receives published message", (done) => {
const channel = "test"
const message = "hello"
relay.subscribe(channel, (msg) => {
expect(msg).to.equal(message)
done()
})
relay.publish(channel, message)
})
})

0 comments on commit 0dcfd0d

Please sign in to comment.