Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

Commit

Permalink
feat: NextButton component
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeason Centaure committed Feb 1, 2018
1 parent 487e392 commit 7225d84
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/NextButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'
import PropTypes from 'prop-types'

const NextButton = ({ disabled }) => <button disabled={disabled}>Next</button>

NextButton.propTypes = {
disabled: PropTypes.bool,
}

export default NextButton
17 changes: 17 additions & 0 deletions components/NextButton.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { shallow } from 'enzyme'
import React from 'react'
import NextButton from './NextButton'

describe('#NextButton', () => {
it('should render a button that can be disabled', () => {
const wrapper = shallow(
<div>
<NextButton disabled />
<NextButton />
</div>,
)
const buttons = wrapper.find('NextButton')
expect(buttons.at(0).props().disabled).toBe(true)
expect(buttons.at(1).props().disabled).toBeUndefined()
})
})
4 changes: 4 additions & 0 deletions stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import ProgressBar from '../components/ProgressBar'
import Timer from '../components/Timer'
import NextButton from '../components/NextButton'

storiesOf('ProgressBar', module)
.add('0/20', () => <ProgressBar currentQuestion={0} />)
Expand All @@ -14,3 +15,6 @@ storiesOf('ProgressBar', module)
.add('Red', () => <ProgressBar color="#BD4932" />)

storiesOf('Timer', module).add('Basic', () => <Timer countdown={15} />)
storiesOf('NextButton', module)
.add('disabled', () => <NextButton disabled />)
.add('not disabled', () => <NextButton />)

0 comments on commit 7225d84

Please sign in to comment.