Skip to content

Commit dfb3e05

Browse files
docs(cdk/testing): fix a few grammar issues (#18293)
1 parent 8df0350 commit dfb3e05

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/cdk/testing/test-harnesses.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,20 @@ Calls to `getHarness` and `getAllHarnesses` can either take `ComponentHarness` s
141141
for a button that has some particular text, etc). The
142142
[details of `HarnessPredicate`](#filtering-harness-instances-with-harnesspredicate) are discussed in
143143
the [API for component harness authors](#api-for-component-harness-authors); harness authors should
144-
provide convenience methods on their `ComponentHarness` subclass to facilitate creation of
144+
provide convenience methods on their `ComponentHarness` subclass to facilitate the creation of
145145
`HarnessPredicate` instances. However, if the harness author's API is not sufficient, they can be
146146
created manually.
147147

148148
#### Working with asynchronous component harness methods
149149

150-
In order to support both unit and end-to-end tests, and to insulate tests against changes in
150+
To support both unit and end-to-end tests, and to insulate tests against changes in
151151
asynchronous behavior, almost all harness methods are asynchronous and return a `Promise`;
152152
therefore, the Angular team recommends using
153153
[ES2017 `async`/`await` syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function)
154154
to improve the test readability.
155155

156156
Note that `await` statements block the execution of your test until the associated `Promise`
157-
resolves. When reading multiple properties off a harness it may not be necessary to block on the
157+
resolves. When reading multiple properties of a harness it may not be necessary to block on the
158158
first before asking for the next, in these cases use `Promise.all` to parallelize.
159159

160160
For example, consider the following example of reading both the `checked` and `indeterminate` state
@@ -184,7 +184,7 @@ common components for a large Angular application.
184184
The abstract `ComponentHarness` class is the base class for all component harnesses. To create a
185185
custom component harness, extend `ComponentHarness` and implement the static property
186186
`hostSelector`. The `hostSelector` property identifies elements in the DOM that match this harness
187-
subclass. In most cases the `hostSelector` should be the same as the `selector` of the corresponding
187+
subclass. In most cases, the `hostSelector` should be the same as the `selector` of the corresponding
188188
`Component` or `Directive`. For example, consider a simple popup component:
189189

190190
```ts
@@ -285,7 +285,7 @@ unless its an element the component consumer defines directly (e.g. the host ele
285285
`TestElement` instances for internal elements leads users to depend on a component's internal DOM
286286
structure.
287287

288-
Instead, provide more narrow-focused methods for particular actions the end user will
288+
Instead, provide more narrow-focused methods for particular actions the end-user will
289289
take or particular state they may want to check. For example, `MyPopupHarness` could provide methods
290290
like `toggle` and `isOpen`:
291291

@@ -322,7 +322,7 @@ earlier has an alternate signature that can be used for locating sub-harnesses r
322322
| `locatorForOptional<T extends ComponentHarness>(harnessType: ComponentHarnessConstructor<T>): () => Promise<T \| null>` | Creates a function that returns a `Promise` for the first harness matching the given harness type when called. If no matching harness is found, the `Promise` is resolved with `null`. |
323323
| `locatorForAll<T extends ComponentHarness>(harnessType: ComponentHarnessConstructor<T>): () => Promise<T[]>` | Creates a function that returns a `Promise` for a list of all harnesses matching the given harness type when called. |
324324

325-
For example consider a menu build using the popup shown above:
325+
For example, consider a menu build using the popup shown above:
326326

327327
```ts
328328
@Component({
@@ -498,10 +498,8 @@ class MyPopupHarness extends ComponentHarness {
498498

499499
#### Accessing elements outside of the component's host element
500500

501-
There are times when a component harness might need to access elements outside of it's corresponding
502-
component's host element. A good example of this is components that use the
503-
[CDK overlay](https://material.angular.io/cdk/overlay/overview). The CDK overlay creates an element
504-
that is attached directly to the body, outside of the component's host element. In this case,
501+
There are times when a component harness might need to access elements outside of its corresponding
502+
component's host element. Components that use [CDK overlay](https://material.angular.io/cdk/overlay/overview) serve as examples of this. The CDK overlay creates an element that is attached directly to the body, outside of the component's host element. In this case,
505503
`ComponentHarness` provides a method that can be used to get a `LocatorFactory` for the root element
506504
of the document. The `LocatorFactory` supports most of the same APIs as the `ComponentHarness` base
507505
class, and can then be used to query relative to the document's root element.
@@ -537,8 +535,8 @@ subsequent `NgZone` stabilization before animation events are fully flushed. In
537535
needed, the `ComponentHarness` offers a `forceStabilize()` method that can be called to do the
538536
second round.
539537

540-
Additionally some components may intentionally schedule tasks _outside_ of `NgZone`, this is
541-
typically accomplished by using `NgZone.runOutsideAngular`. In this case the corresponding harness
538+
Additionally, some components may intentionally schedule tasks _outside_ of `NgZone`, this is
539+
typically accomplished by using `NgZone.runOutsideAngular`. In this case, the corresponding harness
542540
may need to explicitly wait for tasks outside `NgZone`, as this does not happen automatically.
543541
`ComponentHarness` offers a method called `waitForTasksOutsideAngular` for this purpose.
544542

@@ -560,7 +558,7 @@ The first step in adding support for a new testing environment is to create a `T
560558
implementation. The `TestElement` interface serves as an environment-agnostic representation of a
561559
DOM element; it lets harnesses interact with DOM elements regardless of the underlying environment.
562560
Because some environments don't support interacting with DOM elements synchronously
563-
(e.g. webdriver), all of `TestElement` methods are asynchronous, returning a `Promise` with the
561+
(e.g. webdriver), all of the `TestElement` methods are asynchronous, returning a `Promise` with the
564562
result of the operation.
565563

566564
| Method | Description |
@@ -599,7 +597,7 @@ Test authors use `HarnessEnvironemnt` to create component harness instances for
599597

600598
`HarnessEnvironment` is an abstract class that must be extended to create a concrete subclass for
601599
the new environment. When supporting a new test environment, you must create a `HarnessEnvironment`
602-
subclass that add concrete implementations for all abstract members.
600+
subclass that adds concrete implementations for all abstract members.
603601

604602
You will notice that `HarnessEnvironment` has a generic type parameter: `HarnessEnvironment<E>`.
605603
This parameter, `E`, represents the raw element type of the environment. For example, this parameter

0 commit comments

Comments
 (0)