mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:41:03 +08:00
Upgrade QUnit to latest version
This commit is contained in:
@ -1,16 +1,15 @@
|
||||
import createStore from 'helpers/create-store';
|
||||
import { blank, present } from 'helpers/qunit-helpers';
|
||||
|
||||
module("lib:category-link");
|
||||
QUnit.module("lib:category-link");
|
||||
|
||||
import parseHTML from 'helpers/parse-html';
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
|
||||
test("categoryBadge without a category", function() {
|
||||
blank(categoryBadgeHTML(), "it returns no HTML");
|
||||
QUnit.test("categoryBadge without a category", assert => {
|
||||
assert.blank(categoryBadgeHTML(), "it returns no HTML");
|
||||
});
|
||||
|
||||
test("Regular categoryBadge", function() {
|
||||
QUnit.test("Regular categoryBadge", assert => {
|
||||
const store = createStore();
|
||||
const category = store.createRecord('category', {
|
||||
name: 'hello',
|
||||
@ -21,28 +20,28 @@ test("Regular categoryBadge", function() {
|
||||
});
|
||||
const tag = parseHTML(categoryBadgeHTML(category))[0];
|
||||
|
||||
equal(tag.name, 'a', 'it creates a `a` wrapper tag');
|
||||
equal(tag.attributes['class'].trim(), 'badge-wrapper', 'it has the correct class');
|
||||
assert.equal(tag.name, 'a', 'it creates a `a` wrapper tag');
|
||||
assert.equal(tag.attributes['class'].trim(), 'badge-wrapper', 'it has the correct class');
|
||||
|
||||
const label = tag.children[1];
|
||||
equal(label.attributes.title, 'cool description', 'it has the correct title');
|
||||
assert.equal(label.attributes.title, 'cool description', 'it has the correct title');
|
||||
|
||||
equal(label.children[0].data, 'hello', 'it has the category name');
|
||||
assert.equal(label.children[0].data, 'hello', 'it has the category name');
|
||||
});
|
||||
|
||||
test("undefined color", function() {
|
||||
QUnit.test("undefined color", assert => {
|
||||
const store = createStore();
|
||||
const noColor = store.createRecord('category', { name: 'hello', id: 123 });
|
||||
const tag = parseHTML(categoryBadgeHTML(noColor))[0];
|
||||
|
||||
blank(tag.attributes.style, "it has no color style because there are no colors");
|
||||
assert.blank(tag.attributes.style, "it has no color style because there are no colors");
|
||||
});
|
||||
|
||||
test("allowUncategorized", function() {
|
||||
QUnit.test("allowUncategorized", assert => {
|
||||
const store = createStore();
|
||||
const uncategorized = store.createRecord('category', {name: 'uncategorized', id: 345});
|
||||
sandbox.stub(Discourse.Site, 'currentProp').withArgs('uncategorized_category_id').returns(345);
|
||||
|
||||
blank(categoryBadgeHTML(uncategorized), "it doesn't return HTML for uncategorized by default");
|
||||
present(categoryBadgeHTML(uncategorized, {allowUncategorized: true}), "it returns HTML");
|
||||
});
|
||||
assert.blank(categoryBadgeHTML(uncategorized), "it doesn't return HTML for uncategorized by default");
|
||||
assert.present(categoryBadgeHTML(uncategorized, {allowUncategorized: true}), "it returns HTML");
|
||||
});
|
Reference in New Issue
Block a user