-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Initial Test Cases And Styling to Clock Component
- Loading branch information
1 parent
c9e1519
commit bf6c3f2
Showing
17 changed files
with
584 additions
and
130 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var React = require('react'); | ||
|
||
var Clock = React.createClass({ | ||
getInitialProps : function () { | ||
totalSeconds : 0 | ||
}, | ||
propTypes : function () { | ||
totalSeconds = React.PropTypes.number | ||
}, | ||
formatSeconds : function (totalSeconds) { | ||
var seconds = totalSeconds % 60; | ||
var minutes = Math.floor(totalSeconds / 60); | ||
if(seconds < 10) { | ||
seconds = '0' + seconds; | ||
} | ||
if(minutes < 10) { | ||
minutes = '0' + minutes; | ||
} | ||
return minutes + ':' + seconds; | ||
}, | ||
render : function () { | ||
var {totalSeconds} = this.props; | ||
return ( | ||
<div className="clock"> | ||
<span className="clock-text"> | ||
{this.formatSeconds(totalSeconds)} | ||
</span> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = Clock; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var React = require('react'); | ||
var Clock = require('Clock'); | ||
var Countdown = React.createClass({ | ||
render : function () { | ||
return ( | ||
<div> | ||
<Clock totalSeconds={1190}/> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = Countdown; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var React = require('react'); | ||
|
||
var Timer = React.createClass({ | ||
render : function () { | ||
return( | ||
<div> | ||
<h5>Timer.jsx</h5> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = Timer; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import "base/variables"; | ||
@import "components/navigation"; | ||
@import "components/navigation"; | ||
@import "components/clock"; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.clock { | ||
align-items: center; | ||
background-color: $clock-bg-color; | ||
border: 2px solid $clock-border-color; | ||
border-radius : 50%; | ||
display : flex; | ||
height : 14rem; | ||
justify-content :center; | ||
margin: 4rem auto; | ||
width: 14rem; | ||
|
||
} | ||
|
||
.clock-text { | ||
color: $clock-text-color; | ||
font-size : 2.25rem; | ||
font-weight : 300; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var expect = require('expect'); | ||
|
||
describe('App',() => { | ||
it('should properly run tests',() => { | ||
expect(1).toBe(1); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var React = require('react'); | ||
var ReactDOM = require('react-dom'); | ||
var expect = require('expect'); | ||
var $ = require('jQuery'); | ||
|
||
var TestUtils = require('react-addons-test-utils'); | ||
|
||
var Clock = require('Clock'); | ||
|
||
describe('Clock', ()=> { | ||
it('should exist', ()=> { | ||
expect(Clock).toExist(); | ||
}); | ||
|
||
describe('render', ()=> { | ||
it('should render clock component',()=>{ | ||
var clock = TestUtils.renderIntoDocument(<Clock totalSeconds = {90}/>); | ||
var $el = $(ReactDOM.findDOMNode(clock)); | ||
var actualText = $el.find('.clock-test').text(); | ||
expect(actualText).toBe('01:30'); | ||
}); | ||
}); | ||
|
||
describe('formatSeconds', ()=> { | ||
it('should formatSeconds',()=> { | ||
var clock = TestUtils.renderIntoDocument(<Clock/>); | ||
var seconds = 615; | ||
var expected = '10:15'; | ||
var actual = clock.formatSeconds(seconds); | ||
|
||
expect(actual).toBe(expected); | ||
}); | ||
}); | ||
|
||
describe('formatSeconds when seconds and minutes < 10', ()=> { | ||
it('should formatSeconds',()=> { | ||
var clock = TestUtils.renderIntoDocument(<Clock/>); | ||
var seconds = 61; | ||
var expected = '01:01'; | ||
var actual = clock.formatSeconds(seconds); | ||
|
||
expect(actual).toBe(expected); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var webpackConfig = require('./webpack.config.js'); | ||
module.exports = function (config) { | ||
config.set({ | ||
browsers: ['Chrome'], | ||
singleRun: true, | ||
frameworks: ['mocha'], | ||
files : ['app/tests/**/*.test.jsx'], | ||
preprocessors: { | ||
'app/tests/**/*.test.jsx' : ['webpack','sourcemap'] | ||
}, | ||
reporters:['mocha'], | ||
client: { | ||
mocha: { | ||
timeout: '5000' | ||
} | ||
}, | ||
webpack: webpackConfig, | ||
webpackServer: { | ||
noInfo : true | ||
} | ||
}); | ||
} |
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
Oops, something went wrong.