-
-
Notifications
You must be signed in to change notification settings - Fork 868
Conversation
🎉 |
Thanks @toddjordan for this PR. I read it and it's ok for me. 👍 |
@@ -180,3 +180,96 @@ test('should trigger external action on form submit', function(assert) { | |||
this.$('input').click(); | |||
}); | |||
``` | |||
### Stubbing Services | |||
|
|||
In cases where components have dependencies on Ember services, its possible to stub these |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "its" should be "it's" (missing apostrophe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'll just change it to "it is"
0730c86
to
737caa4
Compare
``` | ||
|
||
Since services default to being singletons, we can get a reference to the service within our test | ||
and modify values on it so that we can assert on how we expect our component to react. In the next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This first sentence is kind of hairy :) I think you could just remove it entirely without losing any meaning, and it would make it clearer to most people.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so just to be clear, remove the sentence starting with "Since services default...."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, will update
Thanks @toddjordan! I've added a couple notes, and also asked in the testing Slack channel for someone with more expertise to review. |
### Stubbing Services | ||
|
||
In cases where components have dependencies on Ember services, it is possible to stub these | ||
dependencies for integration tests. Stub Ember services by using the container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update this to "by using the registry"
737caa4
to
35932d8
Compare
@toddjordan @michaelrkn I think the section on stubbing a service is well done 👍 |
integration: true, | ||
|
||
beforeEach: function () { | ||
this.registry.register('service:location-service', locationStub); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.registry
is the private internal registry. I do not think we should recommend using it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, then what would you suggest we use to register the stub service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code being added in emberjs/ember-test-helpers#105:
this.register('service:location', locationStub);
Can you update the private usage of |
minor updates incorporate grammar feedback Update based on additional PR feedback Update api calls based on new public function
35932d8
to
c095e36
Compare
@rwjblue updates made. Now we'll just wait for the next ember-qunit release to make sure it works ;-) |
Sounds good, I'll update here once @ef4 updates that PR to fix that last comment... |
I see ember-qunit 0.4.12 is out. Trying it out on the examples... |
Validated that the updated example works on ember-qunit 0.4.12. @michaelrkn @rwjblue I believe we are good to go |
I added a followup in #846 that takes advantage of the new |
👍 |
Thanks for the hard work, y'all! |
PR for issue #840
I've validated the below approach is functional, just need feedback on whether these apis are sanctioned.