Skip to content

Commit

Permalink
fix: ensure stubService returns reference to the service
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlafroscia committed Jul 17, 2018
1 parent f6f3721 commit 5924b6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addon-test-support/stub-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function stubService() {
let [name] = arguments;
let { owner } = getContext();

replace(owner, name);
return replace(owner, name);
} else {
throw new Error("Unexpected number of arguments");
}
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/test-support/stub-service-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ module("Test Helpers | stub-service", function(hooks) {

module("invoking without `hooks`", function(hooks) {
hooks.beforeEach(function() {
stubService("to-stub");
this.service = stubService("to-stub");
});

test("it can replace a service", function(assert) {
let service = this.owner.lookup("service:to-stub");
service.method();

assert.verify(service.method());
assert.equal(
service,
this.service,
"Returns a references to the stubbed service"
);
});
});
});

0 comments on commit 5924b6f

Please sign in to comment.