Skip to content

Commit

Permalink
Add test for handler
Browse files Browse the repository at this point in the history
  • Loading branch information
astralarya committed Aug 19, 2016
1 parent 9a2681e commit c6cb7f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = function(config) {

// list of files / patterns to load in the browser
files: [
'./node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js', //HOPE one day ditch PhantomJS polyfill
'test/*.tsx'
],

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"karma-webpack": "^1.7.0",
"mocha": "^3.0.1",
"node-sass": "^3.8.0",
"phantomjs-polyfill-object-assign": "0.0.2",
"react": "^15.1.0",
"react-addons-test-utils": "^15.3.0",
"react-dom": "^15.1.0",
Expand Down
18 changes: 18 additions & 0 deletions test/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ describe('<Console />', function() {
expect(wrapper.find('.react-console-nofocus')).length(0);
});
});
describe('[Property] handler: ', function () {
it('Recieves input value', function(done) {
function handler(command: string) {
expect(command).equals('ababa');
done();
}
var wrapper = enzyme.mount(<Console handler={handler}/>);
var typer = wrapper.find('.react-console-typer');
(typer.get(0) as HTMLTextAreaElement).value = 'ababa';
typer.simulate('change');
typer.simulate('keyDown', { keyCode: 13 /* Return */ });
/*
wrapper.setState({promptText: 'ababa'});
var instance = wrapper.instance() as Console;
instance.acceptLine();
*/
});
});
describe('[Property] promptLabel: ', function () {
it('Has label \'> \' when promptLabel undefined', function() {
var wrapper = enzyme.mount(<Console />);
Expand Down

0 comments on commit c6cb7f3

Please sign in to comment.