Skip to content

Commit 8cc8236

Browse files
committed
Added aris-disabled test
1 parent 7bac588 commit 8cc8236

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/lib/list/selection-list.spec.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {async, TestBed, ComponentFixture, inject} from '@angular/core/testing';
2-
import {Component, DebugElement} from '@angular/core';
2+
import {Component, DebugElement, ViewChildren} from '@angular/core';
33
import {By} from '@angular/platform-browser';
44
import {MdSelectionList, MdListOption, MdListModule} from './index';
55
import {createKeyboardEvent} from '@angular/cdk/testing';
@@ -51,11 +51,13 @@ describe('test normal selection list with list option', () => {
5151
let selectList = selectionList.injector.get<MdSelectionList>(MdSelectionList).selectedOptions;
5252

5353
expect(selectList.selected.length).toBe(0);
54+
expect(listOption[2].nativeElement.getAttribute('aria-selected')).toBe('false');
5455

5556
testListItem.toggle();
5657
fixture.detectChanges();
5758

5859
expect(listOption[2].nativeElement.getAttribute('aria-selected')).toBe('true');
60+
expect(listOption[2].nativeElement.getAttribute('aria-disabled')).toBe('false');
5961
expect(selectList.selected.length).toBe(1);
6062
});
6163

@@ -65,6 +67,8 @@ describe('test normal selection list with list option', () => {
6567
let selectList = selectionList.injector.get<MdSelectionList>(MdSelectionList).selectedOptions;
6668

6769
expect(selectList.selected.length).toBe(0);
70+
expect(listOption[2].nativeElement.getAttribute('aria-selected')).toBe('false');
71+
expect(listOption[1].nativeElement.getAttribute('aria-selected')).toBe('false');
6872

6973
testListItem.toggle();
7074
fixture.detectChanges();
@@ -75,6 +79,8 @@ describe('test normal selection list with list option', () => {
7579
expect(selectList.selected.length).toBe(2);
7680
expect(listOption[2].nativeElement.getAttribute('aria-selected')).toBe('true');
7781
expect(listOption[1].nativeElement.getAttribute('aria-selected')).toBe('true');
82+
expect(listOption[1].nativeElement.getAttribute('aria-disabled')).toBe('false');
83+
expect(listOption[2].nativeElement.getAttribute('aria-disabled')).toBe('false');
7884
});
7985

8086
it('should be able to deselect an option', () => {
@@ -107,6 +113,17 @@ describe('test normal selection list with list option', () => {
107113
expect(selectList.selected.length).toBe(0);
108114
});
109115

116+
it('should be able to un-disable disabled items', () => {
117+
let testListItem = listOption[0].injector.get<MdListOption>(MdListOption);
118+
119+
expect(listOption[0].nativeElement.getAttribute('aria-disabled')).toBe('true');
120+
121+
testListItem.disabled = false;
122+
fixture.detectChanges();
123+
124+
expect(listOption[0].nativeElement.getAttribute('aria-disabled')).toBe('false');
125+
});
126+
110127
it('should be able to use keyboard select with SPACE', () => {
111128
let testListItem = listOption[1].nativeElement as HTMLElement;
112129
let SPACE_EVENT: KeyboardEvent =
@@ -202,7 +219,7 @@ describe('test selection list with single option', () => {
202219
fixture.detectChanges();
203220

204221
expect(listItemEl.nativeElement).toBe(document.activeElement);
205-
if (!platform.IS_TRIDENT) {
222+
if (!platform.TRIDENT) {
206223
expect(listItemEl.nativeElement.className).toContain('mat-list-item-focus');
207224
}
208225

0 commit comments

Comments
 (0)