Created
February 19, 2016 17:40
-
-
Save mmfilesi/c0ca6316bdbe94fbbb28 to your computer and use it in GitHub Desktop.
demo jasmine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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