Skip to content

Instantly share code, notes, and snippets.

@mmfilesi
Created February 19, 2016 17:40
Show Gist options
  • Save mmfilesi/c0ca6316bdbe94fbbb28 to your computer and use it in GitHub Desktop.
Save mmfilesi/c0ca6316bdbe94fbbb28 to your computer and use it in GitHub Desktop.
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 = '[email protected]';
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