Skip to content

Instantly share code, notes, and snippets.

@coderberry
Created March 10, 2014 18:04
Show Gist options
  • Save coderberry/9470545 to your computer and use it in GitHub Desktop.
Save coderberry/9470545 to your computer and use it in GitHub Desktop.
document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');
Ember.testing = true;
window.startApp = require('appkit/tests/helpers/start-app')['default'];
window.isolatedContainer = require('appkit/tests/helpers/isolated-container')['default'];
window.fakeServer = require('appkit/tests/helpers/fake-server')['default'];
function exists(selector) {
return !!find(selector).length;
}
function getAssertionMessage(actual, expected, message) {
return message || QUnit.jsDump.parse(expected) + " expected but was " + QUnit.jsDump.parse(actual);
}
function equal(actual, expected, message) {
message = getAssertionMessage(actual, expected, message);
QUnit.equal.call(this, actual, expected, message);
}
function strictEqual(actual, expected, message) {
message = getAssertionMessage(actual, expected, message);
QUnit.strictEqual.call(this, actual, expected, message);
}
function currentRouteName(app){
var appController = app.__container__.lookup('controller:application');
return appController.get('currentRouteName');
}
function currentPath(app){
var appController = app.__container__.lookup('controller:application');
return appController.get('currentPath');
}
function currentURL(app){
var router = app.__container__.lookup('router:main');
return router.get('location').getURL();
}
function pushToStore(app, modelName, payload) {
var myStore = app.__container__.lookup('store:main');
Ember.run(function() {
myStore.pushPayload(modelName, payload);
});
}
Ember.Test.registerAsyncHelper('submitForm',
function(app, selector, context) {
var $el = findWithAssert(selector, context);
Ember.run(function() {
$el.submit();
});
}
);
window.exists = exists;
window.equal = equal;
window.strictEqual = strictEqual;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment