Upgrade to ember-qunit

This commit is contained in:
Robin Ward
2014-07-30 17:53:14 -04:00
parent d29157dab9
commit b6684e7168
15 changed files with 350 additions and 161 deletions
@@ -1,29 +1,26 @@
module("controller:admin-badges");
moduleFor("controller:admin-badges", "controller:admin-badges", {
needs: ['controller:modal', 'controller:admin-badge']
});
test("canEditDescription", function() {
var badge, controller;
badge = Discourse.Badge.create({id: 101, name: "Test Badge"});
controller = testController("admin-badges", [badge]);
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"});
var controller = this.subject({ model: [badge] });
controller.send('selectBadge', badge);
ok(controller.get('canEditDescription'), "allows editing description when a translation exists for the badge name");
this.stub(I18n, "t").returns("translated string");
badge = Discourse.Badge.create({id: 102, name: "Test Badge"});
controller = testController("admin-badges", [badge]);
controller.send('selectBadge', badge);
ok(!controller.get('canEditDescription'), "shows the displayName when it is different from the name");
badge.set('translatedDescription', 'translated');
ok(!controller.get('canEditDescription'), "can't edit the description when it's got a translation");
});
test("createNewBadge", function() {
var controller = testController("admin-badges", []);
var controller = this.subject();
controller.send('createNewBadge');
equal(controller.get('model.length'), 1, "adds a new badge to the list of badges");
});
test("selectBadge", function() {
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
controller = testController("admin-badges", [badge]);
controller = this.subject({ model: [badge] });
controller.send('selectBadge', badge);
equal(controller.get('selectedItem'), badge, "the badge is selected");
@@ -32,10 +29,10 @@ test("selectBadge", function() {
test("save", function() {
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
otherBadge = Discourse.Badge.create({id: 102, name: "Other Badge"}),
controller = testController("admin-badges", [badge, otherBadge]);
controller = this.subject({ model: [badge, otherBadge] });
controller.send('selectBadge', badge);
this.stub(badge, "save").returns(Ember.RSVP.resolve({}));
sinon.stub(badge, "save").returns(Ember.RSVP.resolve({}));
controller.send("save");
ok(badge.save.calledOnce, "called save on the badge");
});
@@ -43,9 +40,9 @@ test("save", function() {
test("destroy", function() {
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
otherBadge = Discourse.Badge.create({id: 102, name: "Other Badge"}),
controller = testController("admin-badges", [badge, otherBadge]);
controller = this.subject({model: [badge, otherBadge]});
this.stub(badge, 'destroy').returns(Ember.RSVP.resolve({}));
sinon.stub(badge, 'destroy').returns(Ember.RSVP.resolve({}));
bootbox.confirm = function(text, yes, no, func) {
func(false);