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
Jarek Radosz 1b52cdedb1
DEV: Move more tests into modules (#11119)
Models, services, mixins, utilities, and most of the controllers
2020-11-05 20:23:28 +01:00

32 lines
869 B
JavaScript

import { test, module } from "qunit";
import User from "discourse/models/user";
import Topic from "discourse/models/topic";
function buildDetails(id) {
const topic = Topic.create({ id: id });
return topic.get("details");
}
module("Unit | Model | topic-details", function () {
test("defaults", function (assert) {
var 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) {
var details = buildDetails(1234);
details.updateFromJson({
allowed_users: [{ username: "eviltrout" }],
});
assert.equal(
details.get("allowed_users.length"),
1,
"it loaded the allowed users"
);
assert.containsInstance(details.get("allowed_users"), User);
});
});