From 608f55d259fca1dafea849bd85e482548e1e601b Mon Sep 17 00:00:00 2001 From: Jeason Centaure Date: Tue, 16 Jan 2018 11:42:16 +0100 Subject: [PATCH] feat: Timer component --- components/Timer.js | 14 ++++++++++++++ components/Timer.test.js | 10 ++++++++++ package.json | 1 + stories/index.js | 4 +++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 components/Timer.js create mode 100644 components/Timer.test.js diff --git a/components/Timer.js b/components/Timer.js new file mode 100644 index 0000000..2db8253 --- /dev/null +++ b/components/Timer.js @@ -0,0 +1,14 @@ +import React from 'react' +import PropTypes from 'prop-types' + +const Timer = ({ countdown }) => ( +
+ {countdown} +
+) + +Timer.propTypes = { + countdown: PropTypes.number, +} + +export default Timer diff --git a/components/Timer.test.js b/components/Timer.test.js new file mode 100644 index 0000000..d1c054b --- /dev/null +++ b/components/Timer.test.js @@ -0,0 +1,10 @@ +import React from 'react' +import { shallow } from 'enzyme' +import Timer from './Timer' + +describe('Timer', () => { + it('should render a timer', () => { + const wrapper = shallow() + expect(wrapper.text()).toEqual('42') + }) +}) diff --git a/package.json b/package.json index a31f915..bd87807 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "passport-github2": "^0.1.11", "pg": "^7.4.1", "polished": "^1.9.0", + "prop-types": "^15.6.0", "react": "^16.2.0", "react-dom": "^16.2.0", "styled-components": "^2.4.0" diff --git a/stories/index.js b/stories/index.js index 1108ea6..505e5e1 100644 --- a/stories/index.js +++ b/stories/index.js @@ -1,7 +1,7 @@ import React from 'react' import { storiesOf } from '@storybook/react' -// import { action } from '@storybook/addon-actions' import ProgressBar from '../components/ProgressBar' +import Timer from '../components/Timer' storiesOf('ProgressBar', module) .add('0/20', () => ) @@ -12,3 +12,5 @@ storiesOf('ProgressBar', module) .add('Large', () => ) .add('Without ScoreBox', () => ) .add('Red', () => ) + +storiesOf('Timer', module).add('Basic', () => )