Add tests for category hashtag.

This commit is contained in:
Guo Xiang Tan 2016-02-04 15:38:50 +08:00
parent 4cd07fbb29
commit c0feea4629
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Category hashtag", {
loggedIn: true,
setup() {
const response = (object) => {
return [
200,
{"Content-Type": "application/json"},
object
];
};
server.get('/category_hashtags/check', () => { //eslint-disable-line
return response({ valid: [{ slug: "bug", url: '/c/bugs' }] });
});
}
});
test("category hashtag is cooked properly", () => {
visit("/t/internationalization-localization/280");
click('#topic-footer-buttons .btn.create');
fillIn('.d-editor-input', "this is a category hashtag #bug");
andThen(() => {
// TODO: Test that the autocomplete shows
equal(find('.d-editor-preview:visible').html().trim(), "<p>this is a category hashtag <a href=\"/c/bugs\" class=\"hashtag\">#<span>bug</span></a></p>");
});
click('#reply-control .btn.create');
andThen(() => {
equal(find('.topic-post:last .cooked p').html().trim(), "this is a category hashtag <a href=\"/c/bugs\" class=\"hashtag\">#<span>bug</span></a>");
});
});