diff --git a/src/material-experimental/mdc-list/testing/list-harness.spec.ts b/src/material-experimental/mdc-list/testing/list-harness.spec.ts index 709c395a9fba..f1ae58040970 100644 --- a/src/material-experimental/mdc-list/testing/list-harness.spec.ts +++ b/src/material-experimental/mdc-list/testing/list-harness.spec.ts @@ -30,8 +30,9 @@ function runBaseListFunctionalityTests< BaseListItemHarnessFilters >, I extends MatListItemHarnessBase, + F extends {disableThirdItem: boolean}, >( - testComponentFn: () => Type<{}>, + testComponentFn: () => Type, listHarness: ComponentHarnessConstructor & { with: (config?: BaseHarnessFilters) => HarnessPredicate; }, @@ -40,7 +41,7 @@ function runBaseListFunctionalityTests< describe('base list functionality', () => { let simpleListHarness: L; let emptyListHarness: L; - let fixture: ComponentFixture<{}>; + let fixture: ComponentFixture; beforeEach(async () => { const testComponent = testComponentFn(); @@ -292,6 +293,14 @@ function runBaseListFunctionalityTests< const loader = await items[1].getChildLoader(MatListItemSection.CONTENT); await expectAsync(loader.getHarness(TestItemContentHarness)).toBeResolved(); }); + + it('should check disabled state of items', async () => { + fixture.componentInstance.disableThirdItem = true; + const items = await simpleListHarness.getItems(); + expect(items.length).toBe(5); + expect(await items[0].isDisabled()).toBe(false); + expect(await items[2].isDisabled()).toBe(true); + }); }); } @@ -488,14 +497,6 @@ describe('MatSelectionListHarness', () => { await items[0].deselect(); expect(await items[0].isSelected()).toBe(false); }); - - it('should check disabled state of options', async () => { - fixture.componentInstance.disableItem3 = true; - const items = await harness.getItems(); - expect(items.length).toBe(5); - expect(await items[0].isDisabled()).toBe(false); - expect(await items[2].isDisabled()).toBe(true); - }); }); }); @@ -513,7 +514,7 @@ describe('MatSelectionListHarness', () => { Item 2 - +
Section 2
@@ -531,7 +532,9 @@ describe('MatSelectionListHarness', () => { `, }) -class ListHarnessTest {} +class ListHarnessTest { + disableThirdItem = false; +} @Component({ template: ` @@ -547,7 +550,10 @@ class ListHarnessTest {} Item 2 - +
Section 2
+
Section 2
@@ -482,7 +491,9 @@ export function runHarnessTests( `, }) -class ListHarnessTest {} +class ListHarnessTest { + disableThirdItem = false; +} @Component({ template: ` @@ -498,7 +509,10 @@ class ListHarnessTest {} Item 2 - +
Section 2
@@ -508,6 +522,7 @@ class ListHarnessTest {} }) class ActionListHarnessTest { lastClicked: string; + disableThirdItem = false; } @Component({ @@ -524,7 +539,11 @@ class ActionListHarnessTest { Item 2 - Item 3 + Item 3
Section 2
@@ -534,6 +553,7 @@ class ActionListHarnessTest { }) class NavListHarnessTest { lastClicked: string; + disableThirdItem = false; onClick(event: Event, value: string) { event.preventDefault(); @@ -555,7 +575,7 @@ class NavListHarnessTest { Item 2 - Item 3 + Item 3
Section 2
@@ -564,7 +584,7 @@ class NavListHarnessTest { `, }) class SelectionListHarnessTest { - disableItem3 = false; + disableThirdItem = false; } class TestItemContentHarness extends ComponentHarness { diff --git a/tools/public_api_guard/material/list-testing.md b/tools/public_api_guard/material/list-testing.md index 12fe03a49397..6f3b794bd565 100644 --- a/tools/public_api_guard/material/list-testing.md +++ b/tools/public_api_guard/material/list-testing.md @@ -87,7 +87,6 @@ export class MatListOptionHarness extends MatListItemHarnessBase { focus(): Promise; getCheckboxPosition(): Promise; static hostSelector: string; - isDisabled(): Promise; isFocused(): Promise; isSelected(): Promise; select(): Promise;