2024-07-25 21:09:06 +08:00
|
|
|
import { getOwner } from "@ember/owner";
|
2024-04-09 03:00:09 +08:00
|
|
|
import { setupTest } from "ember-qunit";
|
2023-09-16 00:09:45 +08:00
|
|
|
import { module, test } from "qunit";
|
2024-04-09 03:00:09 +08:00
|
|
|
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
2023-09-16 00:09:45 +08:00
|
|
|
import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message";
|
|
|
|
|
2024-09-13 05:25:34 +08:00
|
|
|
module("Discourse Chat | Unit | Models | chat-message", function (hooks) {
|
2024-04-09 03:00:09 +08:00
|
|
|
setupTest(hooks);
|
|
|
|
|
2023-09-16 00:09:45 +08:00
|
|
|
test(".persisted", function (assert) {
|
2024-04-09 03:00:09 +08:00
|
|
|
const channel = new ChatFabricators(getOwner(this)).channel();
|
2023-09-16 00:09:45 +08:00
|
|
|
let message = ChatMessage.create(channel, { id: null });
|
|
|
|
assert.strictEqual(message.persisted, false);
|
|
|
|
|
|
|
|
message = ChatMessage.create(channel, {
|
|
|
|
id: 1,
|
|
|
|
staged: true,
|
|
|
|
});
|
|
|
|
assert.strictEqual(message.persisted, false);
|
|
|
|
|
|
|
|
message = ChatMessage.create(channel, {
|
|
|
|
id: 1,
|
|
|
|
staged: false,
|
|
|
|
});
|
|
|
|
assert.strictEqual(message.persisted, true);
|
|
|
|
});
|
|
|
|
});
|