Skip to content

Commit ef0196d

Browse files
author
Josh Thomas
committed
Chore: formatting
Signed-off-by: Josh Thomas <jthomas@ignite-retail.com>
1 parent 2fa13ef commit ef0196d

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

packages/binding-websockets/src/ws-client.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ export default class WebSocketClient implements ProtocolClient {
9696
response = await this.sendRequest(ws, request);
9797

9898
// Extract value from W3C response
99-
const value = (response as Record<string, unknown>).value !== undefined ? (response as Record<string, unknown>).value : response;
99+
const value =
100+
(response as Record<string, unknown>).value !== undefined
101+
? (response as Record<string, unknown>).value
102+
: response;
100103
return new Content(
101104
form.contentType ?? "application/json",
102105
this.bufferToStream(Buffer.from(JSON.stringify(value)))
@@ -169,7 +172,10 @@ export default class WebSocketClient implements ProtocolClient {
169172
response = await this.sendRequest(ws, request);
170173

171174
// Extract output from W3C response
172-
const output = (response as Record<string, unknown>).output !== undefined ? (response as Record<string, unknown>).output : response;
175+
const output =
176+
(response as Record<string, unknown>).output !== undefined
177+
? (response as Record<string, unknown>).output
178+
: response;
173179
return new Content(
174180
form.response?.contentType ?? form.contentType ?? "application/json",
175181
this.bufferToStream(Buffer.from(JSON.stringify(output)))
@@ -549,7 +555,9 @@ export default class WebSocketClient implements ProtocolClient {
549555
const subprotocol = this.extractSubprotocol(form);
550556
const protocols = subprotocol ? [subprotocol] : undefined;
551557

552-
debug(`Creating WebSocket connection to ${form.href}${protocols ? ` with subprotocol ${subprotocol}` : ""}`);
558+
debug(
559+
`Creating WebSocket connection to ${form.href}${protocols ? ` with subprotocol ${subprotocol}` : ""}`
560+
);
553561

554562
// Connect to the full href, not just baseUrl
555563
const ws = new WebSocket(form.href, protocols, wsOptions);

packages/binding-websockets/test/ws-tests.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Protocol test suite to test protocol implementations
1818
*/
1919

20-
import Servient, { createLoggers, ExposedThing } from "@node-wot/core";
20+
import Servient, { createLoggers } from "@node-wot/core";
2121
import { suite, test } from "@testdeck/mocha";
2222
import { expect, should } from "chai";
2323
import WebSocketServer from "../src/ws-server";
@@ -54,7 +54,7 @@ class WebSocketsTest {
5454
const receivedConnections: string[] = [];
5555

5656
mockServer.on("connection", (ws, req) => {
57-
receivedConnections.push(req.url || "/");
57+
receivedConnections.push(req.url ?? "/");
5858
ws.on("message", (msg) => {
5959
const data = JSON.parse(msg.toString());
6060
// Echo back with id
@@ -77,8 +77,8 @@ class WebSocketsTest {
7777
};
7878

7979
// Both should succeed and connect to different paths
80-
const result1 = await client.readResource(form1);
81-
const result2 = await client.readResource(form2);
80+
await client.readResource(form1);
81+
await client.readResource(form2);
8282

8383
expect(receivedConnections).to.include("/endpoint1");
8484
expect(receivedConnections).to.include("/endpoint2");
@@ -181,12 +181,7 @@ class WebSocketsTest {
181181
op: "subscribeproperty",
182182
};
183183

184-
const subscription = await client.subscribeResource(
185-
form,
186-
() => {},
187-
undefined,
188-
undefined
189-
);
184+
await client.subscribeResource(form, () => {}, undefined, undefined);
190185

191186
// Unsubscribe should trigger the correct operation
192187
await client.unlinkResource(form);
@@ -247,12 +242,7 @@ class WebSocketsTest {
247242
op: "subscribeevent",
248243
};
249244

250-
const subscription = await client.subscribeResource(
251-
form,
252-
() => {},
253-
undefined,
254-
undefined
255-
);
245+
await client.subscribeResource(form, () => {}, undefined, undefined);
256246

257247
// Unsubscribe should trigger the correct operation
258248
await client.unlinkResource(form);

0 commit comments

Comments
 (0)