-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not use assert.throws when testing actions in integration tests
ember@2.11.3 introduces a (breaking?) change in how exceptions are propagated in backburner which causes some test that were previously working, to fail. See emberjs/ember.js#14898 (comment) Also fix some descriptions in blueprint tests
- Loading branch information
Showing
6 changed files
with
88 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,45 @@ | ||
import Ember from 'ember'; | ||
import resolver from './helpers/resolver'; | ||
import { | ||
setResolver | ||
} from 'ember-qunit'; | ||
|
||
setResolver(resolver); | ||
|
||
|
||
// ember@2.11.3 introduces a (breaking?) change in how the errors are propagated | ||
// in backburner which causes some test that were previously working, to fail. | ||
// | ||
// See https://github.com/emberjs/ember.js/pull/14898#issuecomment-285510703 | ||
|
||
// We need to use this hack to test with >= 2.11 | ||
function useHack() { | ||
var [major, minor] = Ember.VERSION.split('.'); | ||
major = Number(major); | ||
minor = Number(minor); | ||
|
||
return (major === 2 && minor >= 11) || major > 2; | ||
} | ||
|
||
export function expectEmberError(assert, callback, matcher, message) { | ||
if (useHack()) { | ||
let origTestAdapter = Ember.Test.adapter; | ||
let testError; | ||
let TestAdapter = Ember.Test.QUnitAdapter.extend({ | ||
exception(error) { | ||
testError = error; | ||
} | ||
}); | ||
|
||
Ember.run(() => { Ember.Test.adapter = TestAdapter.create(); }); | ||
callback(); | ||
Ember.run(() => { | ||
Ember.Test.adapter.destroy(); | ||
}); | ||
Ember.Test.adapter = origTestAdapter; | ||
|
||
assert.ok(testError && testError.message.match(matcher), message); | ||
} else { | ||
assert.throws(callback, matcher, message); | ||
} | ||
} |