-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #540 from scalvert/setup-ember-onerror
Feature - adds setupOnerror function to allow patching Ember.onerror in tests
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Ember from 'ember'; | ||
import { module, test } from 'qunit'; | ||
import hasEmberVersion from '@ember/test-helpers/has-ember-version'; | ||
import { setupContext, teardownContext, setupOnerror } from '@ember/test-helpers'; | ||
|
||
module('setupOnerror', function() { | ||
if (!hasEmberVersion(2, 4)) { | ||
test('Will throw if on < Ember 2.4', function(assert) { | ||
assert.expect(1); | ||
|
||
assert.throws(function() { | ||
setupOnerror(); | ||
}, 'The `setupOnerror` function requires that you be on a minimum version of Ember 2.4.'); | ||
}); | ||
} | ||
|
||
if (hasEmberVersion(2, 4)) { | ||
test('Ember.onerror is undefined by default', function(assert) { | ||
assert.expect(1); | ||
|
||
assert.equal(Ember.onerror, undefined); | ||
}); | ||
|
||
test('Ember.onerror is set correctly when using setupOnerror', async function(assert) { | ||
assert.expect(2); | ||
|
||
let context = {}; | ||
let onerror = err => err; | ||
|
||
assert.equal(Ember.onerror, undefined); | ||
|
||
await setupContext(context); | ||
|
||
setupOnerror(onerror); | ||
|
||
assert.equal(Ember.onerror, onerror); | ||
|
||
await teardownContext(context); | ||
}); | ||
|
||
test('Ember.onerror is reset correctly when teardownContext is invoked', async function(assert) { | ||
assert.expect(3); | ||
|
||
let context = {}; | ||
let onerror = err => err; | ||
|
||
assert.equal(Ember.onerror, undefined); | ||
|
||
await setupContext(context); | ||
|
||
setupOnerror(onerror); | ||
|
||
assert.equal(Ember.onerror, onerror); | ||
|
||
await teardownContext(context); | ||
|
||
assert.equal(Ember.onerror, undefined); | ||
}); | ||
} | ||
}); |