Skip to content

Commit

Permalink
Wrap the newParticipant in an object
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasnaphas committed Mar 28, 2022
1 parent c554963 commit 4a5238e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion backend/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ const handleJoin = async (record) => {
for (let i = 0; i < connectionIds.length; i++) {
const postToConnectionParams = {
ConnectionId: connectionIds[i],
Data: Buffer.from(record.dynamodb.NewImage.game_name.S),
Data: Buffer.from(
JSON.stringify({ newParticipant: record.dynamodb.NewImage.game_name.S })
),
};
try {
await api.postToConnection(postToConnectionParams).promise();
Expand Down
8 changes: 5 additions & 3 deletions backend/stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe("stream", () => {
},
expectedPostToConnectionParams: {
ConnectionId: "PktBLdr_IAMCJxA=",
Data: Buffer.from("Le"),
Data: Buffer.from(JSON.stringify({ newParticipant: "Le" })),
},
postToConnectionData: {},
expectedStatusCode: 200,
Expand Down Expand Up @@ -227,11 +227,13 @@ describe("stream", () => {
return MockApiGatewayManagementApi;
});
process.env.TABLE_NAME = TABLE_NAME;
process.env.WS_ENDPOINT = WS_ENDPOINT
process.env.WS_ENDPOINT = WS_ENDPOINT;
const handler = require("./stream").handler;
const result = await handler(event);
expect(result.statusCode).toEqual(expectedStatusCode);
expect(MockApiGatewayManagementApi).toHaveBeenCalledWith({endpoint: WS_ENDPOINT})
expect(MockApiGatewayManagementApi).toHaveBeenCalledWith({
endpoint: WS_ENDPOINT,
});
if (expectedDbQueryParams) {
expect(mockQuery).toHaveBeenCalledWith(expectedDbQueryParams);
}
Expand Down

0 comments on commit 4a5238e

Please sign in to comment.