2015-05-13 14:12:54 -04:00
( function ( ) {
var define , requireModule , require , requirejs ;
( function ( ) {
var _isArray ;
if ( ! Array . isArray ) {
_isArray = function ( x ) {
return Object . prototype . toString . call ( x ) === "[object Array]" ;
} ;
} else {
_isArray = Array . isArray ;
2014-07-30 17:53:14 -04:00
}
2015-05-13 14:12:54 -04:00
var registry = { } , seen = { } , state = { } ;
var FAILED = false ;
define = function ( name , deps , callback ) {
if ( ! _isArray ( deps ) ) {
callback = deps ;
deps = [ ] ;
2014-07-30 17:53:14 -04:00
}
2015-05-13 14:12:54 -04:00
registry [ name ] = {
deps : deps ,
callback : callback
} ;
} ;
2014-07-30 17:53:14 -04:00
2015-05-13 14:12:54 -04:00
function reify ( deps , name , seen ) {
var length = deps . length ;
var reified = new Array ( length ) ;
var dep ;
var exports ;
2014-07-30 17:53:14 -04:00
2015-05-13 14:12:54 -04:00
for ( var i = 0 , l = length ; i < l ; i ++ ) {
dep = deps [ i ] ;
if ( dep === 'exports' ) {
exports = reified [ i ] = seen ;
} else {
reified [ i ] = require ( resolve ( dep , name ) ) ;
}
}
2014-07-30 17:53:14 -04:00
2015-05-13 14:12:54 -04:00
return {
deps : reified ,
exports : 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
2015-05-13 14:12:54 -04:00
requirejs = require = requireModule = function ( name ) {
if ( state [ name ] !== FAILED &&
seen . hasOwnProperty ( name ) ) {
return seen [ name ] ;
}
2014-07-30 17:53:14 -04:00
2015-05-13 14:12:54 -04:00
if ( ! registry [ name ] ) {
throw new Error ( 'Could not find module ' + name ) ;
}
var mod = registry [ name ] ;
var reified ;
var module ;
var loaded = false ;
seen [ name ] = { } ; // placeholder for run-time cycles
try {
reified = reify ( mod . deps , name , seen [ name ] ) ;
module = mod . callback . apply ( this , reified . deps ) ;
loaded = true ;
} finally {
if ( ! loaded ) {
state [ name ] = FAILED ;
}
}
return reified . exports ? seen [ name ] : ( seen [ name ] = module ) ;
} ;
function resolve ( child , name ) {
if ( child . charAt ( 0 ) !== '.' ) { return child ; }
var parts = child . split ( '/' ) ;
var nameParts = name . split ( '/' ) ;
var parentBase ;
if ( nameParts . length === 1 ) {
parentBase = nameParts ;
} else {
parentBase = nameParts . slice ( 0 , - 1 ) ;
}
for ( var i = 0 , l = parts . length ; i < l ; i ++ ) {
var part = parts [ i ] ;
if ( part === '..' ) { parentBase . pop ( ) ; }
else if ( part === '.' ) { continue ; }
else { parentBase . push ( part ) ; }
}
return parentBase . join ( '/' ) ;
}
requirejs . entries = requirejs . _eak _seen = registry ;
requirejs . clear = function ( ) {
requirejs . entries = requirejs . _eak _seen = registry = { } ;
seen = state = { } ;
} ;
} ) ( ) ;
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 ;
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 ( ) {
this . doneCallbacks . push ( _qunit [ 'default' ] . config . current . assert . async ( ) ) ;
} ,
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
asyncEnd : function asyncEnd ( ) {
this . doneCallbacks . pop ( ) ( ) ;
} ,
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 ;
function beforeEachCallback ( callbacks ) {
2016-12-19 11:19:10 -05:00
if ( typeof callbacks !== 'object' ) {
return ;
}
if ( ! callbacks ) {
return ;
}
2015-05-13 14:12:54 -04:00
var beforeEach ;
2016-11-08 14:29:50 -05:00
2015-05-13 14:12:54 -04:00
if ( callbacks . beforeEach ) {
beforeEach = callbacks . beforeEach ;
delete callbacks . beforeEach ;
}
return beforeEach ;
}
function afterEachCallback ( callbacks ) {
2016-12-19 11:19:10 -05:00
if ( typeof callbacks !== 'object' ) {
return ;
}
if ( ! callbacks ) {
return ;
}
2015-05-13 14:12:54 -04:00
var afterEach ;
if ( callbacks . afterEach ) {
afterEach = callbacks . afterEach ;
delete callbacks . afterEach ;
}
return afterEach ;
}
function createModule ( Constructor , name , description , callbacks ) {
2016-12-19 11:19:10 -05:00
var _beforeEach = beforeEachCallback ( callbacks || description ) ;
var _afterEach = afterEachCallback ( callbacks || description ) ;
2015-05-13 14:12:54 -04:00
var module = new Constructor ( name , description , callbacks ) ;
2016-12-19 11:19:10 -05:00
_qunit . module ( module . name , {
beforeEach : function beforeEach ( ) {
var _this = this ,
_arguments = arguments ;
// provide the test context to the underlying module
module . setContext ( this ) ;
return module . setup . apply ( module , arguments ) . then ( function ( ) {
if ( _beforeEach ) {
return _beforeEach . 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
afterEach : function afterEach ( ) {
var _arguments2 = arguments ;
var result = undefined ;
if ( _afterEach ) {
result = _afterEach . apply ( this , arguments ) ;
2015-05-13 14:12:54 -04:00
}
2016-12-19 11:19:10 -05:00
return _ember [ 'default' ] . RSVP . resolve ( result ) . then ( function ( ) {
return module . teardown . apply ( module , _arguments2 ) ;
} ) ;
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
} ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-test-helpers/build-registry' , [ 'exports' , 'ember' ] , function ( exports , _ember ) {
/* globals global, self, requirejs, require */
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
2015-07-14 13:56:59 -04:00
if ( ! container . lookupFactory ( name ) ) {
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
var setupContainer = require ( 'ember-data/setup-container' ) [ 'default' ] ;
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 ;
_TestModule . call ( this , 'component:' + componentName , description , callbacks ) ;
2015-05-13 14:12:54 -04:00
this . componentName = componentName ;
2016-12-19 11:19:10 -05:00
if ( callbacks . needs || 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)
if ( this . container . lookupFactory ( '-view-registry:main' ) ) {
( 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 ;
var OutletView = module . container . lookupFactory ( 'view:-outlet' ) ;
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 ACTION _KEY = undefined ;
if ( _hasEmberVersion [ 'default' ] ( 2 , 0 ) ) {
ACTION _KEY = 'actions' ;
} else {
ACTION _KEY = '_actions' ;
}
2016-12-16 09:52:29 -05:00
2016-12-19 11:19:10 -05:00
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 ( ) {
return 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)
if ( this . container . lookupFactory ( '-view-registry:main' ) ) {
( 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
} ) ;
2016-12-19 11:19:10 -05:00
define ( 'ember-test-helpers/test-module-for-model' , [ 'exports' , './test-module' , 'ember' ] , function ( exports , _testModule , _ember ) {
/* global DS, require, 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 ;
var adapterFactory = container . lookupFactory ( 'adapter:application' ) ;
if ( ! adapterFactory ) {
2016-12-19 11:19:10 -05:00
if ( requirejs . entries [ 'ember-data/adapters/json-api' ] ) {
adapterFactory = require ( 'ember-data/adapters/json-api' ) [ 'default' ] ;
}
// 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 ( ) {
2015-05-13 14:12:54 -04:00
return container . lookupFactory ( subjectName ) ;
} ;
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 ;
var jQuery = _ember [ 'default' ] . $ ;
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 ;
2015-05-13 14:12:54 -04:00
2016-12-19 11:19:10 -05:00
exports . only = only ;
exports [ "default" ] = QUnit ;
2015-05-13 14:12:54 -04:00
} ) ;
define ( "ember" , [ "exports" ] , function ( _ _exports _ _ ) {
_ _exports _ _ [ "default" ] = window . Ember ;
} ) ;
var emberQunit = requireModule ( "ember-qunit" ) ;
window . moduleFor = emberQunit . moduleFor ;
window . moduleForComponent = emberQunit . moduleForComponent ;
window . moduleForModel = emberQunit . moduleForModel ;
window . test = emberQunit . test ;
window . setResolver = emberQunit . setResolver ;
} ) ( ) ;
2016-11-25 14:59:16 -05:00
//# sourceMappingURL=ember-qunit.map