Created
March 2, 2017 17:03
-
-
Save yantakus/950cdbf134a1de3a716d9c245fca4903 to your computer and use it in GitHub Desktop.
This file contains 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
import React from 'react' | |
import { shallow, render } from 'enzyme' | |
import AuthButton from '../AuthButton' | |
import Spinner from 'components/Spinner' | |
describe('<AuthButton />', () => { | |
it('should render <Spinner /> if `isLoading` prop is provided', () => { | |
const renderedComponent = shallow( | |
<AuthButton | |
text='Some text' | |
isLoading | |
/> | |
) | |
expect(renderedComponent.find(Spinner).length).toEqual(1) | |
}) | |
it('should not render <Spinner /> if `isLoading` prop is not provided', () => { | |
const renderedComponent = shallow( | |
<AuthButton | |
text='Some text' | |
/> | |
) | |
expect(renderedComponent.find(Spinner).length).toEqual(0) | |
}) | |
it('should be disabled if messages object has keys', () => { | |
const renderedComponent = render( | |
<AuthButton | |
text='Some text' | |
messages={{ foo: 'bar' }} | |
/> | |
) | |
expect(renderedComponent.find('button').prop('disabled')).toEqual(true) | |
}) | |
it('should not be disabled if messages object has no keys', () => { | |
const renderedComponent = render( | |
<AuthButton | |
text='Some text' | |
messages={{}} | |
/> | |
) | |
expect(renderedComponent.find('button').prop('disabled')).toEqual(false) | |
}) | |
it('should render provided text', () => { | |
const renderedComponent = render( | |
<AuthButton | |
text='Some text' | |
/> | |
) | |
expect(renderedComponent.text()).toContain('Some text') | |
}) | |
it('should render provided hint', () => { | |
const renderedComponent = render( | |
<AuthButton | |
text='Some text' | |
hint='Some hint' | |
/> | |
) | |
expect(renderedComponent.text()).toContain('Some hint') | |
}) | |
it('should render hint wrapper if provided', () => { | |
const renderedComponent = shallow( | |
<AuthButton | |
text='Some text' | |
hint='Some hint' | |
/> | |
) | |
expect(renderedComponent.find('.button__hint').length).toEqual(1) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment