From aa4f0420123b5302233b0317b8b2616b737f4ccd Mon Sep 17 00:00:00 2001 From: Miles Malerba Date: Thu, 29 Aug 2019 23:32:26 -0700 Subject: [PATCH] build: fix rebase conflict between autocomplete harness and selector filter --- .../harness/autocomplete-harness-filters.ts | 7 +++---- .../harness/autocomplete-harness.spec.ts | 20 +++++++++---------- .../harness/autocomplete-harness.ts | 6 +----- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness-filters.ts b/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness-filters.ts index 249805c9cb83..88ad72a586d0 100644 --- a/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness-filters.ts +++ b/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness-filters.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -export type AutocompleteHarnessFilters = { - id?: string; - name?: string, -}; +import {BaseHarnessFilters} from '@angular/cdk-experimental/testing'; + +export interface AutocompleteHarnessFilters extends BaseHarnessFilters {} diff --git a/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness.spec.ts b/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness.spec.ts index 4df8dca68247..a0773525ade5 100644 --- a/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness.spec.ts +++ b/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness.spec.ts @@ -56,20 +56,20 @@ function runTests() { }); it('should be able to get text inside the input', async () => { - const input = await loader.getHarness(harness.with({id: 'prefilled'})); + const input = await loader.getHarness(harness.with({selector: '#prefilled'})); expect(await input.getText()).toBe('Prefilled value'); }); it('should get disabled state', async () => { - const enabled = await loader.getHarness(harness.with({id: 'plain'})); - const disabled = await loader.getHarness(harness.with({id: 'disabled'})); + const enabled = await loader.getHarness(harness.with({selector: '#plain'})); + const disabled = await loader.getHarness(harness.with({selector: '#disabled'})); expect(await enabled.isDisabled()).toBe(false); expect(await disabled.isDisabled()).toBe(true); }); it('should focus and blur an input', async () => { - const input = await loader.getHarness(harness.with({id: 'plain'})); + const input = await loader.getHarness(harness.with({selector: '#plain'})); expect(getActiveElementId()).not.toBe('plain'); await input.focus(); expect(getActiveElementId()).toBe('plain'); @@ -78,19 +78,19 @@ function runTests() { }); it('should be able to type in an input', async () => { - const input = await loader.getHarness(harness.with({id: 'plain'})); + const input = await loader.getHarness(harness.with({selector: '#plain'})); await input.enterText('Hello there'); expect(await input.getText()).toBe('Hello there'); }); it('should be able to get the autocomplete panel', async () => { - const input = await loader.getHarness(harness.with({id: 'plain'})); + const input = await loader.getHarness(harness.with({selector: '#plain'})); await input.focus(); expect(await input.getPanel()).toBeTruthy(); }); it('should be able to get the autocomplete panel options', async () => { - const input = await loader.getHarness(harness.with({id: 'plain'})); + const input = await loader.getHarness(harness.with({selector: '#plain'})); await input.focus(); const options = await input.getOptions(); @@ -99,7 +99,7 @@ function runTests() { }); it('should be able to get the autocomplete panel groups', async () => { - const input = await loader.getHarness(harness.with({id: 'grouped'})); + const input = await loader.getHarness(harness.with({selector: '#grouped'})); await input.focus(); const groups = await input.getOptionGroups(); const options = await input.getOptions(); @@ -113,13 +113,13 @@ function runTests() { fixture.componentInstance.states = []; fixture.detectChanges(); - const input = await loader.getHarness(harness.with({id: 'plain'})); + const input = await loader.getHarness(harness.with({selector: '#plain'})); await input.focus(); expect(await input.isPanelVisible()).toBe(false); }); it('should be able to get whether the autocomplete is open', async () => { - const input = await loader.getHarness(harness.with({id: 'plain'})); + const input = await loader.getHarness(harness.with({selector: '#plain'})); expect(await input.isOpen()).toBe(false); await input.focus(); diff --git a/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness.ts b/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness.ts index eb1995039a41..804bc6880d51 100644 --- a/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness.ts +++ b/src/material-experimental/mdc-autocomplete/harness/autocomplete-harness.ts @@ -34,11 +34,7 @@ export class MatAutocompleteHarness extends ComponentHarness { * @return a `HarnessPredicate` configured with the given options. */ static with(options: AutocompleteHarnessFilters = {}): HarnessPredicate { - return new HarnessPredicate(MatAutocompleteHarness) - .addOption('name', options.name, - async (harness, name) => (await harness.getAttribute('name')) === name) - .addOption('id', options.id, - async (harness, id) => (await harness.getAttribute('id')) === id); + return new HarnessPredicate(MatAutocompleteHarness, options); } async getAttribute(attributeName: string): Promise {