Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[low priority] adding in additional unit tests for acs-ui-common #5457

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});