@@ -7,7 +7,12 @@ import {
7
7
isPhoneNumberIdentifier ,
8
8
isUnknownIdentifier
9
9
} from '@azure/communication-common' ;
10
- import { fromFlatCommunicationIdentifier , toFlatCommunicationIdentifier } from './identifier' ;
10
+ import {
11
+ fromFlatCommunicationIdentifier ,
12
+ toFlatCommunicationIdentifier ,
13
+ _toCommunicationIdentifier ,
14
+ _isValidIdentifier
15
+ } from './identifier' ;
11
16
12
17
test ( 'Communication user conversions' , ( ) => {
13
18
const parsed = fromFlatCommunicationIdentifier ( '8:acs:OPAQUE' ) ;
@@ -94,3 +99,34 @@ test('Unknown user conversions', () => {
94
99
} ) ;
95
100
expect ( toFlatCommunicationIdentifier ( parsed ) ) . toEqual ( 'OPAQUE' ) ;
96
101
} ) ;
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