Skip to content

Commit

Permalink
added tests for a bug where results were null and the parser was tryi…
Browse files Browse the repository at this point in the history
…ng to return json. FIxed the bug as well
  • Loading branch information
dmill-bz committed Apr 9, 2016
1 parent 5b0cd7e commit c865e90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/GraphSONTextParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ class GraphSONTextParser extends Parser {
* @return {Mixed} raw server results
*/
getResults() {
return this.getRawResults()[0].json;
if(this.getRawResults() !== null && typeof this.getRawResults()[0] !== "undefined") {
return this.getRawResults()[0].json;
} else {
return [];
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions test/GraphSONTextParserTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ describe('GraphSONTextParser', () => {
const parser = new Parser({message:"error message"}, [{text:["id=lala"], json: [{id:"lala"}]}]);
expect(parser.getResults()).to.eql([{id:"lala"}]);
});

it('should return [] on null results', () => {
const parser = new Parser({message:"error message"}, null);
expect(parser.getResults()).to.eql([]);
});
});

describe('.getHtmlResults()', () => {
Expand Down

0 comments on commit c865e90

Please sign in to comment.