Skip to content

Commit 2cc954d

Browse files
sonukapoormhevery
authored andcommitted
test(docs-infra): ensure RxJS-related docs examples can compile without errors (#34063)
Previously, some RxJS-related examples (which are not proper Angular apps) were not tested on CI as part of the `example-e2e` npm script. This meant that the examples could get out-of-date or contain compile errors without as noticing. This commit ensures that the `example-e2e` script picks up these examples and checks that they compile successfully. Partly addresses #28017. PR Close #34063
1 parent 3408468 commit 2cc954d

12 files changed

Lines changed: 91 additions & 14 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* This example project is special in that it is not a cli app. To run tests appropriate for this
3+
* project, the test command is overwritten in `aio/content/examples/observables-in-angular/example-config.json`.
4+
*
5+
* This is an empty placeholder file to ensure that `aio/tools/examples/run-example-e2e.js` runs
6+
* tests for this project.
7+
*
8+
* TODO: Fix our infrastructure/tooling, so that this hack is not necessary.
9+
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"e2e": [
3+
{
4+
"cmd": "yarn",
5+
"args": [ "tsc", "--project", "./" ]
6+
}
7+
]
8+
}

aio/content/examples/observables-in-angular/src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export class ZippyComponent {
3939
Time: {{ time | async }}</div>`
4040
})
4141
export class AsyncObservablePipeComponent {
42-
time = new Observable(observer =>
43-
setInterval(() => observer.next(new Date().toString()), 1000)
44-
);
42+
time = new Observable<string>(observer => {
43+
setInterval(() => observer.next(new Date().toString()), 1000);
44+
});
4545
}
4646

4747
// #enddocregion pipe
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* This example project is special in that it is not a cli app. To run tests appropriate for this
3+
* project, the test command is overwritten in `aio/content/examples/observables/example-config.json`.
4+
*
5+
* This is an empty placeholder file to ensure that `aio/tools/examples/run-example-e2e.js` runs
6+
* tests for this project.
7+
*
8+
* TODO: Fix our infrastructure/tooling, so that this hack is not necessary.
9+
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"e2e": [
3+
{
4+
"cmd": "yarn",
5+
"args": [ "tsc", "--project", "./" ]
6+
}
7+
]
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* This example project is special in that it is not a cli app. To run tests appropriate for this
3+
* project, the test command is overwritten in `aio/content/examples/practical-observable-usage/example-config.json`.
4+
*
5+
* This is an empty placeholder file to ensure that `aio/tools/examples/run-example-e2e.js` runs
6+
* tests for this project.
7+
*
8+
* TODO: Fix our infrastructure/tooling, so that this hack is not necessary.
9+
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"e2e": [
3+
{
4+
"cmd": "yarn",
5+
"args": [ "tsc", "--project", "./" ]
6+
}
7+
]
8+
}

aio/content/examples/practical-observable-usage/src/typeahead.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
21
import { fromEvent } from 'rxjs';
32
import { ajax } from 'rxjs/ajax';
4-
import { map, filter, debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators';
3+
import { debounceTime, distinctUntilChanged, filter, map, switchMap } from 'rxjs/operators';
4+
55

66
const searchBox = document.getElementById('search-box');
77

88
const typeahead = fromEvent(searchBox, 'input').pipe(
9-
map((e: KeyboardEvent) => e.target.value),
9+
map((e: KeyboardEvent) => (e.target as HTMLInputElement).value),
1010
filter(text => text.length > 2),
1111
debounceTime(10),
1212
distinctUntilChanged(),
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* This example project is special in that it is not a cli app. To run tests appropriate for this
3+
* project, the test command is overwritten in `aio/content/examples/rx-libary/example-config.json`.
4+
*
5+
* This is an empty placeholder file to ensure that `aio/tools/examples/run-example-e2e.js` runs
6+
* tests for this project.
7+
*
8+
* TODO: Fix our infrastructure/tooling, so that this hack is not necessary.
9+
*/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"e2e": [
3+
{
4+
"cmd": "yarn",
5+
"args": [ "tsc", "--project", "./" ]
6+
}
7+
]
8+
}

0 commit comments

Comments
 (0)