-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
78 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,50 @@ | ||
import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers'; | ||
import EmberError from '@ember/error'; | ||
|
||
moduleFor( | ||
'Ember Error Throwing', | ||
class extends TestCase { | ||
['@test new EmberError displays provided message'](assert) { | ||
assert.throws( | ||
() => { | ||
throw new Error('A Message'); | ||
expectDeprecation(() => { | ||
throw new EmberError('A Message'); | ||
}, 'The @ember/error package merely re-exported the native Error and is deprecated. Please use a native Error directly instead.'); | ||
}, | ||
function (e) { | ||
return e.message === 'A Message'; | ||
}, | ||
'the assigned message was displayed' | ||
); | ||
} | ||
['@test new EmberError is instanceof EmberError'](assert) { | ||
expectDeprecation(() => { | ||
assert.ok( | ||
new EmberError('A Message') instanceof EmberError, | ||
'new EmberError is instanceof EmberError' | ||
); | ||
}, 'The @ember/error package merely re-exported the native Error and is deprecated. Please use a native Error directly instead.'); | ||
} | ||
['@test EmberError(...) displays provided message'](assert) { | ||
assert.throws( | ||
() => { | ||
expectDeprecation(() => { | ||
throw EmberError('A Message'); | ||
}, 'The @ember/error package merely re-exported the native Error and is deprecated. Please use a native Error directly instead.'); | ||
}, | ||
function (e) { | ||
return e.message === 'A Message'; | ||
}, | ||
'the assigned message was displayed' | ||
); | ||
} | ||
['@test EmberError(...) is instanceof EmberError'](assert) { | ||
expectDeprecation(() => { | ||
assert.ok( | ||
EmberError('A Message') instanceof EmberError, | ||
'new EmberError is instanceof EmberError' | ||
); | ||
}, 'The @ember/error package merely re-exported the native Error and is deprecated. Please use a native Error directly instead.'); | ||
} | ||
} | ||
); |
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,4 +1,5 @@ | ||
import EmberError from '@ember/error'; | ||
import { expectTypeOf } from 'expect-type'; | ||
|
||
expectTypeOf(EmberError).toEqualTypeOf<ErrorConstructor>(); | ||
expectTypeOf(EmberError("Blah")).toEqualTypeOf<Error>(); | ||
expectTypeOf(new EmberError("Blah")).toEqualTypeOf<Error>(); |
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