Skip to content

Commit 21876af

Browse files
committed
add e2e test
1 parent ce5ad75 commit 21876af

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/cdk/testing/tests/protractor.e2e.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ describe('ProtractorHarnessEnvironment', () => {
4444
const globalEl = await harness.globalEl();
4545
expect(await globalEl.text()).toBe('I am a sibling!');
4646
});
47+
48+
it('should get correct text excluding certain selectors', async () => {
49+
const results = await harness.subcomponentAndSpecialHarnesses();
50+
const subHarnessHost = await results[0].host();
51+
52+
expect(await subHarnessHost.text({excludes: 'h2'})).toBe('ProtractorTestBedOther');
53+
expect(await subHarnessHost.text({excludes: 'li'})).toBe('List of test tools');
54+
});
4755
});
4856

4957
describe('shadow DOM interaction', () => {

tools/public_api_guard/cdk/testing.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export interface ElementDimensions {
4040
width: number;
4141
}
4242

43+
export declare function getTextWithExcludedElements(element: Element, excludeSelector: string): string;
44+
4345
export declare abstract class HarnessEnvironment<E> implements HarnessLoader, LocatorFactory {
4446
protected rawRootElement: E;
4547
rootElement: TestElement;
@@ -131,7 +133,9 @@ export interface TestElement {
131133
sendKeys(...keys: (string | TestKey)[]): Promise<void>;
132134
sendKeys(modifiers: ModifierKeys, ...keys: (string | TestKey)[]): Promise<void>;
133135
setInputValue?(value: string): Promise<void>;
134-
text(): Promise<string>;
136+
text(options?: {
137+
excludes?: string;
138+
}): Promise<string>;
135139
}
136140

137141
export declare enum TestKey {

tools/public_api_guard/cdk/testing/protractor.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export declare class ProtractorElement implements TestElement {
1717
sendKeys(...keys: (string | TestKey)[]): Promise<void>;
1818
sendKeys(modifiers: ModifierKeys, ...keys: (string | TestKey)[]): Promise<void>;
1919
setInputValue(value: string): Promise<void>;
20-
text(options?: {excludes?: string}): Promise<string>;
20+
text(options?: {
21+
excludes?: string;
22+
}): Promise<string>;
2123
}
2224

2325
export declare class ProtractorHarnessEnvironment extends HarnessEnvironment<ElementFinder> {

tools/public_api_guard/cdk/testing/testbed.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ export declare class UnitTestElement implements TestElement {
3434
sendKeys(...keys: (string | TestKey)[]): Promise<void>;
3535
sendKeys(modifiers: ModifierKeys, ...keys: (string | TestKey)[]): Promise<void>;
3636
setInputValue(value: string): Promise<void>;
37-
text(options?: {excludes?: string}): Promise<string>;
37+
text(options?: {
38+
excludes?: string;
39+
}): Promise<string>;
3840
}

0 commit comments

Comments
 (0)