mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
DEV: adds sendChatMessage client API (#21783)
Usage: ``` api.sendChatMessage(channelId, message, { threadId: 6 }); ```
This commit is contained in:
@ -0,0 +1,23 @@
|
||||
import { module, test } from "qunit";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { setupTest } from "ember-qunit";
|
||||
import pretender from "discourse/tests/helpers/create-pretender";
|
||||
|
||||
module("Chat | Unit | Utility | plugin-api", function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test("#sendChatMessage", async function (assert) {
|
||||
const done = assert.async();
|
||||
|
||||
pretender.post("/chat/1", (request) => {
|
||||
assert.strictEqual(request.url, "/chat/1");
|
||||
assert.strictEqual(request.requestBody, "thread_id=2&message=hello");
|
||||
done();
|
||||
return [200, {}, {}];
|
||||
});
|
||||
|
||||
withPluginApi("1.1.0", async (api) => {
|
||||
await api.sendChatMessage(1, { message: "hello", threadId: 2 });
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user