-
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.
CountdownForm Testing Done Succesfully
- Loading branch information
1 parent
bf6c3f2
commit d3f14ec
Showing
10 changed files
with
114 additions
and
27 deletions.
There are no files selected for viewing
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,3 @@ | ||
{ | ||
"jshint.enable": false | ||
} |
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,27 @@ | ||
var React = require('react'); | ||
|
||
var CountdownForm = React.createClass({ | ||
onSubmit : function (e) { | ||
e.preventDefault(); | ||
var strSeconds = this.refs.seconds.value; | ||
|
||
if(strSeconds.match(/^[0-9,]*$/)) { | ||
this.refs.seconds.value = ''; | ||
this.props.onSetCountDown(parseInt(strSeconds,10)); | ||
} | ||
}, | ||
render : function () { | ||
return( | ||
<div> | ||
<form ref="form" onSubmit={this.onSubmit} className="countdown-form"> | ||
<input type="text" ref="seconds" placeholder="Enter time in seconds"/> | ||
<button className="button expanded">Start</button> | ||
</form> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
|
||
|
||
module.exports = CountdownForm; |
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
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,34 @@ | ||
var expect = require('expect'); | ||
var React = require('react'); | ||
var ReactDOM = require('react-dom'); | ||
var TestUtils = require('react-addons-test-utils'); | ||
var $ = require('jQuery'); | ||
|
||
var CountdownForm = require('CountdownForm'); | ||
|
||
describe('CountdownForm', () => { | ||
it('should exist', () => { | ||
expect(CountdownForm).toExist(); | ||
}); | ||
it('should call onSetCountDown if valid seconds entered', ()=>{ | ||
var spy = expect.createSpy(); | ||
var countdownForm = TestUtils.renderIntoDocument(<CountdownForm onSetCountDown={spy} />); | ||
var $el = $(ReactDOM.findDOMNode(countdownForm)); | ||
countdownForm.refs.seconds.value = '109'; | ||
|
||
TestUtils.Simulate.submit($el.find('form')[0]); | ||
|
||
expect(spy).toHaveBeenCalledWith(109); | ||
}); | ||
|
||
it('should call onSetCountDown if valid seconds not entered', ()=>{ | ||
var spy = expect.createSpy(); | ||
var countdownForm = TestUtils.renderIntoDocument(<CountdownForm onSetCountDown={spy} />); | ||
var $el = $(ReactDOM.findDOMNode(countdownForm)); | ||
countdownForm.refs.seconds.value = '109j'; | ||
|
||
TestUtils.Simulate.submit($el.find('form')[0]); | ||
|
||
expect(spy).toNotHaveBeenCalled(); | ||
}); | ||
}); |
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