2015-05-13 14:12:54 -04:00
( function ( ) {
2017-06-14 13:57:58 -04:00
var loader , define , requireModule , require , requirejs ;
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
( function ( global ) {
'use strict' ;
var heimdall = global . heimdall ;
function dict ( ) {
var obj = Object . create ( null ) ;
obj [ '__' ] = undefined ;
delete obj [ '__' ] ;
return obj ;
}
// Save off the original values of these globals, so we can restore them if someone asks us to
var oldGlobals = {
loader : loader ,
define : define ,
requireModule : requireModule ,
require : require ,
requirejs : requirejs
} ;
requirejs = require = requireModule = function ( name ) {
var pending = [ ] ;
var mod = findModule ( name , '(require)' , pending ) ;
for ( var i = pending . length - 1 ; i >= 0 ; i -- ) {
pending [ i ] . exports ( ) ;
}
return mod . module . exports ;
} ;
loader = {
noConflict : function ( aliases ) {
var oldName , newName ;
for ( oldName in aliases ) {
if ( aliases . hasOwnProperty ( oldName ) ) {
if ( oldGlobals . hasOwnProperty ( oldName ) ) {
newName = aliases [ oldName ] ;
global [ newName ] = global [ oldName ] ;
global [ oldName ] = oldGlobals [ oldName ] ;
}
}
}
}
} ;
2015-05-13 14:12:54 -04:00
var _isArray ;
if ( ! Array . isArray ) {
_isArray = function ( x ) {
2017-06-14 13:57:58 -04:00
return Object . prototype . toString . call ( x ) === '[object Array]' ;
2015-05-13 14:12:54 -04:00
} ;
} else {
_isArray = Array . isArray ;
2014-07-30 17:53:14 -04:00
}
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
var registry = dict ( ) ;
var seen = dict ( ) ;
var uuid = 0 ;
function unsupportedModule ( length ) {
throw new Error ( 'an unsupported module was defined, expected `define(name, deps, module)` instead got: `' + length + '` arguments to define`' ) ;
}
var defaultDeps = [ 'require' , 'exports' , 'module' ] ;
function Module ( name , deps , callback , alias ) {
this . id = uuid ++ ;
this . name = name ;
this . deps = ! deps . length && callback . length ? defaultDeps : deps ;
this . module = { exports : { } } ;
this . callback = callback ;
this . hasExportsAsDep = false ;
this . isAlias = alias ;
this . reified = new Array ( deps . length ) ;
/ *
Each module normally passes through these states , in order :
new : initial state
pending : this module is scheduled to be executed
reifying : this module ' s dependencies are being executed
reified : this module ' s dependencies finished executing successfully
errored : this module ' s dependencies failed to execute
finalized : this module executed successfully
* /
this . state = 'new' ;
}
Module . prototype . makeDefaultExport = function ( ) {
var exports = this . module . exports ;
if ( exports !== null && ( typeof exports === 'object' || typeof exports === 'function' ) && exports [ 'default' ] === undefined && Object . isExtensible ( exports ) ) {
exports [ 'default' ] = exports ;
2014-07-30 17:53:14 -04:00
}
2015-05-13 14:12:54 -04:00
} ;
2014-07-30 17:53:14 -04:00
2017-06-14 13:57:58 -04:00
Module . prototype . exports = function ( ) {
// if finalized, there is no work to do. If reifying, there is a
// circular dependency so we must return our (partial) exports.
if ( this . state === 'finalized' || this . state === 'reifying' ) {
return this . module . exports ;
}
if ( loader . wrapModules ) {
this . callback = loader . wrapModules ( this . name , this . callback ) ;
}
this . reify ( ) ;
2014-07-30 17:53:14 -04:00
2017-06-14 13:57:58 -04:00
var result = this . callback . apply ( this , this . reified ) ;
this . state = 'finalized' ;
if ( ! ( this . hasExportsAsDep && result === undefined ) ) {
this . module . exports = result ;
}
this . makeDefaultExport ( ) ;
return this . module . exports ;
} ;
Module . prototype . unsee = function ( ) {
this . state = 'new' ;
this . module = { exports : { } } ;
} ;
Module . prototype . reify = function ( ) {
if ( this . state === 'reified' ) {
return ;
}
this . state = 'reifying' ;
try {
this . reified = this . _reify ( ) ;
this . state = 'reified' ;
} finally {
if ( this . state === 'reifying' ) {
this . state = 'errored' ;
}
}
} ;
Module . prototype . _reify = function ( ) {
var reified = this . reified . slice ( ) ;
for ( var i = 0 ; i < reified . length ; i ++ ) {
var mod = reified [ i ] ;
reified [ i ] = mod . exports ? mod . exports : mod . module . exports ( ) ;
}
return reified ;
} ;
Module . prototype . findDeps = function ( pending ) {
if ( this . state !== 'new' ) {
return ;
}
this . state = 'pending' ;
var deps = this . deps ;
for ( var i = 0 ; i < deps . length ; i ++ ) {
var dep = deps [ i ] ;
var entry = this . reified [ i ] = { exports : undefined , module : undefined } ;
2015-05-13 14:12:54 -04:00
if ( dep === 'exports' ) {
2017-06-14 13:57:58 -04:00
this . hasExportsAsDep = true ;
entry . exports = this . module . exports ;
} else if ( dep === 'require' ) {
entry . exports = this . makeRequire ( ) ;
} else if ( dep === 'module' ) {
entry . exports = this . module ;
2015-05-13 14:12:54 -04:00
} else {
2017-06-14 13:57:58 -04:00
entry . module = findModule ( resolve ( dep , this . name ) , this . name , pending ) ;
2015-05-13 14:12:54 -04:00
}
}
2017-06-14 13:57:58 -04:00
} ;
2014-07-30 17:53:14 -04:00
2017-06-14 13:57:58 -04:00
Module . prototype . makeRequire = function ( ) {
var name = this . name ;
var r = function ( dep ) {
return require ( resolve ( dep , name ) ) ;
2014-07-30 17:53:14 -04:00
} ;
2017-06-14 13:57:58 -04:00
r [ 'default' ] = r ;
r . has = function ( dep ) {
return has ( resolve ( dep , name ) ) ;
} ;
return r ;
} ;
2014-07-30 17:53:14 -04:00
2017-06-14 13:57:58 -04:00
define = function ( name , deps , callback ) {
var module = registry [ name ] ;
2014-07-30 17:53:14 -04:00
2017-06-14 13:57:58 -04:00
// If a module for this name has already been defined and is in any state
// other than `new` (meaning it has been or is currently being required),
// then we return early to avoid redefinition.
if ( module && module . state !== 'new' ) {
return ;
2015-05-13 14:12:54 -04:00
}
2017-06-14 13:57:58 -04:00
if ( arguments . length < 2 ) {
unsupportedModule ( arguments . length ) ;
}
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
if ( ! _isArray ( deps ) ) {
callback = deps ;
deps = [ ] ;
}
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
if ( callback instanceof Alias ) {
registry [ name ] = new Module ( callback . name , deps , callback , true ) ;
} else {
registry [ name ] = new Module ( name , deps , callback , false ) ;
2015-05-13 14:12:54 -04:00
}
2017-06-14 13:57:58 -04:00
} ;
// we don't support all of AMD
// define.amd = {};
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
function Alias ( path ) {
this . name = path ;
}
define . alias = function ( path ) {
return new Alias ( path ) ;
2015-05-13 14:12:54 -04:00
} ;
2017-06-14 13:57:58 -04:00
function missingModule ( name , referrer ) {
throw new Error ( 'Could not find module `' + name + '` imported from `' + referrer + '`' ) ;
}
function findModule ( name , referrer , pending ) {
var mod = registry [ name ] || registry [ name + '/index' ] ;
while ( mod && mod . isAlias ) {
mod = registry [ mod . name ] ;
}
if ( ! mod ) {
missingModule ( name , referrer ) ;
}
if ( pending && mod . state !== 'pending' && mod . state !== 'finalized' ) {
mod . findDeps ( pending ) ;
pending . push ( mod ) ;
}
return mod ;
}
2015-05-13 14:12:54 -04:00
function resolve ( child , name ) {
2017-06-14 13:57:58 -04:00
if ( child . charAt ( 0 ) !== '.' ) {
return child ;
}
2015-05-13 14:12:54 -04:00
var parts = child . split ( '/' ) ;
var nameParts = name . split ( '/' ) ;
2017-06-14 13:57:58 -04:00
var parentBase = nameParts . slice ( 0 , - 1 ) ;
2015-05-13 14:12:54 -04:00
for ( var i = 0 , l = parts . length ; i < l ; i ++ ) {
var part = parts [ i ] ;
2017-06-14 13:57:58 -04:00
if ( part === '..' ) {
if ( parentBase . length === 0 ) {
throw new Error ( 'Cannot access parent module of root' ) ;
}
parentBase . pop ( ) ;
} else if ( part === '.' ) {
continue ;
} else {
parentBase . push ( part ) ;
}
2015-05-13 14:12:54 -04:00
}
return parentBase . join ( '/' ) ;
}
2017-06-14 13:57:58 -04:00
function has ( name ) {
return ! ! ( registry [ name ] || registry [ name + '/index' ] ) ;
}
2015-05-13 14:12:54 -04:00
requirejs . entries = requirejs . _eak _seen = registry ;
2017-06-14 13:57:58 -04:00
requirejs . has = has ;
requirejs . unsee = function ( moduleName ) {
findModule ( moduleName , '(unsee)' , false ) . unsee ( ) ;
2015-05-13 14:12:54 -04:00
} ;
2017-06-14 13:57:58 -04:00
requirejs . clear = function ( ) {
requirejs . entries = requirejs . _eak _seen = registry = dict ( ) ;
seen = dict ( ) ;
} ;
// This code primes the JS engine for good performance by warming the
// JIT compiler for these functions.
define ( 'foo' , function ( ) { } ) ;
define ( 'foo/bar' , [ ] , function ( ) { } ) ;
define ( 'foo/asdf' , [ 'module' , 'exports' , 'require' ] , function ( module , exports , require ) {
if ( require . has ( 'foo/bar' ) ) {
require ( 'foo/bar' ) ;
}
} ) ;
define ( 'foo/baz' , [ ] , define . alias ( 'foo' ) ) ;
define ( 'foo/quz' , define . alias ( 'foo' ) ) ;
define ( 'foo/bar' , [ 'foo' , './quz' , './baz' , './asdf' , './bar' , '../foo' ] , function ( ) { } ) ;
define ( 'foo/main' , [ 'foo/bar' ] , function ( ) { } ) ;
require ( 'foo/main' ) ;
require . unsee ( 'foo/bar' ) ;
requirejs . clear ( ) ;
if ( typeof exports === 'object' && typeof module === 'object' && module . exports ) {
module . exports = { require : require , define : define } ;
}
} ) ( this ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-qunit' , [ 'exports' , 'ember-qunit/module-for' , 'ember-qunit/module-for-component' , 'ember-qunit/module-for-model' , 'ember-qunit/adapter' , 'ember-test-helpers' , 'qunit' ] , function ( exports , _emberQunitModuleFor , _emberQunitModuleForComponent , _emberQunitModuleForModel , _emberQunitAdapter , _emberTestHelpers , _qunit ) {
'use strict' ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
exports . module = _qunit . module ;
exports . test = _qunit . test ;
exports . skip = _qunit . skip ;
exports . only = _qunit . only ;
2017-06-14 13:57:58 -04:00
exports . todo = _qunit . todo ;
2016-12-19 11:19:10 -05:00
exports . moduleFor = _emberQunitModuleFor [ 'default' ] ;
exports . moduleForComponent = _emberQunitModuleForComponent [ 'default' ] ;
exports . moduleForModel = _emberQunitModuleForModel [ 'default' ] ;
exports . setResolver = _emberTestHelpers . setResolver ;
exports . QUnitAdapter = _emberQunitAdapter [ 'default' ] ;
} ) ;
define ( 'ember-qunit/adapter' , [ 'exports' , 'ember' , 'qunit' ] , function ( exports , _ember , _qunit ) {
2015-05-13 14:12:54 -04:00
'use strict' ;
2016-12-19 11:19:10 -05:00
exports [ 'default' ] = _ember [ 'default' ] . Test . Adapter . extend ( {
init : function init ( ) {
this . doneCallbacks = [ ] ;
} ,
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
asyncStart : function asyncStart ( ) {
2017-06-14 13:57:58 -04:00
this . doneCallbacks . push ( _qunit [ 'default' ] . config . current ? _qunit [ 'default' ] . config . current . assert . async ( ) : null ) ;
2016-12-19 11:19:10 -05:00
} ,
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
asyncEnd : function asyncEnd ( ) {
2017-06-14 13:57:58 -04:00
var done = this . doneCallbacks . pop ( ) ;
// This can be null if asyncStart() was called outside of a test
if ( done ) {
done ( ) ;
}
2016-12-19 11:19:10 -05:00
} ,
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
exception : function exception ( error ) {
_qunit [ 'default' ] . config . current . assert . ok ( false , _ember [ 'default' ] . inspect ( error ) ) ;
}
} ) ;
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-qunit/module-for-component' , [ 'exports' , './qunit-module' , 'ember-test-helpers' ] , function ( exports , _qunitModule , _emberTestHelpers ) {
2016-12-16 10:29:30 -05:00
'use strict' ;
2016-12-15 16:43:38 -05:00
2016-12-16 10:29:30 -05:00
exports [ 'default' ] = moduleForComponent ;
2016-12-19 11:19:10 -05:00
function moduleForComponent ( name , description , callbacks ) {
_qunitModule . createModule ( _emberTestHelpers . TestModuleForComponent , name , description , callbacks ) ;
}
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-qunit/module-for-model' , [ 'exports' , './qunit-module' , 'ember-test-helpers' ] , function ( exports , _qunitModule , _emberTestHelpers ) {
2016-12-16 10:29:30 -05:00
'use strict' ;
2016-12-15 16:43:38 -05:00
2016-12-16 10:29:30 -05:00
exports [ 'default' ] = moduleForModel ;
2016-12-19 11:19:10 -05:00
function moduleForModel ( name , description , callbacks ) {
_qunitModule . createModule ( _emberTestHelpers . TestModuleForModel , name , description , callbacks ) ;
}
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-qunit/module-for' , [ 'exports' , './qunit-module' , 'ember-test-helpers' ] , function ( exports , _qunitModule , _emberTestHelpers ) {
2015-05-13 14:12:54 -04:00
'use strict' ;
exports [ 'default' ] = moduleFor ;
2016-12-19 11:19:10 -05:00
function moduleFor ( name , description , callbacks ) {
_qunitModule . createModule ( _emberTestHelpers . TestModule , name , description , callbacks ) ;
2016-11-08 14:29:50 -05:00
}
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-qunit/qunit-module' , [ 'exports' , 'ember' , 'qunit' ] , function ( exports , _ember , _qunit ) {
2015-05-13 14:12:54 -04:00
'use strict' ;
exports . createModule = createModule ;
2017-06-14 13:57:58 -04:00
function noop ( ) { }
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
function callbackFor ( name , callbacks ) {
2016-12-19 11:19:10 -05:00
if ( typeof callbacks !== 'object' ) {
2017-06-14 13:57:58 -04:00
return noop ;
2016-12-19 11:19:10 -05:00
}
if ( ! callbacks ) {
2017-06-14 13:57:58 -04:00
return noop ;
2016-12-19 11:19:10 -05:00
}
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
var callback = noop ;
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
if ( callbacks [ name ] ) {
callback = callbacks [ name ] ;
delete callbacks [ name ] ;
2015-05-13 14:12:54 -04:00
}
2017-06-14 13:57:58 -04:00
return callback ;
2015-05-13 14:12:54 -04:00
}
function createModule ( Constructor , name , description , callbacks ) {
2017-06-14 13:57:58 -04:00
if ( ! callbacks && typeof description === 'object' ) {
callbacks = description ;
description = name ;
}
var _before = callbackFor ( 'before' , callbacks ) ;
var _beforeEach = callbackFor ( 'beforeEach' , callbacks ) ;
var _afterEach = callbackFor ( 'afterEach' , callbacks ) ;
var _after = callbackFor ( 'after' , callbacks ) ;
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
var module ;
var moduleName = typeof description === 'string' ? description : name ;
_qunit . module ( moduleName , {
before : function before ( ) {
// storing this in closure scope to avoid exposing these
// private internals to the test context
module = new Constructor ( name , description , callbacks ) ;
return _before . apply ( this , arguments ) ;
} ,
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
beforeEach : function beforeEach ( ) {
2017-06-14 13:57:58 -04:00
var _module2 ,
_this = this ,
2016-12-19 11:19:10 -05:00
_arguments = arguments ;
// provide the test context to the underlying module
module . setContext ( this ) ;
2017-06-14 13:57:58 -04:00
return ( _module2 = module ) . setup . apply ( _module2 , arguments ) . then ( function ( ) {
return _beforeEach . apply ( _this , _arguments ) ;
2016-12-19 11:19:10 -05:00
} ) ;
2015-05-13 14:12:54 -04:00
} ,
2016-12-19 11:19:10 -05:00
afterEach : function afterEach ( ) {
var _arguments2 = arguments ;
2017-06-14 13:57:58 -04:00
var result = _afterEach . apply ( this , arguments ) ;
2016-12-19 11:19:10 -05:00
return _ember [ 'default' ] . RSVP . resolve ( result ) . then ( function ( ) {
2017-06-14 13:57:58 -04:00
var _module3 ;
return ( _module3 = module ) . teardown . apply ( _module3 , _arguments2 ) ;
2016-12-19 11:19:10 -05:00
} ) ;
2017-06-14 13:57:58 -04:00
} ,
after : function after ( ) {
try {
return _after . apply ( this , arguments ) ;
} finally {
_after = _afterEach = _before = _beforeEach = callbacks = module = null ;
}
2014-07-30 17:53:14 -04:00
}
2015-05-13 14:12:54 -04:00
} ) ;
}
2016-12-19 11:19:10 -05:00
} ) ;
define ( 'ember-test-helpers' , [ 'exports' , 'ember' , 'ember-test-helpers/test-module' , 'ember-test-helpers/test-module-for-acceptance' , 'ember-test-helpers/test-module-for-integration' , 'ember-test-helpers/test-module-for-component' , 'ember-test-helpers/test-module-for-model' , 'ember-test-helpers/test-context' , 'ember-test-helpers/test-resolver' ] , function ( exports , _ember , _emberTestHelpersTestModule , _emberTestHelpersTestModuleForAcceptance , _emberTestHelpersTestModuleForIntegration , _emberTestHelpersTestModuleForComponent , _emberTestHelpersTestModuleForModel , _emberTestHelpersTestContext , _emberTestHelpersTestResolver ) {
'use strict' ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_ember [ 'default' ] . testing = true ;
exports . TestModule = _emberTestHelpersTestModule [ 'default' ] ;
exports . TestModuleForAcceptance = _emberTestHelpersTestModuleForAcceptance [ 'default' ] ;
exports . TestModuleForIntegration = _emberTestHelpersTestModuleForIntegration [ 'default' ] ;
exports . TestModuleForComponent = _emberTestHelpersTestModuleForComponent [ 'default' ] ;
exports . TestModuleForModel = _emberTestHelpersTestModuleForModel [ 'default' ] ;
exports . getContext = _emberTestHelpersTestContext . getContext ;
exports . setContext = _emberTestHelpersTestContext . setContext ;
exports . unsetContext = _emberTestHelpersTestContext . unsetContext ;
exports . setResolver = _emberTestHelpersTestResolver . setResolver ;
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-test-helpers/-legacy-overrides' , [ 'exports' , 'ember' , './has-ember-version' ] , function ( exports , _ember , _hasEmberVersion ) {
'use strict' ;
exports . preGlimmerSetupIntegrationForComponent = preGlimmerSetupIntegrationForComponent ;
function preGlimmerSetupIntegrationForComponent ( ) {
var module = this ;
var context = this . context ;
this . actionHooks = { } ;
context . dispatcher = this . container . lookup ( 'event_dispatcher:main' ) || _ember [ 'default' ] . EventDispatcher . create ( ) ;
context . dispatcher . setup ( { } , '#ember-testing' ) ;
context . actions = module . actionHooks ;
( this . registry || this . container ) . register ( 'component:-test-holder' , _ember [ 'default' ] . Component . extend ( ) ) ;
context . render = function ( template ) {
// in case `this.render` is called twice, make sure to teardown the first invocation
module . teardownComponent ( ) ;
if ( ! template ) {
throw new Error ( "in a component integration test you must pass a template to `render()`" ) ;
}
if ( _ember [ 'default' ] . isArray ( template ) ) {
template = template . join ( '' ) ;
}
if ( typeof template === 'string' ) {
template = _ember [ 'default' ] . Handlebars . compile ( template ) ;
}
module . component = module . container . lookupFactory ( 'component:-test-holder' ) . create ( {
layout : template
} ) ;
module . component . set ( 'context' , context ) ;
module . component . set ( 'controller' , context ) ;
_ember [ 'default' ] . run ( function ( ) {
module . component . appendTo ( '#ember-testing' ) ;
} ) ;
context . _element = module . component . element ;
} ;
context . $ = function ( ) {
return module . component . $ . apply ( module . component , arguments ) ;
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
context . set = function ( key , value ) {
var ret = _ember [ 'default' ] . run ( function ( ) {
return _ember [ 'default' ] . set ( context , key , value ) ;
} ) ;
if ( _hasEmberVersion [ 'default' ] ( 2 , 0 ) ) {
return ret ;
}
} ;
context . setProperties = function ( hash ) {
var ret = _ember [ 'default' ] . run ( function ( ) {
return _ember [ 'default' ] . setProperties ( context , hash ) ;
} ) ;
if ( _hasEmberVersion [ 'default' ] ( 2 , 0 ) ) {
return ret ;
}
} ;
context . get = function ( key ) {
return _ember [ 'default' ] . get ( context , key ) ;
} ;
context . getProperties = function ( ) {
var args = Array . prototype . slice . call ( arguments ) ;
return _ember [ 'default' ] . getProperties ( context , args ) ;
} ;
context . on = function ( actionName , handler ) {
module . actionHooks [ actionName ] = handler ;
} ;
context . send = function ( actionName ) {
var hook = module . actionHooks [ actionName ] ;
if ( ! hook ) {
throw new Error ( "integration testing template received unexpected action " + actionName ) ;
}
hook . apply ( module , Array . prototype . slice . call ( arguments , 1 ) ) ;
} ;
context . clearRender = function ( ) {
module . teardownComponent ( ) ;
} ;
}
} ) ;
define ( 'ember-test-helpers/abstract-test-module' , [ 'exports' , './wait' , './test-context' , 'ember' ] , function ( exports , _wait , _testContext , _ember ) {
2015-05-13 14:12:54 -04:00
'use strict' ;
2016-12-19 11:19:10 -05:00
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
// calling this `merge` here because we cannot
// actually assume it is like `Object.assign`
// with > 2 args
var merge = _ember [ 'default' ] . assign || _ember [ 'default' ] . merge ;
var _default = ( function ( ) {
function _default ( name , options ) {
_classCallCheck ( this , _default ) ;
this . context = undefined ;
this . name = name ;
this . callbacks = options || { } ;
this . initSetupSteps ( ) ;
this . initTeardownSteps ( ) ;
2016-11-08 14:42:10 -05:00
}
2016-12-19 11:19:10 -05:00
_default . prototype . setup = function setup ( assert ) {
var _this = this ;
return this . invokeSteps ( this . setupSteps , this , assert ) . then ( function ( ) {
_this . contextualizeCallbacks ( ) ;
return _this . invokeSteps ( _this . contextualizedSetupSteps , _this . context , assert ) ;
} ) ;
} ;
_default . prototype . teardown = function teardown ( assert ) {
var _this2 = this ;
return this . invokeSteps ( this . contextualizedTeardownSteps , this . context , assert ) . then ( function ( ) {
return _this2 . invokeSteps ( _this2 . teardownSteps , _this2 , assert ) ;
} ) . then ( function ( ) {
_this2 . cache = null ;
_this2 . cachedCalls = null ;
} ) ;
} ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . initSetupSteps = function initSetupSteps ( ) {
this . setupSteps = [ ] ;
this . contextualizedSetupSteps = [ ] ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
if ( this . callbacks . beforeSetup ) {
this . setupSteps . push ( this . callbacks . beforeSetup ) ;
delete this . callbacks . beforeSetup ;
}
this . setupSteps . push ( this . setupContext ) ;
this . setupSteps . push ( this . setupTestElements ) ;
this . setupSteps . push ( this . setupAJAXListeners ) ;
if ( this . callbacks . setup ) {
this . contextualizedSetupSteps . push ( this . callbacks . setup ) ;
delete this . callbacks . setup ;
}
} ;
_default . prototype . invokeSteps = function invokeSteps ( steps , context , assert ) {
steps = steps . slice ( ) ;
function nextStep ( ) {
var step = steps . shift ( ) ;
if ( step ) {
// guard against exceptions, for example missing components referenced from needs.
return new _ember [ 'default' ] . RSVP . Promise ( function ( resolve ) {
resolve ( step . call ( context , assert ) ) ;
} ) . then ( nextStep ) ;
2015-05-13 14:12:54 -04:00
} else {
2016-12-19 11:19:10 -05:00
return _ember [ 'default' ] . RSVP . resolve ( ) ;
2015-05-13 14:12:54 -04:00
}
}
2016-12-19 11:19:10 -05:00
return nextStep ( ) ;
} ;
_default . prototype . contextualizeCallbacks = function contextualizeCallbacks ( ) { } ;
_default . prototype . initTeardownSteps = function initTeardownSteps ( ) {
this . teardownSteps = [ ] ;
this . contextualizedTeardownSteps = [ ] ;
if ( this . callbacks . teardown ) {
this . contextualizedTeardownSteps . push ( this . callbacks . teardown ) ;
delete this . callbacks . teardown ;
}
this . teardownSteps . push ( this . teardownContext ) ;
this . teardownSteps . push ( this . teardownTestElements ) ;
this . teardownSteps . push ( this . teardownAJAXListeners ) ;
if ( this . callbacks . afterTeardown ) {
this . teardownSteps . push ( this . callbacks . afterTeardown ) ;
delete this . callbacks . afterTeardown ;
}
} ;
_default . prototype . setupTestElements = function setupTestElements ( ) {
var testEl = document . querySelector ( '#ember-testing' ) ;
if ( ! testEl ) {
var element = document . createElement ( 'div' ) ;
element . setAttribute ( 'id' , 'ember-testing' ) ;
document . body . appendChild ( element ) ;
this . fixtureResetValue = '' ;
} else {
this . fixtureResetValue = testEl . innerHTML ;
}
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . setupContext = function setupContext ( options ) {
var context = this . getContext ( ) ;
merge ( context , {
dispatcher : null ,
inject : { }
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
merge ( context , options ) ;
2016-12-12 16:24:36 -05:00
2016-12-19 11:19:10 -05:00
this . setToString ( ) ;
_testContext . setContext ( context ) ;
this . context = context ;
} ;
2016-12-12 16:24:36 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . setContext = function setContext ( context ) {
this . context = context ;
} ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . getContext = function getContext ( ) {
if ( this . context ) {
return this . context ;
}
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
return this . context = _testContext . getContext ( ) || { } ;
} ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . setToString = function setToString ( ) {
var _this3 = this ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
this . context . toString = function ( ) {
if ( _this3 . subjectName ) {
return 'test context for: ' + _this3 . subjectName ;
}
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
if ( _this3 . name ) {
return 'test context for: ' + _this3 . name ;
}
} ;
} ;
_default . prototype . setupAJAXListeners = function setupAJAXListeners ( ) {
_wait . _setupAJAXHooks ( ) ;
} ;
_default . prototype . teardownAJAXListeners = function teardownAJAXListeners ( ) {
_wait . _teardownAJAXHooks ( ) ;
} ;
_default . prototype . teardownTestElements = function teardownTestElements ( ) {
document . getElementById ( 'ember-testing' ) . innerHTML = this . fixtureResetValue ;
// Ember 2.0.0 removed Ember.View as public API, so only do this when
// Ember.View is present
if ( _ember [ 'default' ] . View && _ember [ 'default' ] . View . views ) {
_ember [ 'default' ] . View . views = { } ;
}
} ;
_default . prototype . teardownContext = function teardownContext ( ) {
var context = this . context ;
this . context = undefined ;
_testContext . unsetContext ( ) ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
if ( context && context . dispatcher && ! context . dispatcher . isDestroyed ) {
_ember [ 'default' ] . run ( function ( ) {
context . dispatcher . destroy ( ) ;
} ) ;
}
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
return _default ;
} ) ( ) ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
exports [ 'default' ] = _default ;
2015-05-13 14:12:54 -04:00
} ) ;
2017-06-14 13:57:58 -04:00
define ( 'ember-test-helpers/build-registry' , [ 'exports' , 'require' , 'ember' ] , function ( exports , _require , _ember ) {
/* globals global, self, requirejs */
2015-05-13 14:12:54 -04:00
'use strict' ;
function exposeRegistryMethodsWithoutDeprecations ( container ) {
2016-12-19 11:19:10 -05:00
var methods = [ 'register' , 'unregister' , 'resolve' , 'normalize' , 'typeInjection' , 'injection' , 'factoryInjection' , 'factoryTypeInjection' , 'has' , 'options' , 'optionsForType' ] ;
2015-05-13 14:12:54 -04:00
function exposeRegistryMethod ( container , method ) {
2016-11-08 14:29:50 -05:00
if ( method in container ) {
2016-12-19 11:19:10 -05:00
container [ method ] = function ( ) {
2016-11-08 14:29:50 -05:00
return container . _registry [ method ] . apply ( container . _registry , arguments ) ;
} ;
}
2015-05-13 14:12:54 -04:00
}
for ( var i = 0 , l = methods . length ; i < l ; i ++ ) {
exposeRegistryMethod ( container , methods [ i ] ) ;
}
}
2016-12-19 11:19:10 -05:00
var Owner = ( function ( ) {
if ( _ember [ 'default' ] . _RegistryProxyMixin && _ember [ 'default' ] . _ContainerProxyMixin ) {
return _ember [ 'default' ] . Object . extend ( _ember [ 'default' ] . _RegistryProxyMixin , _ember [ 'default' ] . _ContainerProxyMixin ) ;
2016-11-08 14:29:50 -05:00
}
2016-12-19 11:19:10 -05:00
return _ember [ 'default' ] . Object . extend ( ) ;
2016-11-08 14:29:50 -05:00
} ) ( ) ;
2016-12-19 11:19:10 -05:00
exports [ 'default' ] = function ( resolver ) {
2016-11-08 14:29:50 -05:00
var fallbackRegistry , registry , container ;
2016-12-19 11:19:10 -05:00
var namespace = _ember [ 'default' ] . Object . create ( {
Resolver : { create : function create ( ) {
return resolver ;
} }
2015-07-14 13:56:59 -04:00
} ) ;
2015-05-13 14:12:54 -04:00
2015-07-14 13:56:59 -04:00
function register ( name , factory ) {
var thingToRegisterWith = registry || container ;
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
if ( ! ( container . factoryFor ? container . factoryFor ( name ) : container . lookupFactory ( name ) ) ) {
2015-07-14 13:56:59 -04:00
thingToRegisterWith . register ( name , factory ) ;
}
}
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
if ( _ember [ 'default' ] . Application . buildRegistry ) {
fallbackRegistry = _ember [ 'default' ] . Application . buildRegistry ( namespace ) ;
fallbackRegistry . register ( 'component-lookup:main' , _ember [ 'default' ] . ComponentLookup ) ;
2016-11-08 14:29:50 -05:00
2016-12-19 11:19:10 -05:00
registry = new _ember [ 'default' ] . Registry ( {
2016-11-08 14:29:50 -05:00
fallback : fallbackRegistry
} ) ;
2016-12-19 11:19:10 -05:00
if ( _ember [ 'default' ] . ApplicationInstance && _ember [ 'default' ] . ApplicationInstance . setupRegistry ) {
_ember [ 'default' ] . ApplicationInstance . setupRegistry ( registry ) ;
}
2016-11-08 14:29:50 -05:00
// these properties are set on the fallback registry by `buildRegistry`
// and on the primary registry within the ApplicationInstance constructor
// but we need to manually recreate them since ApplicationInstance's are not
// exposed externally
registry . normalizeFullName = fallbackRegistry . normalizeFullName ;
registry . makeToString = fallbackRegistry . makeToString ;
registry . describe = fallbackRegistry . describe ;
var owner = Owner . create ( {
_ _registry _ _ : registry ,
_ _container _ _ : null
} ) ;
container = registry . container ( { owner : owner } ) ;
owner . _ _container _ _ = container ;
2015-07-14 13:56:59 -04:00
2015-05-13 14:12:54 -04:00
exposeRegistryMethodsWithoutDeprecations ( container ) ;
2014-07-30 17:53:14 -04:00
} else {
2016-12-19 11:19:10 -05:00
container = _ember [ 'default' ] . Application . buildContainer ( namespace ) ;
container . register ( 'component-lookup:main' , _ember [ 'default' ] . ComponentLookup ) ;
2014-07-30 17:53:14 -04:00
}
2015-07-14 13:56:59 -04:00
// Ember 1.10.0 did not properly add `view:toplevel` or `view:default`
// to the registry in Ember.Application.buildRegistry :(
2016-11-08 14:29:50 -05:00
//
// Ember 2.0.0 removed Ember.View as public API, so only do this when
// Ember.View is present
2016-12-19 11:19:10 -05:00
if ( _ember [ 'default' ] . View ) {
register ( 'view:toplevel' , _ember [ 'default' ] . View . extend ( ) ) ;
2016-11-08 14:29:50 -05:00
}
// Ember 2.0.0 removed Ember._MetamorphView from the Ember global, so only
// do this when present
2016-12-19 11:19:10 -05:00
if ( _ember [ 'default' ] . _MetamorphView ) {
register ( 'view:default' , _ember [ 'default' ] . _MetamorphView ) ;
2016-11-08 14:29:50 -05:00
}
2014-07-30 17:53:14 -04:00
2015-05-13 14:12:54 -04:00
var globalContext = typeof global === 'object' && global || self ;
2016-12-19 11:19:10 -05:00
if ( requirejs . entries [ 'ember-data/setup-container' ] ) {
// ember-data is a proper ember-cli addon since 2.3; if no 'import
// 'ember-data'' is present somewhere in the tests, there is also no `DS`
// available on the globalContext and hence ember-data wouldn't be setup
// correctly for the tests; that's why we import and call setupContainer
// here; also see https://github.com/emberjs/data/issues/4071 for context
2017-06-14 13:57:58 -04:00
var setupContainer = _require [ 'default' ] ( 'ember-data/setup-container' ) [ 'default' ] ;
2016-12-19 11:19:10 -05:00
setupContainer ( registry || container ) ;
} else if ( globalContext . DS ) {
2015-05-13 14:12:54 -04:00
var DS = globalContext . DS ;
if ( DS . _setupContainer ) {
2015-07-14 13:56:59 -04:00
DS . _setupContainer ( registry || container ) ;
2015-05-13 14:12:54 -04:00
} else {
2015-07-14 13:56:59 -04:00
register ( 'transform:boolean' , DS . BooleanTransform ) ;
register ( 'transform:date' , DS . DateTransform ) ;
register ( 'transform:number' , DS . NumberTransform ) ;
register ( 'transform:string' , DS . StringTransform ) ;
register ( 'serializer:-default' , DS . JSONSerializer ) ;
register ( 'serializer:-rest' , DS . RESTSerializer ) ;
register ( 'adapter:-rest' , DS . RESTAdapter ) ;
2015-05-13 14:12:54 -04:00
}
}
return {
2015-07-14 13:56:59 -04:00
registry : registry ,
container : container
2014-07-30 17:53:14 -04:00
} ;
2016-12-19 11:19:10 -05:00
} ;
2015-07-14 13:56:59 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-test-helpers/has-ember-version' , [ 'exports' , 'ember' ] , function ( exports , _ember ) {
2016-12-16 10:29:30 -05:00
'use strict' ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
exports [ 'default' ] = hasEmberVersion ;
2016-11-08 14:29:50 -05:00
function hasEmberVersion ( major , minor ) {
2016-12-19 11:19:10 -05:00
var numbers = _ember [ 'default' ] . VERSION . split ( '-' ) [ 0 ] . split ( '.' ) ;
2016-11-08 14:29:50 -05:00
var actualMajor = parseInt ( numbers [ 0 ] , 10 ) ;
var actualMinor = parseInt ( numbers [ 1 ] , 10 ) ;
2016-12-19 11:19:10 -05:00
return actualMajor > major || actualMajor === major && actualMinor >= minor ;
2016-11-08 14:29:50 -05:00
}
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
define ( "ember-test-helpers/test-context" , [ "exports" ] , function ( exports ) {
"use strict" ;
2015-05-13 14:12:54 -04:00
exports . setContext = setContext ;
exports . getContext = getContext ;
2016-11-08 14:29:50 -05:00
exports . unsetContext = unsetContext ;
2015-05-13 14:12:54 -04:00
var _ _test _context _ _ ;
function setContext ( context ) {
_ _test _context _ _ = context ;
}
function getContext ( ) {
return _ _test _context _ _ ;
}
2016-11-08 14:29:50 -05:00
function unsetContext ( ) {
_ _test _context _ _ = undefined ;
}
2016-12-16 09:52:29 -05:00
} ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-test-helpers/test-module-for-acceptance' , [ 'exports' , './abstract-test-module' , 'ember' , './test-context' ] , function ( exports , _abstractTestModule , _ember , _testContext ) {
'use strict' ;
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
function _inherits ( subClass , superClass ) { if ( typeof superClass !== 'function' && superClass !== null ) { throw new TypeError ( 'Super expression must either be null or a function, not ' + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . _ _proto _ _ = superClass ; }
var _default = ( function ( _AbstractTestModule ) {
_inherits ( _default , _AbstractTestModule ) ;
function _default ( ) {
_classCallCheck ( this , _default ) ;
_AbstractTestModule . apply ( this , arguments ) ;
}
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . setupContext = function setupContext ( ) {
_AbstractTestModule . prototype . setupContext . call ( this , { application : this . createApplication ( ) } ) ;
} ;
_default . prototype . teardownContext = function teardownContext ( ) {
_ember [ 'default' ] . run ( function ( ) {
_testContext . getContext ( ) . application . destroy ( ) ;
} ) ;
_AbstractTestModule . prototype . teardownContext . call ( this ) ;
} ;
_default . prototype . createApplication = function createApplication ( ) {
var _callbacks = this . callbacks ;
var Application = _callbacks . Application ;
var config = _callbacks . config ;
var application = undefined ;
_ember [ 'default' ] . run ( function ( ) {
application = Application . create ( config ) ;
application . setupForTesting ( ) ;
application . injectTestHelpers ( ) ;
} ) ;
return application ;
} ;
return _default ;
} ) ( _abstractTestModule [ 'default' ] ) ;
exports [ 'default' ] = _default ;
} ) ;
define ( 'ember-test-helpers/test-module-for-component' , [ 'exports' , './test-module' , 'ember' , './has-ember-version' , './-legacy-overrides' ] , function ( exports , _testModule , _ember , _hasEmberVersion , _legacyOverrides ) {
2016-12-16 10:29:30 -05:00
'use strict' ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
exports . setupComponentIntegrationTest = _setupComponentIntegrationTest ;
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
function _inherits ( subClass , superClass ) { if ( typeof superClass !== 'function' && superClass !== null ) { throw new TypeError ( 'Super expression must either be null or a function, not ' + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . _ _proto _ _ = superClass ; }
var ACTION _KEY = undefined ;
if ( _hasEmberVersion [ 'default' ] ( 2 , 0 ) ) {
ACTION _KEY = 'actions' ;
} else {
ACTION _KEY = '_actions' ;
}
var isPreGlimmer = ! _hasEmberVersion [ 'default' ] ( 1 , 13 ) ;
var getOwner = _ember [ 'default' ] . getOwner ;
var _default = ( function ( _TestModule ) {
_inherits ( _default , _TestModule ) ;
function _default ( componentName , description , callbacks ) {
_classCallCheck ( this , _default ) ;
2016-11-08 14:42:10 -05:00
2015-05-13 14:12:54 -04:00
// Allow `description` to be omitted
if ( ! callbacks && typeof description === 'object' ) {
2015-07-14 13:56:59 -04:00
callbacks = description ;
2015-05-13 14:12:54 -04:00
description = null ;
2015-07-14 13:56:59 -04:00
} else if ( ! callbacks ) {
callbacks = { } ;
2015-05-13 14:12:54 -04:00
}
2016-12-19 11:19:10 -05:00
var integrationOption = callbacks . integration ;
2017-06-14 13:57:58 -04:00
var hasNeeds = Array . isArray ( callbacks . needs ) ;
2016-12-19 11:19:10 -05:00
_TestModule . call ( this , 'component:' + componentName , description , callbacks ) ;
2015-05-13 14:12:54 -04:00
this . componentName = componentName ;
2017-06-14 13:57:58 -04:00
if ( hasNeeds || callbacks . unit || integrationOption === false ) {
2015-05-13 14:12:54 -04:00
this . isUnitTest = true ;
2016-12-19 11:19:10 -05:00
} else if ( integrationOption ) {
2015-05-13 14:12:54 -04:00
this . isUnitTest = false ;
} else {
2016-12-19 11:19:10 -05:00
_ember [ 'default' ] . deprecate ( "the component:" + componentName + " test module is implicitly running in unit test mode, " + "which will change to integration test mode by default in an upcoming version of " + "ember-test-helpers. Add `unit: true` or a `needs:[]` list to explicitly opt in to unit " + "test mode." , false , { id : 'ember-test-helpers.test-module-for-component.test-type' , until : '0.6.0' } ) ;
2015-05-13 14:12:54 -04:00
this . isUnitTest = true ;
}
2016-11-08 14:42:10 -05:00
if ( ! this . isUnitTest && ! this . isLegacy ) {
callbacks . integration = true ;
}
if ( this . isUnitTest || this . isLegacy ) {
2015-05-13 14:12:54 -04:00
this . setupSteps . push ( this . setupComponentUnitTest ) ;
} else {
2016-12-19 11:19:10 -05:00
this . callbacks . subject = function ( ) {
throw new Error ( "component integration tests do not support `subject()`. Instead, render the component as if it were HTML: `this.render('<my-component foo=true>');`. For more information, read: http://guides.emberjs.com/v2.2.0/testing/testing-components/" ) ;
2015-05-13 14:12:54 -04:00
} ;
this . setupSteps . push ( this . setupComponentIntegrationTest ) ;
2016-11-08 14:29:50 -05:00
this . teardownSteps . unshift ( this . teardownComponent ) ;
2015-05-13 14:12:54 -04:00
}
2016-11-08 14:29:50 -05:00
2016-12-19 11:19:10 -05:00
if ( _ember [ 'default' ] . View && _ember [ 'default' ] . View . views ) {
2016-11-08 14:29:50 -05:00
this . setupSteps . push ( this . _aliasViewRegistry ) ;
this . teardownSteps . unshift ( this . _resetViewRegistry ) ;
}
2016-12-19 11:19:10 -05:00
}
_default . prototype . initIntegration = function initIntegration ( options ) {
this . isLegacy = options . integration === 'legacy' ;
this . isIntegration = options . integration !== 'legacy' ;
} ;
2016-11-08 14:29:50 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . _aliasViewRegistry = function _aliasViewRegistry ( ) {
this . _originalGlobalViewRegistry = _ember [ 'default' ] . View . views ;
2016-11-08 14:29:50 -05:00
var viewRegistry = this . container . lookup ( '-view-registry:main' ) ;
if ( viewRegistry ) {
2016-12-19 11:19:10 -05:00
_ember [ 'default' ] . View . views = viewRegistry ;
2016-11-08 14:29:50 -05:00
}
2016-12-19 11:19:10 -05:00
} ;
2016-11-08 14:29:50 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . _resetViewRegistry = function _resetViewRegistry ( ) {
_ember [ 'default' ] . View . views = this . _originalGlobalViewRegistry ;
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . setupComponentUnitTest = function setupComponentUnitTest ( ) {
2015-05-13 14:12:54 -04:00
var _this = this ;
2016-12-19 11:19:10 -05:00
var resolver = this . resolver ;
2015-05-13 14:12:54 -04:00
var context = this . context ;
var layoutName = 'template:components/' + this . componentName ;
var layout = resolver . resolve ( layoutName ) ;
2016-11-08 14:29:50 -05:00
var thingToRegisterWith = this . registry || this . container ;
2015-05-13 14:12:54 -04:00
if ( layout ) {
2016-11-08 14:29:50 -05:00
thingToRegisterWith . register ( layoutName , layout ) ;
thingToRegisterWith . injection ( this . subjectName , 'layout' , layoutName ) ;
2015-05-13 14:12:54 -04:00
}
2016-12-19 11:19:10 -05:00
context . dispatcher = this . container . lookup ( 'event_dispatcher:main' ) || _ember [ 'default' ] . EventDispatcher . create ( ) ;
2015-05-13 14:12:54 -04:00
context . dispatcher . setup ( { } , '#ember-testing' ) ;
2016-12-19 11:19:10 -05:00
context . _element = null ;
this . callbacks . render = function ( ) {
2016-11-08 14:29:50 -05:00
var subject ;
2016-12-19 11:19:10 -05:00
_ember [ 'default' ] . run ( function ( ) {
2016-11-08 14:29:50 -05:00
subject = context . subject ( ) ;
subject . appendTo ( '#ember-testing' ) ;
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
context . _element = subject . element ;
_this . teardownSteps . unshift ( function ( ) {
_ember [ 'default' ] . run ( function ( ) {
_ember [ 'default' ] . tryInvoke ( subject , 'destroy' ) ;
2015-05-13 14:12:54 -04:00
} ) ;
} ) ;
} ;
2016-12-19 11:19:10 -05:00
this . callbacks . append = function ( ) {
_ember [ 'default' ] . deprecate ( 'this.append() is deprecated. Please use this.render() or this.$() instead.' , false , { id : 'ember-test-helpers.test-module-for-component.append' , until : '0.6.0' } ) ;
2015-05-13 14:12:54 -04:00
return context . $ ( ) ;
} ;
2016-12-19 11:19:10 -05:00
context . $ = function ( ) {
2015-05-13 14:12:54 -04:00
this . render ( ) ;
var subject = this . subject ( ) ;
return subject . $ . apply ( subject , arguments ) ;
} ;
2016-12-19 11:19:10 -05:00
} ;
2016-12-12 16:24:36 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . setupComponentIntegrationTest = function setupComponentIntegrationTest ( ) {
if ( isPreGlimmer ) {
return _legacyOverrides . preGlimmerSetupIntegrationForComponent . apply ( this , arguments ) ;
} else {
return _setupComponentIntegrationTest . apply ( this , arguments ) ;
}
} ;
2016-12-12 16:24:36 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . setupContext = function setupContext ( ) {
_TestModule . prototype . setupContext . call ( this ) ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
// only setup the injection if we are running against a version
// of Ember that has `-view-registry:main` (Ember >= 1.12)
2017-06-14 13:57:58 -04:00
if ( this . container . factoryFor ? this . container . factoryFor ( '-view-registry:main' ) : this . container . lookupFactory ( '-view-registry:main' ) ) {
2016-12-19 11:19:10 -05:00
( this . registry || this . container ) . injection ( 'component' , '_viewRegistry' , '-view-registry:main' ) ;
}
if ( ! this . isUnitTest && ! this . isLegacy ) {
this . context . factory = function ( ) { } ;
}
} ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . teardownComponent = function teardownComponent ( ) {
var component = this . component ;
if ( component ) {
_ember [ 'default' ] . run ( component , 'destroy' ) ;
this . component = null ;
}
} ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
return _default ;
} ) ( _testModule [ 'default' ] ) ;
exports [ 'default' ] = _default ;
function _setupComponentIntegrationTest ( ) {
var module = this ;
var context = this . context ;
this . actionHooks = context [ ACTION _KEY ] = { } ;
context . dispatcher = this . container . lookup ( 'event_dispatcher:main' ) || _ember [ 'default' ] . EventDispatcher . create ( ) ;
context . dispatcher . setup ( { } , '#ember-testing' ) ;
var hasRendered = false ;
2017-06-14 13:57:58 -04:00
var OutletView = module . container . factoryFor ? module . container . factoryFor ( 'view:-outlet' ) : module . container . lookupFactory ( 'view:-outlet' ) ;
2016-12-19 11:19:10 -05:00
var OutletTemplate = module . container . lookup ( 'template:-outlet' ) ;
var toplevelView = module . component = OutletView . create ( ) ;
var hasOutletTemplate = ! ! OutletTemplate ;
var outletState = {
render : {
owner : getOwner ? getOwner ( module . container ) : undefined ,
into : undefined ,
outlet : 'main' ,
name : 'application' ,
controller : module . context ,
ViewClass : undefined ,
template : OutletTemplate
} ,
2016-12-12 16:24:36 -05:00
2016-12-19 11:19:10 -05:00
outlets : { }
} ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
var element = document . getElementById ( 'ember-testing' ) ;
var templateId = 0 ;
if ( hasOutletTemplate ) {
_ember [ 'default' ] . run ( function ( ) {
toplevelView . setOutletState ( outletState ) ;
} ) ;
}
context . render = function ( template ) {
if ( ! template ) {
throw new Error ( "in a component integration test you must pass a template to `render()`" ) ;
}
if ( _ember [ 'default' ] . isArray ( template ) ) {
template = template . join ( '' ) ;
}
if ( typeof template === 'string' ) {
template = _ember [ 'default' ] . Handlebars . compile ( template ) ;
}
var templateFullName = 'template:-undertest-' + ++ templateId ;
this . registry . register ( templateFullName , template ) ;
var stateToRender = {
owner : getOwner ? getOwner ( module . container ) : undefined ,
into : undefined ,
outlet : 'main' ,
name : 'index' ,
controller : module . context ,
ViewClass : undefined ,
template : module . container . lookup ( templateFullName ) ,
outlets : { }
2016-12-16 10:29:30 -05:00
} ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
if ( hasOutletTemplate ) {
stateToRender . name = 'index' ;
outletState . outlets . main = { render : stateToRender , outlets : { } } ;
} else {
stateToRender . name = 'application' ;
outletState = { render : stateToRender , outlets : { } } ;
}
_ember [ 'default' ] . run ( function ( ) {
toplevelView . setOutletState ( outletState ) ;
} ) ;
if ( ! hasRendered ) {
_ember [ 'default' ] . run ( module . component , 'appendTo' , '#ember-testing' ) ;
hasRendered = true ;
}
// ensure the element is based on the wrapping toplevel view
// Ember still wraps the main application template with a
// normal tagged view
context . _element = element = document . querySelector ( '#ember-testing > .ember-view' ) ;
} ;
context . $ = function ( selector ) {
// emulates Ember internal behavor of `this.$` in a component
// https://github.com/emberjs/ember.js/blob/v2.5.1/packages/ember-views/lib/views/states/has_element.js#L18
return selector ? _ember [ 'default' ] . $ ( selector , element ) : _ember [ 'default' ] . $ ( element ) ;
} ;
context . set = function ( key , value ) {
var ret = _ember [ 'default' ] . run ( function ( ) {
return _ember [ 'default' ] . set ( context , key , value ) ;
} ) ;
if ( _hasEmberVersion [ 'default' ] ( 2 , 0 ) ) {
return ret ;
}
} ;
context . setProperties = function ( hash ) {
var ret = _ember [ 'default' ] . run ( function ( ) {
return _ember [ 'default' ] . setProperties ( context , hash ) ;
} ) ;
if ( _hasEmberVersion [ 'default' ] ( 2 , 0 ) ) {
return ret ;
}
} ;
context . get = function ( key ) {
return _ember [ 'default' ] . get ( context , key ) ;
} ;
context . getProperties = function ( ) {
var args = Array . prototype . slice . call ( arguments ) ;
return _ember [ 'default' ] . getProperties ( context , args ) ;
} ;
context . on = function ( actionName , handler ) {
module . actionHooks [ actionName ] = handler ;
} ;
context . send = function ( actionName ) {
var hook = module . actionHooks [ actionName ] ;
if ( ! hook ) {
throw new Error ( "integration testing template received unexpected action " + actionName ) ;
}
hook . apply ( module . context , Array . prototype . slice . call ( arguments , 1 ) ) ;
} ;
context . clearRender = function ( ) {
_ember [ 'default' ] . run ( function ( ) {
toplevelView . setOutletState ( {
render : {
owner : module . container ,
into : undefined ,
outlet : 'main' ,
name : 'application' ,
controller : module . context ,
ViewClass : undefined ,
template : undefined
} ,
outlets : { }
2016-12-16 10:29:30 -05:00
} ) ;
2016-12-19 11:19:10 -05:00
} ) ;
} ;
}
} ) ;
define ( 'ember-test-helpers/test-module-for-integration' , [ 'exports' , 'ember' , './abstract-test-module' , './test-resolver' , './build-registry' , './has-ember-version' , './-legacy-overrides' , './test-module-for-component' ] , function ( exports , _ember , _abstractTestModule , _testResolver , _buildRegistry , _hasEmberVersion , _legacyOverrides , _testModuleForComponent ) {
'use strict' ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
function _inherits ( subClass , superClass ) { if ( typeof superClass !== 'function' && superClass !== null ) { throw new TypeError ( 'Super expression must either be null or a function, not ' + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . _ _proto _ _ = superClass ; }
var isPreGlimmer = ! _hasEmberVersion [ 'default' ] ( 1 , 13 ) ;
var _default = ( function ( _AbstractTestModule ) {
_inherits ( _default , _AbstractTestModule ) ;
function _default ( ) {
_classCallCheck ( this , _default ) ;
_AbstractTestModule . apply ( this , arguments ) ;
this . resolver = this . callbacks . resolver || _testResolver . getResolver ( ) ;
}
_default . prototype . initSetupSteps = function initSetupSteps ( ) {
this . setupSteps = [ ] ;
this . contextualizedSetupSteps = [ ] ;
if ( this . callbacks . beforeSetup ) {
this . setupSteps . push ( this . callbacks . beforeSetup ) ;
delete this . callbacks . beforeSetup ;
}
this . setupSteps . push ( this . setupContainer ) ;
this . setupSteps . push ( this . setupContext ) ;
this . setupSteps . push ( this . setupTestElements ) ;
this . setupSteps . push ( this . setupAJAXListeners ) ;
this . setupSteps . push ( this . setupComponentIntegrationTest ) ;
if ( _ember [ 'default' ] . View && _ember [ 'default' ] . View . views ) {
this . setupSteps . push ( this . _aliasViewRegistry ) ;
}
if ( this . callbacks . setup ) {
this . contextualizedSetupSteps . push ( this . callbacks . setup ) ;
delete this . callbacks . setup ;
}
} ;
_default . prototype . initTeardownSteps = function initTeardownSteps ( ) {
this . teardownSteps = [ ] ;
this . contextualizedTeardownSteps = [ ] ;
if ( this . callbacks . teardown ) {
this . contextualizedTeardownSteps . push ( this . callbacks . teardown ) ;
delete this . callbacks . teardown ;
}
this . teardownSteps . push ( this . teardownContainer ) ;
this . teardownSteps . push ( this . teardownContext ) ;
this . teardownSteps . push ( this . teardownAJAXListeners ) ;
this . teardownSteps . push ( this . teardownComponent ) ;
if ( _ember [ 'default' ] . View && _ember [ 'default' ] . View . views ) {
this . teardownSteps . push ( this . _resetViewRegistry ) ;
}
this . teardownSteps . push ( this . teardownTestElements ) ;
if ( this . callbacks . afterTeardown ) {
this . teardownSteps . push ( this . callbacks . afterTeardown ) ;
delete this . callbacks . afterTeardown ;
}
} ;
_default . prototype . setupContainer = function setupContainer ( ) {
var resolver = this . resolver ;
var items = _buildRegistry [ 'default' ] ( resolver ) ;
this . container = items . container ;
this . registry = items . registry ;
if ( _hasEmberVersion [ 'default' ] ( 1 , 13 ) ) {
var thingToRegisterWith = this . registry || this . container ;
var router = resolver . resolve ( 'router:main' ) ;
router = router || _ember [ 'default' ] . Router . extend ( ) ;
thingToRegisterWith . register ( 'router:main' , router ) ;
}
} ;
_default . prototype . setupContext = function setupContext ( ) {
var subjectName = this . subjectName ;
var container = this . container ;
var factory = function factory ( ) {
2017-06-14 13:57:58 -04:00
return container . factoryFor ? container . factoryFor ( subjectName ) : container . lookupFactory ( subjectName ) ;
2016-12-16 10:29:30 -05:00
} ;
2016-12-19 11:19:10 -05:00
_AbstractTestModule . prototype . setupContext . call ( this , {
container : this . container ,
registry : this . registry ,
factory : factory ,
register : function register ( ) {
var target = this . registry || this . container ;
return target . register . apply ( target , arguments ) ;
2016-11-08 14:29:50 -05:00
}
2016-12-19 11:19:10 -05:00
} ) ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
var context = this . context ;
if ( _ember [ 'default' ] . setOwner ) {
_ember [ 'default' ] . setOwner ( context , this . container . owner ) ;
}
if ( _ember [ 'default' ] . inject ) {
var keys = ( Object . keys || _ember [ 'default' ] . keys ) ( _ember [ 'default' ] . inject ) ;
keys . forEach ( function ( typeName ) {
context . inject [ typeName ] = function ( name , opts ) {
var alias = opts && opts . as || name ;
_ember [ 'default' ] . run ( function ( ) {
_ember [ 'default' ] . set ( context , alias , context . container . lookup ( typeName + ':' + name ) ) ;
} ) ;
} ;
} ) ;
}
2015-05-13 14:12:54 -04:00
2016-11-08 14:29:50 -05:00
// only setup the injection if we are running against a version
// of Ember that has `-view-registry:main` (Ember >= 1.12)
2017-06-14 13:57:58 -04:00
if ( this . container . factoryFor ? this . container . factoryFor ( '-view-registry:main' ) : this . container . lookupFactory ( '-view-registry:main' ) ) {
2016-11-08 14:29:50 -05:00
( this . registry || this . container ) . injection ( 'component' , '_viewRegistry' , '-view-registry:main' ) ;
}
2016-12-19 11:19:10 -05:00
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . setupComponentIntegrationTest = function setupComponentIntegrationTest ( ) {
if ( isPreGlimmer ) {
return _legacyOverrides . preGlimmerSetupIntegrationForComponent . apply ( this , arguments ) ;
} else {
return _testModuleForComponent . setupComponentIntegrationTest . apply ( this , arguments ) ;
2015-05-13 14:12:54 -04:00
}
2016-12-19 11:19:10 -05:00
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . teardownComponent = function teardownComponent ( ) {
2015-05-13 14:12:54 -04:00
var component = this . component ;
if ( component ) {
2016-12-19 11:19:10 -05:00
_ember [ 'default' ] . run ( function ( ) {
2015-05-13 14:12:54 -04:00
component . destroy ( ) ;
} ) ;
}
2016-12-19 11:19:10 -05:00
} ;
_default . prototype . teardownContainer = function teardownContainer ( ) {
var container = this . container ;
_ember [ 'default' ] . run ( function ( ) {
container . destroy ( ) ;
} ) ;
} ;
// allow arbitrary named factories, like rspec let
_default . prototype . contextualizeCallbacks = function contextualizeCallbacks ( ) {
var callbacks = this . callbacks ;
var context = this . context ;
this . cache = this . cache || { } ;
this . cachedCalls = this . cachedCalls || { } ;
var keys = ( Object . keys || _ember [ 'default' ] . keys ) ( callbacks ) ;
var keysLength = keys . length ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
if ( keysLength ) {
for ( var i = 0 ; i < keysLength ; i ++ ) {
this . _contextualizeCallback ( context , keys [ i ] , context ) ;
}
}
} ;
_default . prototype . _contextualizeCallback = function _contextualizeCallback ( context , key , callbackContext ) {
var _this = this ;
var callbacks = this . callbacks ;
var factory = context . factory ;
context [ key ] = function ( options ) {
if ( _this . cachedCalls [ key ] ) {
return _this . cache [ key ] ;
}
var result = callbacks [ key ] . call ( callbackContext , options , factory ( ) ) ;
_this . cache [ key ] = result ;
_this . cachedCalls [ key ] = true ;
return result ;
} ;
} ;
_default . prototype . _aliasViewRegistry = function _aliasViewRegistry ( ) {
this . _originalGlobalViewRegistry = _ember [ 'default' ] . View . views ;
var viewRegistry = this . container . lookup ( '-view-registry:main' ) ;
if ( viewRegistry ) {
_ember [ 'default' ] . View . views = viewRegistry ;
}
} ;
_default . prototype . _resetViewRegistry = function _resetViewRegistry ( ) {
_ember [ 'default' ] . View . views = this . _originalGlobalViewRegistry ;
} ;
return _default ;
} ) ( _abstractTestModule [ 'default' ] ) ;
exports [ 'default' ] = _default ;
2015-05-13 14:12:54 -04:00
} ) ;
2017-06-14 13:57:58 -04:00
define ( 'ember-test-helpers/test-module-for-model' , [ 'exports' , 'require' , './test-module' , 'ember' ] , function ( exports , _require , _testModule , _ember ) {
/* global DS, requirejs */ // added here to prevent an import from erroring when ED is not present
2015-05-13 14:12:54 -04:00
'use strict' ;
2016-12-19 11:19:10 -05:00
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
2016-12-15 16:43:38 -05:00
2016-12-19 11:19:10 -05:00
function _inherits ( subClass , superClass ) { if ( typeof superClass !== 'function' && superClass !== null ) { throw new TypeError ( 'Super expression must either be null or a function, not ' + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . _ _proto _ _ = superClass ; }
var _default = ( function ( _TestModule ) {
_inherits ( _default , _TestModule ) ;
function _default ( modelName , description , callbacks ) {
_classCallCheck ( this , _default ) ;
_TestModule . call ( this , 'model:' + modelName , description , callbacks ) ;
this . modelName = modelName ;
2016-12-16 10:29:30 -05:00
2015-05-13 14:12:54 -04:00
this . setupSteps . push ( this . setupModel ) ;
2016-12-19 11:19:10 -05:00
}
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . setupModel = function setupModel ( ) {
2015-05-13 14:12:54 -04:00
var container = this . container ;
var defaultSubject = this . defaultSubject ;
var callbacks = this . callbacks ;
var modelName = this . modelName ;
2017-06-14 13:57:58 -04:00
var adapterFactory = container . factoryFor ? container . factoryFor ( 'adapter:application' ) : container . lookupFactory ( 'adapter:application' ) ;
2015-05-13 14:12:54 -04:00
if ( ! adapterFactory ) {
2016-12-19 11:19:10 -05:00
if ( requirejs . entries [ 'ember-data/adapters/json-api' ] ) {
2017-06-14 13:57:58 -04:00
adapterFactory = _require [ 'default' ] ( 'ember-data/adapters/json-api' ) [ 'default' ] ;
2016-12-19 11:19:10 -05:00
}
// when ember-data/adapters/json-api is provided via ember-cli shims
// using Ember Data 1.x the actual JSONAPIAdapter isn't found, but the
// above require statement returns a bizzaro object with only a `default`
// property (circular reference actually)
if ( ! adapterFactory || ! adapterFactory . create ) {
adapterFactory = DS . JSONAPIAdapter || DS . FixtureAdapter ;
}
2016-11-08 14:29:50 -05:00
var thingToRegisterWith = this . registry || this . container ;
thingToRegisterWith . register ( 'adapter:application' , adapterFactory ) ;
2015-05-13 14:12:54 -04:00
}
2016-12-19 11:19:10 -05:00
callbacks . store = function ( ) {
2015-05-13 14:12:54 -04:00
var container = this . container ;
2016-12-19 11:19:10 -05:00
return container . lookup ( 'service:store' ) || container . lookup ( 'store:main' ) ;
2015-05-13 14:12:54 -04:00
} ;
if ( callbacks . subject === defaultSubject ) {
2016-12-19 11:19:10 -05:00
callbacks . subject = function ( options ) {
2015-05-13 14:12:54 -04:00
var container = this . container ;
2016-12-19 11:19:10 -05:00
return _ember [ 'default' ] . run ( function ( ) {
2015-07-14 13:56:59 -04:00
var store = container . lookup ( 'service:store' ) || container . lookup ( 'store:main' ) ;
return store . createRecord ( modelName , options ) ;
2015-05-13 14:12:54 -04:00
} ) ;
} ;
}
2016-12-19 11:19:10 -05:00
} ;
2016-12-12 16:24:36 -05:00
2016-12-19 11:19:10 -05:00
return _default ;
} ) ( _testModule [ 'default' ] ) ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
exports [ 'default' ] = _default ;
} ) ;
define ( 'ember-test-helpers/test-module' , [ 'exports' , 'ember' , './abstract-test-module' , './test-resolver' , './build-registry' , './has-ember-version' ] , function ( exports , _ember , _abstractTestModule , _testResolver , _buildRegistry , _hasEmberVersion ) {
2016-12-16 10:29:30 -05:00
'use strict' ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
function _inherits ( subClass , superClass ) { if ( typeof superClass !== 'function' && superClass !== null ) { throw new TypeError ( 'Super expression must either be null or a function, not ' + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . _ _proto _ _ = superClass ; }
var _default = ( function ( _AbstractTestModule ) {
_inherits ( _default , _AbstractTestModule ) ;
function _default ( subjectName , description , callbacks ) {
_classCallCheck ( this , _default ) ;
2015-05-13 14:12:54 -04:00
// Allow `description` to be omitted, in which case it should
// default to `subjectName`
if ( ! callbacks && typeof description === 'object' ) {
callbacks = description ;
description = subjectName ;
}
2016-12-19 11:19:10 -05:00
_AbstractTestModule . call ( this , description || subjectName , callbacks ) ;
2015-05-13 14:12:54 -04:00
this . subjectName = subjectName ;
this . description = description || subjectName ;
2016-12-19 11:19:10 -05:00
this . resolver = this . callbacks . resolver || _testResolver . getResolver ( ) ;
2015-05-13 14:12:54 -04:00
2016-11-08 14:29:50 -05:00
if ( this . callbacks . integration && this . callbacks . needs ) {
throw new Error ( "cannot declare 'integration: true' and 'needs' in the same module" ) ;
}
2015-05-13 14:12:54 -04:00
if ( this . callbacks . integration ) {
2016-12-19 11:19:10 -05:00
this . initIntegration ( callbacks ) ;
2015-05-13 14:12:54 -04:00
delete callbacks . integration ;
}
this . initSubject ( ) ;
this . initNeeds ( ) ;
2016-12-19 11:19:10 -05:00
}
_default . prototype . initIntegration = function initIntegration ( options ) {
if ( options . integration === 'legacy' ) {
throw new Error ( '`integration: \'legacy\'` is only valid for component tests.' ) ;
}
this . isIntegration = true ;
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . initSubject = function initSubject ( ) {
2015-05-13 14:12:54 -04:00
this . callbacks . subject = this . callbacks . subject || this . defaultSubject ;
2016-12-19 11:19:10 -05:00
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . initNeeds = function initNeeds ( ) {
2015-05-13 14:12:54 -04:00
this . needs = [ this . subjectName ] ;
if ( this . callbacks . needs ) {
2015-07-14 13:56:59 -04:00
this . needs = this . needs . concat ( this . callbacks . needs ) ;
2015-05-13 14:12:54 -04:00
delete this . callbacks . needs ;
}
2016-12-19 11:19:10 -05:00
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . initSetupSteps = function initSetupSteps ( ) {
2015-05-13 14:12:54 -04:00
this . setupSteps = [ ] ;
this . contextualizedSetupSteps = [ ] ;
if ( this . callbacks . beforeSetup ) {
2016-12-19 11:19:10 -05:00
this . setupSteps . push ( this . callbacks . beforeSetup ) ;
2015-05-13 14:12:54 -04:00
delete this . callbacks . beforeSetup ;
}
this . setupSteps . push ( this . setupContainer ) ;
this . setupSteps . push ( this . setupContext ) ;
this . setupSteps . push ( this . setupTestElements ) ;
2016-11-08 14:29:50 -05:00
this . setupSteps . push ( this . setupAJAXListeners ) ;
2015-05-13 14:12:54 -04:00
if ( this . callbacks . setup ) {
2016-12-19 11:19:10 -05:00
this . contextualizedSetupSteps . push ( this . callbacks . setup ) ;
2015-05-13 14:12:54 -04:00
delete this . callbacks . setup ;
}
2016-12-19 11:19:10 -05:00
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . initTeardownSteps = function initTeardownSteps ( ) {
2015-05-13 14:12:54 -04:00
this . teardownSteps = [ ] ;
this . contextualizedTeardownSteps = [ ] ;
if ( this . callbacks . teardown ) {
2016-12-19 11:19:10 -05:00
this . contextualizedTeardownSteps . push ( this . callbacks . teardown ) ;
2015-05-13 14:12:54 -04:00
delete this . callbacks . teardown ;
}
this . teardownSteps . push ( this . teardownSubject ) ;
this . teardownSteps . push ( this . teardownContainer ) ;
this . teardownSteps . push ( this . teardownContext ) ;
this . teardownSteps . push ( this . teardownTestElements ) ;
2016-11-08 14:29:50 -05:00
this . teardownSteps . push ( this . teardownAJAXListeners ) ;
2015-05-13 14:12:54 -04:00
if ( this . callbacks . afterTeardown ) {
2016-12-19 11:19:10 -05:00
this . teardownSteps . push ( this . callbacks . afterTeardown ) ;
2015-05-13 14:12:54 -04:00
delete this . callbacks . afterTeardown ;
}
2016-12-19 11:19:10 -05:00
} ;
2016-11-25 14:59:16 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . setupContainer = function setupContainer ( ) {
2016-11-08 14:42:10 -05:00
if ( this . isIntegration || this . isLegacy ) {
2015-05-13 14:12:54 -04:00
this . _setupIntegratedContainer ( ) ;
} else {
this . _setupIsolatedContainer ( ) ;
}
2016-12-19 11:19:10 -05:00
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . setupContext = function setupContext ( ) {
2015-05-13 14:12:54 -04:00
var subjectName = this . subjectName ;
var container = this . container ;
2016-12-19 11:19:10 -05:00
var factory = function factory ( ) {
2017-06-14 13:57:58 -04:00
return container . factoryFor ? container . factoryFor ( subjectName ) : container . lookupFactory ( subjectName ) ;
2015-05-13 14:12:54 -04:00
} ;
2016-12-19 11:19:10 -05:00
_AbstractTestModule . prototype . setupContext . call ( this , {
container : this . container ,
2015-05-13 14:12:54 -04:00
registry : this . registry ,
2016-12-19 11:19:10 -05:00
factory : factory ,
register : function register ( ) {
2016-11-08 14:29:50 -05:00
var target = this . registry || this . container ;
return target . register . apply ( target , arguments ) ;
2016-12-19 11:19:10 -05:00
}
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
if ( _ember [ 'default' ] . setOwner ) {
_ember [ 'default' ] . setOwner ( this . context , this . container . owner ) ;
2016-12-16 10:29:30 -05:00
}
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
this . setupInject ( ) ;
} ;
_default . prototype . setupInject = function setupInject ( ) {
var module = this ;
var context = this . context ;
if ( _ember [ 'default' ] . inject ) {
var keys = ( Object . keys || _ember [ 'default' ] . keys ) ( _ember [ 'default' ] . inject ) ;
keys . forEach ( function ( typeName ) {
context . inject [ typeName ] = function ( name , opts ) {
var alias = opts && opts . as || name ;
_ember [ 'default' ] . run ( function ( ) {
_ember [ 'default' ] . set ( context , alias , module . container . lookup ( typeName + ':' + name ) ) ;
} ) ;
2016-11-08 14:29:50 -05:00
} ;
} ) ;
}
2016-12-19 11:19:10 -05:00
} ;
2016-12-16 10:29:30 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . teardownSubject = function teardownSubject ( ) {
2015-05-13 14:12:54 -04:00
var subject = this . cache . subject ;
if ( subject ) {
2016-12-19 11:19:10 -05:00
_ember [ 'default' ] . run ( function ( ) {
_ember [ 'default' ] . tryInvoke ( subject , 'destroy' ) ;
2015-05-13 14:12:54 -04:00
} ) ;
2014-07-30 17:53:14 -04:00
}
2016-12-19 11:19:10 -05:00
} ;
2014-07-30 17:53:14 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . teardownContainer = function teardownContainer ( ) {
2015-05-13 14:12:54 -04:00
var container = this . container ;
2016-12-19 11:19:10 -05:00
_ember [ 'default' ] . run ( function ( ) {
2014-07-30 17:53:14 -04:00
container . destroy ( ) ;
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
} ;
_default . prototype . defaultSubject = function defaultSubject ( options , factory ) {
return factory . create ( options ) ;
} ;
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
// allow arbitrary named factories, like rspec let
_default . prototype . contextualizeCallbacks = function contextualizeCallbacks ( ) {
var callbacks = this . callbacks ;
2016-11-25 14:59:16 -05:00
var context = this . context ;
2016-12-19 11:19:10 -05:00
this . cache = this . cache || { } ;
this . cachedCalls = this . cachedCalls || { } ;
2016-11-25 14:59:16 -05:00
2016-12-19 11:19:10 -05:00
var keys = ( Object . keys || _ember [ 'default' ] . keys ) ( callbacks ) ;
var keysLength = keys . length ;
2016-11-25 14:59:16 -05:00
2016-12-19 11:19:10 -05:00
if ( keysLength ) {
var deprecatedContext = this . _buildDeprecatedContext ( this , context ) ;
for ( var i = 0 ; i < keysLength ; i ++ ) {
this . _contextualizeCallback ( context , keys [ i ] , deprecatedContext ) ;
}
2016-11-25 14:59:16 -05:00
}
2016-12-19 11:19:10 -05:00
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . _contextualizeCallback = function _contextualizeCallback ( context , key , callbackContext ) {
var _this = this ;
var callbacks = this . callbacks ;
var factory = context . factory ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
context [ key ] = function ( options ) {
if ( _this . cachedCalls [ key ] ) {
return _this . cache [ key ] ;
}
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
var result = callbacks [ key ] . call ( callbackContext , options , factory ( ) ) ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_this . cache [ key ] = result ;
_this . cachedCalls [ key ] = true ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
return result ;
} ;
} ;
2016-11-25 14:29:24 -05:00
2016-12-19 11:19:10 -05:00
/ *
Builds a version of the passed in context that contains deprecation warnings
for accessing properties that exist on the module .
* /
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . _buildDeprecatedContext = function _buildDeprecatedContext ( module , context ) {
var deprecatedContext = Object . create ( context ) ;
2016-12-01 14:04:22 -05:00
2016-12-19 11:19:10 -05:00
var keysForDeprecation = Object . keys ( module ) ;
2016-12-12 16:24:36 -05:00
2016-12-19 11:19:10 -05:00
for ( var i = 0 , l = keysForDeprecation . length ; i < l ; i ++ ) {
this . _proxyDeprecation ( module , deprecatedContext , keysForDeprecation [ i ] ) ;
}
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
return deprecatedContext ;
} ;
/ *
Defines a key on an object to act as a proxy for deprecating the original .
* /
2016-11-25 14:29:24 -05:00
2016-12-19 11:19:10 -05:00
_default . prototype . _proxyDeprecation = function _proxyDeprecation ( obj , proxy , key ) {
if ( typeof proxy [ key ] === 'undefined' ) {
Object . defineProperty ( proxy , key , {
get : function get ( ) {
_ember [ 'default' ] . deprecate ( 'Accessing the test module property "' + key + '" from a callback is deprecated.' , false , { id : 'ember-test-helpers.test-module.callback-context' , until : '0.6.0' } ) ;
return obj [ key ] ;
}
} ) ;
2015-05-13 14:12:54 -04:00
}
2016-12-19 11:19:10 -05:00
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . _setupContainer = function _setupContainer ( isolated ) {
var resolver = this . resolver ;
2016-11-08 14:42:10 -05:00
2016-12-19 11:19:10 -05:00
var items = _buildRegistry [ 'default' ] ( ! isolated ? resolver : Object . create ( resolver , {
2016-11-08 14:42:10 -05:00
resolve : {
2016-12-19 11:19:10 -05:00
value : function value ( ) { }
2016-11-08 14:42:10 -05:00
}
} ) ) ;
2015-05-13 14:12:54 -04:00
2015-07-14 13:56:59 -04:00
this . container = items . container ;
this . registry = items . registry ;
2016-12-19 11:19:10 -05:00
if ( _hasEmberVersion [ 'default' ] ( 1 , 13 ) ) {
2016-11-08 14:29:50 -05:00
var thingToRegisterWith = this . registry || this . container ;
var router = resolver . resolve ( 'router:main' ) ;
2016-12-19 11:19:10 -05:00
router = router || _ember [ 'default' ] . Router . extend ( ) ;
2016-11-08 14:29:50 -05:00
thingToRegisterWith . register ( 'router:main' , router ) ;
}
2016-12-19 11:19:10 -05:00
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . _setupIsolatedContainer = function _setupIsolatedContainer ( ) {
var resolver = this . resolver ;
2016-11-08 14:42:10 -05:00
this . _setupContainer ( true ) ;
2015-05-13 14:12:54 -04:00
2015-07-14 13:56:59 -04:00
var thingToRegisterWith = this . registry || this . container ;
for ( var i = this . needs . length ; i > 0 ; i -- ) {
var fullName = this . needs [ i - 1 ] ;
var normalizedFullName = resolver . normalize ( fullName ) ;
thingToRegisterWith . register ( fullName , resolver . resolve ( normalizedFullName ) ) ;
2015-05-13 14:12:54 -04:00
}
2015-07-14 13:56:59 -04:00
2016-11-08 14:42:10 -05:00
if ( ! this . registry ) {
2016-12-19 11:19:10 -05:00
this . container . resolver = function ( ) { } ;
2016-11-08 14:29:50 -05:00
}
2016-12-19 11:19:10 -05:00
} ;
2015-07-14 13:56:59 -04:00
2016-12-19 11:19:10 -05:00
_default . prototype . _setupIntegratedContainer = function _setupIntegratedContainer ( ) {
2015-07-14 13:56:59 -04:00
this . _setupContainer ( ) ;
2016-12-19 11:19:10 -05:00
} ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
return _default ;
} ) ( _abstractTestModule [ 'default' ] ) ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
exports [ 'default' ] = _default ;
2015-05-13 14:12:54 -04:00
} ) ;
define ( 'ember-test-helpers/test-resolver' , [ 'exports' ] , function ( exports ) {
'use strict' ;
exports . setResolver = setResolver ;
exports . getResolver = getResolver ;
var _ _resolver _ _ ;
function setResolver ( resolver ) {
_ _resolver _ _ = resolver ;
}
function getResolver ( ) {
2016-12-19 11:19:10 -05:00
if ( _ _resolver _ _ == null ) {
throw new Error ( 'you must set a resolver with `testResolver.set(resolver)`' ) ;
}
2015-05-13 14:12:54 -04:00
return _ _resolver _ _ ;
}
2016-11-08 14:29:50 -05:00
} ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-test-helpers/wait' , [ 'exports' , 'ember' ] , function ( exports , _ember ) {
/* globals self */
2016-11-08 14:29:50 -05:00
'use strict' ;
exports . _teardownAJAXHooks = _teardownAJAXHooks ;
exports . _setupAJAXHooks = _setupAJAXHooks ;
2016-12-19 11:19:10 -05:00
exports [ 'default' ] = wait ;
2019-10-23 13:25:25 -04:00
var jQuery = $ ;
2016-11-08 14:29:50 -05:00
var requests ;
function incrementAjaxPendingRequests ( _ , xhr ) {
requests . push ( xhr ) ;
}
function decrementAjaxPendingRequests ( _ , xhr ) {
2016-12-19 11:19:10 -05:00
for ( var i = 0 ; i < requests . length ; i ++ ) {
2016-11-08 14:29:50 -05:00
if ( xhr === requests [ i ] ) {
requests . splice ( i , 1 ) ;
}
}
}
function _teardownAJAXHooks ( ) {
2016-12-19 11:19:10 -05:00
if ( ! jQuery ) {
return ;
}
2016-11-08 14:29:50 -05:00
jQuery ( document ) . off ( 'ajaxSend' , incrementAjaxPendingRequests ) ;
jQuery ( document ) . off ( 'ajaxComplete' , decrementAjaxPendingRequests ) ;
}
function _setupAJAXHooks ( ) {
requests = [ ] ;
2016-12-19 11:19:10 -05:00
if ( ! jQuery ) {
return ;
}
2016-11-08 14:29:50 -05:00
jQuery ( document ) . on ( 'ajaxSend' , incrementAjaxPendingRequests ) ;
jQuery ( document ) . on ( 'ajaxComplete' , decrementAjaxPendingRequests ) ;
}
2016-12-19 11:19:10 -05:00
var _internalCheckWaiters ;
if ( _ember [ 'default' ] . _ _loader . registry [ 'ember-testing/test/waiters' ] ) {
_internalCheckWaiters = _ember [ 'default' ] . _ _loader . require ( 'ember-testing/test/waiters' ) . checkWaiters ;
}
function checkWaiters ( ) {
if ( _internalCheckWaiters ) {
return _internalCheckWaiters ( ) ;
} else if ( _ember [ 'default' ] . Test . waiters ) {
if ( _ember [ 'default' ] . Test . waiters . any ( function ( _ref ) {
var context = _ref [ 0 ] ;
var callback = _ref [ 1 ] ;
return ! callback . call ( context ) ;
} ) ) {
return true ;
}
}
return false ;
}
2016-11-08 14:29:50 -05:00
function wait ( _options ) {
var options = _options || { } ;
var waitForTimers = options . hasOwnProperty ( 'waitForTimers' ) ? options . waitForTimers : true ;
var waitForAJAX = options . hasOwnProperty ( 'waitForAJAX' ) ? options . waitForAJAX : true ;
2016-12-19 11:19:10 -05:00
var waitForWaiters = options . hasOwnProperty ( 'waitForWaiters' ) ? options . waitForWaiters : true ;
2016-11-08 14:29:50 -05:00
2016-12-19 11:19:10 -05:00
return new _ember [ 'default' ] . RSVP . Promise ( function ( resolve ) {
var watcher = self . setInterval ( function ( ) {
if ( waitForTimers && ( _ember [ 'default' ] . run . hasScheduledTimers ( ) || _ember [ 'default' ] . run . currentRunLoop ) ) {
2016-11-08 14:29:50 -05:00
return ;
}
if ( waitForAJAX && requests && requests . length > 0 ) {
return ;
}
2016-12-19 11:19:10 -05:00
if ( waitForWaiters && checkWaiters ( ) ) {
return ;
}
2016-11-08 14:29:50 -05:00
// Stop polling
self . clearInterval ( watcher ) ;
// Synchronously resolve the promise
2016-12-19 11:19:10 -05:00
_ember [ 'default' ] . run ( null , resolve ) ;
2016-11-08 14:29:50 -05:00
} , 10 ) ;
} ) ;
}
2015-05-13 14:12:54 -04:00
} ) ;
2016-12-19 11:19:10 -05:00
define ( "qunit" , [ "exports" ] , function ( exports ) {
/* globals QUnit */
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
"use strict" ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
var _module = QUnit . module ;
exports . module = _module ;
var test = QUnit . test ;
exports . test = test ;
var skip = QUnit . skip ;
exports . skip = skip ;
var only = QUnit . only ;
exports . only = only ;
2017-06-14 13:57:58 -04:00
var todo = QUnit . todo ;
exports . todo = todo ;
2016-12-19 11:19:10 -05:00
exports [ "default" ] = QUnit ;
2015-05-13 14:12:54 -04:00
} ) ;
define ( "ember" , [ "exports" ] , function ( _ _exports _ _ ) {
_ _exports _ _ [ "default" ] = window . Ember ;
} ) ;
2017-06-14 13:57:58 -04:00
var emberQUnit = requireModule ( "ember-qunit" ) ;
2015-05-13 14:12:54 -04:00
2017-06-14 13:57:58 -04:00
for ( var exportName in emberQUnit ) {
window [ exportName ] = emberQUnit [ exportName ] ;
}
2015-05-13 14:12:54 -04:00
} ) ( ) ;
2019-10-23 13:25:25 -04:00
//# sourceMappingURL=ember-qunit.map