Skip to content

Commit

Permalink
Merge 7b99ce3 into 0caf3a6
Browse files Browse the repository at this point in the history
  • Loading branch information
vitor-vidal committed Sep 10, 2019
2 parents 0caf3a6 + 7b99ce3 commit 9147a22
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/rawToObject.js
Expand Up @@ -72,7 +72,13 @@ function rowReducer(resultObj, row){
let pair = row.split(ROW_SPLITTER);

if(pair.length > 1){
resultObj[pair[0].trim()] = pair.slice(1).join(ROW_SPLITTER).trim();
const key = pair[0].trim();
const value = pair.slice(1).join(ROW_SPLITTER).trim();
if(key === 'Output' && typeof resultObj[key] === 'string' && resultObj[key] !== ''){
resultObj[key] += CRLF + value;
}else{
resultObj[key] = value;
}
}
return resultObj;
}
Expand Down
20 changes: 20 additions & 0 deletions test/utilsTest.js
Expand Up @@ -128,6 +128,26 @@ describe('Event utils test', () => {
});
});

it('with a multiline output response', () => {
let commandStr = [
'Response: Success',
'Message: Command output follows',
'Output: Version: 16.1.1',
'Output: Build Options: BUILD_NATIVE, OPTIONAL_API',
'Output: Maximum calls: Not set'
].join(CRLF) + CRLF.repeat(2);

assert.deepEqual(eventUtil.toObject(commandStr), {
Response: 'Success',
Message: 'Command output follows',
Output: [
'Version: 16.1.1',
'Build Options: BUILD_NATIVE, OPTIONAL_API',
'Maximum calls: Not set'
].join(CRLF)
});
});

it('without event\'s raw string', () => {
assert.deepEqual(eventUtil.toObject(), {});
});
Expand Down

0 comments on commit 9147a22

Please sign in to comment.