mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:21:04 +08:00
Upgrade QUnit to latest version
This commit is contained in:
@ -1,23 +1,22 @@
|
||||
import createStore from 'helpers/create-store';
|
||||
import { blank, present } from 'helpers/qunit-helpers';
|
||||
|
||||
module("model:site");
|
||||
QUnit.module("model:site");
|
||||
|
||||
test('create', function() {
|
||||
ok(Discourse.Site.create(), 'it can create with no parameters');
|
||||
QUnit.test('create', assert => {
|
||||
assert.ok(Discourse.Site.create(), 'it can create with no parameters');
|
||||
});
|
||||
|
||||
test('instance', function() {
|
||||
QUnit.test('instance', assert => {
|
||||
const site = Discourse.Site.current();
|
||||
|
||||
present(site, "We have a current site singleton");
|
||||
present(site.get('categories'), "The instance has a list of categories");
|
||||
present(site.get('flagTypes'), "The instance has a list of flag types");
|
||||
present(site.get('trustLevels'), "The instance has a list of trust levels");
|
||||
assert.present(site, "We have a current site singleton");
|
||||
assert.present(site.get('categories'), "The instance has a list of categories");
|
||||
assert.present(site.get('flagTypes'), "The instance has a list of flag types");
|
||||
assert.present(site.get('trustLevels'), "The instance has a list of trust levels");
|
||||
|
||||
});
|
||||
|
||||
test('create categories', function() {
|
||||
QUnit.test('create categories', assert => {
|
||||
const store = createStore();
|
||||
const site = store.createRecord('site', {
|
||||
categories: [{ id: 1234, name: 'Test'},
|
||||
@ -28,22 +27,22 @@ test('create categories', function() {
|
||||
const categories = site.get('categories');
|
||||
site.get('sortedCategories');
|
||||
|
||||
present(categories, "The categories are present");
|
||||
equal(categories.length, 3, "it loaded all three categories");
|
||||
assert.present(categories, "The categories are present");
|
||||
assert.equal(categories.length, 3, "it loaded all three categories");
|
||||
|
||||
const parent = categories.findBy('id', 1234);
|
||||
present(parent, "it loaded the parent category");
|
||||
blank(parent.get('parentCategory'), 'it has no parent category');
|
||||
assert.present(parent, "it loaded the parent category");
|
||||
assert.blank(parent.get('parentCategory'), 'it has no parent category');
|
||||
|
||||
const subcategory = categories.findBy('id', 3456);
|
||||
present(subcategory, "it loaded the subcategory");
|
||||
equal(subcategory.get('parentCategory'), parent, "it has associated the child with the parent");
|
||||
assert.present(subcategory, "it loaded the subcategory");
|
||||
assert.equal(subcategory.get('parentCategory'), parent, "it has associated the child with the parent");
|
||||
|
||||
// remove invalid category and child
|
||||
categories.removeObject(categories[2]);
|
||||
categories.removeObject(categories[1]);
|
||||
|
||||
equal(categories.length, site.get('categoriesByCount').length, "categories by count should change on removal");
|
||||
equal(categories.length, site.get('sortedCategories').length, "sorted categories should change on removal");
|
||||
assert.equal(categories.length, site.get('categoriesByCount').length, "categories by count should change on removal");
|
||||
assert.equal(categories.length, site.get('sortedCategories').length, "sorted categories should change on removal");
|
||||
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user