Repository navigation
test(docs-infra): add unit tests for rxjs examples - #34190
sonukapoor wants to merge 2 commits into
Conversation
48592a0 to
b1fcd71
Compare
|
@gkalpak Please review. The assumption is that the step to run the stand-alone tests runs after the e2e tests have run. This will ensure that the |
b1fcd71 to
dff4783
Compare
|
This lgtm for now. We will re-work the infrastructure before merging the PR, but this is good enough for now so that you can keep working on the actual tests. Thx for sorting it out 👍 |
2e3651b to
747e9d0
Compare
|
As discussed "offline", here are my thoughts (and suggestions for next steps):
So, given the above, I think a good solution ("good" in the sense that it is fairly simple, will not take a lot of time to implement infrastructure for and will allow us to focus on tests (which is the primary focus for now)) would be the following:
As an example, here is what a code snippet could look like before my suggested change: // #docregion foo
const elem = document.querySelector('foo');
const subscription = fromEvent(elem, 'click').subscribe(() => console.log('*click*'));
setTimeout(() => subscription.unsubscribe(), 10000);
// #enddocregion fooAnd here is how it would be transformed with my suggestion: // By wrapping a function around the code, we make it "lazy"
// (i.e. it won't be executed immediately).
//
// We can pass in "globals" (in TS we can give them proper types).
// Here for example, we can pass in a mock `console` to capture the logs.
// (We could even pass a mock `setTimeout()`, but that is unnecessary,
// since we can mock that with `jasmine.clock().install()` etc.)
export function docregionFoo(console, document) {
// The code-snippet that the user will see remains unchanged.
// (The indentation might change, but that is fine.)
// #docregion foo
const elem = document.querySelector('foo');
const subscription = fromEvent(elem, 'click').subscribe(() => console.log('*click*'));
setTimeout(() => subscription.unsubscribe(), 10000);
// #enddocregion foo
// Here, return the `subscription`, if we need to run assertions against it.
return subscription;
} |
d717fd8 to
fe5d2cd
Compare
fe5d2cd to
e4e23a4
Compare
|
@sonukapoor can we close this PR? |
This PR is awaiting @gkalpak's review :) |
|
You can preview 230b42f at https://pr34190-230b42f.ngbuilds.io/. |
gkalpak
left a comment
There was a problem hiding this comment.
Thx, @sonukapoor! Here's another round of review comments 😃
(I have reviewed all examples except for the rx-library one.)
Pending comments from previous review (for my reference):
628cd35 to
e7bc538
Compare
|
You can preview e7bc538 at https://pr34190-e7bc538.ngbuilds.io/. |
There was a problem hiding this comment.
We are getting there 😃
In addition to my other comments, can you also:
- Move the change of using
searchTermin the typeahead request to a separate commit (as discussed in #34190 (comment)) and adjust the tests accordingly (i.e. each commit should include the tests that are relevant to the source code changes it introduces). - Move the changes to the
rx-libraryexample to a new PR (in the interest of getting this one in faster and avoiding its getting stale).
1bfa192 to
9bb142e
Compare
This commit adds missing unit tests for all rxjs examples from the docs. Closes angular#28017
9bb142e to
02c43e5
Compare
gkalpak
left a comment
There was a problem hiding this comment.
Almost ready 🎉
BTW, please update the second commit message to use imperative, present tesne (per our guidelines):
improves typeahead example and adds unit test --> improve typeahead example and add unit test …
c125ab9 to
435cf42
Compare
This commit improves the typeahead example, by using the emitted input value. It also adds a unit test to ensure that the example is working as intended.
435cf42 to
1939ada
Compare
gkalpak
left a comment
There was a problem hiding this comment.
Nice 🎉
Reviewed-for: global-docs-approvers
This commit improves the typeahead example, by using the emitted input value. It also adds a unit test to ensure that the example is working as intended. PR Close #34190
This commit improves the typeahead example, by using the emitted input value. It also adds a unit test to ensure that the example is working as intended. PR Close #34190
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information