Skip to content

Commit

Permalink
fix(init): trim the inputs
Browse files Browse the repository at this point in the history
Closes #663
  • Loading branch information
vojtajina committed Jul 30, 2013
1 parent 9dc1cf6 commit b72355c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ var StateMachine = function(rli) {

this.onLine = function(line) {
if (pendingQuestionId) {
line = line.trim();

if (currentOptions) {
currentOptionsPointer = currentOptions.indexOf(line);
if (currentOptionsPointer === -1) {
Expand Down
14 changes: 14 additions & 0 deletions test/unit/init.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ describe 'init', ->
expect(done).to.have.been.called


it 'should treat spaces as confirmation of multiple answers', ->
questions = [
{id: 'browsers', multiple: true}
]

done = sinon.spy (answers) ->
expect(answers.browsers).to.deep.equal ['Chrome']

machine.process questions, done
machine.onLine 'Chrome'
machine.onLine ' '
expect(done).to.have.been.called


it 'should always return array for multiple', ->
questions = [
{id: 'empty', multiple: true}
Expand Down

0 comments on commit b72355c

Please sign in to comment.