2013-06-17 23:38:30 +08:00
|
|
|
module("Discourse.Site");
|
|
|
|
|
|
|
|
test('instance', function(){
|
|
|
|
|
2013-08-09 00:49:58 +08:00
|
|
|
var site = Discourse.Site.current();
|
2013-06-17 23:38:30 +08:00
|
|
|
|
|
|
|
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");
|
2013-07-13 04:18:32 +08:00
|
|
|
present(site.get('trustLevels'), "The instance has a list of trust levels");
|
2013-06-17 23:38:30 +08:00
|
|
|
|
2013-10-24 01:29:20 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('create categories', function() {
|
|
|
|
|
|
|
|
var site = Discourse.Site.create({
|
|
|
|
categories: [{ id: 1234, name: 'Test'},
|
|
|
|
{ id: 3456, name: 'Test Subcategory', parent_category_id: 1234},
|
|
|
|
{ id: 3456, name: 'Invalid Subcategory', parent_category_id: 6666}]
|
|
|
|
});
|
|
|
|
|
|
|
|
var categories = site.get('categories');
|
|
|
|
|
|
|
|
present(categories, "The categories are present");
|
|
|
|
equal(categories.length, 3, "it loaded all three categories");
|
|
|
|
|
|
|
|
var parent = categories.findBy('id', 1234);
|
|
|
|
present(parent, "it loaded the parent category");
|
|
|
|
blank(parent.get('parentCategory'), 'it has no parent category');
|
|
|
|
|
|
|
|
var subcategory = categories.findBy('id', 3456);
|
|
|
|
present(subcategory, "it loaded the subcategory");
|
|
|
|
equal(subcategory.get('parentCategory'), parent, "it has associated the child with the parent");
|
|
|
|
|
|
|
|
|
2013-06-17 23:38:30 +08:00
|
|
|
});
|