diff --git a/src/connection.ts b/src/connection.ts index 03ee9fe..052ebfa 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -365,7 +365,8 @@ export class Connection { } else { body = String(body); } - } else if ((path && path.includes("/streams")) === true) { + } + if ((path && path.includes("/streams")) === true) { contentType = "application/json"; } diff --git a/src/test/28-manipulating-streams.ts b/src/test/28-manipulating-streams.ts index a4a4c55..32713e2 100644 --- a/src/test/28-manipulating-streams.ts +++ b/src/test/28-manipulating-streams.ts @@ -3,8 +3,6 @@ import { C8Client } from "../jsC8"; import { Stream } from "../stream"; import * as dotenv from "dotenv"; -// TODO : @VIKAS Update Test cases - describe("Manipulating streams", function () { dotenv.config(); // create fabric takes 11s in a standard cluster @@ -194,6 +192,22 @@ describe("Manipulating streams", function () { // }); // }); + describe("publish message to stream", async () => { + it("publishes message to stream", async () => { + const name = `stream${Date.now()}`; + stream = client.stream(name, false); + const response = await stream.createStream(); + expect(response.error).to.be.false; + const messageResponse = await stream.publishMessage( + "Hello Macrometa stream!" + ); + expect(messageResponse.code).to.equal(202); + expect(messageResponse.error).to.be.false; + const deleteStreamResponse = await stream.deleteStream(); + expect(deleteStreamResponse.error).to.be.false; + }); + }); + describe("stream.websocket", function () { let dcName: string; let consumer: any;