Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
brockallen committed Feb 10, 2019
2 parents a82ec66 + 510d2c5 commit c7cf6e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ResponseValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ export class ResponseValidator {
}
}
else if (result[name] !== value) {
result[name] = [result[name], value];
if (typeof value === 'object') {
result[name] = this._mergeClaims(result[name], value);
}
else {
result[name] = [result[name], value];
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/unit/ResponseValidator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,14 @@ describe("ResponseValidator", function () {

});

it("should merge claims when claim types are objects", function () {

var c1 = { custom: {'apple': 'foo', 'pear': 'bar'} };
var c2 = { custom: {'apple': 'foo', 'orange': 'peel'}, b: 'banana' };
var result = subject._mergeClaims(c1, c2);
result.should.deep.equal({ custom: {'apple': 'foo', 'pear': 'bar', 'orange': 'peel'}, b: 'banana' });
});

it("should merge same claim types into array", function () {

var c1 = { a: 'apple', b: 'banana' };
Expand Down

0 comments on commit c7cf6e5

Please sign in to comment.