Skip to content

Instantly share code, notes, and snippets.

@jakecraige
Last active August 29, 2015 14:03
Show Gist options
  • Save jakecraige/c19b3c9b8b2d787ad8d0 to your computer and use it in GitHub Desktop.
Save jakecraige/c19b3c9b8b2d787ad8d0 to your computer and use it in GitHub Desktop.
describe('Validations', function() {
before(function() {
this.alert = stub(window, 'alert');
});
after(function() {
this.alert.restore();
});
it('validates password', function() {
var test = this;
expect(2);
visit('/tab/planning/sign-in');
fillIn('input.email', 'example@example.com');
click('button.signin');
andThen(function() {
expect(test.alert.called).to.eql(1);
expect(test.alert.calledWith[0][0]).to.match(/.*must.*password.*/i);
});
});
it('validates email', function() {
var test = this;
expect(2);
visit('/tab/planning/sign-in');
fillIn('input.password', 'password');
click('button.signin');
andThen(function() {
expect(test.alert.called).to.eql(1);
expect(test.alert.calledWith[0][0]).to.match(/.*must.*email.*/i);
});
});
});
export default function (obj, name, value) {
var original = obj[name];
obj[name] = function() {
obj[name].called++;
obj[name].calledWith.push(arguments);
return value;
};
obj[name].restore = function() {
obj[name] = original;
};
obj[name].called = 0;
obj[name].calledWith = [];
return obj[name];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment