-
-
Save darthdeus/5303646 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.server = sinon.fakeServer.create(); | |
Ember.run(function() { | |
alertAdminController = EurekaJ.__container__.lookup("controller:administrationAlerts"); | |
}); | |
}, | |
teardown: function() { | |
this.server.restore(); | |
delete this.server; | |
} | |
}); | |
var thing = { | |
verifyContentLength: function() { | |
console.log('content.length'); | |
console.log('later: ' + alertAdminController.get('content.length')); | |
if (alertAdminController.get('content.length') > 0 ) { | |
strictEqual(1, alertAdminController.get('content.length'), "Expecting one alert. Got: " + alertAdminController.get('content.length')); | |
start(); | |
} | |
} | |
}; | |
asyncTest("Create a new Alert and verify that it is shown", 3, function() { | |
EurekaJ.reset(); | |
ok(alertAdminController, "Exepcting a non-null AdministrationAlertsController"); | |
console.log(alertAdminController.get('content.length')); | |
Ember.addObserver(alertAdminController.get('content'), 'length', thing, 'verifyContentLength'); | |
console.log(alertAdminController.get('content.length')); | |
alertAdminController.set('newAlertName', 'New Alert'); | |
alertAdminController.createNewAlert(); | |
var newAlert = alertAdminController.get('newAlert'); | |
newAlert.one('didCreate', function() { | |
console.log('didCreate: ' + alertAdminController.get('content.length')); | |
}); | |
console.log('committing'); | |
EurekaJ.store.commit(); | |
//Set up the response | |
this.server.respondWith("POST", "/alert_models", | |
[200, { "Content-Type": "text/json" }, | |
'{"alert_model":{"alert_source":"null","id":"New Alert","alert_delay":0,"alert_plugin_ids":[],"alert_notifications":"","alert_activated":false,"alert_type":"greater_than"}}']); | |
console.log('responding'); | |
this.server.respond(); | |
strictEqual(1, this.server.requests.length, "Expecting a total of 1 XHR"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment