* 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')
| 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); |
no outgoing calls
no test coverage detected