mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 20:03:45 +08:00
1060e4573a
The complexity of the situation is that we don't want to load faker into production by default but fabricators and styleguide are available on production. This is made possible through app/assets/javascripts/discourse/app/lib/load-faker.js which contains a function to ensure faker is loaded asynchronously (loadFaker) and another function to access the loaded faker (getLoadedFaker). Note 1: this commit also refactors fabricators to have access to context and use faker where possible Note 2: this commit moves automation to admin bundle --------- Co-authored-by: David Taylor <david@taylorhq.com>
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
import { getOwner } from "@ember/application";
|
|
import { setupTest } from "ember-qunit";
|
|
import { module, test } from "qunit";
|
|
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
|
|
|
module(
|
|
"Discourse Chat | Unit | Service | chat-drafts-manager",
|
|
function (hooks) {
|
|
setupTest(hooks);
|
|
|
|
hooks.beforeEach(function () {
|
|
this.subject = getOwner(this).lookup("service:chat-drafts-manager");
|
|
});
|
|
|
|
test("storing and retrieving message", async function (assert) {
|
|
const message1 = new ChatFabricators(getOwner(this)).message();
|
|
|
|
await this.subject.add(message1, message1.channel.id);
|
|
|
|
assert.strictEqual(this.subject.get(message1.channel.id), message1);
|
|
|
|
const message2 = new ChatFabricators(getOwner(this)).message();
|
|
|
|
await this.subject.add(message2, message2.channel.id);
|
|
|
|
assert.strictEqual(this.subject.get(message2.channel.id), message2);
|
|
});
|
|
|
|
test("#reset", async function (assert) {
|
|
const message = new ChatFabricators(getOwner(this)).message();
|
|
|
|
await this.subject.add(message, message.channel.id);
|
|
|
|
assert.strictEqual(Object.keys(this.subject.drafts).length, 1);
|
|
|
|
this.subject.reset();
|
|
|
|
assert.strictEqual(Object.keys(this.subject.drafts).length, 0);
|
|
});
|
|
}
|
|
);
|