-
-
Save darthdeus/5280687 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var alertAdminController; | |
module("EurekaJ.AdministrationAlertsController", { | |
setup: function() { | |
this.xhr = sinon.useFakeXMLHttpRequest(); | |
this.server = sinon.fakeServer.create(); | |
var requests = this.requests = []; | |
this.xhr.onCreate = function (xhr) { | |
requests.push(xhr); | |
}; | |
Ember.run(function() { | |
alertAdminController = EurekaJ.__container__.lookup("controller:administrationAlerts"); | |
}); | |
}, | |
teardown: function() { | |
this.xhr.restore(); | |
this.server.restore(); | |
delete this.server; | |
} | |
}); | |
test("Verify non-null controller", function() { | |
EurekaJ.reset(); | |
ok(alertAdminController, "Exepcting a non-null AdministrationAlertsController"); | |
}); | |
asyncTest("Create a new Alert and verify that it is shown", 1, function() { | |
EurekaJ.reset(); | |
//Set up the response | |
this.server.respondWith("POST", "/alert_models", | |
[200, { "Content-Type": "text/json" }, | |
'{"alert_model":{"alert_source":"null","id":"newAlert","alert_delay":0,"alert_plugin_ids":[],"alert_notifications":"","alert_activated":false,"alert_type":"greater_than"}}']); | |
alertAdminController.set('newAlertName', 'New Alert'); | |
alertAdminController.createNewAlert(); | |
console.log('responding from fakeServer'); | |
this.server.respond(); | |
var newAlert = alertAdminController.get('newAlert'); | |
console.log('newAlert: ' + newAlert); | |
newAlert.one('didCreate', function() { | |
console.log('newAlert didCreate'); | |
console.log("content.length: " + alertAdminController.get('content.length')); | |
strictEqual(1, alertAdminController.get('content.length'), "Expecting one alert"); | |
start(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment