Skip to content

Commit

Permalink
adding in additional unit tests (#5457)
Browse files Browse the repository at this point in the history
Co-authored-by: Donald McEachern <[email protected]>
  • Loading branch information
alkwa-msft and dmceachernmsft authored Jan 11, 2025
1 parent 5464a3a commit 02306f8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "none",
"area": "improvement",
"workstream": "[Test Coverage] Adding additional unit tests for _isValidIdentifier and _toCommunicationIdentifier",
"comment": "Added on several unit tests to the acs-ui-common packlet",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "none"
}
38 changes: 37 additions & 1 deletion packages/acs-ui-common/src/identifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import {
isPhoneNumberIdentifier,
isUnknownIdentifier
} from '@azure/communication-common';
import { fromFlatCommunicationIdentifier, toFlatCommunicationIdentifier } from './identifier';
import {
fromFlatCommunicationIdentifier,
toFlatCommunicationIdentifier,
_toCommunicationIdentifier,
_isValidIdentifier
} from './identifier';

test('Communication user conversions', () => {
const parsed = fromFlatCommunicationIdentifier('8:acs:OPAQUE');
Expand Down Expand Up @@ -94,3 +99,34 @@ test('Unknown user conversions', () => {
});
expect(toFlatCommunicationIdentifier(parsed)).toEqual('OPAQUE');
});

test('toCommunicationIdentifier with communication identifier', () => {
const userId = { kind: 'communicationUser', communicationUserId: '8:acs:OPAQUE' };
const identifierResponse = _toCommunicationIdentifier(userId);
expect(userId).toEqual(identifierResponse);
expect(identifierResponse).toEqual({
kind: 'communicationUser',
communicationUserId: '8:acs:OPAQUE'
});
});

test('toCommunicationIdentifier with communication identifier as string', () => {
const identifierResponse = _toCommunicationIdentifier('8:acs:OPAQUE');
expect(isCommunicationUserIdentifier(identifierResponse)).toBeTruthy();
expect(identifierResponse).toEqual({
kind: 'communicationUser',
communicationUserId: '8:acs:OPAQUE'
});
});

test('isValidIdentifier with communication identifier', () => {
const userId = { kind: 'communicationUser', communicationUserId: '8:acs:OPAQUE' };
const isValid = _isValidIdentifier(userId);
expect(isValid).toBeTruthy();
});

test('isValidIdentifier with unknown identifier', () => {
const userId = { kind: 'unknown', id: 'OPAQUE' };
const isValid = _isValidIdentifier(userId);
expect(isValid).toBeTruthy();
});

0 comments on commit 02306f8

Please sign in to comment.