mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 13:31:18 +08:00
Refactor code; add tests
This commit is contained in:
@ -45,3 +45,28 @@ QUnit.test("allowUncategorized", assert => {
|
||||
assert.blank(categoryBadgeHTML(uncategorized), "it doesn't return HTML for uncategorized by default");
|
||||
assert.present(categoryBadgeHTML(uncategorized, {allowUncategorized: true}), "it returns HTML");
|
||||
});
|
||||
|
||||
QUnit.test("category names are wrapped in dir-spans", assert => {
|
||||
Discourse.SiteSettings.support_mixed_text_direction = true;
|
||||
const store = createStore();
|
||||
const rtlCategory = store.createRecord('category', {
|
||||
name: 'תכנות עם Ruby',
|
||||
id: 123,
|
||||
description_text: 'cool description',
|
||||
color: 'ff0',
|
||||
text_color: 'f00'
|
||||
});
|
||||
|
||||
const ltrCategory = store.createRecord('category', {
|
||||
name: 'Programming in Ruby',
|
||||
id: 234
|
||||
});
|
||||
|
||||
let tag = parseHTML(categoryBadgeHTML(rtlCategory))[0];
|
||||
let dirSpan = tag.children[1].children[0];
|
||||
assert.equal(dirSpan.attributes.dir, 'rtl');
|
||||
|
||||
tag = parseHTML(categoryBadgeHTML(ltrCategory))[0];
|
||||
dirSpan = tag.children[1].children[0];
|
||||
assert.equal(dirSpan.attributes.dir, 'ltr');
|
||||
});
|
||||
|
Reference in New Issue
Block a user