-
-
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 #994 from wagenet/better-onerror-handling
- Loading branch information
Showing
6 changed files
with
94 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,67 @@ | ||
import Ember from 'ember'; | ||
import { module, test } from 'qunit'; | ||
import hasEmberVersion from '@ember/test-helpers/has-ember-version'; | ||
import { setupContext, teardownContext } from '@ember/test-helpers'; | ||
import { setupOnerror, resetOnerror } from '@ember/test-helpers'; | ||
|
||
module('setupOnerror', function (hooks) { | ||
hooks.afterEach(function () { | ||
resetOnerror(); | ||
let context; | ||
|
||
hooks.beforeEach(function () { | ||
context = {}; | ||
}); | ||
|
||
hooks.afterEach(async function () { | ||
if (context.owner) { | ||
await teardownContext(context); | ||
} | ||
}); | ||
|
||
if (hasEmberVersion(2, 4)) { | ||
test('Ember.onerror is undefined by default', function (assert) { | ||
assert.expect(1); | ||
module('with context set', function (hooks) { | ||
hooks.beforeEach(async function () { | ||
await setupContext(context); | ||
}); | ||
|
||
assert.equal(Ember.onerror, undefined); | ||
}); | ||
test('Ember.onerror is undefined by default', function (assert) { | ||
assert.expect(1); | ||
|
||
test('Ember.onerror is setup correctly', async function (assert) { | ||
assert.expect(2); | ||
assert.equal(Ember.onerror, undefined); | ||
}); | ||
|
||
let onerror = err => err; | ||
test('Ember.onerror is setup correctly', async function (assert) { | ||
assert.expect(2); | ||
|
||
assert.equal(Ember.onerror, undefined); | ||
let onerror = err => err; | ||
|
||
setupOnerror(onerror); | ||
assert.equal(Ember.onerror, undefined); | ||
|
||
assert.equal(Ember.onerror, onerror); | ||
}); | ||
setupOnerror(onerror); | ||
|
||
assert.equal(Ember.onerror, onerror); | ||
}); | ||
|
||
test('Ember.onerror is reset correctly', async function (assert) { | ||
assert.expect(3); | ||
test('Ember.onerror is reset correctly', async function (assert) { | ||
assert.expect(3); | ||
|
||
let onerror = err => err; | ||
let onerror = err => err; | ||
|
||
assert.equal(Ember.onerror, undefined); | ||
assert.equal(Ember.onerror, undefined); | ||
|
||
setupOnerror(onerror); | ||
setupOnerror(onerror); | ||
|
||
assert.equal(Ember.onerror, onerror); | ||
assert.equal(Ember.onerror, onerror); | ||
|
||
resetOnerror(); | ||
resetOnerror(); | ||
|
||
assert.equal(Ember.onerror, undefined); | ||
}); | ||
}); | ||
|
||
assert.equal(Ember.onerror, undefined); | ||
test('it raises an error without context', function (assert) { | ||
assert.throws(() => { | ||
setupOnerror(); | ||
}, /Must setup test context before calling setupOnerror/); | ||
}); | ||
} | ||
}); |
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