mirror of
https://github.com/discourse/discourse.git
synced 2024-12-12 03:03:44 +08:00
24 lines
731 B
JavaScript
24 lines
731 B
JavaScript
|
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 });
|
||
|
});
|
||
|
});
|
||
|
});
|