Skip to content

Commit

Permalink
test(cdk/testing): add includeAsyncTests flag (angular#25542)
Browse files Browse the repository at this point in the history
* test(cdk/testing): add includeAsyncTests flag

This is needed by some downstream custom angular harnesses that use this set of tests but also do not rely on Angular framework stabilization.

* test(cdk/testing): rework `includeAsyncTests` into `skipAsyncTests`

* test(cdk/testing): fix stale param doc
  • Loading branch information
mgoldberg524 authored and Martin Forstner committed Sep 16, 2022
1 parent 855ed6c commit 5da2e2e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/cdk/testing/tests/cross-environment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {SubComponentHarness, SubComponentSpecialHarness} from './harnesses/sub-c
* @param getHarnessLoaderFromEnvironment env specific closure to get HarnessLoader
* @param getMainComponentHarnessFromEnvironment env specific closure to get MainComponentHarness
* @param getActiveElementId env specific closure to get active element
* @param skipAsyncTests skip tests that rely on Angular framework stabilization
*
* @docs-private
*/
Expand All @@ -37,6 +38,7 @@ export function crossEnvironmentSpecs(
// Maybe we should introduce HarnessLoader.getActiveElement(): TestElement
// then this 3rd parameter could get removed.
getActiveElementId: () => Promise<string | null>,
skipAsyncTests: boolean = false,
) {
describe('HarnessLoader', () => {
let loader: HarnessLoader;
Expand Down Expand Up @@ -201,13 +203,6 @@ export function crossEnvironmentSpecs(
expect(items4.length).toBe(0);
});

it('should wait for async operation to complete', async () => {
const asyncCounter = await harness.asyncCounter();
expect(await asyncCounter.text()).toBe('5');
await harness.increaseCounter(3);
expect(await asyncCounter.text()).toBe('8');
});

it('should send enter key', async () => {
const specialKey = await harness.specaialKey();
await harness.sendEnter();
Expand Down Expand Up @@ -287,6 +282,15 @@ export function crossEnvironmentSpecs(
expect(element).toBeTruthy();
expect(await element.getText()).toBe('Has comma inside attribute');
});

if (!skipAsyncTests) {
it('should wait for async operation to complete', async () => {
const asyncCounter = await harness.asyncCounter();
expect(await asyncCounter.text()).toBe('5');
await harness.increaseCounter(3);
expect(await asyncCounter.text()).toBe('8');
});
}
});

describe('HarnessPredicate', () => {
Expand Down

0 comments on commit 5da2e2e

Please sign in to comment.