Skip to content

Commit ab02d1b

Browse files
committed
rename some things
1 parent d903734 commit ab02d1b

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

src/cdk-experimental/testing/component-harness.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import {TestElement} from './test-element';
1111
/** An async function that returns a promise of the given type when called. */
1212
export type AsyncFn<T> = () => Promise<T>;
1313

14-
export interface HarnessEnvironment {
15-
findRequired(selector: string): Promise<HarnessEnvironment>;
16-
findOptional(selector: string): Promise<HarnessEnvironment | null>;
17-
findAll(selector: string): Promise<HarnessEnvironment[]>;
14+
export interface HarnessLoader {
15+
findRequired(selector: string): Promise<HarnessLoader>;
16+
findOptional(selector: string): Promise<HarnessLoader | null>;
17+
findAll(selector: string): Promise<HarnessLoader[]>;
1818
requiredHarness<T extends ComponentHarness>(harness: ComponentHarnessConstructor<T>): Promise<T>;
1919
optionalHarness<T extends ComponentHarness>(harness: ComponentHarnessConstructor<T>):
2020
Promise<T | null>;
@@ -34,17 +34,17 @@ export interface LocatorFactory {
3434
}
3535

3636
/** Interface that is used to find elements in the DOM and create harnesses for them. */
37-
export abstract class AbstractHarnessEnvironment<E> implements HarnessEnvironment, LocatorFactory {
37+
export abstract class AbstractHarnessEnvironment<E> implements HarnessLoader, LocatorFactory {
3838
protected constructor(protected rawRootElement: E) {}
3939

4040
abstract documentRootLocatorFactory(): LocatorFactory;
4141

4242
protected abstract createTestElement(element: E): TestElement;
4343

44-
protected abstract createHarness<T extends ComponentHarness>(
44+
protected abstract createComponentHarness<T extends ComponentHarness>(
4545
harnessType: ComponentHarnessConstructor<T>, element: E): T;
4646

47-
protected abstract createEnvironment(element: E): HarnessEnvironment;
47+
protected abstract createHarnessLoader(element: E): HarnessLoader;
4848

4949
protected abstract getRawElement(selector: string): Promise<E | null>;
5050

@@ -67,7 +67,7 @@ export abstract class AbstractHarnessEnvironment<E> implements HarnessEnvironmen
6767
} else {
6868
const element = await this.getRawElement(arg.hostSelector);
6969
if (element) {
70-
return this.createHarness(arg, element);
70+
return this.createComponentHarness(arg, element);
7171
}
7272
}
7373
const selector = typeof arg === 'string' ? arg : arg.hostSelector;
@@ -86,7 +86,7 @@ export abstract class AbstractHarnessEnvironment<E> implements HarnessEnvironmen
8686
return element ? this.createTestElement(element) : null;
8787
} else {
8888
const element = await this.getRawElement(arg.hostSelector);
89-
return element ? this.createHarness(arg, element) : null;
89+
return element ? this.createComponentHarness(arg, element) : null;
9090
}
9191
};
9292
}
@@ -100,7 +100,7 @@ export abstract class AbstractHarnessEnvironment<E> implements HarnessEnvironmen
100100
return (await this.getAllRawElements(arg)).map(e => this.createTestElement(e));
101101
} else {
102102
return (await this.getAllRawElements(arg.hostSelector))
103-
.map(e => this.createHarness(arg, e));
103+
.map(e => this.createComponentHarness(arg, e));
104104
}
105105
};
106106
}
@@ -118,21 +118,21 @@ export abstract class AbstractHarnessEnvironment<E> implements HarnessEnvironmen
118118
return this.allLocator(harness)();
119119
}
120120

