Skip to content

Commit 02306f8

Browse files
adding in additional unit tests (#5457)
Co-authored-by: Donald McEachern <[email protected]>
1 parent 5464a3a commit 02306f8

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "none",
3+
"area": "improvement",
4+
"workstream": "[Test Coverage] Adding additional unit tests for _isValidIdentifier and _toCommunicationIdentifier",
5+
"comment": "Added on several unit tests to the acs-ui-common packlet",
6+
"packageName": "@azure/communication-react",
7+
"email": "[email protected]",
8+
"dependentChangeType": "none"
9+
}

packages/acs-ui-common/src/identifier.test.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import {
77
isPhoneNumberIdentifier,
88
isUnknownIdentifier
99
} from '@azure/communication-common';
10-
import { fromFlatCommunicationIdentifier, toFlatCommunicationIdentifier } from './identifier';
10+
import {
11+
fromFlatCommunicationIdentifier,
12+
toFlatCommunicationIdentifier,
13+
_toCommunicationIdentifier,
14+
_isValidIdentifier
15+
} from './identifier';
1116

1217
test('Communication user conversions', () => {
1318
const parsed = fromFlatCommunicationIdentifier('8:acs:OPAQUE');
@@ -94,3 +99,34 @@ test('Unknown user conversions', () => {
9499
});
95100
expect(toFlatCommunicationIdentifier(parsed)).toEqual('OPAQUE');
96101
});
102+
103+
test('toCommunicationIdentifier with communication identifier', () => {
104+
const userId = { kind: 'communicationUser', communicationUserId: '8:acs:OPAQUE' };
105+
const identifierResponse = _toCommunicationIdentifier(userId);
106+
expect(userId).toEqual(identifierResponse);
107+
expect(identifierResponse).toEqual({
108+
kind: 'communicationUser',
109+
communicationUserId: '8:acs:OPAQUE'
110+
});
111+
});
112+
113+
test('toCommunicationIdentifier with communication identifier as string', () => {
114+
const identifierResponse = _toCommunicationIdentifier('8:acs:OPAQUE');
115+
expect(isCommunicationUserIdentifier(identifierResponse)).toBeTruthy();
116+
expect(identifierResponse).toEqual({
117+
kind: 'communicationUser',
118+
communicationUserId: '8:acs:OPAQUE'
119+
});
120+
});
121+
122+
test('isValidIdentifier with communication identifier', () => {
123+
const userId = { kind: 'communicationUser', communicationUserId: '8:acs:OPAQUE' };
124+
const isValid = _isValidIdentifier(userId);
125+
expect(isValid).toBeTruthy();
126+
});
127+
128+
test('isValidIdentifier with unknown identifier', () => {
129+
const userId = { kind: 'unknown', id: 'OPAQUE' };
130+
const isValid = _isValidIdentifier(userId);
131+
expect(isValid).toBeTruthy();
132+
});

0 commit comments

Comments
 (0)