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

Commit

Permalink
feat: ScoreResult component
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeason Centaure committed Jan 26, 2018
1 parent 487e392 commit bb8ec2d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/Question.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import Question from './Question'
describe('#Question', () => {
it('should render a question component using ReactMarkdown', () => {
const wrapper = shallow(<Question question="2 + 2 ?" />)
expect(wrapper.find('Markdown').prop('source')).toEqual('2 + 2 ?')
expect(wrapper.find('Markdown').prop('source')).toBe('2 + 2 ?')
})
})
13 changes: 13 additions & 0 deletions components/ScoreResult.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react'
import PropTypes from 'prop-types'

const ScoreResult = ({ totalScore, userScore }) => (
<p>{`Vous avez obtenu ${userScore}/${totalScore} au quiz React.`}</p>
)

ScoreResult.propTypes = {
totalScore: PropTypes.number,
userScore: PropTypes.number,
}

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

describe('ScoreResult', () => {
it('should render the ScoreResult component', () => {
const wrapper = shallow(<ScoreResult totalScore={20} userScore={12} />)
expect(wrapper.text()).toEqual('Vous avez obtenu 12/20 au quiz React.')
})
})
7 changes: 6 additions & 1 deletion 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 ScoreResult from '../components/ScoreResult'

storiesOf('ProgressBar', module)
.add('0/20', () => <ProgressBar currentQuestion={0} />)
Expand All @@ -13,4 +14,8 @@ storiesOf('ProgressBar', module)
.add('Without ScoreBox', () => <ProgressBar scoreBox={false} />)
.add('Red', () => <ProgressBar color="#BD4932" />)

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

storiesOf('ScoreResult', module).add('12/20 Final Score', () => (
<ScoreResult totalScore={20} userScore={12} />
))

0 comments on commit bb8ec2d

Please sign in to comment.