-
-
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.
Merge pull request #19540 from emberjs/bugfix/ensure-ember-testing-is…
…-loaded-lazily [BUGFIX release] Ensure ember-testing is loaded lazily
- Loading branch information
Showing
1 changed file
with
25 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
import { Test } from 'ember-testing'; | ||
import require, { has } from 'require'; | ||
|
||
const { | ||
registerAsyncHelper, | ||
registerHelper, | ||
registerWaiter, | ||
unregisterHelper, | ||
unregisterWaiter, | ||
} = Test; | ||
export let registerAsyncHelper; | ||
export let registerHelper; | ||
export let registerWaiter; | ||
export let unregisterHelper; | ||
export let unregisterWaiter; | ||
|
||
export { registerAsyncHelper, registerHelper, registerWaiter, unregisterHelper, unregisterWaiter }; | ||
if (has('ember-testing')) { | ||
let { Test } = require('ember-testing'); | ||
|
||
registerAsyncHelper = Test.registerAsyncHelper; | ||
registerHelper = Test.registerHelper; | ||
registerWaiter = Test.registerWaiter; | ||
unregisterHelper = Test.unregisterHelper; | ||
unregisterWaiter = Test.unregisterWaiter; | ||
} else { | ||
let testingNotAvailableMessage = () => { | ||
throw new Error('Attempted to use test utilities, but `ember-testing` was not included'); | ||
}; | ||
|
||
registerAsyncHelper = testingNotAvailableMessage; | ||
registerHelper = testingNotAvailableMessage; | ||
registerWaiter = testingNotAvailableMessage; | ||
unregisterHelper = testingNotAvailableMessage; | ||
unregisterWaiter = testingNotAvailableMessage; | ||
} |