Skip to content

Instantly share code, notes, and snippets.

@sminutoli
Created September 1, 2016 20:34
Show Gist options
  • Save sminutoli/29c5fa060cee1c6d82f151f5949bb8ca to your computer and use it in GitHub Desktop.
Save sminutoli/29c5fa060cee1c6d82f151f5949bb8ca to your computer and use it in GitHub Desktop.
describe('Component Type and Props', function () {
it('should be a stateless component', ()=>{
expect(Login.prototype).toNotBeA(React.Component);
});
it('should have the correct props defined', ()=>{
var propTypes = {
username: PropTypes.string,
password: PropTypes.string,
isValid: PropTypes.bool,
isWaiting: PropTypes.bool,
error: PropTypes.object,
onSignIn: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired
};
expect(Login.propTypes).toEqual(propTypes);
//necesitamos comparar estricto porque si no cualquier PropType == PropType
Object.keys(propTypes).forEach(
(key)=>expect(propTypes[key]).toBe(Login.propTypes[key])
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment