diff --git a/test/contact.spec.ts b/test/contact.spec.ts index 185255f0a580b295006ddc89f1025fabed7f3e59..3a479b3582c86e9f6d9467ce8fa1875c5920e7ee 100644 --- a/test/contact.spec.ts +++ b/test/contact.spec.ts @@ -18,6 +18,7 @@ test('Contact smoke testing', async t => { /* tslint:disable:variable-name */ const UserName = '@0bb3e4dd746fdbd4a80546aef66f4085' const NickName = 'Nick Name Test' + const RemarkName = 'Alias Test' // Mock const mockContactGetter = function (id) { @@ -27,6 +28,7 @@ test('Contact smoke testing', async t => { return resolve({ UserName: UserName , NickName: NickName + , RemarkName: RemarkName }) }, 200) }) @@ -38,6 +40,8 @@ test('Contact smoke testing', async t => { const r = await c.ready(mockContactGetter) t.is(r.get('id') , UserName, 'UserName set') t.is(r.get('name') , NickName, 'NickName set') + t.is(r.name(), NickName, 'should get the right name from Contact') + t.is(r.alias(), RemarkName, 'should get the right alias from Contact') const s = r.toString() t.is(typeof s, 'string', 'toString()') diff --git a/test/room.spec.ts b/test/room.spec.ts index d9bc86fbc8155006ae537e034c1cf099bd1e9a2d..324fa9866f9ffdcf337abc4f2b28ca1b0c2b6a1f 100644 --- a/test/room.spec.ts +++ b/test/room.spec.ts @@ -109,11 +109,17 @@ test('Room smoking test', async t => { const contact1 = new Contact(EXPECTED.memberId1) const nick1 = r.nick(contact1) - t.is(nick1, EXPECTED.memberNick1, 'should get nick1 from DisplayName') + t.is(nick1, EXPECTED.memberNick1, 'should get nick1 from roomAlias') + + const name1 = r.name(contact1) + t.is(name1, EXPECTED.memberNick1, 'should get name1 from roomAlias') const contact2 = new Contact(EXPECTED.memberId2) const nick2 = r.nick(contact2) - t.is(nick2, EXPECTED.memberNick2, 'should get nick2 from NickName because there is no DisplayName, ') + t.is(nick2, EXPECTED.memberNick2, 'should get nick2 from name because there is no roomAlias, ') + + const name2 = r.name(contact2) + t.is(name2, EXPECTED.memberNick2, 'should get nick2 from name because there is no roomAlias, ') t.truthy(r.has(contact1), 'should has contact1') const noSuchContact = new Contact('not exist id') @@ -131,9 +137,9 @@ test('Room smoking test', async t => { if (!contactA || !contactB || !contactC) { throw new Error('no a or b') } - t.is(contactA.id, EXPECTED.memberId1, 'should get the right id from nick 1, find member by nickName') - t.is(contactB.id, EXPECTED.memberId2, 'should get the right id from nick 2, find member by displayName') - t.is(contactC.id, EXPECTED.memberId3, 'should get the right id from nick 3, find member by remark') + t.is(contactA.id, EXPECTED.memberId1, 'should get the right id from nick 1, find member by name') + t.is(contactB.id, EXPECTED.memberId2, 'should get the right id from nick 2, find member by roomAlias') + t.is(contactC.id, EXPECTED.memberId3, 'should get the right id from nick 3, find member by alias') const s = r.toString() t.is(typeof s, 'string', 'toString()')