discourse/plugins/chat/test/javascripts/unit/utility/plugin-api-test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
731 B
JavaScript
Raw Normal View History

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 });
});
});
});