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/bookmark-test.js
Jarek Radosz 4f12fd0339
DEV: Modernize model tests (#19104)
Uses `module()` instead of `discourseModule()`, native getters instead of `.get()`, fixes some assertions, uses the store instead of creating models directly
2022-11-18 20:36:32 +01:00

48 lines
1.3 KiB
JavaScript

import { module, test } from "qunit";
import { setupTest } from "ember-qunit";
import { getOwner } from "discourse-common/lib/get-owner";
module("Unit | Model | bookmark", function (hooks) {
setupTest(hooks);
test("topicForList - Topic bookmarkable", function (assert) {
const store = getOwner(this).lookup("service:store");
const bookmark = store.createRecord("bookmark", {
id: 1,
bookmarkable_type: "Topic",
bookmarkable_id: 999,
linked_post_number: null,
topic_id: 999,
fancy_title: "Some test topic",
last_read_post_number: 23,
highest_post_number: 30,
});
assert.strictEqual(
bookmark.topicForList.linked_post_number,
null,
"linked_post_number is null"
);
});
test("topicForList - Post bookmarkable", function (assert) {
const store = getOwner(this).lookup("service:store");
const bookmark = store.createRecord("bookmark", {
id: 1,
bookmarkable_type: "Post",
bookmarkable_id: 999,
linked_post_number: 787,
topic_id: 999,
fancy_title: "Some test topic",
last_read_post_number: 23,
highest_post_number: 30,
});
assert.strictEqual(
bookmark.topicForList.linked_post_number,
787,
"linked_post_number is correct"
);
});
});