Guard against account being null

gr-message.html#149 uses message.reviewer, which may be null.

Bug: Issue 5072
Change-Id: I1f63b078720a68ee29a4d876c09f18790b20f535
This commit is contained in:
Viktar Donich
2016-12-06 13:58:57 -08:00
parent 3532684fd9
commit ca535f0b60
2 changed files with 13 additions and 0 deletions

View File

@@ -46,6 +46,9 @@
},
_computeEmailStr: function(account) {
if (!account || !account.email) {
return '';
}
if (account.name) {
return '(' + account.email + ')';
}

View File

@@ -42,6 +42,16 @@ limitations under the License.
element = fixture('basic');
});
test('null guard', function() {
assert.doesNotThrow(function() {
element.account = null;
});
});
test('missing email', function() {
assert.equal('', element._computeEmailStr({name: 'foo'}));
});
test('computed fields', function() {
assert.equal(element._computeAccountTitle(
{