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/pending-post-test.js
Loïc Guitaut a5fbb90df4 FEATURE: Display pending posts on user’s page
Currently when a user creates posts that are moderated (for whatever
reason), a popup is displayed saying the post needs approval and the
total number of the user’s pending posts. But then this piece of
information is kind of lost and there is nowhere for the user to know
what are their pending posts or how many there are.

This patch solves this issue by adding a new “Pending” section to the
user’s activity page when there are some pending posts to display. When
there are none, then the “Pending” section isn’t displayed at all.
2021-11-29 10:26:33 +01:00

37 lines
1.1 KiB
JavaScript

import { module, test } from "qunit";
import PendingPost from "discourse/models/pending-post";
import createStore from "discourse/tests/helpers/create-store";
import { run } from "@ember/runloop";
module("Unit | Model | pending-post", function () {
test("Properties", function (assert) {
const store = createStore();
const category = store.createRecord("category", { id: 2 });
const post = PendingPost.create({
id: 1,
topic_url: "topic-url",
username: "USERNAME",
category_id: 2,
});
assert.equal(post.postUrl, "topic-url", "topic_url is aliased to postUrl");
assert.equal(post.truncated, false, "truncated is always false");
assert.equal(
post.userUrl,
"/u/username",
"it returns user URL from the username"
);
assert.strictEqual(
post.category,
category,
"it returns the proper category object based on category_id"
);
});
test("it cooks raw_text", function (assert) {
const post = run(() => PendingPost.create({ raw_text: "**bold text**" }));
assert.equal(
post.expandedExcerpt.string,
"<p><strong>bold text</strong></p>"
);
});
});