Created
July 18, 2016 15:44
-
-
Save rondale-sc/8eb39a99102749eb63172ba6dd9f523f to your computer and use it in GitHub Desktop.
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
import { module } from 'qunit'; | |
import startApp from '../helpers/start-app'; | |
import destroyApp from '../helpers/destroy-app'; | |
import { assertionInjector, assertionCleanup } from '../assertions'; | |
export default function(name, options = {}) { | |
module(name, { | |
beforeEach() { | |
this.application = startApp(); | |
assertionInjector(this.application); | |
// BugFix: Can be removed after 2.1. If resolver is set then fallback doesn't happen properly | |
// for more information: https://github.com/emberjs/ember.js/commit/e3ad9e2772e066459ddb3af78be45d9a6003f5ce | |
var legacyRegistry = this.application.__deprecatedInstance__.registry; | |
if (legacyRegistry) { | |
legacyRegistry.resolver = function noOpResolverBugFix() {}; | |
} | |
this.register = (fullName, Factory) => { | |
let instance = this.application.__deprecatedInstance__; | |
let registry = instance.register ? instance : instance.registry; | |
return registry.register(fullName, Factory); | |
} | |
if (options.beforeEach) { | |
options.beforeEach.apply(this, arguments); | |
} | |
}, | |
afterEach() { | |
destroyApp(this.application); | |
assertionCleanup(this.application); | |
if (options.afterEach) { | |
options.afterEach.apply(this, arguments); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment