@@ -19,11 +19,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
1919import { ContentTestingModule } from '../../../testing/content.testing.module' ;
2020import { UserIconColumnComponent } from './user-icon-column.component' ;
2121import { NodeEntry } from '@alfresco/js-api' ;
22+ import { UnitTestingUtils } from '@alfresco/adf-core' ;
23+ import { DebugElement } from '@angular/core' ;
2224
2325describe ( 'UserIconColumnComponent' , ( ) => {
2426 let fixture : ComponentFixture < UserIconColumnComponent > ;
2527 let component : UserIconColumnComponent ;
26- let element : HTMLElement ;
28+ let testingUtils : UnitTestingUtils ;
2729 const person = {
2830 firstName : 'fake' ,
2931 lastName : 'user' ,
@@ -35,18 +37,20 @@ describe('UserIconColumnComponent', () => {
3537 displayName : 'fake authority'
3638 } ;
3739
40+ const getVisuallyHiddenText = ( ) : string => testingUtils . getInnerTextByCSS ( '.cdk-visually-hidden' ) ;
41+
3842 beforeEach ( ( ) => {
3943 TestBed . configureTestingModule ( {
4044 imports : [ ContentTestingModule ]
4145 } ) ;
4246 fixture = TestBed . createComponent ( UserIconColumnComponent ) ;
4347 component = fixture . componentInstance ;
44- element = fixture . nativeElement ;
48+ testingUtils = new UnitTestingUtils ( fixture . debugElement ) ;
4549 fixture . detectChanges ( ) ;
4650 } ) ;
4751
4852 describe ( 'person initial' , ( ) => {
49- const getInitials = ( ) => element . querySelector ( '[data-automation-id=" user-initials-image"]' ) ?. textContent ;
53+ const getInitials = ( ) : string => testingUtils . getInnerTextByDataAutomationId ( ' user-initials-image' ) ;
5054
5155 it ( 'should render person value from context' , ( ) => {
5256 component . context = {
@@ -58,7 +62,7 @@ describe('UserIconColumnComponent', () => {
5862 } ;
5963 component . ngOnInit ( ) ;
6064 fixture . detectChanges ( ) ;
61- expect ( getInitials ( ) ) . toContain ( 'fu ' ) ;
65+ expect ( getInitials ( ) ) . toContain ( 'FU ' ) ;
6266 } ) ;
6367
6468 it ( 'should render person value from node' , ( ) => {
@@ -80,7 +84,7 @@ describe('UserIconColumnComponent', () => {
8084 } ) ;
8185
8286 describe ( 'group initial' , ( ) => {
83- const getGroupIcon = ( ) => element . querySelector ( '[id="group-icon"] .adf-group-icon' ) ;
87+ const getGroupIcon = ( ) : DebugElement => testingUtils . getByCSS ( '[id="group-icon"] .adf-group-icon' ) ;
8488
8589 it ( 'should render group value from context' , ( ) => {
8690 component . context = {
@@ -93,7 +97,8 @@ describe('UserIconColumnComponent', () => {
9397 component . ngOnInit ( ) ;
9498 fixture . detectChanges ( ) ;
9599 expect ( getGroupIcon ( ) ) . toBeDefined ( ) ;
96- expect ( getGroupIcon ( ) . textContent ) . toContain ( 'people_alt_outline' ) ;
100+ expect ( getGroupIcon ( ) . nativeElement . textContent ) . toContain ( 'people_alt_outline' ) ;
101+ expect ( getVisuallyHiddenText ( ) ) . toBe ( 'USER_ICON.GROUP_ICON_ALT' ) ;
97102 } ) ;
98103
99104 it ( 'should render person value from node' , ( ) => {
@@ -108,15 +113,17 @@ describe('UserIconColumnComponent', () => {
108113 component . ngOnInit ( ) ;
109114 fixture . detectChanges ( ) ;
110115 expect ( getGroupIcon ( ) ) . toBeDefined ( ) ;
111- expect ( getGroupIcon ( ) . textContent ) . toContain ( 'people_alt_outline' ) ;
116+ expect ( getGroupIcon ( ) . nativeElement . textContent ) . toContain ( 'people_alt_outline' ) ;
117+ expect ( getVisuallyHiddenText ( ) ) . toBe ( 'USER_ICON.GROUP_ICON_ALT' ) ;
112118 } ) ;
113119 } ) ;
114120
115121 it ( 'should render select icon' , ( ) => {
116122 component . selected = true ;
117123 component . ngOnInit ( ) ;
118124 fixture . detectChanges ( ) ;
119- expect ( element . querySelector ( '.adf-people-select-icon[svgIcon="selected"]' ) ) . toBeDefined ( ) ;
125+ expect ( testingUtils . getByCSS ( '.adf-people-select-icon[svgIcon="selected"]' ) ) . toBeDefined ( ) ;
126+ expect ( getVisuallyHiddenText ( ) ) . toBe ( 'USER_ICON.GROUP_USER_SELECTED_ALT' ) ;
120127 expect ( component . isSelected ) . toBe ( true ) ;
121128 } ) ;
122129} ) ;
0 commit comments