Add tests from discourse-tagging.

This commit is contained in:
Guo Xiang Tan 2016-06-20 11:22:36 +08:00
parent 9416c93a23
commit a891125b92
No known key found for this signature in database
GPG key ID: 19C321C8952B0F72

View file

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