提交 ee01871e 编写于 作者: L lijiarui 提交者: Huan (李卓桓)

#283 (#303)

* #283

* add jsDoc
上级 35d412a5
......@@ -222,7 +222,7 @@ export class Room extends EventEmitter implements Sayable {
tmpName = contact.alias() || contact.name()
break
case 'alias':
tmpName = member.DisplayName || contact.name()
tmpName = member.DisplayName
break
default:
throw new Error('parseMap failed, member not found')
......@@ -339,6 +339,11 @@ export class Room extends EventEmitter implements Sayable {
return this.alias(contact)
}
/**
* find contact's roomAlias in the room
* @param {Contact} contact
* @returns {string | null} If can find contact's roomAlias, return string, or return null
*/
public alias(contact: Contact): string | null {
if (!this.obj || !this.obj.aliasMap) {
return null
......
......@@ -119,7 +119,7 @@ test('Room smoking test', async t => {
t.is(nick2, EXPECTED.memberNick2, 'should get name if not set roomAlias')
const name2 = r.alias(contact2)
t.is(name2, EXPECTED.memberNick2, 'should get name if not set roomAlias')
t.is(name2, null, 'should return null if not set roomAlias')
t.truthy(r.has(contact1), 'should has contact1')
const noSuchContact = new Contact('not exist id')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册