mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Various bugs with Category breadcrumbs
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,12 +1,4 @@
|
||||
// Test helpers
|
||||
// var resolvingPromise = Ember.Deferred.promise(function (p) {
|
||||
// p.resolve();
|
||||
// });
|
||||
|
||||
// var resolvingPromiseWith = function(result) {
|
||||
// return Ember.Deferred.promise(function (p) { p.resolve(result); });
|
||||
// };
|
||||
|
||||
function exists(selector) {
|
||||
return !!count(selector);
|
||||
}
|
||||
|
||||
7
test/javascripts/helpers/parse_html.js
Normal file
7
test/javascripts/helpers/parse_html.js
Normal file
@@ -0,0 +1,7 @@
|
||||
function parseHTML(rawHtml) {
|
||||
var builder = new Tautologistics.NodeHtmlParser.HtmlBuilder(),
|
||||
parser = new Tautologistics.NodeHtmlParser.Parser(builder);
|
||||
|
||||
parser.parseComplete(rawHtml);
|
||||
return builder.dom;
|
||||
}
|
||||
@@ -124,6 +124,7 @@ var jsHintOpts = {
|
||||
"controllerFor",
|
||||
"testController",
|
||||
"containsInstance",
|
||||
"parseHTML",
|
||||
"deepEqual",
|
||||
"notEqual",
|
||||
"Blob",
|
||||
|
||||
43
test/javascripts/lib/html_test.js
Normal file
43
test/javascripts/lib/html_test.js
Normal file
@@ -0,0 +1,43 @@
|
||||
module("Discourse.HTML");
|
||||
|
||||
var html = Discourse.HTML;
|
||||
|
||||
test("categoryLink without a category", function() {
|
||||
blank(Discourse.HTML.categoryLink(), "it returns no HTML");
|
||||
});
|
||||
|
||||
test("Regular categoryLink", function() {
|
||||
var category = Discourse.Category.create({
|
||||
name: 'hello',
|
||||
id: 123,
|
||||
description: 'cool description',
|
||||
color: 'ff0',
|
||||
text_color: 'f00'
|
||||
}),
|
||||
tag = parseHTML(Discourse.HTML.categoryLink(category))[0];
|
||||
|
||||
equal(tag.name, 'a', 'it creates an `a` tag');
|
||||
equal(tag.attributes['class'], 'badge-category', 'it has the correct class');
|
||||
equal(tag.attributes.title, 'cool description', 'it has the correct title');
|
||||
|
||||
ok(tag.attributes.style.indexOf('#ff0') !== -1, "it has the color style");
|
||||
ok(tag.attributes.style.indexOf('#f00') !== -1, "it has the textColor style");
|
||||
|
||||
equal(tag.children[0].data, 'hello', 'it has the category name');
|
||||
});
|
||||
|
||||
test("undefined color", function() {
|
||||
var noColor = Discourse.Category.create({ name: 'hello', id: 123 }),
|
||||
tag = parseHTML(Discourse.HTML.categoryLink(noColor))[0];
|
||||
|
||||
blank(tag.attributes.style, "it has no color style because there are no colors");
|
||||
});
|
||||
|
||||
test("allowUncategorized", function() {
|
||||
var uncategorized = Discourse.Category.create({name: 'uncategorized', id: 345});
|
||||
this.stub(Discourse.Site, 'currentProp').withArgs('uncategorized_category_id').returns(345);
|
||||
|
||||
blank(Discourse.HTML.categoryLink(uncategorized), "it doesn't return HTML for uncategorized by default");
|
||||
present(Discourse.HTML.categoryLink(uncategorized, {allowUncategorized: true}), "it returns HTML");
|
||||
});
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
//= require mousetrap.js
|
||||
//= require rsvp.js
|
||||
//= require show-html.js
|
||||
//= require htmlparser.js
|
||||
|
||||
// Stuff we need to load first
|
||||
//= require main_include
|
||||
|
||||
Reference in New Issue
Block a user