2015-05-14 02:12:54 +08: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-31 05:53:14 +08:00
}
2015-05-14 02:12:54 +08:00
var registry = { } , seen = { } , state = { } ;
var FAILED = false ;
define = function ( name , deps , callback ) {
if ( ! _isArray ( deps ) ) {
callback = deps ;
deps = [ ] ;
2014-07-31 05:53:14 +08:00
}
2015-05-14 02:12:54 +08:00
registry [ name ] = {
deps : deps ,
callback : callback
} ;
} ;
2014-07-31 05:53:14 +08:00
2015-05-14 02:12:54 +08:00
function reify ( deps , name , seen ) {
var length = deps . length ;
var reified = new Array ( length ) ;
var dep ;
var exports ;
2014-07-31 05:53:14 +08:00
2015-05-14 02:12:54 +08: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-31 05:53:14 +08:00
2015-05-14 02:12:54 +08:00
return {
deps : reified ,
exports : exports
2014-07-31 05:53:14 +08:00
} ;
2015-05-14 02:12:54 +08:00
}
2014-07-31 05:53:14 +08:00
2015-05-14 02:12:54 +08:00
requirejs = require = requireModule = function ( name ) {
if ( state [ name ] !== FAILED &&
seen . hasOwnProperty ( name ) ) {
return seen [ name ] ;
}
2014-07-31 05:53:14 +08:00
2015-05-14 02:12:54 +08: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 = { } ;
} ;
} ) ( ) ;
define ( 'ember-qunit' , [ 'exports' , 'ember-qunit/module-for' , 'ember-qunit/module-for-component' , 'ember-qunit/module-for-model' , 'ember-qunit/test' , 'ember-test-helpers' ] , function ( exports , moduleFor , moduleForComponent , moduleForModel , test , ember _test _helpers ) {
'use strict' ;
exports . moduleFor = moduleFor [ 'default' ] ;
exports . moduleForComponent = moduleForComponent [ 'default' ] ;
exports . moduleForModel = moduleForModel [ 'default' ] ;
exports . test = test [ 'default' ] ;
exports . setResolver = ember _test _helpers . setResolver ;
} ) ;
define ( 'ember-qunit/module-for-component' , [ 'exports' , 'ember-qunit/qunit-module' , 'ember-test-helpers' ] , function ( exports , qunit _module , ember _test _helpers ) {
'use strict' ;
function moduleForComponent ( name , description , callbacks ) {
qunit _module . createModule ( ember _test _helpers . TestModuleForComponent , name , description , callbacks ) ;
}
exports [ 'default' ] = moduleForComponent ;
} ) ;
define ( 'ember-qunit/module-for-model' , [ 'exports' , 'ember-qunit/qunit-module' , 'ember-test-helpers' ] , function ( exports , qunit _module , ember _test _helpers ) {
'use strict' ;
function moduleForModel ( name , description , callbacks ) {
qunit _module . createModule ( ember _test _helpers . TestModuleForModel , name , description , callbacks ) ;
}
exports [ 'default' ] = moduleForModel ;
} ) ;
define ( 'ember-qunit/module-for' , [ 'exports' , 'ember-qunit/qunit-module' , 'ember-test-helpers' ] , function ( exports , qunit _module , ember _test _helpers ) {
'use strict' ;
function moduleFor ( name , description , callbacks ) {
qunit _module . createModule ( ember _test _helpers . TestModule , name , description , callbacks ) ;
}
exports [ 'default' ] = moduleFor ;
} ) ;
define ( 'ember-qunit/qunit-module' , [ 'exports' , 'qunit' ] , function ( exports , qunit ) {
'use strict' ;
exports . createModule = createModule ;
function beforeEachCallback ( callbacks ) {
if ( typeof callbacks !== 'object' ) { return ; }
if ( ! callbacks ) { return ; }
var beforeEach ;
if ( callbacks . setup ) {
beforeEach = callbacks . setup ;
delete callbacks . setup ;
}
if ( callbacks . beforeEach ) {
beforeEach = callbacks . beforeEach ;
delete callbacks . beforeEach ;
}
return beforeEach ;
}
function afterEachCallback ( callbacks ) {
if ( typeof callbacks !== 'object' ) { return ; }
if ( ! callbacks ) { return ; }
var afterEach ;
if ( callbacks . teardown ) {
afterEach = callbacks . teardown ;
delete callbacks . teardown ;
}
if ( callbacks . afterEach ) {
afterEach = callbacks . afterEach ;
delete callbacks . afterEach ;
}
return afterEach ;
}
function createModule ( Constructor , name , description , callbacks ) {
var beforeEach = beforeEachCallback ( callbacks || description ) ;
var afterEach = afterEachCallback ( callbacks || description ) ;
var module = new Constructor ( name , description , callbacks ) ;
qunit . module ( module . name , {
setup : function ( assert ) {
var done = assert . async ( ) ;
module . setup ( ) . then ( function ( ) {
if ( beforeEach ) {
beforeEach . call ( module . context , assert ) ;
}
} ) [ 'finally' ] ( done ) ;
} ,
teardown : function ( assert ) {
if ( afterEach ) {
afterEach . call ( module . context , assert ) ;
}
var done = assert . async ( ) ;
module . teardown ( ) [ 'finally' ] ( done ) ;
2014-07-31 05:53:14 +08:00
}
2015-05-14 02:12:54 +08:00
} ) ;
}
} ) ;
define ( 'ember-qunit/test' , [ 'exports' , 'ember' , 'ember-test-helpers' , 'qunit' ] , function ( exports , Ember , ember _test _helpers , qunit ) {
'use strict' ;
function test ( testName , callback ) {
function wrapper ( assert ) {
var context = ember _test _helpers . getContext ( ) ;
var result = callback . call ( context , assert ) ;
function failTestOnPromiseRejection ( reason ) {
var message ;
if ( reason instanceof Error ) {
message = reason . stack ;
} else {
message = Ember [ 'default' ] . inspect ( reason ) ;
}
ok ( false , message ) ;
}
Ember [ 'default' ] . run ( function ( ) {
QUnit . stop ( ) ;
Ember [ 'default' ] . RSVP . Promise . resolve ( result ) [ 'catch' ] ( failTestOnPromiseRejection ) [ 'finally' ] ( QUnit . start ) ;
} ) ;
}
qunit . test ( testName , wrapper ) ;
}
exports [ 'default' ] = test ;
} ) ;
2015-07-15 01:56:59 +08:00
define ( 'ember-test-helpers' , [ 'exports' , 'ember' , 'ember-test-helpers/test-module' , '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 , TestModule , TestModuleForComponent , TestModuleForModel , test _context , test _resolver ) {
2015-05-14 02:12:54 +08:00
'use strict' ;
Ember [ 'default' ] . testing = true ;
exports . TestModule = TestModule [ 'default' ] ;
exports . TestModuleForComponent = TestModuleForComponent [ 'default' ] ;
exports . TestModuleForModel = TestModuleForModel [ 'default' ] ;
exports . getContext = test _context . getContext ;
exports . setContext = test _context . setContext ;
exports . setResolver = test _resolver . setResolver ;
} ) ;
2015-07-15 01:56:59 +08:00
define ( 'ember-test-helpers/build-registry' , [ 'exports' ] , function ( exports ) {
2015-05-14 02:12:54 +08:00
'use strict' ;
function exposeRegistryMethodsWithoutDeprecations ( container ) {
var methods = [
'register' ,
'unregister' ,
'resolve' ,
'normalize' ,
'typeInjection' ,
'injection' ,
'factoryInjection' ,
'factoryTypeInjection' ,
'has' ,
'options' ,
'optionsForType'
] ;
function exposeRegistryMethod ( container , method ) {
container [ method ] = function ( ) {
return container . _registry [ method ] . apply ( container . _registry , arguments ) ;
} ;
}
for ( var i = 0 , l = methods . length ; i < l ; i ++ ) {
exposeRegistryMethod ( container , methods [ i ] ) ;
}
}
2015-07-15 01:56:59 +08:00
exports [ 'default' ] = function ( resolver ) {
var registry , container ;
var namespace = Ember . Object . create ( {
Resolver : { create : function ( ) { return resolver ; } }
} ) ;
2015-05-14 02:12:54 +08:00
2015-07-15 01:56:59 +08:00
function register ( name , factory ) {
var thingToRegisterWith = registry || container ;
2015-05-14 02:12:54 +08:00
2015-07-15 01:56:59 +08:00
if ( ! container . lookupFactory ( name ) ) {
thingToRegisterWith . register ( name , factory ) ;
}
}
2015-05-14 02:12:54 +08:00
2015-07-15 01:56:59 +08:00
if ( Ember . Application . buildRegistry ) {
registry = Ember . Application . buildRegistry ( namespace ) ;
registry . register ( 'component-lookup:main' , Ember . ComponentLookup ) ;
registry = registry ;
2015-05-14 02:12:54 +08:00
container = registry . container ( ) ;
exposeRegistryMethodsWithoutDeprecations ( container ) ;
2014-07-31 05:53:14 +08:00
} else {
2015-07-15 01:56:59 +08:00
container = Ember . Application . buildContainer ( namespace ) ;
container . register ( 'component-lookup:main' , Ember . ComponentLookup ) ;
2014-07-31 05:53:14 +08:00
}
2015-07-15 01:56:59 +08:00
// Ember 1.10.0 did not properly add `view:toplevel` or `view:default`
// to the registry in Ember.Application.buildRegistry :(
register ( 'view:toplevel' , Ember . View . extend ( ) ) ;
register ( 'view:default' , Ember . _MetamorphView ) ;
2014-07-31 05:53:14 +08:00
2015-05-14 02:12:54 +08:00
var globalContext = typeof global === 'object' && global || self ;
if ( globalContext . DS ) {
var DS = globalContext . DS ;
if ( DS . _setupContainer ) {
2015-07-15 01:56:59 +08:00
DS . _setupContainer ( registry || container ) ;
2015-05-14 02:12:54 +08:00
} else {
2015-07-15 01:56:59 +08: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-14 02:12:54 +08:00
}
}
return {
2015-07-15 01:56:59 +08:00
registry : registry ,
container : container
2014-07-31 05:53:14 +08:00
} ;
2015-05-14 02:12:54 +08:00
}
2014-07-31 05:53:14 +08:00
2015-07-15 01:56:59 +08:00
} ) ;
define ( 'ember-test-helpers/isolated-container' , function ( ) {
'use strict' ;
2015-05-14 02:12:54 +08:00
} ) ;
define ( 'ember-test-helpers/test-context' , [ 'exports' ] , function ( exports ) {
'use strict' ;
exports . setContext = setContext ;
exports . getContext = getContext ;
var _ _test _context _ _ ;
function setContext ( context ) {
_ _test _context _ _ = context ;
}
function getContext ( ) {
return _ _test _context _ _ ;
}
} ) ;
define ( 'ember-test-helpers/test-module-for-component' , [ 'exports' , 'ember-test-helpers/test-module' , 'ember' , 'ember-test-helpers/test-resolver' ] , function ( exports , TestModule , Ember , test _resolver ) {
'use strict' ;
exports [ 'default' ] = TestModule [ 'default' ] . extend ( {
init : function ( componentName , description , callbacks ) {
// Allow `description` to be omitted
if ( ! callbacks && typeof description === 'object' ) {
2015-07-15 01:56:59 +08:00
callbacks = description ;
2015-05-14 02:12:54 +08:00
description = null ;
2015-07-15 01:56:59 +08:00
} else if ( ! callbacks ) {
callbacks = { } ;
2015-05-14 02:12:54 +08:00
}
this . componentName = componentName ;
if ( callbacks . needs || callbacks . unit || callbacks . integration === false ) {
this . isUnitTest = true ;
} else if ( callbacks . integration ) {
this . isUnitTest = false ;
} else {
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." ) ;
this . isUnitTest = true ;
}
if ( ! this . isUnitTest ) {
callbacks . integration = true ;
}
if ( description ) {
this . _super . call ( this , 'component:' + componentName , description , callbacks ) ;
} else {
this . _super . call ( this , 'component:' + componentName , callbacks ) ;
}
if ( this . isUnitTest ) {
this . setupSteps . push ( this . setupComponentUnitTest ) ;
} else {
this . callbacks . subject = function ( ) {
throw new Error ( "component integration tests do not support `subject()`." ) ;
} ;
this . setupSteps . push ( this . setupComponentIntegrationTest ) ;
this . teardownSteps . push ( this . teardownComponent ) ;
}
} ,
setupComponentUnitTest : function ( ) {
var _this = this ;
var resolver = test _resolver . getResolver ( ) ;
var container = this . container ;
var context = this . context ;
var layoutName = 'template:components/' + this . componentName ;
var layout = resolver . resolve ( layoutName ) ;
if ( layout ) {
container . register ( layoutName , layout ) ;
container . injection ( this . subjectName , 'layout' , layoutName ) ;
}
context . dispatcher = Ember [ 'default' ] . EventDispatcher . create ( ) ;
context . dispatcher . setup ( { } , '#ember-testing' ) ;
this . callbacks . render = function ( ) {
var containerView = Ember [ 'default' ] . ContainerView . create ( { container : container } ) ;
Ember [ 'default' ] . run ( function ( ) {
var subject = context . subject ( ) ;
containerView . pushObject ( subject ) ;
containerView . appendTo ( '#ember-testing' ) ;
} ) ;
_this . teardownSteps . unshift ( function ( ) {
Ember [ 'default' ] . run ( function ( ) {
Ember [ 'default' ] . tryInvoke ( containerView , 'destroy' ) ;
} ) ;
} ) ;
} ;
this . callbacks . append = function ( ) {
Ember [ 'default' ] . deprecate ( 'this.append() is deprecated. Please use this.render() or this.$() instead.' ) ;
return context . $ ( ) ;
} ;
context . $ = function ( ) {
this . render ( ) ;
var subject = this . subject ( ) ;
return subject . $ . apply ( subject , arguments ) ;
} ;
} ,
setupComponentIntegrationTest : function ( ) {
2015-07-15 01:56:59 +08:00
var module = this ;
2015-05-14 02:12:54 +08:00
var context = this . context ;
context . dispatcher = Ember [ 'default' ] . EventDispatcher . create ( ) ;
context . dispatcher . setup ( { } , '#ember-testing' ) ;
this . actionHooks = { } ;
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 ) ;
}
2015-07-15 01:56:59 +08:00
module . component = Ember [ 'default' ] . Component . create ( {
layout : template ,
container : module . container
2014-07-31 05:53:14 +08:00
} ) ;
2015-07-15 01:56:59 +08:00
module . component . set ( 'context' , context ) ;
module . component . set ( 'controller' , module ) ;
2015-05-14 02:12:54 +08:00
Ember [ 'default' ] . run ( function ( ) {
2015-07-15 01:56:59 +08:00
module . component . appendTo ( '#ember-testing' ) ;
2015-05-14 02:12:54 +08:00
} ) ;
} ;
context . $ = function ( ) {
2015-07-15 01:56:59 +08:00
return module . component . $ . apply ( module . component , arguments ) ;
2014-07-31 05:53:14 +08:00
} ;
2015-05-14 02:12:54 +08:00
context . set = function ( key , value ) {
Ember [ 'default' ] . run ( function ( ) {
Ember [ 'default' ] . set ( context , key , value ) ;
} ) ;
} ;
context . get = function ( key ) {
return Ember [ 'default' ] . get ( context , key ) ;
} ;
context . on = function ( actionName , handler ) {
2015-07-15 01:56:59 +08:00
module . actionHooks [ actionName ] = handler ;
2015-05-14 02:12:54 +08:00
} ;
} ,
setupContext : function ( ) {
this . _super . call ( this ) ;
if ( ! this . isUnitTest ) {
this . context . factory = function ( ) { } ;
}
} ,
send : function ( actionName ) {
var hook = this . actionHooks [ actionName ] ;
if ( ! hook ) {
throw new Error ( "integration testing template received unexpected action " + actionName ) ;
}
hook . apply ( this , Array . prototype . slice . call ( arguments , 1 ) ) ;
} ,
teardownComponent : function ( ) {
var component = this . component ;
if ( component ) {
Ember [ 'default' ] . run ( function ( ) {
component . destroy ( ) ;
} ) ;
}
2014-07-31 05:53:14 +08:00
}
2015-05-14 02:12:54 +08:00
2014-07-31 05:53:14 +08:00
} ) ;
2015-05-14 02:12:54 +08:00
} ) ;
define ( 'ember-test-helpers/test-module-for-model' , [ 'exports' , 'ember-test-helpers/test-module' , 'ember' ] , function ( exports , TestModule , Ember ) {
'use strict' ;
exports [ 'default' ] = TestModule [ 'default' ] . extend ( {
init : function ( modelName , description , callbacks ) {
this . modelName = modelName ;
this . _super . call ( this , 'model:' + modelName , description , callbacks ) ;
this . setupSteps . push ( this . setupModel ) ;
} ,
setupModel : function ( ) {
var container = this . container ;
var defaultSubject = this . defaultSubject ;
var callbacks = this . callbacks ;
var modelName = this . modelName ;
var adapterFactory = container . lookupFactory ( 'adapter:application' ) ;
if ( ! adapterFactory ) {
container . register ( 'adapter:application' , DS . FixtureAdapter ) ;
}
callbacks . store = function ( ) {
var container = this . container ;
2015-07-15 01:56:59 +08:00
var store = container . lookup ( 'service:store' ) || container . lookup ( 'store:main' ) ;
return store ;
2015-05-14 02:12:54 +08:00
} ;
if ( callbacks . subject === defaultSubject ) {
callbacks . subject = function ( options ) {
var container = this . container ;
return Ember [ 'default' ] . run ( function ( ) {
2015-07-15 01:56:59 +08:00
var store = container . lookup ( 'service:store' ) || container . lookup ( 'store:main' ) ;
return store . createRecord ( modelName , options ) ;
2015-05-14 02:12:54 +08:00
} ) ;
} ;
}
}
} ) ;
} ) ;
2015-07-15 01:56:59 +08:00
define ( 'ember-test-helpers/test-module' , [ 'exports' , 'ember' , 'ember-test-helpers/test-context' , 'klassy' , 'ember-test-helpers/test-resolver' , 'ember-test-helpers/build-registry' ] , function ( exports , Ember , test _context , klassy , test _resolver , buildRegistry ) {
2015-05-14 02:12:54 +08:00
'use strict' ;
exports [ 'default' ] = klassy . Klass . extend ( {
init : function ( subjectName , description , callbacks ) {
// Allow `description` to be omitted, in which case it should
// default to `subjectName`
if ( ! callbacks && typeof description === 'object' ) {
callbacks = description ;
description = subjectName ;
}
this . subjectName = subjectName ;
this . description = description || subjectName ;
this . name = description || subjectName ;
this . callbacks = callbacks || { } ;
if ( this . callbacks . integration ) {
2015-07-15 01:56:59 +08:00
this . isIntegration = callbacks . integration ;
2015-05-14 02:12:54 +08:00
delete callbacks . integration ;
}
this . initSubject ( ) ;
this . initNeeds ( ) ;
this . initSetupSteps ( ) ;
this . initTeardownSteps ( ) ;
} ,
initSubject : function ( ) {
this . callbacks . subject = this . callbacks . subject || this . defaultSubject ;
} ,
initNeeds : function ( ) {
this . needs = [ this . subjectName ] ;
if ( this . callbacks . needs ) {
2015-07-15 01:56:59 +08:00
this . needs = this . needs . concat ( this . callbacks . needs ) ;
2015-05-14 02:12:54 +08:00
delete this . callbacks . needs ;
}
} ,
initSetupSteps : function ( ) {
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 ) ;
if ( this . callbacks . setup ) {
this . contextualizedSetupSteps . push ( this . callbacks . setup ) ;
delete this . callbacks . setup ;
}
} ,
initTeardownSteps : function ( ) {
this . teardownSteps = [ ] ;
this . contextualizedTeardownSteps = [ ] ;
if ( this . callbacks . teardown ) {
this . contextualizedTeardownSteps . push ( this . callbacks . teardown ) ;
delete this . callbacks . teardown ;
}
this . teardownSteps . push ( this . teardownSubject ) ;
this . teardownSteps . push ( this . teardownContainer ) ;
this . teardownSteps . push ( this . teardownContext ) ;
this . teardownSteps . push ( this . teardownTestElements ) ;
if ( this . callbacks . afterTeardown ) {
this . teardownSteps . push ( this . callbacks . afterTeardown ) ;
delete this . callbacks . afterTeardown ;
}
} ,
setup : function ( ) {
var self = this ;
return self . invokeSteps ( self . setupSteps ) . then ( function ( ) {
self . contextualizeCallbacks ( ) ;
return self . invokeSteps ( self . contextualizedSetupSteps , self . context ) ;
2014-07-31 05:53:14 +08:00
} ) ;
2015-05-14 02:12:54 +08:00
} ,
2014-07-31 05:53:14 +08:00
2015-05-14 02:12:54 +08:00
teardown : function ( ) {
var self = this ;
return self . invokeSteps ( self . contextualizedTeardownSteps , self . context ) . then ( function ( ) {
return self . invokeSteps ( self . teardownSteps ) ;
} ) . then ( function ( ) {
self . cache = null ;
self . cachedCalls = null ;
} ) ;
} ,
invokeSteps : function ( steps , _context ) {
var context = _context ;
if ( ! context ) {
context = this ;
}
steps = steps . slice ( ) ;
function nextStep ( ) {
var step = steps . shift ( ) ;
if ( step ) {
2015-07-15 01:56:59 +08:00
// guard against exceptions, for example missing components referenced from needs.
return new Ember [ 'default' ] . RSVP . Promise ( function ( ok ) {
ok ( step . call ( context ) ) ;
} ) . then ( nextStep ) ;
2015-05-14 02:12:54 +08:00
} else {
return Ember [ 'default' ] . RSVP . resolve ( ) ;
}
}
return nextStep ( ) ;
} ,
setupContainer : function ( ) {
if ( this . isIntegration ) {
this . _setupIntegratedContainer ( ) ;
} else {
this . _setupIsolatedContainer ( ) ;
}
} ,
setupContext : function ( ) {
var subjectName = this . subjectName ;
var container = this . container ;
var factory = function ( ) {
return container . lookupFactory ( subjectName ) ;
} ;
test _context . setContext ( {
container : this . container ,
registry : this . registry ,
factory : factory ,
dispatcher : null
} ) ;
this . context = test _context . getContext ( ) ;
} ,
setupTestElements : function ( ) {
if ( Ember [ 'default' ] . $ ( '#ember-testing' ) . length === 0 ) {
Ember [ 'default' ] . $ ( '<div id="ember-testing"/>' ) . appendTo ( document . body ) ;
2014-07-31 05:53:14 +08:00
}
2015-05-14 02:12:54 +08:00
} ,
teardownSubject : function ( ) {
var subject = this . cache . subject ;
if ( subject ) {
Ember [ 'default' ] . run ( function ( ) {
Ember [ 'default' ] . tryInvoke ( subject , 'destroy' ) ;
} ) ;
2014-07-31 05:53:14 +08:00
}
} ,
2015-05-14 02:12:54 +08:00
teardownContainer : function ( ) {
var container = this . container ;
Ember [ 'default' ] . run ( function ( ) {
2014-07-31 05:53:14 +08:00
container . destroy ( ) ;
2015-05-14 02:12:54 +08:00
} ) ;
} ,
teardownContext : function ( ) {
var context = this . context ;
if ( context . dispatcher ) {
Ember [ 'default' ] . run ( function ( ) {
2014-07-31 05:53:14 +08:00
context . dispatcher . destroy ( ) ;
2015-05-14 02:12:54 +08:00
} ) ;
}
} ,
teardownTestElements : function ( ) {
Ember [ 'default' ] . $ ( '#ember-testing' ) . empty ( ) ;
Ember [ 'default' ] . View . views = { } ;
} ,
defaultSubject : function ( options , factory ) {
return factory . create ( options ) ;
} ,
// allow arbitrary named factories, like rspec let
contextualizeCallbacks : function ( ) {
var _this = this ;
var callbacks = this . callbacks ;
var context = this . context ;
var factory = context . factory ;
this . cache = this . cache || { } ;
this . cachedCalls = this . cachedCalls || { } ;
2015-07-15 01:56:59 +08:00
var keys = ( Object . keys || Ember [ 'default' ] . keys ) ( callbacks ) ;
2015-05-14 02:12:54 +08:00
for ( var i = 0 , l = keys . length ; i < l ; i ++ ) {
( function ( key ) {
context [ key ] = function ( options ) {
if ( _this . cachedCalls [ key ] ) { return _this . cache [ key ] ; }
var result = callbacks [ key ] . call ( _this , options , factory ( ) ) ;
_this . cache [ key ] = result ;
_this . cachedCalls [ key ] = true ;
return result ;
} ;
} ) ( keys [ i ] ) ;
}
} ,
2015-07-15 01:56:59 +08:00
_setupContainer : function ( ) {
var resolver = test _resolver . getResolver ( ) ;
var items = buildRegistry [ 'default' ] ( resolver ) ;
2015-05-14 02:12:54 +08:00
2015-07-15 01:56:59 +08:00
this . container = items . container ;
this . registry = items . registry ;
var thingToRegisterWith = this . registry || this . container ;
var router = resolver . resolve ( 'router:main' ) ;
router = router || Ember [ 'default' ] . Router . extend ( ) ;
thingToRegisterWith . register ( 'router:main' , router ) ;
2015-05-14 02:12:54 +08:00
} ,
2015-07-15 01:56:59 +08:00
_setupIsolatedContainer : function ( ) {
2015-05-14 02:12:54 +08:00
var resolver = test _resolver . getResolver ( ) ;
2015-07-15 01:56:59 +08:00
this . _setupContainer ( ) ;
2015-05-14 02:12:54 +08:00
2015-07-15 01:56:59 +08: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-14 02:12:54 +08:00
}
2015-07-15 01:56:59 +08:00
thingToRegisterWith . resolver = function ( ) { } ;
} ,
_setupIntegratedContainer : function ( ) {
this . _setupContainer ( ) ;
2015-05-14 02:12:54 +08: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 ( ) {
if ( _ _resolver _ _ == null ) throw new Error ( 'you must set a resolver with `testResolver.set(resolver)`' ) ;
return _ _resolver _ _ ;
}
} ) ;
define ( 'klassy' , [ 'exports' ] , function ( exports ) {
'use strict' ;
/ * *
Extend a class with the properties and methods of one or more other classes .
When a method is replaced with another method , it will be wrapped in a
function that makes the replaced method accessible via ` this._super ` .
@ method extendClass
@ param { Object } destination The class to merge into
@ param { Object } source One or more source classes
* /
var extendClass = function ( destination ) {
var sources = Array . prototype . slice . call ( arguments , 1 ) ;
var source ;
for ( var i = 0 , l = sources . length ; i < l ; i ++ ) {
source = sources [ i ] ;
for ( var p in source ) {
if ( source . hasOwnProperty ( p ) &&
destination [ p ] &&
typeof destination [ p ] === 'function' &&
typeof source [ p ] === 'function' ) {
/* jshint loopfunc:true */
destination [ p ] =
( function ( destinationFn , sourceFn ) {
var wrapper = function ( ) {
var prevSuper = this . _super ;
this . _super = destinationFn ;
var ret = sourceFn . apply ( this , arguments ) ;
this . _super = prevSuper ;
return ret ;
} ;
wrapper . wrappedFunction = sourceFn ;
return wrapper ;
} ) ( destination [ p ] , source [ p ] ) ;
} else {
destination [ p ] = source [ p ] ;
}
}
2014-07-31 05:53:14 +08:00
}
} ;
2015-05-14 02:12:54 +08:00
// `subclassing` is a state flag used by `defineClass` to track when a class is
// being subclassed. It allows constructors to avoid calling `init`, which can
// be expensive and cause undesirable side effects.
var subclassing = false ;
2014-07-31 05:53:14 +08:00
2015-05-14 02:12:54 +08:00
/ * *
Define a new class with the properties and methods of one or more other classes .
2014-07-31 05:53:14 +08:00
2015-05-14 02:12:54 +08:00
The new class can be based on a ` SuperClass ` , which will be inserted into its
prototype chain .
Furthermore , one or more mixins ( object that contain properties and / or methods )
may be specified , which will be applied in order . When a method is replaced
with another method , it will be wrapped in a function that makes the previous
method accessible via ` this._super ` .
@ method defineClass
@ param { Object } SuperClass A base class to extend . If ` mixins ` are to be included
without a ` SuperClass ` , pass ` null ` for SuperClass .
@ param { Object } mixins One or more objects that contain properties and methods
to apply to the new class .
* /
var defineClass = function ( SuperClass ) {
var Klass = function ( ) {
if ( ! subclassing && this . init ) {
this . init . apply ( this , arguments ) ;
}
2014-07-31 05:53:14 +08:00
} ;
2015-05-14 02:12:54 +08:00
if ( SuperClass ) {
subclassing = true ;
Klass . prototype = new SuperClass ( ) ;
subclassing = false ;
2014-07-31 05:53:14 +08:00
}
2015-05-14 02:12:54 +08:00
if ( arguments . length > 1 ) {
var extendArgs = Array . prototype . slice . call ( arguments , 1 ) ;
extendArgs . unshift ( Klass . prototype ) ;
extendClass . apply ( Klass . prototype , extendArgs ) ;
}
Klass . constructor = Klass ;
Klass . extend = function ( ) {
var args = Array . prototype . slice . call ( arguments , 0 ) ;
args . unshift ( Klass ) ;
return defineClass . apply ( Klass , args ) ;
} ;
return Klass ;
} ;
/ * *
A base class that can be extended .
@ example
` ` ` javascript
var CelestialObject = Klass . extend ( {
init : function ( name ) {
this . _super ( ) ;
this . name = name ;
this . isCelestialObject = true ;
} ,
greeting : function ( ) {
return 'Hello from ' + this . name ;
}
} ) ;
var Planet = CelestialObject . extend ( {
init : function ( name ) {
this . _super . apply ( this , arguments ) ;
this . isPlanet = true ;
} ,
greeting : function ( ) {
return this . _super ( ) + '!' ;
} ,
} ) ;
var earth = new Planet ( 'Earth' ) ;
console . log ( earth instanceof Klass ) ; // true
console . log ( earth instanceof CelestialObject ) ; // true
console . log ( earth instanceof Planet ) ; // true
console . log ( earth . isCelestialObject ) ; // true
console . log ( earth . isPlanet ) ; // true
console . log ( earth . greeting ( ) ) ; // 'Hello from Earth!'
` ` `
@ class Klass
* /
var Klass = defineClass ( null , {
init : function ( ) { }
} ) ;
exports . Klass = Klass ;
exports . defineClass = defineClass ;
exports . extendClass = extendClass ;
2014-07-31 05:53:14 +08:00
2015-05-02 04:35:52 +08:00
} ) ;
2015-05-14 02:12:54 +08:00
define ( 'qunit' , [ 'exports' ] , function ( exports ) {
'use strict' ;
/* globals test:true */
var module = QUnit . module ;
var test = QUnit . test ;
var skip = QUnit . skip ;
exports [ 'default' ] = QUnit ;
exports . module = module ;
exports . test = test ;
exports . skip = skip ;
} ) ;
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 ;
} ) ( ) ;
2015-07-15 01:56:59 +08:00
//# sourceMappingURL=ember-qunit.map