121-
async findRequired(selector: string): Promise<HarnessEnvironment> {
121+
async findRequired(selector: string): Promise<HarnessLoader> {
122122
const element = await this.getRawElement(selector);
123123
if (element) {
124-
return this.createEnvironment(element);
124+
return this.createHarnessLoader(element);
125125
}
126126
throw Error(`Expected to find element matching selector: "${selector}", but none was found`);
127127
}
128128

129-
async findOptional(selector: string): Promise<HarnessEnvironment | null> {
129+
async findOptional(selector: string): Promise<HarnessLoader | null> {
130130
const element = await this.getRawElement(selector);
131-
return element ? this.createEnvironment(element) : null;
131+
return element ? this.createHarnessLoader(element) : null;
132132
}
133133

134-
async findAll(selector: string): Promise<HarnessEnvironment[]> {
135-
return (await this.getAllRawElements(selector)).map(e => this.createEnvironment(e));
134+
async findAll(selector: string): Promise<HarnessLoader[]> {
135+
return (await this.getAllRawElements(selector)).map(e => this.createHarnessLoader(e));
136136
}
137137
}
138138

src/cdk-experimental/testing/protractor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
AbstractHarnessEnvironment,
1313
ComponentHarness,
1414
ComponentHarnessConstructor,
15-
HarnessEnvironment,
15+
HarnessLoader,
1616
LocatorFactory,
1717
} from './component-harness';
1818
import {TestElement} from './test-element';
@@ -22,7 +22,7 @@ export class ProtractorHarnessEnvironment extends AbstractHarnessEnvironment<Ele
2222
super(rawRootElement);
2323
}
2424

25-
static create(): HarnessEnvironment {
25+
static create(): HarnessLoader {
2626
return new ProtractorHarnessEnvironment(protractorElement(by.css('body')));
2727
}
2828

@@ -34,12 +34,12 @@ export class ProtractorHarnessEnvironment extends AbstractHarnessEnvironment<Ele
3434
return new ProtractorElement(element);
3535
}
3636

37-
protected createHarness<T extends ComponentHarness>(
37+
protected createComponentHarness<T extends ComponentHarness>(
3838
harnessType: ComponentHarnessConstructor<T>, element: ElementFinder): T {
3939
return new harnessType(new ProtractorHarnessEnvironment(element));
4040
}
4141

42-
protected createEnvironment(element: ElementFinder): HarnessEnvironment {
42+
protected createHarnessLoader(element: ElementFinder): HarnessLoader {
4343
return new ProtractorHarnessEnvironment(element);
4444
}
4545

src/cdk-experimental/testing/testbed.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
AbstractHarnessEnvironment,
2020
ComponentHarness,
2121
ComponentHarnessConstructor,
22-
HarnessEnvironment,
22+
HarnessLoader,
2323
LocatorFactory
2424
} from './component-harness';
2525
import {TestElement} from './test-element';
@@ -33,7 +33,7 @@ export class TestbedHarnessEnvironment extends AbstractHarnessEnvironment<Elemen
3333
super(rawRootElement);
3434
}
3535

36-
static create(fixture: ComponentFixture<unknown>): HarnessEnvironment {
36+
static create(fixture: ComponentFixture<unknown>): HarnessLoader {
3737
const stabilize = async () => {
3838
fixture.detectChanges();
3939
await fixture.whenStable();
@@ -49,7 +49,7 @@ export class TestbedHarnessEnvironment extends AbstractHarnessEnvironment<Elemen
4949
};
5050
const environment = new TestbedHarnessEnvironment(fixture.nativeElement, stabilize);
5151
await environment._stabilize();
52-
return environment.createHarness(harnessType, fixture.nativeElement);
52+
return environment.createComponentHarness(harnessType, fixture.nativeElement);
5353
}
5454

5555
documentRootLocatorFactory(): LocatorFactory {
@@ -64,12 +64,12 @@ export class TestbedHarnessEnvironment extends AbstractHarnessEnvironment<Elemen
6464
return new UnitTestElement(element, this._stabilize);
6565
}
6666

67-
protected createHarness<T extends ComponentHarness>(
67+
protected createComponentHarness<T extends ComponentHarness>(
6868
harnessType: ComponentHarnessConstructor<T>, element: Element): T {
6969
return new harnessType(new TestbedHarnessEnvironment(element, this._stabilize));
7070
}
7171

72-
protected createEnvironment(element: Element): HarnessEnvironment {
72+
protected createHarnessLoader(element: Element): HarnessLoader {
7373
return new TestbedHarnessEnvironment(element, this._stabilize);
7474
}
7575

0 commit comments

Comments
 (0)