-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce preload-assets helper for testing
- Loading branch information
1 parent
5c89b39
commit ce07c01
Showing
2 changed files
with
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Ember from 'ember'; | ||
import AssetLoader from 'ember-asset-loader/services/asset-loader'; | ||
|
||
const { Test, RSVP } = Ember; | ||
|
||
/** | ||
* Preloads all the bundles specified in an asset manifest | ||
* to make sure all files are available for testing. | ||
* | ||
* Uses the Ember.Test.Promise class to make sure tests | ||
* wait for the assets to load first. | ||
* | ||
* @return {Promise} | ||
*/ | ||
export default function preloadAssets(manifest) { | ||
const loader = AssetLoader.create(); | ||
loader.pushManifest(manifest); | ||
|
||
const bundlePromises = Object.keys(manifest.bundles).map((bundle) => loader.loadBundle(bundle)); | ||
const allBundles = RSVP.all(bundlePromises); | ||
|
||
return Test.resolve(allBundles); | ||
} |