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

feat: ScoreResult component #28

Merged
merged 1 commit into from
Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toBe

})
})
6 changes: 6 additions & 0 deletions stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { storiesOf } from '@storybook/react'
import ProgressBar from '../components/ProgressBar'
import Timer from '../components/Timer'
import NextButton from '../components/NextButton'
import ScoreResult from '../components/ScoreResult'

storiesOf('ProgressBar', module)
.add('0/20', () => <ProgressBar currentQuestion={0} />)
Expand All @@ -18,3 +19,8 @@ storiesOf('Timer', module).add('Basic', () => <Timer countdown={15} />)
storiesOf('NextButton', module)
.add('disabled', () => <NextButton disabled />)
.add('not disabled', () => <NextButton />)
storiesOf('Timer', module).add('Basic Timer', () => <Timer countdown={15} />)

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