discourse/plugins/chat/test/javascripts/unit/models/chat-message-test.js
Jarek Radosz 038e5deb2a
DEV: Clean up imports (#28060)
* `@ember/owner` instead of `@ember/application`
* `discourse-i18n` instead of `I18n`
* `{ service } from "@ember/service"` instead of `inject as service`
2024-07-25 15:09:06 +02:00

28 lines
879 B
JavaScript

import { getOwner } from "@ember/owner";
import { setupTest } from "ember-qunit";
import { module, test } from "qunit";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message";
module("Discourse Chat | Unit | Models | chat-message", function (hooks) {
setupTest(hooks);
test(".persisted", function (assert) {
const channel = new ChatFabricators(getOwner(this)).channel();
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);
});
});