Skip to content

Instantly share code, notes, and snippets.

@dadamssg
Last active August 29, 2015 14:19
Show Gist options
  • Save dadamssg/3ce5ac40eb65b64d627e to your computer and use it in GitHub Desktop.
Save dadamssg/3ce5ac40eb65b64d627e to your computer and use it in GitHub Desktop.
import Ember from "ember";
import { module, test } from 'qunit';
import startApp from '../helpers/start-app';
var App;
module('SignIn failure', {
beforeEach: function() {
App = startApp();
this.xhr = sinon.useFakeXMLHttpRequest();
this.server = sinon.fakeServer.create();
this.server.autoRespond = true;
sinon.spy(Ember.$, 'ajax');
this.server.respondWith('POST', 'http://app.dev/app_test.php/oauth/v2/token', [
400,
{ 'Content-Type': 'application/json' },
'{"error":"invalid_grant","error_description":"Invalid username and password combination"}'
]);
},
afterEach: function() {
Ember.run(App, App.destroy);
}
});
test("Error is shown on invalid usernmae/password", function(assert) {
assert.expect(2);
visit('/login').then(function() {
assert.equal(find('.has-error').length, 0, "Error div is shown when shouldn't be");
fillIn('input.identification', 'foobar');
fillIn('input.password', 's3cr3t');
click('button.submit');
andThen(function() {
assert.equal(find('.has-error').length, 1, "Error div is not shown when it should be");
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment