Last active
May 5, 2017 18:25
-
-
Save alexmiddeleer/baee64ad24ab4569c979a19bcc02d5d2 to your computer and use it in GitHub Desktop.
Why does the test fail if I wrap the catch in Ember.run?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .... service boilerplate | |
doAsyncThing() { | |
return get(this, 'someService').postV2Request().catch((e) => { | |
// If I wrap this code in Ember.run, the tests fail after upgrading to Ember 2.13 from 2.3 | |
let logError = new Error('foobar error'); | |
this.reportError(logError); | |
throw(e); | |
}); | |
} | |
// ... service boilerplate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test('doAsyncThing reports an error if there is one', function(assert) { | |
assert.expect(3); | |
let done = assert.async(); | |
let deferred = RSVP.defer(); | |
let apiService = mock({ | |
postV2Request: sinon.stub().returns(deferred.promise) | |
}); | |
let reportErrorStub = sinon.stub(); | |
let service = this.subject({ | |
apiService, | |
reportError: reportErrorStub | |
}); | |
service.doAsyncThing('foo', 'bar', 'baz').catch(() => { | |
assert.ok(true, 'The exception is rethrown'); | |
assert.ok(reportErrorStub.called, 'reportError was called'); | |
assert.equal(reportErrorStub.args[0][0].message, 'foobar error', 'format of message is ok'); | |
done(); | |
}); | |
deferred.reject(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment