Skip to content

Instantly share code, notes, and snippets.

@mmfilesi

mmfilesi/app.js

Created Feb 19, 2016
Embed
What would you like to do?
demo jasmine
var checkForm = {
checkInputs: function(user, pass) {
var isValid = true;
if ( !user || !pass || user.indexOf('@') === -1 ) {
isValid = false;
}
return isValid;
},
init: function(user, pass) {
this.checkInputs(user, pass);
}
};
describe('checkForm', function() {
var user = '',
pass = '';
afterEach(function() {
user = '',
pass = '';
});
it('checkForm must be an object', function() {
expect(typeof checkForm).toBe('object');
});
it('checkForm has init method', function() {
expect(typeof checkForm.init).toBe('function');
});
it('checkForm has checkInputs method', function() {
expect(typeof checkForm.checkInputs).toBe('function');
});
it('inputs corrects are true', function() {
user = 'foo@bar.com';
pass = 'bazinga';
var inputs = checkForm.checkInputs(user, pass);
expect(inputs).toBeTruthy();
});
it('empty inputs are false', function() {
var inputs = checkForm.checkInputs(user, pass);
expect(inputs).toBeFalsy();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.