You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/v3.1.0/tutorial/service.md
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -243,10 +243,11 @@ You may now either move onto the [next feature](../subroutes/), or continue here
243
243
We'll use a unit test to validate the service.
244
244
Unit tests are more isolated than integration tests and application tests,
245
245
and are intended for testing specific logic within a class.
246
+
(Note: you should restart `ember test --server` whenever you add a new service, otherwise the new service will not be available to your unit tests).
246
247
247
248
For our service unit test, we'll want to verify that locations that have been previously loaded are fetched from cache, while new locations are created using the utility.
248
249
We will isolate our tests from actually calling Google Maps by stubbing our map utility.
249
-
On line 6 of `maps-test.js` below we create an Ember object to simulate the behavior of the utility, but instead of creating a google map, we return an empty JavaScript object.
250
+
On line 19 of `maps-test.js` below we create a Javascript object to simulate the behavior of the utility, but instead of creating a google map, we return an empty JavaScript object.
250
251
251
252
To instantiate the service, we can instantiate it through ember's resolver using the [`factoryFor`](https://emberjs.com/api/ember/release/classes/ApplicationInstance/methods/factoryFor?anchor=factoryFor) method.
252
253
`factoryFor` allows us to have control over the creation of the service in Ember, to pass arguments to the constructor that can override parts of the service for our tests.
0 commit comments