This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/unit/models/topic-details-test.js
2021-11-08 10:26:28 +01:00

32 lines
917 B
JavaScript

import { module, test } from "qunit";
import Topic from "discourse/models/topic";
import User from "discourse/models/user";
function buildDetails(id, topicParams = {}) {
const topic = Topic.create(Object.assign({ id }, topicParams));
return topic.get("details");
}
module("Unit | Model | topic-details", function () {
test("defaults", function (assert) {
let details = buildDetails(1234);
assert.present(details, "the details are present by default");
assert.ok(!details.get("loaded"), "details are not loaded by default");
});
test("updateFromJson", function (assert) {
let details = buildDetails(1234);
details.updateFromJson({
allowed_users: [{ username: "eviltrout" }],
});
assert.strictEqual(
details.get("allowed_users.length"),
1,
"it loaded the allowed users"
);
assert.containsInstance(details.get("allowed_users"), User);
});
});