MCPcopy Create free account
hub / github.com/angular/components / expectAvatarAt

Function expectAvatarAt

src/material/list/selection-list.spec.ts:967–982  ·  view source on GitHub ↗

* Expects an avatar to be shown at the given position. Also * ensures that no icon is shown at the specified position.

(item: HTMLElement, position: 'before' | 'after')

Source from the content-addressed store, hash-verified

965 * ensures that no icon is shown at the specified position.
966 */
967 function expectAvatarAt(item: HTMLElement, position: 'before' | 'after') {
968 const avatar = item.querySelector('.mat-mdc-list-item-avatar')!;
969
970 expect(item.classList).not.toContain('mdc-list-item--with-leading-icon');
971 expect(item.classList).not.toContain('mdc-list-item--with-trailing-icon');
972
973 if (position === 'before') {
974 expect(avatar.classList).toContain('mdc-list-item__start');
975 expect(item.classList).toContain('mdc-list-item--with-leading-avatar');
976 expect(item.classList).not.toContain('mat-mdc-list-option-with-trailing-avatar');
977 } else {
978 expect(avatar.classList).toContain('mdc-list-item__end');
979 expect(item.classList).toContain('mat-mdc-list-option-with-trailing-avatar');
980 expect(item.classList).not.toContain('mdc-list-item--with-leading-avatar');
981 }
982 }
983
984 it('should add a class to reflect that it has an avatar', () => {
985 const fixture = TestBed.createComponent(SelectionListWithAvatar);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected