Merge pull request #1846 from velesin/admin_site_settings_controller_test_fix

fixes unit test broken (and commented out) after adding debounce behavio...
This commit is contained in:
Neil Lalonde 2014-01-20 14:26:24 -08:00
commit 9be481f035
1 changed files with 30 additions and 24 deletions

View File

@ -1,4 +1,12 @@
module("Discourse.AdminSiteSettingsController");
module("Discourse.AdminSiteSettingsController", {
setup: function() {
sinon.stub(Ember.run, "debounce").callsArg(1);
},
teardown: function() {
Ember.run.debounce.restore();
}
});
test("filter", function() {
var allSettings = Em.A([Ember.Object.create({
@ -13,31 +21,29 @@ test("filter", function() {
equal(adminSiteSettingsController.get('content')[0].nameKey, 'users', "Can get first site setting category's name key.");
// I don't know how to test a debounced function...
adminSiteSettingsController.set('filter', 'username_change');
equal(adminSiteSettingsController.get('content').length, 2, "a. Filter with one match for username_change");
equal(adminSiteSettingsController.get('content')[0].nameKey, "all_results", "b. First element is all the results that match");
equal(adminSiteSettingsController.get('content')[1].nameKey, "users", "c. Filter with one match for username_change");
equal(adminSiteSettingsController.get('content')[1].siteSettings[0].setting, "username_change_period", "d. Filter with one match for username_change");
// adminSiteSettingsController.set('filter', 'username_change');
// equal(adminSiteSettingsController.get('content').length, 2, "a. Filter with one match for username_change");
// equal(adminSiteSettingsController.get('content')[0].nameKey, "all_results", "b. First element is all the results that match");
// equal(adminSiteSettingsController.get('content')[1].nameKey, "users", "c. Filter with one match for username_change");
// equal(adminSiteSettingsController.get('content')[1].siteSettings[0].setting, "username_change_period", "d. Filter with one match for username_change");
adminSiteSettingsController.set('filter', 'name_on');
equal(adminSiteSettingsController.get('content').length, 2, "a. Filter with one match for name_on");
equal(adminSiteSettingsController.get('content')[1].nameKey, "posting", "b. Filter with one match for name_on");
equal(adminSiteSettingsController.get('content')[1].siteSettings[0].setting, "display_name_on_posts", "c. Filter with one match for name_on");
// adminSiteSettingsController.set('filter', 'name_on');
// equal(adminSiteSettingsController.get('content').length, 2, "a. Filter with one match for name_on");
// equal(adminSiteSettingsController.get('content')[1].nameKey, "posting", "b. Filter with one match for name_on");
// equal(adminSiteSettingsController.get('content')[1].siteSettings[0].setting, "display_name_on_posts", "c. Filter with one match for name_on");
adminSiteSettingsController.set('filter', 'name');
equal(adminSiteSettingsController.get('content').length, 3, "a. Filter with one match for name");
equal(adminSiteSettingsController.get('content')[0].nameKey, "all_results", "b. First element is all the results that match");
equal(adminSiteSettingsController.get('content')[1].nameKey, "users", "c. Filter with one match for name");
equal(adminSiteSettingsController.get('content')[2].nameKey, "posting", "d. Filter with one match for name");
equal(adminSiteSettingsController.get('content')[1].siteSettings[0].setting, "username_change_period", "e. Filter with one match for name");
equal(adminSiteSettingsController.get('content')[2].siteSettings[0].setting, "display_name_on_posts", "f. Filter with one match for name");
// adminSiteSettingsController.set('filter', 'name');
// equal(adminSiteSettingsController.get('content').length, 3, "a. Filter with one match for name");
// equal(adminSiteSettingsController.get('content')[0].nameKey, "all_results", "b. First element is all the results that match");
// equal(adminSiteSettingsController.get('content')[1].nameKey, "users", "c. Filter with one match for name");
// equal(adminSiteSettingsController.get('content')[2].nameKey, "posting", "d. Filter with one match for name");
// equal(adminSiteSettingsController.get('content')[1].siteSettings[0].setting, "username_change_period", "e. Filter with one match for name");
// equal(adminSiteSettingsController.get('content')[2].siteSettings[0].setting, "display_name_on_posts", "f. Filter with one match for name");
// adminSiteSettingsController.set('filter', '');
// adminSiteSettingsController.set('onlyOverridden', true);
// equal(adminSiteSettingsController.get('content').length, 2, "a. onlyOverridden with one match");
// equal(adminSiteSettingsController.get('content')[1].nameKey, "posting", "b. onlyOverridden with one match");
// equal(adminSiteSettingsController.get('content')[1].siteSettings[0].setting, "display_name_on_posts", "c. onlyOverridden with one match");
adminSiteSettingsController.set('filter', '');
adminSiteSettingsController.set('onlyOverridden', true);
equal(adminSiteSettingsController.get('content').length, 2, "a. onlyOverridden with one match");
equal(adminSiteSettingsController.get('content')[1].nameKey, "posting", "b. onlyOverridden with one match");
equal(adminSiteSettingsController.get('content')[1].siteSettings[0].setting, "display_name_on_posts", "c. onlyOverridden with one match");
});