var define, requireModule, require, requirejs, Ember; (function() { Ember = this.Ember = this.Ember || {}; if (typeof Ember === 'undefined') { Ember = {} }; if (typeof Ember.__loader === 'undefined') { var registry = {}, seen = {}; define = function(name, deps, callback) { registry[name] = { deps: deps, callback: callback }; }; requirejs = require = requireModule = function(name) { if (seen.hasOwnProperty(name)) { return seen[name]; } seen[name] = {}; if (!registry[name]) { throw new Error("Could not find module " + name); } var mod = registry[name], deps = mod.deps, callback = mod.callback, reified = [], exports; for (var i=0, l=deps.length; i\";\n };\n\n Klass.create = create;\n Klass.extend = extend;\n Klass.reopen = extend;\n Klass.reopenClass = reopenClass;\n\n return Klass;\n\n function create(options) {\n var passedOptions = options;\n return new this.prototype.constructor(options);\n }\n\n function reopenClass(options) {\n setProperties(this, options);\n }\n\n function extend(options) {\n var Child = function(options) {\n Klass.call(this, options);\n };\n\n var Parent = this;\n\n Child.prototype = new Parent();\n Child.prototype.constructor = Child;\n\n setProperties(Child.prototype, options);\n\n Child.create = create;\n Child.extend = extend;\n Child.reopen = extend;\n\n Child.reopenClass = reopenClass;\n\n return Child;\n }\n };\n\n __exports__.factory = factory;\n __exports__.o_create = o_create;\n __exports__.setProperties = setProperties;\n });\ndefine(\"container/tests/container_test\",\n [\"container/tests/container_helper\",\"container\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var factory = __dependency1__.factory;\n var o_create = __dependency1__.o_create;\n var setProperties = __dependency1__.setProperties;\n\n var Container = __dependency2__[\"default\"];\n\n var originalModelInjections;\n\n module(\"Container\", {\n setup: function() {\n originalModelInjections = Ember.MODEL_FACTORY_INJECTIONS;\n },\n teardown: function() {\n Ember.MODEL_FACTORY_INJECTIONS = originalModelInjections;\n }\n });\n\n test(\"A registered factory returns the same instance each time\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.register('controller:post', PostController);\n\n var postController = container.lookup('controller:post');\n\n ok(postController instanceof PostController, \"The lookup is an instance of the factory\");\n\n equal(postController, container.lookup('controller:post'));\n });\n\n test(\"A registered factory is returned from lookupFactory\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.register('controller:post', PostController);\n\n var PostControllerFactory = container.lookupFactory('controller:post');\n\n ok(PostControllerFactory, 'factory is returned');\n ok(PostControllerFactory.create() instanceof PostController, \"The return of factory.create is an instance of PostController\");\n });\n\n test(\"A registered factory is returned from lookupFactory is the same factory each time\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.register('controller:post', PostController);\n\n deepEqual(container.lookupFactory('controller:post'), container.lookupFactory('controller:post'), 'The return of lookupFactory is always the same');\n });\n\n test(\"A factory returned from lookupFactory has a debugkey\", function(){\n var container = new Container();\n var PostController = factory();\n var instance;\n\n container.register('controller:post', PostController);\n var PostFactory = container.lookupFactory('controller:post');\n\n ok(!PostFactory.container, 'factory instance receives a container');\n equal(PostFactory._debugContainerKey, 'controller:post', 'factory instance receives _debugContainerKey');\n });\n\n test(\"fallback for to create time injections if factory has no extend\", function(){\n var container = new Container();\n var AppleController = factory();\n var PostController = factory();\n\n PostController.extend = undefined; // remove extend\n\n var instance;\n\n container.register('controller:apple', AppleController);\n container.register('controller:post', PostController);\n container.injection('controller:post', 'apple', 'controller:apple');\n\n var postController = container.lookup('controller:post');\n\n ok(postController.container, 'instance receives a container');\n equal(postController.container, container, 'instance receives the correct container');\n equal(postController._debugContainerKey, 'controller:post', 'instance receives _debugContainerKey');\n ok(postController.apple instanceof AppleController, 'instance receives an apple of instance AppleController');\n });\n\n test(\"The descendants of a factory returned from lookupFactory have a container and debugkey\", function(){\n var container = new Container();\n var PostController = factory();\n var instance;\n\n container.register('controller:post', PostController);\n instance = container.lookupFactory('controller:post').create();\n\n ok(instance.container, 'factory instance receives a container');\n equal(instance._debugContainerKey, 'controller:post', 'factory instance receives _debugContainerKey');\n\n ok(instance instanceof PostController, 'factory instance is instance of factory');\n });\n\n test(\"A registered factory returns a fresh instance if singleton: false is passed as an option\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.register('controller:post', PostController);\n\n var postController1 = container.lookup('controller:post');\n var postController2 = container.lookup('controller:post', { singleton: false });\n var postController3 = container.lookup('controller:post', { singleton: false });\n var postController4 = container.lookup('controller:post');\n\n equal(postController1.toString(), postController4.toString(), \"Singleton factories looked up normally return the same value\");\n notEqual(postController1.toString(), postController2.toString(), \"Singleton factories are not equal to factories looked up with singleton: false\");\n notEqual(postController2.toString(), postController3.toString(), \"Two factories looked up with singleton: false are not equal\");\n notEqual(postController3.toString(), postController4.toString(), \"A singleton factory looked up after a factory called with singleton: false is not equal\");\n\n ok(postController1 instanceof PostController, \"All instances are instances of the registered factory\");\n ok(postController2 instanceof PostController, \"All instances are instances of the registered factory\");\n ok(postController3 instanceof PostController, \"All instances are instances of the registered factory\");\n ok(postController4 instanceof PostController, \"All instances are instances of the registered factory\");\n });\n\n test(\"A registered factory returns true for `has` if an item is registered\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.register('controller:post', PostController);\n\n equal(container.has('controller:post'), true, \"The `has` method returned true for registered factories\");\n equal(container.has('controller:posts'), false, \"The `has` method returned false for unregistered factories\");\n });\n\n test(\"A Registered factory can be unregistered, and all cached instances are removed\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.register('controller:post', PostController);\n\n equal(container.has('controller:post'), true, \"container is aware of the PostController\");\n\n ok(container.lookup('controller:post') instanceof PostController, \"lookup is correct instance\");\n\n container.unregister(\"controller:post\");\n\n equal(container.has('controller:post'), false, \"container is no-longer aware of the PostController\");\n equal(container.lookup('controller:post'), undefined, \"lookup no longer returns a controller\");\n\n // re-registration continues to work\n container.register('controller:post', PostController);\n\n equal(container.has('controller:post'), true, \"container is aware of the PostController\");\n\n ok(container.lookup('controller:post') instanceof PostController, \"lookup is correct instance\");\n });\n\n test(\"A container lookup has access to the container\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.register('controller:post', PostController);\n\n var postController = container.lookup('controller:post');\n\n equal(postController.container, container);\n });\n\n test(\"Throw exception when trying to inject `type:thing` on all type(s)\", function(){\n var container = new Container(),\n PostController = factory();\n\n container.register('controller:post', PostController);\n\n throws(function(){\n container.typeInjection('controller', 'injected', 'controller:post');\n }, 'Cannot inject a `controller:post` on other controller(s). Register the `controller:post` as a different type and perform the typeInjection.');\n });\n\n test(\"A factory type with a registered injection's instances receive that injection\", function() {\n var container = new Container();\n var PostController = factory();\n var Store = factory();\n\n container.register('controller:post', PostController);\n container.register('store:main', Store);\n\n container.typeInjection('controller', 'store', 'store:main');\n\n var postController = container.lookup('controller:post');\n var store = container.lookup('store:main');\n\n equal(postController.store, store);\n });\n\n test(\"An individual factory with a registered injection receives the injection\", function() {\n var container = new Container();\n var PostController = factory();\n var Store = factory();\n\n container.register('controller:post', PostController);\n container.register('store:main', Store);\n\n container.injection('controller:post', 'store', 'store:main');\n\n var postController = container.lookup('controller:post');\n var store = container.lookup('store:main');\n\n equal(store.container, container);\n equal(store._debugContainerKey, 'store:main');\n\n equal(postController.container, container);\n equal(postController._debugContainerKey, 'controller:post');\n equal(postController.store, store, 'has the correct store injected');\n });\n\n test(\"A factory with both type and individual injections\", function() {\n var container = new Container();\n var PostController = factory();\n var Store = factory();\n var Router = factory();\n\n container.register('controller:post', PostController);\n container.register('store:main', Store);\n container.register('router:main', Router);\n\n container.injection('controller:post', 'store', 'store:main');\n container.typeInjection('controller', 'router', 'router:main');\n\n var postController = container.lookup('controller:post');\n var store = container.lookup('store:main');\n var router = container.lookup('router:main');\n\n equal(postController.store, store);\n equal(postController.router, router);\n });\n\n test(\"A factory with both type and individual factoryInjections\", function() {\n var container = new Container();\n var PostController = factory();\n var Store = factory();\n var Router = factory();\n\n container.register('controller:post', PostController);\n container.register('store:main', Store);\n container.register('router:main', Router);\n\n container.factoryInjection('controller:post', 'store', 'store:main');\n container.factoryTypeInjection('controller', 'router', 'router:main');\n\n var PostControllerFactory = container.lookupFactory('controller:post');\n var store = container.lookup('store:main');\n var router = container.lookup('router:main');\n\n equal(PostControllerFactory.store, store, 'PostControllerFactory has the instance of store');\n equal(PostControllerFactory.router, router, 'PostControllerFactory has the route instance');\n });\n\n test(\"A non-singleton instance is never cached\", function() {\n var container = new Container();\n var PostView = factory();\n\n container.register('view:post', PostView, { singleton: false });\n\n var postView1 = container.lookup('view:post');\n var postView2 = container.lookup('view:post');\n\n ok(postView1 !== postView2, \"Non-singletons are not cached\");\n });\n\n test(\"A non-instantiated property is not instantiated\", function() {\n var container = new Container();\n\n var template = function() {};\n container.register('template:foo', template, { instantiate: false });\n equal(container.lookup('template:foo'), template);\n });\n\n test(\"A failed lookup returns undefined\", function() {\n var container = new Container();\n\n equal(container.lookup('doesnot:exist'), undefined);\n });\n\n test(\"Injecting a failed lookup raises an error\", function() {\n Ember.MODEL_FACTORY_INJECTIONS = true;\n\n var container = new Container();\n\n var fooInstance = {};\n var fooFactory = {};\n\n var Foo = {\n create: function(args) { return fooInstance; },\n extend: function(args) { return fooFactory; }\n };\n\n container.register('model:foo', Foo);\n container.injection('model:foo', 'store', 'store:main');\n\n throws(function() {\n container.lookup('model:foo');\n });\n });\n\n test(\"Injecting a falsy value does not raise an error\", function() {\n var container = new Container();\n var ApplicationController = factory();\n\n container.register('controller:application', ApplicationController);\n container.register('user:current', null, { instantiate: false });\n container.injection('controller:application', 'currentUser', 'user:current');\n\n equal(container.lookup('controller:application').currentUser, null);\n });\n\n test(\"Destroying the container destroys any cached singletons\", function() {\n var container = new Container();\n var PostController = factory();\n var PostView = factory();\n var template = function() {};\n\n container.register('controller:post', PostController);\n container.register('view:post', PostView, { singleton: false });\n container.register('template:post', template, { instantiate: false });\n\n container.injection('controller:post', 'postView', 'view:post');\n\n var postController = container.lookup('controller:post');\n var postView = postController.postView;\n\n ok(postView instanceof PostView, \"The non-singleton was injected\");\n\n container.destroy();\n\n ok(postController.isDestroyed, \"Singletons are destroyed\");\n ok(!postView.isDestroyed, \"Non-singletons are not destroyed\");\n });\n\n test(\"The container can take a hook to resolve factories lazily\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.resolver = function(fullName) {\n if (fullName === 'controller:post') {\n return PostController;\n }\n };\n\n var postController = container.lookup('controller:post');\n\n ok(postController instanceof PostController, \"The correct factory was provided\");\n });\n\n test(\"The container respect the resolver hook for `has`\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.resolver = function(fullName) {\n if (fullName === 'controller:post') {\n return PostController;\n }\n };\n\n ok(container.has('controller:post'), \"the `has` method uses the resolver hook\");\n });\n\n test(\"The container normalizes names before resolving\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.normalize = function(fullName) {\n return 'controller:post';\n };\n\n container.register('controller:post', PostController);\n var postController = container.lookup('controller:normalized');\n\n ok(postController instanceof PostController, \"Normalizes the name before resolving\");\n });\n\n test(\"The container normalizes names when unregistering\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.normalize = function(fullName) {\n return 'controller:post';\n };\n\n container.register('controller:post', PostController);\n var postController = container.lookup('controller:normalized');\n\n ok(postController instanceof PostController, \"Normalizes the name before resolving\");\n\n container.unregister('controller:post');\n postController = container.lookup('controller:normalized');\n\n equal(postController, undefined);\n });\n\n test(\"The container normalizes names when resolving\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.normalize = function(fullName) {\n return 'controller:post';\n };\n\n container.register('controller:post', PostController);\n var type = container.resolve('controller:normalized');\n\n equal(type === PostController, true, \"Normalizes the name when resolving\");\n });\n\n test(\"The container normalizes names when looking factory up\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.normalize = function(fullName) {\n return 'controller:post';\n };\n\n container.register('controller:post', PostController);\n var fact = container.lookupFactory('controller:normalized');\n\n equal(fact.toString() === PostController.extend().toString(), true, \"Normalizes the name when looking factory up\");\n });\n\n test(\"The container normalizes names when checking if the factory or instance is present\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.normalize = function(fullName) {\n return 'controller:post';\n };\n\n container.register('controller:post', PostController);\n var isPresent = container.has('controller:normalized');\n\n equal(isPresent, true, \"Normalizes the name when checking if the factory or instance is present\");\n });\n\n test(\"validateFullName throws an error if name is incorrect\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.normalize = function(fullName) {\n return 'controller:post';\n };\n\n container.register('controller:post', PostController);\n throws(function() {\n container.lookupFactory('post');\n }, 'TypeError: Invalid Fullname, expected: `type:name` got: post');\n });\n\n test(\"The container normalizes names when injecting\", function() {\n var container = new Container();\n var PostController = factory();\n var user = { name: 'Stef' };\n\n container.normalize = function(fullName) {\n return 'controller:post';\n };\n\n container.register('controller:post', PostController);\n container.register('user:post', user, { instantiate: false });\n container.injection('controller:post', 'user', 'controller:normalized');\n\n deepEqual(container.lookup('controller:post'), user, \"Normalizes the name when injecting\");\n });\n\n test(\"The container can get options that should be applied to all factories for a given type\", function() {\n var container = new Container();\n var PostView = factory();\n\n container.resolver = function(fullName) {\n if (fullName === 'view:post') {\n return PostView;\n }\n };\n\n container.optionsForType('view', { singleton: false });\n\n var postView1 = container.lookup('view:post');\n var postView2 = container.lookup('view:post');\n\n ok(postView1 instanceof PostView, \"The correct factory was provided\");\n ok(postView2 instanceof PostView, \"The correct factory was provided\");\n\n ok(postView1 !== postView2, \"The two lookups are different\");\n });\n\n test(\"cannot register an `undefined` factory\", function(){\n var container = new Container();\n\n throws(function(){\n container.register('controller:apple', undefined);\n }, '');\n });\n\n test(\"can re-register a factory\", function(){\n var container = new Container(),\n FirstApple = factory('first'),\n SecondApple = factory('second');\n\n container.register('controller:apple', FirstApple);\n container.register('controller:apple', SecondApple);\n\n ok(container.lookup('controller:apple') instanceof SecondApple);\n });\n\n test(\"cannot re-register a factory if has been looked up\", function(){\n var container = new Container(),\n FirstApple = factory('first'),\n SecondApple = factory('second');\n\n container.register('controller:apple', FirstApple);\n ok(container.lookup('controller:apple') instanceof FirstApple);\n\n throws(function(){\n container.register('controller:apple', SecondApple);\n }, 'Cannot re-register: `controller:apple`, as it has already been looked up.');\n\n ok(container.lookup('controller:apple') instanceof FirstApple);\n });\n\n\n test('container.has should not accidentally cause injections on that factory to be run. (Mitigate merely on observing)', function(){\n expect(1);\n\n var container = new Container(),\n FirstApple = factory('first'),\n SecondApple = factory('second');\n\n SecondApple.extend = function(a,b,c) {\n ok(false, 'should not extend or touch the injected model, merely to inspect existence of another');\n };\n\n container.register('controller:apple', FirstApple);\n container.register('controller:second-apple', SecondApple);\n container.injection('controller:apple', 'badApple', 'controller:second-apple');\n\n ok(container.has('controller:apple'));\n });\n\n test('once resolved, always return the same result', function(){\n expect(1);\n\n var container = new Container();\n\n container.resolver = function() {\n return 'bar';\n };\n\n var Bar = container.resolve('models:bar');\n\n container.resolver = function() {\n return 'not bar';\n };\n\n equal(container.resolve('models:bar'), Bar);\n });\n });\ndefine(\"container/tests/sub_container_test\",\n [\"container/tests/container_helper\",\"container\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var factory = __dependency1__.factory;\n var o_create = __dependency1__.o_create;\n var setProperties = __dependency1__.setProperties;\n\n var Container = __dependency2__[\"default\"];\n var container;\n\n module(\"Container (sub-containers)\", {\n setup: function() {\n container = new Container();\n var PostController = factory();\n\n container.register('controller:post', PostController);\n },\n\n teardown: function() {\n if (!container.isDestroyed) {\n container.destroy();\n }\n }\n });\n\n test(\"Singletons already found on the parent container will be found again on the sub-container\", function() {\n var postController = container.lookup('controller:post');\n var subContainer = container.child();\n\n equal(postController, subContainer.lookup('controller:post'));\n });\n\n test(\"Destroying a sub-container doesn't destroy any singletons on the parent\", function() {\n var postController = container.lookup('controller:post');\n var subContainer = container.child();\n subContainer.destroy();\n\n equal(postController.isDestroyed, undefined, \"The parent's singletons are not destroyed\");\n });\n\n test(\"Looking up a singleton that wasn't yet looked up on a child container will cache it on the child\", function() {\n var subContainer1 = container.child();\n var subContainer2 = container.child();\n\n var postController1 = subContainer1.lookup('controller:post');\n var postController2 = subContainer2.lookup('controller:post');\n\n notEqual(postController1, postController2);\n });\n\n test(\"Destroying a parent container destroys the sub-containers\", function() {\n var subContainer1 = container.child();\n var subContainer2 = container.child();\n\n var postController1 = subContainer1.lookup('controller:post');\n var postController2 = subContainer2.lookup('controller:post');\n\n container.destroy();\n\n equal(postController1.isDestroyed, true, \"The child's singleton is destroyed\");\n equal(postController2.isDestroyed, true, \"The child's singleton is destroyed\");\n });\n\n test(\"Resolver is inherited from parent container\", function() {\n var otherController = factory();\n container.resolver = function(fullName) {\n return otherController;\n };\n var subContainer = container.child();\n\n equal(subContainer.resolve('controller:post'), otherController, 'should use parent resolver');\n equal(container.resolve('controller:post'), otherController, 'should use resolver');\n });\n\n test(\"Type injections should be inherited\", function() {\n var container = new Container();\n var PostController = factory();\n var Store = factory();\n\n container.register('controller:post', PostController);\n container.register('store:main', Store);\n\n container.typeInjection('controller', 'store', 'store:main');\n\n var store = container.lookup('store:main');\n\n var childContainer = container.child();\n var postController = childContainer.lookup('controller:post');\n\n equal(postController.store, store);\n });\n });\n})();\n//@ sourceURL=container/~tests/container");minispade.register('container/~tests/container_test', "(function() {minispade.require(\"container/~tests/container\");\nrequireModule(\"container/tests/container_test\");\nrequireModule(\"container/tests/sub_container_test\");\n})();\n//@ sourceURL=container/~tests/container_test");minispade.register('ember-application/~tests/ember-application', "(function() {define(\"ember-application/tests/system/application_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/array\",\"ember-metal/run_loop\",\"ember-application/system/application\",\"ember-application/system/resolver\",\"ember-routing/system/router\",\"ember-views/views/view\",\"ember-runtime/controllers/controller\",\"ember-routing/location/none_location\",\"ember-handlebars\",\"ember-runtime/system/object\",\"ember-routing/helpers/outlet\",\"ember-views/system/jquery\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__) {\n \"use strict\";\n /*globals EmberDev */\n\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var forEach = __dependency4__.forEach;\n var run = __dependency5__[\"default\"];\n var Application = __dependency6__[\"default\"];\n var DefaultResolver = __dependency7__.DefaultResolver;\n var Router = __dependency8__[\"default\"];\n var View = __dependency9__.View;\n var Controller = __dependency10__.Controller;\n var NoneLocation = __dependency11__[\"default\"];\n var EmberHandlebars = __dependency12__[\"default\"];\n var EmberObject = __dependency13__[\"default\"];\n var outletHelper = __dependency14__.outletHelper;\n\n var jQuery = __dependency15__[\"default\"];\n var trim = jQuery.trim;\n\n var view, app, application, originalLookup, originalDebug;\n\n module(\"Ember.Application\", {\n setup: function() {\n originalLookup = Ember.lookup;\n originalDebug = Ember.debug;\n\n jQuery(\"#qunit-fixture\").html(\"
HI
HI
\");\n run(function() {\n application = Application.create({ rootElement: '#one', router: null });\n });\n },\n\n teardown: function() {\n jQuery(\"#qunit-fixture\").empty();\n Ember.debug = originalDebug;\n\n Ember.lookup = originalLookup;\n\n if (application) {\n run(application, 'destroy');\n }\n\n if (app) {\n run(app, 'destroy');\n }\n }\n });\n\n test(\"you can make a new application in a non-overlapping element\", function() {\n run(function() {\n app = Application.create({ rootElement: '#two', router: null });\n });\n\n run(app, 'destroy');\n ok(true, \"should not raise\");\n });\n\n test(\"you cannot make a new application that is a parent of an existing application\", function() {\n expectAssertion(function() {\n run(function() {\n Application.create({ rootElement: '#qunit-fixture' });\n });\n });\n });\n\n test(\"you cannot make a new application that is a descendent of an existing application\", function() {\n expectAssertion(function() {\n run(function() {\n Application.create({ rootElement: '#one-child' });\n });\n });\n });\n\n test(\"you cannot make a new application that is a duplicate of an existing application\", function() {\n expectAssertion(function() {\n run(function() {\n Application.create({ rootElement: '#one' });\n });\n });\n });\n\n test(\"you cannot make two default applications without a rootElement error\", function() {\n expectAssertion(function() {\n run(function() {\n Application.create({ router: false });\n });\n });\n });\n\n test(\"acts like a namespace\", function() {\n var lookup = Ember.lookup = {}, app;\n\n run(function() {\n app = lookup.TestApp = Application.create({ rootElement: '#two', router: false });\n });\n\n Ember.BOOTED = false;\n app.Foo = EmberObject.extend();\n equal(app.Foo.toString(), \"TestApp.Foo\", \"Classes pick up their parent namespace\");\n });\n\n module(\"Ember.Application initialization\", {\n teardown: function() {\n if (app) {\n run(app, 'destroy');\n }\n Ember.TEMPLATES = {};\n }\n });\n\n test('initialized application go to initial route', function() {\n run(function() {\n app = Application.create({\n rootElement: '#qunit-fixture'\n });\n\n app.Router.reopen({\n location: 'none'\n });\n\n app.register('template:application',\n EmberHandlebars.compile(\"{{outlet}}\")\n );\n\n Ember.TEMPLATES.index = EmberHandlebars.compile(\n \"

Hi from index

\"\n );\n });\n\n equal(jQuery('#qunit-fixture h1').text(), \"Hi from index\");\n });\n\n test(\"initialize application via initialize call\", function() {\n run(function() {\n app = Application.create({\n rootElement: '#qunit-fixture'\n });\n\n app.Router.reopen({\n location: 'none'\n });\n\n app.ApplicationView = View.extend({\n template: function() { return \"

Hello!

\"; }\n });\n });\n\n // This is not a public way to access the container; we just\n // need to make some assertions about the created router\n var router = app.__container__.lookup('router:main');\n equal(router instanceof Router, true, \"Router was set from initialize call\");\n equal(router.location instanceof NoneLocation, true, \"Location was set from location implementation name\");\n });\n\n test(\"initialize application with stateManager via initialize call from Router class\", function() {\n run(function() {\n app = Application.create({\n rootElement: '#qunit-fixture'\n });\n\n app.Router.reopen({\n location: 'none'\n });\n\n app.register('template:application', function() {\n return \"

Hello!

\";\n });\n });\n\n var router = app.__container__.lookup('router:main');\n equal(router instanceof Router, true, \"Router was set from initialize call\");\n equal(jQuery(\"#qunit-fixture h1\").text(), \"Hello!\");\n });\n\n test(\"ApplicationView is inserted into the page\", function() {\n run(function() {\n app = Application.create({\n rootElement: '#qunit-fixture'\n });\n\n app.ApplicationView = View.extend({\n render: function(buffer) {\n buffer.push(\"

Hello!

\");\n }\n });\n\n app.ApplicationController = Controller.extend();\n\n app.Router.reopen({\n location: 'none'\n });\n });\n\n equal(jQuery(\"#qunit-fixture h1\").text(), \"Hello!\");\n });\n\n test(\"Minimal Application initialized with just an application template\", function() {\n jQuery('#qunit-fixture').html('');\n run(function () {\n app = Application.create({\n rootElement: '#qunit-fixture'\n });\n });\n\n equal(trim(jQuery('#qunit-fixture').text()), 'Hello World');\n });\n\n test('enable log of libraries with an ENV var', function() {\n if (EmberDev && EmberDev.runningProdBuild){\n ok(true, 'Logging does not occur in production builds');\n return;\n }\n\n var debug = Ember.debug;\n var messages = [];\n\n Ember.LOG_VERSION = true;\n\n Ember.debug = function(message) {\n messages.push(message);\n };\n\n Ember.libraries.register(\"my-lib\", \"2.0.0a\");\n\n run(function() {\n app = Application.create({\n rootElement: '#qunit-fixture'\n });\n });\n\n equal(messages[1], \"Ember : \" + Ember.VERSION);\n equal(messages[2], \"Handlebars : \" + EmberHandlebars.VERSION);\n equal(messages[3], \"jQuery : \" + jQuery().jquery);\n equal(messages[4], \"my-lib : \" + \"2.0.0a\");\n\n Ember.libraries.deRegister(\"my-lib\");\n Ember.LOG_VERSION = false;\n Ember.debug = debug;\n });\n\n test('disable log version of libraries with an ENV var', function() {\n var logged = false;\n\n Ember.LOG_VERSION = false;\n\n Ember.debug = function(message) {\n logged = true;\n };\n\n jQuery(\"#qunit-fixture\").empty();\n\n run(function() {\n app = Application.create({\n rootElement: '#qunit-fixture'\n });\n\n app.Router.reopen({\n location: 'none'\n });\n });\n\n ok(!logged, 'library version logging skipped');\n });\n\n test(\"can resolve custom router\", function(){\n var CustomRouter = Router.extend();\n\n var CustomResolver = DefaultResolver.extend({\n resolveOther: function(parsedName){\n if (parsedName.type === \"router\") {\n return CustomRouter;\n } else {\n return this._super(parsedName);\n }\n }\n });\n\n app = run(function(){\n return Application.create({\n Resolver: CustomResolver\n });\n });\n\n ok(app.__container__.lookup('router:main') instanceof CustomRouter, 'application resolved the correct router');\n });\n });\ndefine(\"ember-application/tests/system/controller_test\",\n [\"ember-runtime/controllers/controller\",\"ember-application/ext/controller\",\"ember-runtime/system/container\",\"ember-runtime/system/native_array\",\"ember-runtime/controllers/array_controller\",\"ember-metal/computed\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n /*jshint newcap:false */\n\n var Controller = __dependency1__.Controller;\n\n var Container = __dependency3__[\"default\"];\n var A = __dependency4__.A;\n var ArrayController = __dependency5__[\"default\"];\n var computed = __dependency6__.computed;\n\n module(\"Controller dependencies\");\n\n test(\"If a controller specifies a dependency, but does not have a container it should error\", function(){\n var AController = Controller.extend({\n needs: 'posts'\n });\n\n expectAssertion(function(){\n AController.create();\n }, /specifies `needs`, but does not have a container. Please ensure this controller was instantiated with a container./);\n });\n\n test(\"If a controller specifies a dependency, it is accessible\", function() {\n var container = new Container();\n\n container.register('controller:post', Controller.extend({\n needs: 'posts'\n }));\n\n container.register('controller:posts', Controller.extend());\n\n var postController = container.lookup('controller:post'),\n postsController = container.lookup('controller:posts');\n\n equal(postsController, postController.get('controllers.posts'), \"controller.posts must be auto synthesized\");\n });\n\n test(\"If a controller specifies an unavailable dependency, it raises\", function() {\n var container = new Container();\n\n container.register('controller:post', Controller.extend({\n needs: ['comments']\n }));\n\n throws(function() {\n container.lookup('controller:post');\n }, /controller:comments/);\n\n container.register('controller:blog', Controller.extend({\n needs: ['posts', 'comments']\n }));\n\n throws(function() {\n container.lookup('controller:blog');\n }, /controller:posts, controller:comments/);\n });\n\n test(\"Mixin sets up controllers if there is needs before calling super\", function() {\n var container = new Container();\n\n container.register('controller:other', ArrayController.extend({\n needs: 'posts',\n content: computed.alias('controllers.posts')\n }));\n\n container.register('controller:another', ArrayController.extend({\n needs: 'posts',\n contentBinding: 'controllers.posts'\n }));\n\n container.register('controller:posts', ArrayController.extend());\n\n container.lookup('controller:posts').set('content', A(['a','b','c']));\n\n deepEqual(['a','b','c'], container.lookup('controller:other').toArray());\n deepEqual(['a','b','c'], container.lookup('controller:another').toArray());\n });\n\n test(\"raises if trying to get a controller that was not pre-defined in `needs`\", function() {\n var container = new Container();\n\n container.register('controller:foo', Controller.extend());\n container.register('controller:bar', Controller.extend({\n needs: 'foo'\n }));\n\n var fooController = container.lookup('controller:foo');\n var barController = container.lookup('controller:bar');\n\n throws(function(){\n fooController.get('controllers.bar');\n }, /#needs does not include `bar`/,\n 'throws if controllers is accesed but needs not defined');\n\n equal(barController.get('controllers.foo'), fooController, 'correctly needed controllers should continue to work');\n\n throws(function(){\n barController.get('controllers.baz');\n }, /#needs does not include `baz`/,\n 'should throw if no such controller was needed');\n });\n\n test (\"setting the value of a controller dependency should not be possible\", function(){\n var container = new Container();\n\n container.register('controller:post', Controller.extend({\n needs: 'posts'\n }));\n\n container.register('controller:posts', Controller.extend());\n\n var postController = container.lookup('controller:post'),\n postsController = container.lookup('controller:posts');\n\n throws(function(){\n postController.set('controllers.posts', 'epic-self-troll');\n },\n /You cannot overwrite the value of `controllers.posts` of .+/,\n 'should raise when attempting to set the value of a controller dependency property');\n\n postController.set('controllers.posts.title', \"A Troll's Life\");\n equal(postController.get('controllers.posts.title'), \"A Troll's Life\", \"can set the value of controllers.posts.title\");\n });\n\n test(\"raises if a dependency with a period is requested\", function() {\n var container = new Container();\n\n container.register('controller:big.bird', Controller.extend());\n container.register('controller:foo', Controller.extend({\n needs: 'big.bird'\n }));\n\n expectAssertion(function() {\n container.lookup('controller:foo');\n }, /needs must not specify dependencies with periods in their names \\(big\\.bird\\)/,\n 'throws if periods used');\n });\n\n test(\"can unit test controllers with `needs` dependencies by stubbing their `controllers` properties\", function() {\n expect(1);\n\n var BrotherController = Controller.extend({\n needs: 'sister',\n foo: computed.alias('controllers.sister.foo')\n });\n\n var broController = BrotherController.create({\n controllers: {\n sister: { foo: 5 }\n }\n });\n\n equal(broController.get('foo'), 5, \"`needs` dependencies can be stubbed\");\n });\n });\ndefine(\"ember-application/tests/system/dependency_injection/custom_resolver_test\",\n [\"ember-views/system/jquery\",\"ember-metal/run_loop\",\"ember-application/system/application\",\"ember-application/system/resolver\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var jQuery = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var Application = __dependency3__[\"default\"];\n var DefaultResolver = __dependency4__.DefaultResolver;\n\n var application;\n\n module(\"Ember.Application Depedency Injection – customResolver\",{\n setup: function() {\n function fallbackTemplate() { return \"

Fallback

\"; }\n\n var Resolver = DefaultResolver.extend({\n resolveTemplate: function(resolvable) {\n var resolvedTemplate = this._super(resolvable);\n if (resolvedTemplate) { return resolvedTemplate; }\n return fallbackTemplate;\n }\n });\n\n application = run(function() {\n return Application.create({\n Resolver: Resolver,\n rootElement: '#qunit-fixture'\n\n });\n });\n },\n teardown: function() {\n run(application, 'destroy');\n }\n });\n\n test(\"a resolver can be supplied to application\", function() {\n equal(jQuery(\"h1\", application.rootElement).text(), \"Fallback\");\n });\n });\ndefine(\"ember-application/tests/system/dependency_injection/default_resolver_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-metal/logger\",\"ember-runtime/controllers/controller\",\"ember-runtime/system/object\",\"ember-handlebars\",\"ember-runtime/system/namespace\",\"ember-application/system/application\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // Ember.TEMPLATES\n var run = __dependency2__[\"default\"];\n var Logger = __dependency3__[\"default\"];\n var Controller = __dependency4__.Controller;\n var EmberObject = __dependency5__[\"default\"];\n var EmberHandlebars = __dependency6__[\"default\"];\n var Namespace = __dependency7__[\"default\"];\n var Application = __dependency8__[\"default\"];\n\n var locator, application, lookup, originalLookup, originalLoggerInfo;\n\n module(\"Ember.Application Depedency Injection\", {\n setup: function() {\n originalLookup = Ember.lookup;\n application = run(Application, 'create');\n\n locator = application.__container__;\n originalLoggerInfo = Logger.info;\n },\n\n teardown: function() {\n Ember.TEMPLATES = {};\n Ember.lookup = originalLookup;\n run(application, 'destroy');\n var UserInterfaceNamespace = Namespace.NAMESPACES_BY_ID['UserInterface'];\n if (UserInterfaceNamespace) { run(UserInterfaceNamespace, 'destroy'); }\n\n Logger.info = originalLoggerInfo;\n }\n });\n\n test('the default resolver can look things up in other namespaces', function() {\n var UserInterface = Ember.lookup.UserInterface = Namespace.create();\n UserInterface.NavigationController = Controller.extend();\n\n var nav = locator.lookup('controller:userInterface/navigation');\n\n ok(nav instanceof UserInterface.NavigationController, \"the result should be an instance of the specified class\");\n });\n\n test('the default resolver looks up templates in Ember.TEMPLATES', function() {\n function fooTemplate() {}\n function fooBarTemplate() {}\n function fooBarBazTemplate() {}\n\n Ember.TEMPLATES['foo'] = fooTemplate;\n Ember.TEMPLATES['fooBar'] = fooBarTemplate;\n Ember.TEMPLATES['fooBar/baz'] = fooBarBazTemplate;\n\n equal(locator.lookup('template:foo'), fooTemplate, \"resolves template:foo\");\n equal(locator.lookup('template:fooBar'), fooBarTemplate, \"resolves template:foo_bar\");\n equal(locator.lookup('template:fooBar.baz'), fooBarBazTemplate, \"resolves template:foo_bar.baz\");\n });\n\n test('the default resolver looks up basic name as no prefix', function() {\n ok(Controller.detect(locator.lookup('controller:basic')), 'locator looksup correct controller');\n });\n\n function detectEqual(first, second, message) {\n ok(first.detect(second), message);\n }\n\n test('the default resolver looks up arbitrary types on the namespace', function() {\n application.FooManager = EmberObject.extend({});\n\n detectEqual(application.FooManager, locator.resolver('manager:foo'),\"looks up FooManager on application\");\n });\n\n test(\"the default resolver resolves models on the namespace\", function() {\n application.Post = EmberObject.extend({});\n\n detectEqual(application.Post, locator.lookupFactory('model:post'), \"looks up Post model on application\");\n });\n\n test(\"the default resolver resolves helpers from EmberHandlebars.helpers\", function(){\n function fooresolvertestHelper(){ return 'FOO'; }\n function barBazResolverTestHelper(){ return 'BAZ'; }\n EmberHandlebars.registerHelper('fooresolvertest', fooresolvertestHelper);\n EmberHandlebars.registerHelper('bar-baz-resolver-test', barBazResolverTestHelper);\n equal(fooresolvertestHelper, locator.lookup('helper:fooresolvertest'), \"looks up fooresolvertestHelper helper\");\n equal(barBazResolverTestHelper, locator.lookup('helper:bar-baz-resolver-test'), \"looks up barBazResolverTestHelper helper\");\n });\n\n test(\"the default resolver resolves container-registered helpers\", function(){\n function gooresolvertestHelper(){ return 'GOO'; }\n function gooGazResolverTestHelper(){ return 'GAZ'; }\n application.register('helper:gooresolvertest', gooresolvertestHelper);\n application.register('helper:goo-baz-resolver-test', gooGazResolverTestHelper);\n equal(gooresolvertestHelper, locator.lookup('helper:gooresolvertest'), \"looks up gooresolvertest helper\");\n equal(gooGazResolverTestHelper, locator.lookup('helper:goo-baz-resolver-test'), \"looks up gooGazResolverTestHelper helper\");\n });\n\n test(\"the default resolver throws an error if the fullName to resolve is invalid\", function(){\n raises(function(){ locator.resolve(undefined);}, TypeError, /Invalid fullName/ );\n raises(function(){ locator.resolve(null); }, TypeError, /Invalid fullName/ );\n raises(function(){ locator.resolve(''); }, TypeError, /Invalid fullName/ );\n raises(function(){ locator.resolve(''); }, TypeError, /Invalid fullName/ );\n raises(function(){ locator.resolve(':'); }, TypeError, /Invalid fullName/ );\n raises(function(){ locator.resolve('model'); }, TypeError, /Invalid fullName/ );\n raises(function(){ locator.resolve('model:'); }, TypeError, /Invalid fullName/ );\n raises(function(){ locator.resolve(':type'); }, TypeError, /Invalid fullName/ );\n });\n\n test(\"the default resolver logs hits if `LOG_RESOLVER` is set\", function() {\n expect(3);\n\n application.LOG_RESOLVER = true;\n application.ScoobyDoo = EmberObject.extend();\n application.toString = function() { return 'App'; };\n\n Logger.info = function(symbol, name, padding, lookupDescription) {\n equal(symbol, '[✓]', 'proper symbol is printed when a module is found');\n equal(name, 'doo:scooby', 'proper lookup value is logged');\n equal(lookupDescription, 'App.ScoobyDoo');\n };\n\n locator.resolve('doo:scooby');\n });\n\n test(\"the default resolver logs misses if `LOG_RESOLVER` is set\", function() {\n expect(3);\n\n application.LOG_RESOLVER = true;\n application.toString = function() { return 'App'; };\n\n Logger.info = function(symbol, name, padding, lookupDescription) {\n equal(symbol, '[ ]', 'proper symbol is printed when a module is not found');\n equal(name, 'doo:scooby', 'proper lookup value is logged');\n equal(lookupDescription, 'App.ScoobyDoo');\n };\n\n locator.resolve('doo:scooby');\n });\n\n test(\"doesn't log without LOG_RESOLVER\", function(){\n var infoCount = 0;\n\n application.ScoobyDoo = EmberObject.extend();\n\n Logger.info = function(symbol, name) {\n infoCount = infoCount + 1;\n };\n\n locator.resolve('doo:scooby');\n locator.resolve('doo:scrappy');\n equal(infoCount, 0, 'Logger.info should not be called if LOG_RESOLVER is not set');\n });\n });\ndefine(\"ember-application/tests/system/dependency_injection/normalization_test\",\n [\"ember-metal/run_loop\",\"ember-metal/array\",\"ember-application/system/application\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var forEach = __dependency2__.forEach;\n var Application = __dependency3__[\"default\"];\n\n var application, locator;\n\n module(\"Ember.Application Depedency Injection – normalization\", {\n setup: function() {\n application = run(Application, 'create');\n locator = application.__container__;\n },\n\n teardown: function() {\n run(application, 'destroy');\n }\n });\n\n test('normalization', function() {\n ok(locator.normalize, 'locator#normalize is present');\n\n equal(locator.normalize('foo:bar'), 'foo:bar');\n\n equal(locator.normalize('controller:posts'), 'controller:posts');\n equal(locator.normalize('controller:posts_index'), 'controller:postsIndex');\n equal(locator.normalize('controller:posts.index'), 'controller:postsIndex');\n equal(locator.normalize('controller:posts.post.index'), 'controller:postsPostIndex');\n equal(locator.normalize('controller:posts_post.index'), 'controller:postsPostIndex');\n equal(locator.normalize('controller:posts.post_index'), 'controller:postsPostIndex');\n equal(locator.normalize('controller:postsIndex'), 'controller:postsIndex');\n equal(locator.normalize('controller:blogPosts.index'), 'controller:blogPostsIndex');\n equal(locator.normalize('controller:blog/posts.index'), 'controller:blog/postsIndex');\n equal(locator.normalize('controller:blog/posts.post.index'), 'controller:blog/postsPostIndex');\n equal(locator.normalize('controller:blog/posts_post.index'), 'controller:blog/postsPostIndex');\n\n equal(locator.normalize('template:blog/posts_index'), 'template:blog/posts_index');\n });\n\n test('normalization is indempotent', function() {\n var examples = ['controller:posts', 'controller:posts.post.index', 'controller:blog/posts.post_index', 'template:foo_bar'];\n\n forEach.call(examples, function (example) {\n equal(locator.normalize(locator.normalize(example)), locator.normalize(example));\n });\n });\n });\ndefine(\"ember-application/tests/system/dependency_injection/to_string_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-application/system/application\",\"ember-runtime/system/object\",\"ember-application/system/resolver\",\"ember-metal/utils\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // lookup, etc\n var run = __dependency2__[\"default\"];\n var Application = __dependency3__[\"default\"];\n var EmberObject = __dependency4__[\"default\"];\n var DefaultResolver = __dependency5__.DefaultResolver;\n var guidFor = __dependency6__.guidFor;\n\n var originalLookup, App, originalModelInjections;\n\n module(\"Ember.Application Dependency Injection – toString\",{\n setup: function() {\n originalModelInjections = Ember.MODEL_FACTORY_INJECTIONS;\n Ember.MODEL_FACTORY_INJECTIONS = true;\n\n originalLookup = Ember.lookup;\n\n run(function(){\n App = Application.create();\n Ember.lookup = {\n App: App\n };\n });\n\n App.Post = EmberObject.extend();\n\n },\n\n teardown: function() {\n Ember.lookup = originalLookup;\n run(App, 'destroy');\n Ember.MODEL_FACTORY_INJECTIONS = originalModelInjections;\n }\n });\n\n test(\"factories\", function() {\n var PostFactory = App.__container__.lookupFactory('model:post');\n equal(PostFactory.toString(), 'App.Post', 'expecting the model to be post');\n });\n\n test(\"instances\", function() {\n var post = App.__container__.lookup('model:post');\n var guid = guidFor(post);\n\n equal(post.toString(), '', 'expecting the model to be post');\n });\n\n test(\"with a custom resolver\", function() {\n run(App,'destroy');\n\n run(function(){\n App = Application.create({\n Resolver: DefaultResolver.extend({\n makeToString: function(factory, fullName) {\n return fullName;\n }\n })\n });\n });\n\n App.__container__.register('model:peter', EmberObject.extend());\n\n var peter = App.__container__.lookup('model:peter');\n var guid = guidFor(peter);\n\n equal(peter.toString(), '', 'expecting the supermodel to be peter');\n });\n });\ndefine(\"ember-application/tests/system/dependency_injection_test\",\n [\"ember-metal/run_loop\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/array\",\"ember-runtime/system/object\",\"ember-application/system/application\",\"ember-runtime/system/container\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var forEach = __dependency4__.forEach;\n var EmberObject = __dependency5__[\"default\"];\n var Application = __dependency6__[\"default\"];\n var Container = __dependency7__[\"default\"];\n\n var EmberApplication = Application;\n\n var locator, originalLookup = Ember.lookup, lookup,\n application, originalModelInjections;\n\n module(\"Ember.Application Dependency Injection\", {\n setup: function() {\n originalModelInjections = Ember.MODEL_FACTORY_INJECTIONS;\n Ember.MODEL_FACTORY_INJECTIONS = true;\n\n application = run(EmberApplication, 'create');\n\n application.Person = EmberObject.extend({});\n application.Orange = EmberObject.extend({});\n application.Email = EmberObject.extend({});\n application.User = EmberObject.extend({});\n application.PostIndexController = EmberObject.extend({});\n\n application.register('model:person', application.Person, {singleton: false });\n application.register('model:user', application.User, {singleton: false });\n application.register('fruit:favorite', application.Orange);\n application.register('communication:main', application.Email, {singleton: false});\n application.register('controller:postIndex', application.PostIndexController, {singleton: true});\n\n locator = application.__container__;\n\n lookup = Ember.lookup = {};\n },\n teardown: function() {\n run(application, 'destroy');\n application = locator = null;\n Ember.lookup = originalLookup;\n Ember.MODEL_FACTORY_INJECTIONS = originalModelInjections;\n }\n });\n\n test('container lookup is normalized', function() {\n var dotNotationController = locator.lookup('controller:post.index');\n var camelCaseController = locator.lookup('controller:postIndex');\n\n ok(dotNotationController instanceof application.PostIndexController);\n ok(camelCaseController instanceof application.PostIndexController);\n\n equal(dotNotationController, camelCaseController);\n });\n\n test('Container.defaultContainer is the same as the Apps container, but emits deprecation warnings', function() {\n expectDeprecation(/Using the defaultContainer is no longer supported./);\n var routerFromContainer = locator.lookup('router:main'),\n routerFromDefaultContainer = Container.defaultContainer.lookup('router:main');\n\n equal(routerFromContainer, routerFromDefaultContainer, 'routers from both containers are equal');\n });\n\n test('registered entities can be looked up later', function() {\n equal(locator.resolve('model:person'), application.Person);\n equal(locator.resolve('model:user'), application.User);\n equal(locator.resolve('fruit:favorite'), application.Orange);\n equal(locator.resolve('communication:main'), application.Email);\n equal(locator.resolve('controller:postIndex'), application.PostIndexController);\n\n equal(locator.lookup('fruit:favorite'), locator.lookup('fruit:favorite'), 'singleton lookup worked');\n ok(locator.lookup('model:user') !== locator.lookup('model:user'), 'non-singleton lookup worked');\n });\n\n\n test('injections', function() {\n application.inject('model', 'fruit', 'fruit:favorite');\n application.inject('model:user', 'communication', 'communication:main');\n\n var user = locator.lookup('model:user'),\n person = locator.lookup('model:person'),\n fruit = locator.lookup('fruit:favorite');\n\n equal(user.get('fruit'), fruit);\n equal(person.get('fruit'), fruit);\n\n ok(application.Email.detectInstance(user.get('communication')));\n });\n });\ndefine(\"ember-application/tests/system/initializers_test\",\n [\"ember-metal/run_loop\",\"ember-application/system/application\",\"ember-metal/array\",\"ember-views/system/jquery\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var Application = __dependency2__[\"default\"];\n var indexOf = __dependency3__.indexOf;\n var jQuery = __dependency4__[\"default\"];\n\n var oldInitializers, app;\n\n module(\"Ember.Application initializers\", {\n setup: function() {\n },\n\n teardown: function() {\n if (app) {\n run(function() { app.destroy(); });\n }\n }\n });\n\n test(\"initializers can be registered in a specified order\", function() {\n var order = [];\n var MyApplication = Application.extend();\n MyApplication.initializer({\n name: 'fourth',\n after: 'third',\n initialize: function(container) {\n order.push('fourth');\n }\n });\n\n MyApplication.initializer({\n name: 'second',\n before: 'third',\n initialize: function(container) {\n order.push('second');\n }\n });\n\n MyApplication.initializer({\n name: 'fifth',\n after: 'fourth',\n initialize: function(container) {\n order.push('fifth');\n }\n });\n\n MyApplication.initializer({\n name: 'first',\n before: 'second',\n initialize: function(container) {\n order.push('first');\n }\n });\n\n MyApplication.initializer({\n name: 'third',\n initialize: function(container) {\n order.push('third');\n }\n });\n\n run(function() {\n app = MyApplication.create({\n router: false,\n rootElement: '#qunit-fixture'\n });\n });\n\n deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth']);\n });\n\n test(\"initializers can have multiple dependencies\", function () {\n var order = [],\n a = {\n name: \"a\",\n before: \"b\",\n initialize: function(container) {\n order.push('a');\n }\n },\n b = {\n name: \"b\",\n initialize: function(container) {\n order.push('b');\n }\n },\n c = {\n name: \"c\",\n after: \"b\",\n initialize: function(container) {\n order.push('c');\n }\n },\n afterB = {\n name: \"after b\",\n after: \"b\",\n initialize: function(container) {\n order.push(\"after b\");\n }\n },\n afterC = {\n name: \"after c\",\n after: \"c\",\n initialize: function(container) {\n order.push(\"after c\");\n }\n };\n Application.initializer(b);\n Application.initializer(a);\n Application.initializer(afterC);\n Application.initializer(afterB);\n Application.initializer(c);\n\n run(function() {\n app = Application.create({\n router: false,\n rootElement: '#qunit-fixture'\n });\n });\n\n ok(indexOf.call(order, a.name) < indexOf.call(order, b.name), 'a < b');\n ok(indexOf.call(order, b.name) < indexOf.call(order, c.name), 'b < c');\n ok(indexOf.call(order, b.name) < indexOf.call(order, afterB.name), 'b < afterB');\n ok(indexOf.call(order, c.name) < indexOf.call(order, afterC.name), 'c < afterC');\n });\n\n test(\"initializers set on Application subclasses should not be shared between apps\", function(){\n var firstInitializerRunCount = 0, secondInitializerRunCount = 0;\n var FirstApp = Application.extend();\n FirstApp.initializer({\n name: 'first',\n initialize: function(container) {\n firstInitializerRunCount++;\n }\n });\n var SecondApp = Application.extend();\n SecondApp.initializer({\n name: 'second',\n initialize: function(container) {\n secondInitializerRunCount++;\n }\n });\n jQuery('#qunit-fixture').html('
');\n run(function() {\n var firstApp = FirstApp.create({\n router: false,\n rootElement: '#qunit-fixture #first'\n });\n });\n equal(firstInitializerRunCount, 1, 'first initializer only was run');\n equal(secondInitializerRunCount, 0, 'first initializer only was run');\n run(function() {\n var secondApp = SecondApp.create({\n router: false,\n rootElement: '#qunit-fixture #second'\n });\n });\n equal(firstInitializerRunCount, 1, 'second initializer only was run');\n equal(secondInitializerRunCount, 1, 'second initializer only was run');\n });\n\n test(\"initializers are concatenated\", function(){\n var firstInitializerRunCount = 0, secondInitializerRunCount = 0;\n var FirstApp = Application.extend();\n FirstApp.initializer({\n name: 'first',\n initialize: function(container) {\n firstInitializerRunCount++;\n }\n });\n\n var SecondApp = FirstApp.extend();\n SecondApp.initializer({\n name: 'second',\n initialize: function(container) {\n secondInitializerRunCount++;\n }\n });\n\n jQuery('#qunit-fixture').html('
');\n run(function() {\n var firstApp = FirstApp.create({\n router: false,\n rootElement: '#qunit-fixture #first'\n });\n });\n equal(firstInitializerRunCount, 1, 'first initializer only was run when base class created');\n equal(secondInitializerRunCount, 0, 'first initializer only was run when base class created');\n firstInitializerRunCount = 0;\n run(function() {\n var secondApp = SecondApp.create({\n router: false,\n rootElement: '#qunit-fixture #second'\n });\n });\n equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created');\n equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created');\n });\n\n test(\"initializers are per-app\", function(){\n expect(0);\n var FirstApp = Application.extend();\n FirstApp.initializer({\n name: 'shouldNotCollide',\n initialize: function(container) {}\n });\n\n var SecondApp = Application.extend();\n SecondApp.initializer({\n name: 'shouldNotCollide',\n initialize: function(container) {}\n });\n });\n });\ndefine(\"ember-application/tests/system/logging_test\",\n [\"ember-metal/run_loop\",\"ember-application/system/application\",\"ember-views/views/view\",\"ember-runtime/controllers/controller\",\"ember-routing/system/route\",\"ember-runtime/ext/rsvp\",\"ember-runtime/keys\",\"ember-routing\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n /*globals EmberDev */\n\n var run = __dependency1__[\"default\"];\n var Application = __dependency2__[\"default\"];\n var View = __dependency3__.View;\n var Controller = __dependency4__.Controller;\n var Route = __dependency5__[\"default\"];\n var RSVP = __dependency6__[\"default\"];\n var keys = __dependency7__[\"default\"];\n\n\n var App, logs, originalLogger;\n\n module(\"Ember.Application – logging of generated classes\", {\n setup: function() {\n logs = {};\n\n originalLogger = Ember.Logger.info;\n\n Ember.Logger.info = function() {\n var fullName = arguments[1].fullName;\n\n logs[fullName] = logs[fullName] || 0;\n logs[fullName]++;\n };\n\n run(function() {\n App = Application.create({\n LOG_ACTIVE_GENERATION: true\n });\n\n App.Router.reopen({\n location: 'none'\n });\n\n App.Router.map(function() {\n this.resource(\"posts\");\n });\n\n App.deferReadiness();\n });\n },\n\n teardown: function() {\n Ember.Logger.info = originalLogger;\n\n run(App, 'destroy');\n\n logs = App = null;\n }\n });\n\n function visit(path) {\n QUnit.stop();\n\n var promise = run(function(){\n return new RSVP.Promise(function(resolve, reject){\n var router = App.__container__.lookup('router:main');\n\n resolve(router.handleURL(path).then(function(value){\n QUnit.start();\n ok(true, 'visited: `' + path + '`');\n return value;\n }, function(reason) {\n QUnit.start();\n ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason));\n throw reason;\n }));\n });\n });\n\n return {\n then: function(resolve, reject) {\n run(promise, 'then', resolve, reject);\n }\n };\n }\n\n test(\"log class generation if logging enabled\", function() {\n if (EmberDev && EmberDev.runningProdBuild){\n ok(true, 'Logging does not occur in production builds');\n return;\n }\n\n run(App, 'advanceReadiness');\n\n visit('/posts').then(function() {\n equal(keys(logs).length, 6, 'expected logs');\n });\n });\n\n test(\"do NOT log class generation if logging disabled\", function() {\n App.reopen({\n LOG_ACTIVE_GENERATION: false\n });\n\n run(App, 'advanceReadiness');\n\n visit('/posts').then(function() {\n equal(keys(logs).length, 0, 'expected no logs');\n });\n });\n\n test(\"actively generated classes get logged\", function() {\n if (EmberDev && EmberDev.runningProdBuild){\n ok(true, 'Logging does not occur in production builds');\n return;\n }\n\n run(App, 'advanceReadiness');\n\n visit('/posts').then(function() {\n equal(logs['controller:application'], 1, 'expected: ApplicationController was generated');\n equal(logs['controller:posts'], 1, 'expected: PostsController was generated');\n\n equal(logs['route:application'], 1, 'expected: ApplicationRoute was generated');\n equal(logs['route:posts'], 1, 'expected: PostsRoute was generated');\n });\n });\n\n test(\"predefined classes do not get logged\", function() {\n App.ApplicationController = Controller.extend();\n App.PostsController = Controller.extend();\n\n App.ApplicationRoute = Route.extend();\n App.PostsRoute = Route.extend();\n\n run(App, 'advanceReadiness');\n\n visit('/posts').then(function() {\n ok(!logs['controller:application'], 'did not expect: ApplicationController was generated');\n ok(!logs['controller:posts'], 'did not expect: PostsController was generated');\n\n ok(!logs['route:application'], 'did not expect: ApplicationRoute was generated');\n ok(!logs['route:posts'], 'did not expect: PostsRoute was generated');\n });\n });\n\n module(\"Ember.Application – logging of view lookups\", {\n setup: function() {\n logs = {};\n\n originalLogger = Ember.Logger.info;\n\n Ember.Logger.info = function() {\n var fullName = arguments[1].fullName;\n\n logs[fullName] = logs[fullName] || 0;\n logs[fullName]++;\n };\n\n run(function() {\n App = Application.create({\n LOG_VIEW_LOOKUPS: true\n });\n\n App.Router.reopen({\n location: 'none'\n });\n\n App.Router.map(function() {\n this.resource(\"posts\");\n });\n\n App.deferReadiness();\n });\n },\n\n teardown: function() {\n Ember.Logger.info = originalLogger;\n\n run(App, 'destroy');\n\n logs = App = null;\n }\n });\n\n test(\"log when template and view are missing when flag is active\", function() {\n if (EmberDev && EmberDev.runningProdBuild){\n ok(true, 'Logging does not occur in production builds');\n return;\n }\n\n App.register('template:application', function() { return ''; });\n run(App, 'advanceReadiness');\n\n visit('/posts').then(function() {\n equal(logs['template:application'], undefined, 'expected: Should not log template:application since it exists.');\n equal(logs['template:index'], 1, 'expected: Could not find \"index\" template or view.');\n equal(logs['template:posts'], 1, 'expected: Could not find \"posts\" template or view.');\n });\n });\n\n test(\"do not log when template and view are missing when flag is not true\", function() {\n App.reopen({\n LOG_VIEW_LOOKUPS: false\n });\n\n run(App, 'advanceReadiness');\n\n visit('/posts').then(function() {\n equal(keys(logs).length, 0, 'expected no logs');\n });\n });\n\n test(\"log which view is used with a template\", function() {\n if (EmberDev && EmberDev.runningProdBuild){\n ok(true, 'Logging does not occur in production builds');\n return;\n }\n\n App.register('template:application', function() { return 'Template with default view'; });\n App.register('template:foo', function() { return 'Template with custom view'; });\n App.register('view:posts', View.extend({templateName: 'foo'}));\n run(App, 'advanceReadiness');\n\n visit('/posts').then(function() {\n equal(logs['view:application'], 1, 'expected: Should log use of default view');\n equal(logs['view:index'], undefined, 'expected: Should not log when index is not present.');\n equal(logs['view:posts'], 1, 'expected: Rendering posts with PostsView.');\n });\n });\n\n test(\"do not log which views are used with templates when flag is not true\", function() {\n App.reopen({\n LOG_VIEW_LOOKUPS: false\n });\n\n run(App, 'advanceReadiness');\n\n visit('/posts').then(function() {\n equal(keys(logs).length, 0, 'expected no logs');\n });\n });\n });\ndefine(\"ember-application/tests/system/readiness_test\",\n [\"ember-metal/run_loop\",\"ember-application/system/application\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var Application = __dependency2__[\"default\"];\n var EmberApplication = Application;\n\n var jQuery, application;\n var readyWasCalled, domReady, readyCallbacks;\n\n // We are using a small mock of jQuery because jQuery is third-party code with\n // very well-defined semantics, and we want to confirm that a jQuery stub run\n // in a more minimal server environment that implements this behavior will be\n // sufficient for Ember's requirements.\n\n module(\"Application readiness\", {\n setup: function() {\n readyWasCalled = 0;\n readyCallbacks = [];\n\n var jQueryInstance = {\n ready: function(callback) {\n readyCallbacks.push(callback);\n if (jQuery.isReady) {\n domReady();\n }\n }\n };\n\n jQuery = function() {\n return jQueryInstance;\n };\n jQuery.isReady = false;\n\n var domReadyCalled = 0;\n domReady = function() {\n if (domReadyCalled !== 0) { return; }\n domReadyCalled++;\n var i;\n for (i=0; itemplate was called\"));\n\n view = EmberView.create({\n container: container,\n templateName: 'testTemplate'\n });\n\n appendView();\n\n ok(view.$('#twas-called').length, \"the named template was called\");\n });\n\n test(\"template view should call the function of the associated template with itself as the context\", function() {\n container.register('template:testTemplate', EmberHandlebars.compile(\"

template was called for {{view.personName}}. Yea {{view.personName}}

\"));\n\n view = EmberView.createWithMixins({\n container: container,\n templateName: 'testTemplate',\n\n _personName: \"Tom DAAAALE\",\n _i: 0,\n\n personName: computed(function() {\n this._i++;\n return this._personName + this._i;\n })\n });\n\n appendView();\n\n equal(\"template was called for Tom DAAAALE1. Yea Tom DAAAALE1\", view.$('#twas-called').text(), \"the named template was called with the view as the data source\");\n });\n\n test(\"should allow values from normal JavaScript hash objects to be used\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#with view.person}}{{firstName}} {{lastName}} (and {{pet.name}}){{/with}}'),\n\n person: {\n firstName: 'Señor',\n lastName: 'CFC',\n pet: {\n name: 'Fido'\n }\n }\n });\n\n appendView();\n\n equal(view.$().text(), \"Señor CFC (and Fido)\", \"prints out values from a hash\");\n });\n\n test(\"htmlSafe should return an instance of Handlebars.SafeString\", function() {\n var safeString = htmlSafe(\"you need to be more bold\");\n\n ok(safeString instanceof Handlebars.SafeString, \"should return SafeString\");\n });\n\n test(\"should escape HTML in normal mustaches\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{view.output}}'),\n output: \"you need to be more bold\"\n });\n\n appendView();\n equal(view.$('b').length, 0, \"does not create an element\");\n equal(view.$().text(), 'you need to be more bold', \"inserts entities, not elements\");\n\n run(function() { set(view, 'output', \"you are so super\"); });\n equal(view.$().text(), 'you are so super', \"updates with entities, not elements\");\n equal(view.$('i').length, 0, \"does not create an element when value is updated\");\n });\n\n test(\"should not escape HTML in triple mustaches\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{{view.output}}}'),\n output: \"you need to be more bold\"\n });\n\n appendView();\n\n equal(view.$('b').length, 1, \"creates an element\");\n\n run(function() {\n set(view, 'output', \"you are so super\");\n });\n\n equal(view.$('i').length, 1, \"creates an element when value is updated\");\n });\n\n test(\"should not escape HTML if string is a Handlebars.SafeString\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{view.output}}'),\n output: new Handlebars.SafeString(\"you need to be more bold\")\n });\n\n appendView();\n\n equal(view.$('b').length, 1, \"creates an element\");\n\n run(function() {\n set(view, 'output', new Handlebars.SafeString(\"you are so super\"));\n });\n\n equal(view.$('i').length, 1, \"creates an element when value is updated\");\n });\n\n test(\"child views can be inserted using the {{view}} Handlebars helper\", function() {\n container.register('template:nester', EmberHandlebars.compile(\"

Hello {{world}}

{{view \\\"TemplateTests.LabelView\\\"}}\"));\n container.register('template:nested', EmberHandlebars.compile(\"
Goodbye {{cruel}} {{world}}
\"));\n\n var context = {\n world: \"world!\"\n };\n\n TemplateTests.LabelView = EmberView.extend({\n container: container,\n tagName: \"aside\",\n templateName: 'nested'\n });\n\n view = EmberView.create({\n container: container,\n templateName: 'nester',\n context: context\n });\n\n set(context, 'cruel', \"cruel\");\n\n appendView();\n\n ok(view.$(\"#hello-world:contains('Hello world!')\").length, \"The parent view renders its contents\");\n ok(view.$(\"#child-view:contains('Goodbye cruel world!')\").length === 1, \"The child view renders its content once\");\n ok(view.$().text().match(/Hello world!.*Goodbye cruel world\\!/), \"parent view should appear before the child view\");\n });\n\n test(\"should accept relative paths to views\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('Hey look, at {{view \"view.myCool.view\"}}'),\n\n myCool: EmberObject.create({\n view: EmberView.extend({\n template: EmberHandlebars.compile(\"my cool view\")\n })\n })\n });\n\n appendView();\n\n equal(view.$().text(), \"Hey look, at my cool view\");\n });\n\n test(\"child views can be inserted inside a bind block\", function() {\n container.register('template:nester', EmberHandlebars.compile(\"

Hello {{world}}

{{view \\\"TemplateTests.BQView\\\"}}\"));\n container.register('template:nested', EmberHandlebars.compile(\"
Goodbye {{#with content}}{{blah}} {{view \\\"TemplateTests.OtherView\\\"}}{{/with}} {{world}}
\"));\n container.register('template:other', EmberHandlebars.compile(\"cruel\"));\n\n var context = {\n world: \"world!\"\n };\n\n TemplateTests.BQView = EmberView.extend({\n container: container,\n tagName: \"blockquote\",\n templateName: 'nested'\n });\n\n TemplateTests.OtherView = EmberView.extend({\n container: container,\n templateName: 'other'\n });\n\n view = EmberView.create({\n container: container,\n context: context,\n templateName: 'nester'\n });\n\n set(context, 'content', EmberObject.create({ blah: \"wot\" }));\n\n appendView();\n\n ok(view.$(\"#hello-world:contains('Hello world!')\").length, \"The parent view renders its contents\");\n\n ok(view.$(\"blockquote\").text().match(/Goodbye.*wot.*cruel.*world\\!/), \"The child view renders its content once\");\n ok(view.$().text().match(/Hello world!.*Goodbye.*wot.*cruel.*world\\!/), \"parent view should appear before the child view\");\n });\n\n test(\"View should bind properties in the parent context\", function() {\n var context = {\n content: EmberObject.create({\n wham: 'bam'\n }),\n\n blam: \"shazam\"\n };\n\n view = EmberView.create({\n context: context,\n template: EmberHandlebars.compile('

{{#with content}}{{wham}}-{{../blam}}{{/with}}

')\n });\n\n appendView();\n\n equal(view.$('#first').text(), \"bam-shazam\", \"renders parent properties\");\n });\n\n test(\"using Handlebars helper that doesn't exist should result in an error\", function() {\n var names = [{ name: 'Alex' }, { name: 'Stef' }],\n context = {\n content: A(names)\n };\n\n throws(function() {\n view = EmberView.create({\n context: context,\n template: EmberHandlebars.compile('{{#group}}{{#each name in content}}{{name}}{{/each}}{{/group}}')\n });\n\n appendView();\n }, \"Missing helper: 'group'\");\n });\n\n test(\"View should bind properties in the grandparent context\", function() {\n var context = {\n content: EmberObject.create({\n wham: 'bam',\n thankYou: EmberObject.create({\n value: \"ma'am\"\n })\n }),\n\n blam: \"shazam\"\n };\n\n view = EmberView.create({\n context: context,\n template: EmberHandlebars.compile('

{{#with content}}{{#with thankYou}}{{value}}-{{../wham}}-{{../../blam}}{{/with}}{{/with}}

')\n });\n\n appendView();\n\n equal(view.$('#first').text(), \"ma'am-bam-shazam\", \"renders grandparent properties\");\n });\n\n test(\"View should update when a property changes and the bind helper is used\", function() {\n container.register('template:foo', EmberHandlebars.compile('

{{#with view.content}}{{bind \"wham\"}}{{/with}}

'));\n\n view = EmberView.create({\n container: container,\n templateName: 'foo',\n\n content: EmberObject.create({\n wham: 'bam',\n thankYou: \"ma'am\"\n })\n });\n\n appendView();\n\n equal(view.$('#first').text(), \"bam\", \"precond - view renders Handlebars template\");\n\n run(function() { set(get(view, 'content'), 'wham', 'bazam'); });\n equal(view.$('#first').text(), \"bazam\", \"view updates when a bound property changes\");\n });\n\n test(\"View should not use keyword incorrectly - Issue #1315\", function() {\n container.register('template:foo', EmberHandlebars.compile('{{#each value in view.content}}{{value}}-{{#each option in view.options}}{{option.value}}:{{option.label}} {{/each}}{{/each}}'));\n\n view = EmberView.create({\n container: container,\n templateName: 'foo',\n\n content: A(['X', 'Y']),\n options: A([\n { label: 'One', value: 1 },\n { label: 'Two', value: 2 }\n ])\n });\n\n appendView();\n\n equal(view.$().text(), 'X-1:One 2:Two Y-1:One 2:Two ');\n });\n\n test(\"View should update when a property changes and no bind helper is used\", function() {\n container.register('template:foo', EmberHandlebars.compile('

{{#with view.content}}{{wham}}{{/with}}

'));\n\n var templates = EmberObject.create({\n foo: EmberHandlebars.compile('

{{#with view.content}}{{wham}}{{/with}}

')\n });\n\n view = EmberView.create({\n container: container,\n templateName: 'foo',\n\n content: EmberObject.create({\n wham: 'bam',\n thankYou: \"ma'am\"\n })\n });\n\n appendView();\n\n equal(view.$('#first').text(), \"bam\", \"precond - view renders Handlebars template\");\n\n run(function() { set(get(view, 'content'), 'wham', 'bazam'); });\n\n equal(view.$('#first').text(), \"bazam\", \"view updates when a bound property changes\");\n });\n\n test(\"View should update when the property used with the #with helper changes\", function() {\n container.register('template:foo', EmberHandlebars.compile('

{{#with view.content}}{{wham}}{{/with}}

'));\n\n view = EmberView.create({\n container: container,\n templateName: 'foo',\n\n content: EmberObject.create({\n wham: 'bam',\n thankYou: \"ma'am\"\n })\n });\n\n appendView();\n\n equal(view.$('#first').text(), \"bam\", \"precond - view renders Handlebars template\");\n\n run(function() {\n set(view, 'content', EmberObject.create({\n wham: 'bazam'\n }));\n });\n\n equal(view.$('#first').text(), \"bazam\", \"view updates when a bound property changes\");\n });\n\n test(\"should not update when a property is removed from the view\", function() {\n container.register('template:foo', EmberHandlebars.compile('

{{#bind \"view.content\"}}{{#bind \"foo\"}}{{bind \"baz\"}}{{/bind}}{{/bind}}

'));\n\n view = EmberView.create({\n container: container,\n templateName: 'foo',\n\n content: EmberObject.create({\n foo: EmberObject.create({\n baz: \"unicorns\"\n })\n })\n });\n\n appendView();\n\n equal(view.$('#first').text(), \"unicorns\", \"precond - renders the bound value\");\n\n var oldContent = get(view, 'content');\n\n run(function() {\n set(view, 'content', EmberObject.create({\n foo: EmberObject.create({\n baz: \"ninjas\"\n })\n }));\n });\n\n equal(view.$('#first').text(), 'ninjas', \"updates to new content value\");\n\n run(function() {\n set(oldContent, 'foo.baz', 'rockstars');\n });\n\n run(function() {\n set(oldContent, 'foo.baz', 'ewoks');\n });\n\n equal(view.$('#first').text(), \"ninjas\", \"does not update removed object\");\n });\n\n test(\"Handlebars templates update properties if a content object changes\", function() {\n container.register('template:menu', EmberHandlebars.compile('

Today\\'s Menu

{{#bind \"view.coffee\"}}

{{color}} coffee

{{bind \"price\"}}{{/bind}}'));\n\n run(function() {\n view = EmberView.create({\n container: container,\n templateName: 'menu',\n\n coffee: EmberObject.create({\n color: 'brown',\n price: '$4'\n })\n });\n });\n\n appendView();\n\n equal(view.$('h2').text(), \"brown coffee\", \"precond - renders color correctly\");\n equal(view.$('#price').text(), '$4', \"precond - renders price correctly\");\n\n run(function() {\n set(view, 'coffee', EmberObject.create({\n color: \"mauve\",\n price: \"$4.50\"\n }));\n });\n\n equal(view.$('h2').text(), \"mauve coffee\", \"should update name field when content changes\");\n equal(view.$('#price').text(), \"$4.50\", \"should update price field when content changes\");\n\n run(function() {\n set(view, 'coffee', EmberObject.create({\n color: \"mauve\",\n price: \"$5.50\"\n }));\n });\n\n equal(view.$('h2').text(), \"mauve coffee\", \"should update name field when content changes\");\n equal(view.$('#price').text(), \"$5.50\", \"should update price field when content changes\");\n\n run(function() {\n set(view, 'coffee.price', \"$5\");\n });\n\n equal(view.$('#price').text(), \"$5\", \"should update price field when price property is changed\");\n\n run(function() {\n view.destroy();\n });\n });\n\n test(\"Template updates correctly if a path is passed to the bind helper\", function() {\n container.register('template:menu', EmberHandlebars.compile('

{{bind \"view.coffee.price\"}}

'));\n\n view = EmberView.create({\n container: container,\n templateName: 'menu',\n\n coffee: EmberObject.create({\n price: '$4'\n })\n });\n\n appendView();\n\n equal(view.$('h1').text(), \"$4\", \"precond - renders price\");\n\n run(function() {\n set(view, 'coffee.price', \"$5\");\n });\n\n equal(view.$('h1').text(), \"$5\", \"updates when property changes\");\n\n run(function() {\n set(view, 'coffee', { price: \"$6\" });\n });\n\n equal(view.$('h1').text(), \"$6\", \"updates when parent property changes\");\n });\n\n test(\"Template updates correctly if a path is passed to the bind helper and the context object is an ObjectController\", function() {\n container.register('template:menu', EmberHandlebars.compile('

{{bind \"view.coffee.price\"}}

'));\n\n var controller = ObjectController.create();\n\n var realObject = EmberObject.create({\n price: \"$4\"\n });\n\n set(controller, 'content', realObject);\n\n view = EmberView.create({\n container: container,\n templateName: 'menu',\n\n coffee: controller\n });\n\n appendView();\n\n equal(view.$('h1').text(), \"$4\", \"precond - renders price\");\n\n run(function() {\n set(realObject, 'price', \"$5\");\n });\n\n equal(view.$('h1').text(), \"$5\", \"updates when property is set on real object\");\n\n run(function() {\n set(controller, 'price', \"$6\" );\n });\n\n equal(view.$('h1').text(), \"$6\", \"updates when property is set on object controller\");\n });\n\n test(\"should update the block when object passed to #if helper changes\", function() {\n container.register('template:menu', EmberHandlebars.compile('

{{#if view.inception}}{{view.INCEPTION}}{{/if}}

'));\n\n view = EmberView.create({\n container: container,\n templateName: 'menu',\n\n INCEPTION: \"BOOOOOOOONG doodoodoodoodooodoodoodoo\",\n inception: 'OOOOoooooOOOOOOooooooo'\n });\n\n appendView();\n\n equal(view.$('h1').text(), \"BOOOOOOOONG doodoodoodoodooodoodoodoo\", \"renders block if a string\");\n\n var tests = [false, null, undefined, [], '', 0];\n\n forEach(tests, function(val) {\n run(function() {\n set(view, 'inception', val);\n });\n\n equal(view.$('h1').text(), '', fmt(\"hides block when conditional is '%@'\", [String(val)]));\n\n run(function() {\n set(view, 'inception', true);\n });\n\n equal(view.$('h1').text(), \"BOOOOOOOONG doodoodoodoodooodoodoodoo\", \"precond - renders block when conditional is true\");\n });\n });\n\n test(\"should update the block when object passed to #unless helper changes\", function() {\n container.register('template:advice', EmberHandlebars.compile('

{{#unless view.onDrugs}}{{view.doWellInSchool}}{{/unless}}

'));\n\n view = EmberView.create({\n container: container,\n templateName: 'advice',\n\n onDrugs: true,\n doWellInSchool: \"Eat your vegetables\"\n });\n\n appendView();\n\n equal(view.$('h1').text(), \"\", \"hides block if true\");\n\n var tests = [false, null, undefined, [], '', 0];\n\n forEach(tests, function(val) {\n run(function() {\n set(view, 'onDrugs', val);\n });\n\n equal(view.$('h1').text(), 'Eat your vegetables', fmt(\"renders block when conditional is '%@'; %@\", [String(val), typeOf(val)]));\n\n run(function() {\n set(view, 'onDrugs', true);\n });\n\n equal(view.$('h1').text(), \"\", \"precond - hides block when conditional is true\");\n });\n });\n\n test(\"should update the block when object passed to #if helper changes and an inverse is supplied\", function() {\n container.register('template:menu', EmberHandlebars.compile('

{{#if view.inception}}{{view.INCEPTION}}{{else}}{{view.SAD}}{{/if}}

'));\n\n view = EmberView.create({\n container: container,\n templateName: 'menu',\n\n INCEPTION: \"BOOOOOOOONG doodoodoodoodooodoodoodoo\",\n inception: false,\n SAD: 'BOONG?'\n });\n\n appendView();\n\n equal(view.$('h1').text(), \"BOONG?\", \"renders alternate if false\");\n\n run(function() { set(view, 'inception', true); });\n\n var tests = [false, null, undefined, [], '', 0];\n\n forEach(tests, function(val) {\n run(function() {\n set(view, 'inception', val);\n });\n\n equal(view.$('h1').text(), 'BOONG?', fmt(\"renders alternate if %@\", [String(val)]));\n\n run(function() {\n set(view, 'inception', true);\n });\n\n equal(view.$('h1').text(), \"BOOOOOOOONG doodoodoodoodooodoodoodoo\", \"precond - renders block when conditional is true\");\n });\n });\n\n test(\"edge case: child conditional should not render children if parent conditional becomes false\", function() {\n var childCreated = false;\n\n view = EmberView.create({\n cond1: true,\n cond2: false,\n viewClass: EmberView.extend({\n init: function() {\n this._super();\n childCreated = true;\n }\n }),\n template: EmberHandlebars.compile('{{#if view.cond1}}{{#if view.cond2}}{{#view view.viewClass}}test{{/view}}{{/if}}{{/if}}')\n });\n\n appendView();\n\n run(function() {\n // The order of these sets is important for the test\n view.set('cond2', true);\n view.set('cond1', false);\n });\n\n ok(!childCreated, 'child should not be created');\n });\n\n test(\"Template views return throw if their template cannot be found\", function() {\n view = EmberView.create({\n templateName: 'cantBeFound',\n container: { lookup: function() { }}\n });\n\n expectAssertion(function() {\n get(view, 'template');\n }, /cantBeFound/);\n });\n\n test(\"Layout views return throw if their layout cannot be found\", function() {\n view = EmberView.create({\n layoutName: 'cantBeFound'\n });\n\n expectAssertion(function() {\n get(view, 'layout');\n }, /cantBeFound/);\n });\n\n test(\"Template views add an elementId to child views created using the view helper\", function() {\n container.register('template:parent', EmberHandlebars.compile('
{{view \"TemplateTests.ChildView\"}}
'));\n container.register('template:child', EmberHandlebars.compile(\"I can't believe it's not butter.\"));\n\n TemplateTests.ChildView = EmberView.extend({\n container: container,\n templateName: 'child'\n });\n\n view = EmberView.create({\n container: container,\n templateName: 'parent'\n });\n\n appendView();\n var childView = get(view, 'childViews.firstObject');\n equal(view.$().children().first().children().first().attr('id'), get(childView, 'elementId'));\n });\n\n test(\"views set the template of their children to a passed block\", function() {\n container.register('template:parent', EmberHandlebars.compile('

{{#view \"TemplateTests.NoTemplateView\"}}It worked!{{/view}}

'));\n\n TemplateTests.NoTemplateView = EmberView.extend();\n\n view = EmberView.create({\n container: container,\n templateName: 'parent'\n });\n\n appendView();\n ok(view.$('h1:has(span)').length === 1, \"renders the passed template inside the parent template\");\n });\n\n test(\"views render their template in the context of the parent view's context\", function() {\n container.register('template:parent', EmberHandlebars.compile('

{{#with content}}{{#view}}{{firstName}} {{lastName}}{{/view}}{{/with}}

'));\n\n var context = {\n content: {\n firstName: \"Lana\",\n lastName: \"del Heeeyyyyyy\"\n }\n };\n\n view = EmberView.create({\n container: container,\n templateName: 'parent',\n context: context\n });\n\n appendView();\n equal(view.$('h1').text(), \"Lana del Heeeyyyyyy\", \"renders properties from parent context\");\n });\n\n test(\"views make a view keyword available that allows template to reference view context\", function() {\n container.register('template:parent', EmberHandlebars.compile('

{{#with view.content}}{{#view subview}}{{view.firstName}} {{lastName}}{{/view}}{{/with}}

'));\n\n view = EmberView.create({\n container: container,\n templateName: 'parent',\n\n content: {\n subview: EmberView.extend({\n firstName: \"Brodele\"\n }),\n firstName: \"Lana\",\n lastName: \"del Heeeyyyyyy\"\n }\n });\n\n appendView();\n equal(view.$('h1').text(), \"Brodele del Heeeyyyyyy\", \"renders properties from parent context\");\n });\n\n test(\"a view helper's bindings are to the parent context\", function() {\n var Subview = EmberView.extend({\n classNameBindings: ['color'],\n controller: EmberObject.create({\n color: 'green',\n name: \"bar\"\n }),\n template: EmberHandlebars.compile('{{view.someController.name}} {{name}}')\n });\n var View = EmberView.extend({\n controller: EmberObject.create({\n color: \"mauve\",\n name: 'foo'\n }),\n Subview: Subview,\n template: EmberHandlebars.compile('

{{view view.Subview colorBinding=\"color\" someControllerBinding=\"this\"}}

')\n });\n view = View.create();\n appendView();\n equal(view.$('h1 .mauve').length, 1, \"renders property on helper declaration from parent context\");\n equal(view.$('h1 .mauve').text(), \"foo bar\", \"renders property bound in template from subview context\");\n });\n\n // test(\"should warn if setting a template on a view with a templateName already specified\", function() {\n // view = EmberView.create({\n // childView: EmberView.extend({\n // templateName: 'foo'\n // }),\n\n // template: EmberHandlebars.compile('{{#view childView}}test{{/view}}')\n // });\n\n // expectAssertion(function() {\n // appendView();\n // }, \"Unable to find view at path 'childView'\");\n\n // run(function() {\n // view.destroy();\n // });\n\n // view = EmberView.create({\n // childView: EmberView.extend(),\n // template: EmberHandlebars.compile('{{#view childView templateName=\"foo\"}}test{{/view}}')\n // });\n\n // expectAssertion(function() {\n // appendView();\n // }, \"Unable to find view at path 'childView'\");\n // });\n\n test(\"Child views created using the view helper should have their parent view set properly\", function() {\n TemplateTests = {};\n\n var template = '{{#view \"Ember.View\"}}{{#view \"Ember.View\"}}{{view \"Ember.View\"}}{{/view}}{{/view}}';\n\n view = EmberView.create({\n template: EmberHandlebars.compile(template)\n });\n\n appendView();\n\n var childView = firstGrandchild(view);\n equal(childView, get(firstChild(childView), 'parentView'), 'parent view is correct');\n });\n\n test(\"Child views created using the view helper should have their IDs registered for events\", function() {\n TemplateTests = {};\n\n var template = '{{view \"Ember.View\"}}{{view \"Ember.View\" id=\"templateViewTest\"}}';\n\n view = EmberView.create({\n template: EmberHandlebars.compile(template)\n });\n\n appendView();\n\n var childView = firstChild(view);\n var id = childView.$()[0].id;\n equal(EmberView.views[id], childView, 'childView without passed ID is registered with View.views so that it can properly receive events from EventDispatcher');\n\n childView = nthChild(view, 1);\n id = childView.$()[0].id;\n equal(id, 'templateViewTest', 'precond -- id of childView should be set correctly');\n equal(EmberView.views[id], childView, 'childView with passed ID is registered with View.views so that it can properly receive events from EventDispatcher');\n });\n\n test(\"Child views created using the view helper and that have a viewName should be registered as properties on their parentView\", function() {\n TemplateTests = {};\n\n var template = '{{#view Ember.View}}{{view Ember.View viewName=\"ohai\"}}{{/view}}';\n\n view = EmberView.create({\n template: EmberHandlebars.compile(template)\n });\n\n appendView();\n\n var parentView = firstChild(view),\n childView = firstGrandchild(view);\n equal(get(parentView, 'ohai'), childView);\n });\n\n test(\"Collection views that specify an example view class have their children be of that class\", function() {\n TemplateTests.ExampleViewCollection = CollectionView.extend({\n itemViewClass: EmberView.extend({\n isCustom: true\n }),\n\n content: A(['foo'])\n });\n\n var parentView = EmberView.create({\n template: EmberHandlebars.compile('{{#collection \"TemplateTests.ExampleViewCollection\"}}OHAI{{/collection}}')\n });\n\n run(function() {\n parentView.append();\n });\n\n ok(firstGrandchild(parentView).isCustom, \"uses the example view class\");\n\n run(function() {\n parentView.destroy();\n });\n });\n\n test(\"itemViewClass works in the #collection helper\", function() {\n TemplateTests.ExampleController = ArrayProxy.create({\n content: A(['alpha'])\n });\n\n TemplateTests.ExampleItemView = EmberView.extend({\n isAlsoCustom: true\n });\n\n var parentView = EmberView.create({\n template: EmberHandlebars.compile('{{#collection contentBinding=\"TemplateTests.ExampleController\" itemViewClass=\"TemplateTests.ExampleItemView\"}}beta{{/collection}}')\n });\n\n run(function() {\n parentView.append();\n });\n\n ok(firstGrandchild(parentView).isAlsoCustom, \"uses the example view class specified in the #collection helper\");\n\n run(function() {\n parentView.destroy();\n });\n });\n\n test(\"itemViewClass works in the #collection helper relatively\", function() {\n TemplateTests.ExampleController = ArrayProxy.create({\n content: A(['alpha'])\n });\n\n TemplateTests.ExampleItemView = EmberView.extend({\n isAlsoCustom: true\n });\n\n TemplateTests.CollectionView = CollectionView.extend({\n possibleItemView: TemplateTests.ExampleItemView\n });\n\n var parentView = EmberView.create({\n template: EmberHandlebars.compile('{{#collection TemplateTests.CollectionView contentBinding=\"TemplateTests.ExampleController\" itemViewClass=\"possibleItemView\"}}beta{{/collection}}')\n });\n\n run(function() {\n parentView.append();\n });\n\n ok(firstGrandchild(parentView).isAlsoCustom, \"uses the example view class specified in the #collection helper\");\n\n run(function() {\n parentView.destroy();\n });\n });\n\n test(\"should update boundIf blocks if the conditional changes\", function() {\n container.register('template:foo', EmberHandlebars.compile('

{{#boundIf \"view.content.myApp.isEnabled\"}}{{view.content.wham}}{{/boundIf}}

'));\n\n view = EmberView.create({\n container: container,\n templateName: 'foo',\n\n content: EmberObject.create({\n wham: 'bam',\n thankYou: \"ma'am\",\n myApp: EmberObject.create({\n isEnabled: true\n })\n })\n });\n\n appendView();\n\n equal(view.$('#first').text(), \"bam\", \"renders block when condition is true\");\n\n run(function() {\n set(get(view, 'content'), 'myApp.isEnabled', false);\n });\n\n equal(view.$('#first').text(), \"\", \"re-renders without block when condition is false\");\n\n run(function() {\n set(get(view, 'content'), 'myApp.isEnabled', true);\n });\n\n equal(view.$('#first').text(), \"bam\", \"re-renders block when condition changes to true\");\n });\n\n test(\"should not update boundIf if truthiness does not change\", function() {\n var renderCount = 0;\n\n view = EmberView.create({\n template: EmberHandlebars.compile('

{{#boundIf \"view.shouldDisplay\"}}{{view view.InnerViewClass}}{{/boundIf}}

'),\n\n shouldDisplay: true,\n\n InnerViewClass: EmberView.extend({\n template: EmberHandlebars.compile(\"bam\"),\n\n render: function() {\n renderCount++;\n return this._super.apply(this, arguments);\n }\n })\n });\n\n appendView();\n\n equal(renderCount, 1, \"precond - should have rendered once\");\n equal(view.$('#first').text(), \"bam\", \"renders block when condition is true\");\n\n run(function() {\n set(view, 'shouldDisplay', 1);\n });\n\n equal(renderCount, 1, \"should not have rerendered\");\n equal(view.$('#first').text(), \"bam\", \"renders block when condition is true\");\n });\n\n test(\"boundIf should support parent access\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile(\n '

{{#with view.content}}{{#with thankYou}}'+\n '{{#boundIf ../view.show}}parent{{/boundIf}}-{{#boundIf ../../view.show}}grandparent{{/boundIf}}'+\n '{{/with}}{{/with}}

'\n ),\n\n content: EmberObject.create({\n show: true,\n thankYou: EmberObject.create()\n }),\n\n show: true\n });\n\n appendView();\n\n equal(view.$('#first').text(), \"parent-grandparent\", \"renders boundIfs using ..\");\n });\n\n test(\"{{view}} id attribute should set id on layer\", function() {\n container.register('template:foo', EmberHandlebars.compile('{{#view \"TemplateTests.IdView\" id=\"bar\"}}baz{{/view}}'));\n\n TemplateTests.IdView = EmberView;\n\n view = EmberView.create({\n container: container,\n templateName: 'foo'\n });\n\n appendView();\n\n equal(view.$('#bar').length, 1, \"adds id attribute to layer\");\n equal(view.$('#bar').text(), 'baz', \"emits content\");\n });\n\n test(\"{{view}} tag attribute should set tagName of the view\", function() {\n container.register('template:foo', EmberHandlebars.compile('{{#view \"TemplateTests.TagView\" tag=\"span\"}}baz{{/view}}'));\n\n TemplateTests.TagView = EmberView;\n\n view = EmberView.create({\n container: container,\n templateName: 'foo'\n });\n\n appendView();\n\n equal(view.$('span').length, 1, \"renders with tag name\");\n equal(view.$('span').text(), 'baz', \"emits content\");\n });\n\n test(\"{{view}} class attribute should set class on layer\", function() {\n container.register('template:foo', EmberHandlebars.compile('{{#view \"TemplateTests.IdView\" class=\"bar\"}}baz{{/view}}'));\n\n TemplateTests.IdView = EmberView;\n\n view = EmberView.create({\n container: container,\n templateName: 'foo'\n });\n\n appendView();\n\n equal(view.$('.bar').length, 1, \"adds class attribute to layer\");\n equal(view.$('.bar').text(), 'baz', \"emits content\");\n });\n\n test(\"{{view}} should not allow attributeBindings to be set\", function() {\n expectAssertion(function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{view \"Ember.View\" attributeBindings=\"one two\"}}')\n });\n appendView();\n }, /Setting 'attributeBindings' via Handlebars is not allowed/);\n });\n\n test(\"{{view}} should be able to point to a local view\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile(\"{{view view.common}}\"),\n\n common: EmberView.extend({\n template: EmberHandlebars.compile(\"common\")\n })\n });\n\n appendView();\n\n equal(view.$().text(), \"common\", \"tries to look up view name locally\");\n });\n\n test(\"{{view}} should evaluate class bindings set to global paths\", function() {\n var App;\n\n run(function() {\n lookup.App = App = Namespace.create({\n isApp: true,\n isGreat: true,\n directClass: \"app-direct\",\n isEnabled: true\n });\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{view Ember.TextField class=\"unbound\" classBinding=\"App.isGreat:great App.directClass App.isApp App.isEnabled:enabled:disabled\"}}')\n });\n\n appendView();\n\n ok(view.$('input').hasClass('unbound'), \"sets unbound classes directly\");\n ok(view.$('input').hasClass('great'), \"evaluates classes bound to global paths\");\n ok(view.$('input').hasClass('app-direct'), \"evaluates classes bound directly to global paths\");\n ok(view.$('input').hasClass('is-app'), \"evaluates classes bound directly to booleans in global paths - dasherizes and sets class when true\");\n ok(view.$('input').hasClass('enabled'), \"evaluates ternary operator in classBindings\");\n ok(!view.$('input').hasClass('disabled'), \"evaluates ternary operator in classBindings\");\n\n run(function() {\n App.set('isApp', false);\n App.set('isEnabled', false);\n });\n\n ok(!view.$('input').hasClass('is-app'), \"evaluates classes bound directly to booleans in global paths - removes class when false\");\n ok(!view.$('input').hasClass('enabled'), \"evaluates ternary operator in classBindings\");\n ok(view.$('input').hasClass('disabled'), \"evaluates ternary operator in classBindings\");\n\n run(function() {\n lookup.App.destroy();\n });\n });\n\n test(\"{{view}} should evaluate class bindings set in the current context\", function() {\n view = EmberView.create({\n isView: true,\n isEditable: true,\n directClass: \"view-direct\",\n isEnabled: true,\n template: EmberHandlebars.compile('{{view Ember.TextField class=\"unbound\" classBinding=\"view.isEditable:editable view.directClass view.isView view.isEnabled:enabled:disabled\"}}')\n });\n\n appendView();\n\n ok(view.$('input').hasClass('unbound'), \"sets unbound classes directly\");\n ok(view.$('input').hasClass('editable'), \"evaluates classes bound in the current context\");\n ok(view.$('input').hasClass('view-direct'), \"evaluates classes bound directly in the current context\");\n ok(view.$('input').hasClass('is-view'), \"evaluates classes bound directly to booleans in the current context - dasherizes and sets class when true\");\n ok(view.$('input').hasClass('enabled'), \"evaluates ternary operator in classBindings\");\n ok(!view.$('input').hasClass('disabled'), \"evaluates ternary operator in classBindings\");\n\n run(function() {\n view.set('isView', false);\n view.set('isEnabled', false);\n });\n\n ok(!view.$('input').hasClass('is-view'), \"evaluates classes bound directly to booleans in the current context - removes class when false\");\n ok(!view.$('input').hasClass('enabled'), \"evaluates ternary operator in classBindings\");\n ok(view.$('input').hasClass('disabled'), \"evaluates ternary operator in classBindings\");\n });\n\n test(\"{{view}} should evaluate class bindings set with either classBinding or classNameBindings\", function() {\n var App;\n\n run(function() {\n lookup.App = App = Namespace.create({\n isGreat: true,\n isEnabled: true\n });\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{view Ember.TextField class=\"unbound\" classBinding=\"App.isGreat:great App.isEnabled:enabled:disabled\" classNameBindings=\"App.isGreat:really-great App.isEnabled:really-enabled:really-disabled\"}}')\n });\n\n appendView();\n\n ok(view.$('input').hasClass('unbound'), \"sets unbound classes directly\");\n ok(view.$('input').hasClass('great'), \"evaluates classBinding\");\n ok(view.$('input').hasClass('really-great'), \"evaluates classNameBinding\");\n ok(view.$('input').hasClass('enabled'), \"evaluates ternary operator in classBindings\");\n ok(view.$('input').hasClass('really-enabled'), \"evaluates ternary operator in classBindings\");\n ok(!view.$('input').hasClass('disabled'), \"evaluates ternary operator in classBindings\");\n ok(!view.$('input').hasClass('really-disabled'), \"evaluates ternary operator in classBindings\");\n\n run(function() {\n App.set('isEnabled', false);\n });\n\n ok(!view.$('input').hasClass('enabled'), \"evaluates ternary operator in classBindings\");\n ok(!view.$('input').hasClass('really-enabled'), \"evaluates ternary operator in classBindings\");\n ok(view.$('input').hasClass('disabled'), \"evaluates ternary operator in classBindings\");\n ok(view.$('input').hasClass('really-disabled'), \"evaluates ternary operator in classBindings\");\n\n run(function() {\n lookup.App.destroy();\n });\n });\n\n test(\"{{view}} should evaluate other attribute bindings set to global paths\", function() {\n run(function() {\n lookup.App = Namespace.create({\n name: \"myApp\"\n });\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{view Ember.TextField valueBinding=\"App.name\"}}')\n });\n\n appendView();\n\n equal(view.$('input').attr('value'), \"myApp\", \"evaluates attributes bound to global paths\");\n\n run(function() {\n lookup.App.destroy();\n });\n });\n\n test(\"{{view}} should evaluate other attributes bindings set in the current context\", function() {\n view = EmberView.create({\n name: \"myView\",\n template: EmberHandlebars.compile('{{view Ember.TextField valueBinding=\"view.name\"}}')\n });\n\n appendView();\n\n equal(view.$('input').attr('value'), \"myView\", \"evaluates attributes bound in the current context\");\n });\n\n test(\"{{view}} should be able to bind class names to truthy properties\", function() {\n container.register('template:template', EmberHandlebars.compile('{{#view \"TemplateTests.classBindingView\" classBinding=\"view.number:is-truthy\"}}foo{{/view}}'));\n\n TemplateTests.classBindingView = EmberView.extend();\n\n view = EmberView.create({\n container: container,\n number: 5,\n templateName: 'template'\n });\n\n appendView();\n\n equal(view.$('.is-truthy').length, 1, \"sets class name\");\n\n run(function() {\n set(view, 'number', 0);\n });\n\n equal(view.$('.is-truthy').length, 0, \"removes class name if bound property is set to falsey\");\n });\n\n test(\"{{view}} should be able to bind class names to truthy or falsy properties\", function() {\n container.register('template:template', EmberHandlebars.compile('{{#view \"TemplateTests.classBindingView\" classBinding=\"view.number:is-truthy:is-falsy\"}}foo{{/view}}'));\n\n TemplateTests.classBindingView = EmberView.extend();\n\n view = EmberView.create({\n container: container,\n number: 5,\n templateName: 'template'\n });\n\n appendView();\n\n equal(view.$('.is-truthy').length, 1, \"sets class name to truthy value\");\n equal(view.$('.is-falsy').length, 0, \"doesn't set class name to falsy value\");\n\n run(function() {\n set(view, 'number', 0);\n });\n\n equal(view.$('.is-truthy').length, 0, \"doesn't set class name to truthy value\");\n equal(view.$('.is-falsy').length, 1, \"sets class name to falsy value\");\n });\n\n test(\"should be able to bind element attributes using {{bind-attr}}\", function() {\n var template = EmberHandlebars.compile('\"view.content.title\"}}');\n\n view = EmberView.create({\n template: template,\n content: EmberObject.create({\n url: \"http://www.emberjs.com/assets/images/logo.png\",\n title: \"The SproutCore Logo\"\n })\n });\n\n appendView();\n\n equal(view.$('img').attr('src'), \"http://www.emberjs.com/assets/images/logo.png\", \"sets src attribute\");\n equal(view.$('img').attr('alt'), \"The SproutCore Logo\", \"sets alt attribute\");\n\n run(function() {\n set(view, 'content.title', \"El logo de Eember\");\n });\n\n equal(view.$('img').attr('alt'), \"El logo de Eember\", \"updates alt attribute when content's title attribute changes\");\n\n run(function() {\n set(view, 'content', EmberObject.create({\n url: \"http://www.thegooglez.com/theydonnothing\",\n title: \"I CAN HAZ SEARCH\"\n }));\n });\n\n equal(view.$('img').attr('alt'), \"I CAN HAZ SEARCH\", \"updates alt attribute when content object changes\");\n\n run(function() {\n set(view, 'content', {\n url: \"http://www.emberjs.com/assets/images/logo.png\",\n title: \"The SproutCore Logo\"\n });\n });\n\n equal(view.$('img').attr('alt'), \"The SproutCore Logo\", \"updates alt attribute when content object is a hash\");\n\n run(function() {\n set(view, 'content', EmberObject.createWithMixins({\n url: \"http://www.emberjs.com/assets/images/logo.png\",\n title: computed(function() {\n return \"Nanananana Ember!\";\n })\n }));\n });\n\n equal(view.$('img').attr('alt'), \"Nanananana Ember!\", \"updates alt attribute when title property is computed\");\n });\n\n test(\"should be able to bind to view attributes with {{bind-attr}}\", function() {\n view = EmberView.create({\n value: 'Test',\n template: EmberHandlebars.compile('\"view.value\"}}')\n });\n\n appendView();\n\n equal(view.$('img').attr('alt'), \"Test\", \"renders initial value\");\n\n run(function() {\n view.set('value', 'Updated');\n });\n\n equal(view.$('img').attr('alt'), \"Updated\", \"updates value\");\n });\n\n test(\"should be able to bind to globals with {{bind-attr}}\", function() {\n TemplateTests.set('value', 'Test');\n\n view = EmberView.create({\n template: EmberHandlebars.compile('\"TemplateTests.value\"}}')\n });\n\n appendView();\n\n equal(view.$('img').attr('alt'), \"Test\", \"renders initial value\");\n\n run(function() {\n TemplateTests.set('value', 'Updated');\n });\n\n equal(view.$('img').attr('alt'), \"Updated\", \"updates value\");\n });\n\n test(\"should not allow XSS injection via {{bind-attr}}\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('\"view.content.value\"}}'),\n content: {\n value: 'Trololol\" onmouseover=\"alert(\\'HAX!\\');'\n }\n });\n\n appendView();\n\n equal(view.$('img').attr('onmouseover'), undefined);\n // If the whole string is here, then it means we got properly escaped\n equal(view.$('img').attr('alt'), 'Trololol\" onmouseover=\"alert(\\'HAX!\\');');\n });\n\n test(\"should be able to bind use {{bind-attr}} more than once on an element\", function() {\n var template = EmberHandlebars.compile('\"view.content.title\"}}');\n\n view = EmberView.create({\n template: template,\n content: EmberObject.create({\n url: \"http://www.emberjs.com/assets/images/logo.png\",\n title: \"The SproutCore Logo\"\n })\n });\n\n appendView();\n\n equal(view.$('img').attr('src'), \"http://www.emberjs.com/assets/images/logo.png\", \"sets src attribute\");\n equal(view.$('img').attr('alt'), \"The SproutCore Logo\", \"sets alt attribute\");\n\n run(function() {\n set(view, 'content.title', \"El logo de Eember\");\n });\n\n equal(view.$('img').attr('alt'), \"El logo de Eember\", \"updates alt attribute when content's title attribute changes\");\n\n run(function() {\n set(view, 'content', EmberObject.create({\n url: \"http://www.thegooglez.com/theydonnothing\",\n title: \"I CAN HAZ SEARCH\"\n }));\n });\n\n equal(view.$('img').attr('alt'), \"I CAN HAZ SEARCH\", \"updates alt attribute when content object changes\");\n\n run(function() {\n set(view, 'content', {\n url: \"http://www.emberjs.com/assets/images/logo.png\",\n title: \"The SproutCore Logo\"\n });\n });\n\n equal(view.$('img').attr('alt'), \"The SproutCore Logo\", \"updates alt attribute when content object is a hash\");\n\n run(function() {\n set(view, 'content', EmberObject.createWithMixins({\n url: \"http://www.emberjs.com/assets/images/logo.png\",\n title: computed(function() {\n return \"Nanananana Ember!\";\n })\n }));\n });\n\n equal(view.$('img').attr('alt'), \"Nanananana Ember!\", \"updates alt attribute when title property is computed\");\n\n });\n\n test(\"{{bindAttr}} is aliased to {{bind-attr}}\", function() {\n\n var originalBindAttr = EmberHandlebars.helpers['bind-attr'],\n originalWarn = Ember.warn;\n\n Ember.warn = function(msg) {\n equal(msg, \"The 'bindAttr' view helper is deprecated in favor of 'bind-attr'\", 'Warning called');\n };\n\n EmberHandlebars.helpers['bind-attr'] = function() {\n equal(arguments[0], 'foo', 'First arg match');\n equal(arguments[1], 'bar', 'Second arg match');\n return 'result';\n };\n var result = EmberHandlebars.helpers.bindAttr('foo', 'bar');\n equal(result, 'result', 'Result match');\n\n EmberHandlebars.helpers['bind-attr'] = originalBindAttr;\n Ember.warn = originalWarn;\n });\n\n test(\"should not reset cursor position when text field receives keyUp event\", function() {\n view = TextField.create({\n value: \"Broseidon, King of the Brocean\"\n });\n\n run(function() {\n view.append();\n });\n\n view.$().val('Brosiedoon, King of the Brocean');\n setCaretPosition(view.$(), 5);\n\n run(function() {\n view.trigger('keyUp', {});\n });\n\n equal(caretPosition(view.$()), 5, \"The keyUp event should not result in the cursor being reset due to the bind-attr observers\");\n\n run(function() {\n view.destroy();\n });\n });\n\n test(\"should be able to bind element attributes using {{bind-attr}} inside a block\", function() {\n var template = EmberHandlebars.compile('{{#with view.content}}\"title\"}}{{/with}}');\n\n view = EmberView.create({\n template: template,\n content: EmberObject.create({\n url: \"http://www.emberjs.com/assets/images/logo.png\",\n title: \"The SproutCore Logo\"\n })\n });\n\n appendView();\n\n equal(view.$('img').attr('src'), \"http://www.emberjs.com/assets/images/logo.png\", \"sets src attribute\");\n equal(view.$('img').attr('alt'), \"The SproutCore Logo\", \"sets alt attribute\");\n\n run(function() {\n set(view, 'content.title', \"El logo de Eember\");\n });\n\n equal(view.$('img').attr('alt'), \"El logo de Eember\", \"updates alt attribute when content's title attribute changes\");\n });\n\n test(\"should be able to bind class attribute with {{bind-attr}}\", function() {\n var template = EmberHandlebars.compile('');\n\n view = EmberView.create({\n template: template,\n foo: 'bar'\n });\n\n appendView();\n\n equal(view.$('img').attr('class'), 'bar', \"renders class\");\n\n run(function() {\n set(view, 'foo', 'baz');\n });\n\n equal(view.$('img').attr('class'), 'baz', \"updates class\");\n });\n\n test(\"should be able to bind class attribute via a truthy property with {{bind-attr}}\", function() {\n var template = EmberHandlebars.compile('');\n\n view = EmberView.create({\n template: template,\n isNumber: 5\n });\n\n appendView();\n\n equal(view.$('.is-truthy').length, 1, \"sets class name\");\n\n run(function() {\n set(view, 'isNumber', 0);\n });\n\n equal(view.$('.is-truthy').length, 0, \"removes class name if bound property is set to something non-truthy\");\n });\n\n test(\"should be able to bind class to view attribute with {{bind-attr}}\", function() {\n var template = EmberHandlebars.compile('');\n\n view = EmberView.create({\n template: template,\n foo: 'bar'\n });\n\n appendView();\n\n equal(view.$('img').attr('class'), 'bar', \"renders class\");\n\n run(function() {\n set(view, 'foo', 'baz');\n });\n\n equal(view.$('img').attr('class'), 'baz', \"updates class\");\n });\n\n test(\"should not allow XSS injection via {{bind-attr}} with class\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile(''),\n foo: '\" onmouseover=\"alert(\\'I am in your classes hacking your app\\');'\n });\n\n appendView();\n\n equal(view.$('img').attr('onmouseover'), undefined);\n // If the whole string is here, then it means we got properly escaped\n equal(view.$('img').attr('class'), '\" onmouseover=\"alert(\\'I am in your classes hacking your app\\');');\n });\n\n test(\"should be able to bind class attribute using ternary operator in {{bind-attr}}\", function() {\n var template = EmberHandlebars.compile('');\n var content = EmberObject.create({\n isDisabled: true\n });\n\n view = EmberView.create({\n template: template,\n content: content\n });\n\n appendView();\n\n ok(view.$('img').hasClass('disabled'), 'disabled class is rendered');\n ok(!view.$('img').hasClass('enabled'), 'enabled class is not rendered');\n\n run(function() {\n set(content, 'isDisabled', false);\n });\n\n ok(!view.$('img').hasClass('disabled'), 'disabled class is not rendered');\n ok(view.$('img').hasClass('enabled'), 'enabled class is rendered');\n });\n\n test(\"should be able to add multiple classes using {{bind-attr class}}\", function() {\n var template = EmberHandlebars.compile('
');\n var content = EmberObject.create({\n isAwesomeSauce: true,\n isAlsoCool: true,\n isAmazing: true,\n isEnabled: true\n });\n\n view = EmberView.create({\n template: template,\n content: content\n });\n\n appendView();\n\n ok(view.$('div').hasClass('is-awesome-sauce'), \"dasherizes first property and sets classname\");\n ok(view.$('div').hasClass('is-also-cool'), \"dasherizes second property and sets classname\");\n ok(view.$('div').hasClass('amazing'), \"uses alias for third property and sets classname\");\n ok(view.$('div').hasClass('is-super-duper'), \"static class is present\");\n ok(view.$('div').hasClass('enabled'), \"truthy class in ternary classname definition is rendered\");\n ok(!view.$('div').hasClass('disabled'), \"falsy class in ternary classname definition is not rendered\");\n\n run(function() {\n set(content, 'isAwesomeSauce', false);\n set(content, 'isAmazing', false);\n set(content, 'isEnabled', false);\n });\n\n ok(!view.$('div').hasClass('is-awesome-sauce'), \"removes dasherized class when property is set to false\");\n ok(!view.$('div').hasClass('amazing'), \"removes aliased class when property is set to false\");\n ok(view.$('div').hasClass('is-super-duper'), \"static class is still present\");\n ok(!view.$('div').hasClass('enabled'), \"truthy class in ternary classname definition is not rendered\");\n ok(view.$('div').hasClass('disabled'), \"falsy class in ternary classname definition is rendered\");\n });\n\n test(\"should be able to bind classes to globals with {{bind-attr class}}\", function() {\n TemplateTests.set('isOpen', true);\n\n view = EmberView.create({\n template: EmberHandlebars.compile('')\n });\n\n appendView();\n\n ok(view.$('img').hasClass('is-open'), \"sets classname to the dasherized value of the global property\");\n\n run(function() {\n TemplateTests.set('isOpen', false);\n });\n\n ok(!view.$('img').hasClass('is-open'), \"removes the classname when the global property has changed\");\n });\n\n test(\"should be able to bind-attr to 'this' in an {{#each}} block\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#each view.images}}{{/each}}'),\n images: A(['one.png', 'two.jpg', 'three.gif'])\n });\n\n appendView();\n\n var images = view.$('img');\n ok(/one\\.png$/.test(images[0].src));\n ok(/two\\.jpg$/.test(images[1].src));\n ok(/three\\.gif$/.test(images[2].src));\n });\n\n test(\"should be able to bind classes to 'this' in an {{#each}} block with {{bind-attr class}}\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#each view.items}}
  • Item
  • {{/each}}'),\n items: A(['a', 'b', 'c'])\n });\n\n appendView();\n\n ok(view.$('li').eq(0).hasClass('a'), \"sets classname to the value of the first item\");\n ok(view.$('li').eq(1).hasClass('b'), \"sets classname to the value of the second item\");\n ok(view.$('li').eq(2).hasClass('c'), \"sets classname to the value of the third item\");\n });\n\n test(\"should be able to bind-attr to var in {{#each var in list}} block\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#each image in view.images}}{{/each}}'),\n images: A(['one.png', 'two.jpg', 'three.gif'])\n });\n\n appendView();\n\n var images = view.$('img');\n ok(/one\\.png$/.test(images[0].src));\n ok(/two\\.jpg$/.test(images[1].src));\n ok(/three\\.gif$/.test(images[2].src));\n\n run(function() {\n var imagesArray = view.get('images');\n imagesArray.removeAt(0);\n });\n\n images = view.$('img');\n ok(images.length === 2, \"\");\n ok(/two\\.jpg$/.test(images[0].src));\n ok(/three\\.gif$/.test(images[1].src));\n });\n\n test(\"should be able to output a property without binding\", function() {\n var context = {\n content: EmberObject.create({\n anUnboundString: \"No spans here, son.\"\n }),\n\n anotherUnboundString: \"Not here, either.\"\n };\n\n view = EmberView.create({\n context: context,\n template: EmberHandlebars.compile(\n '
    {{unbound content.anUnboundString}}
    '+\n '{{#with content}}
    {{unbound ../anotherUnboundString}}
    {{/with}}'\n )\n });\n\n appendView();\n\n equal(view.$('#first').html(), \"No spans here, son.\");\n equal(view.$('#second').html(), \"Not here, either.\");\n });\n\n test(\"should allow standard Handlebars template usage\", function() {\n view = EmberView.create({\n context: { name: \"Erik\" },\n template: Handlebars.compile(\"Hello, {{name}}\")\n });\n\n appendView();\n\n equal(view.$().text(), \"Hello, Erik\");\n });\n\n test(\"should be able to use standard Handlebars #each helper\", function() {\n view = EmberView.create({\n context: { items: ['a', 'b', 'c'] },\n template: Handlebars.compile(\"{{#each items}}{{this}}{{/each}}\")\n });\n\n appendView();\n\n equal(view.$().html(), \"abc\");\n });\n\n test(\"should be able to use unbound helper in #each helper\", function() {\n view = EmberView.create({\n items: A(['a', 'b', 'c', 1, 2, 3]),\n template: EmberHandlebars.compile(\n \"
      {{#each view.items}}
    • {{unbound this}}
    • {{/each}}
    \")\n });\n\n appendView();\n\n equal(view.$().text(), \"abc123\");\n equal(view.$('li').children().length, 0, \"No markers\");\n });\n\n test(\"should be able to use unbound helper in #each helper (with objects)\", function() {\n view = EmberView.create({\n items: A([{wham: 'bam'}, {wham: 1}]),\n template: EmberHandlebars.compile(\n \"
      {{#each view.items}}
    • {{unbound wham}}
    • {{/each}}
    \")\n });\n\n appendView();\n\n equal(view.$().text(), \"bam1\");\n equal(view.$('li').children().length, 0, \"No markers\");\n });\n\n test(\"should work with precompiled templates\", function() {\n var templateString = EmberHandlebars.precompile(\"{{view.value}}\"),\n compiledTemplate = EmberHandlebars.template(eval(templateString));\n view = EmberView.create({\n value: \"rendered\",\n template: compiledTemplate\n });\n\n appendView();\n\n equal(view.$().text(), \"rendered\", \"the precompiled template was rendered\");\n\n run(function() { view.set('value', 'updated'); });\n\n equal(view.$().text(), \"updated\", \"the precompiled template was updated\");\n });\n\n test(\"should expose a controller keyword when present on the view\", function() {\n var templateString = \"{{controller.foo}}{{#view}}{{controller.baz}}{{/view}}\";\n view = EmberView.create({\n controller: EmberObject.create({\n foo: \"bar\",\n baz: \"bang\"\n }),\n\n template: EmberHandlebars.compile(templateString)\n });\n\n appendView();\n\n equal(view.$().text(), \"barbang\", \"renders values from controller and parent controller\");\n\n var controller = get(view, 'controller');\n\n run(function() {\n controller.set('foo', \"BAR\");\n controller.set('baz', \"BLARGH\");\n });\n\n equal(view.$().text(), \"BARBLARGH\", \"updates the DOM when a bound value is updated\");\n\n run(function() {\n view.destroy();\n });\n\n view = EmberView.create({\n controller: \"aString\",\n template: EmberHandlebars.compile(\"{{controller}}\")\n });\n\n appendView();\n\n equal(view.$().text(), \"aString\", \"renders the controller itself if no additional path is specified\");\n });\n\n test(\"should expose a controller keyword that can be used in conditionals\", function() {\n var templateString = \"{{#view}}{{#if controller}}{{controller.foo}}{{/if}}{{/view}}\";\n view = EmberView.create({\n controller: EmberObject.create({\n foo: \"bar\"\n }),\n\n template: EmberHandlebars.compile(templateString)\n });\n\n appendView();\n\n equal(view.$().text(), \"bar\", \"renders values from controller and parent controller\");\n\n run(function() {\n view.set('controller', null);\n });\n\n equal(view.$().text(), \"\", \"updates the DOM when the controller is changed\");\n });\n\n test(\"should expose a controller keyword that persists through Ember.ContainerView\", function() {\n var templateString = \"{{view Ember.ContainerView}}\";\n view = EmberView.create({\n controller: EmberObject.create({\n foo: \"bar\"\n }),\n\n template: EmberHandlebars.compile(templateString)\n });\n\n appendView();\n\n var containerView = get(view, 'childViews.firstObject');\n var viewInstanceToBeInserted = EmberView.create({\n template: EmberHandlebars.compile('{{controller.foo}}')\n });\n\n run(function() {\n containerView.pushObject(viewInstanceToBeInserted);\n });\n\n equal(trim(viewInstanceToBeInserted.$().text()), \"bar\", \"renders value from parent's controller\");\n });\n\n test(\"should expose a view keyword\", function() {\n var templateString = '{{#with view.differentContent}}{{view.foo}}{{#view baz=\"bang\"}}{{view.baz}}{{/view}}{{/with}}';\n view = EmberView.create({\n differentContent: {\n view: {\n foo: \"WRONG\",\n baz: \"WRONG\"\n }\n },\n\n foo: \"bar\",\n\n template: EmberHandlebars.compile(templateString)\n });\n\n appendView();\n\n equal(view.$().text(), \"barbang\", \"renders values from view and child view\");\n });\n\n test(\"should be able to explicitly set a view's context\", function() {\n var context = EmberObject.create({\n test: 'test'\n });\n\n TemplateTests.CustomContextView = EmberView.extend({\n context: context,\n template: EmberHandlebars.compile(\"{{test}}\")\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile(\"{{view TemplateTests.CustomContextView}}\")\n });\n\n appendView();\n\n equal(view.$().text(), \"test\");\n });\n\n test(\"should escape HTML in primitive value contexts when using normal mustaches\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#each view.kiddos}}{{this}}{{/each}}'),\n kiddos: A(['Max', 'James'])\n });\n\n appendView();\n equal(view.$('b').length, 0, \"does not create an element\");\n equal(view.$().text(), 'MaxJames', \"inserts entities, not elements\");\n\n run(function() { set(view, 'kiddos', A(['Max','James'])); });\n equal(view.$().text(), 'MaxJames', \"updates with entities, not elements\");\n equal(view.$('i').length, 0, \"does not create an element when value is updated\");\n });\n\n test(\"should not escape HTML in primitive value contexts when using triple mustaches\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#each view.kiddos}}{{{this}}}{{/each}}'),\n kiddos: A(['Max', 'James'])\n });\n\n appendView();\n\n equal(view.$('b').length, 2, \"creates an element\");\n\n run(function() { set(view, 'kiddos', A(['Max','James'])); });\n equal(view.$('i').length, 2, \"creates an element when value is updated\");\n });\n\n module(\"Ember.View - handlebars integration\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n\n originalLog = Ember.Logger.log;\n logCalls = [];\n Ember.Logger.log = function(arg) { logCalls.push(arg); };\n },\n\n teardown: function() {\n if (view) {\n run(function() {\n view.destroy();\n });\n view = null;\n }\n\n Ember.Logger.log = originalLog;\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"should be able to log a property\", function() {\n var context = {\n value: 'one',\n valueTwo: 'two',\n\n content: EmberObject.create({})\n };\n\n view = EmberView.create({\n context: context,\n template: EmberHandlebars.compile('{{log value}}{{#with content}}{{log ../valueTwo}}{{/with}}')\n });\n\n appendView();\n\n equal(view.$().text(), \"\", \"shouldn't render any text\");\n equal(logCalls[0], 'one', \"should call log with value\");\n equal(logCalls[1], 'two', \"should call log with valueTwo\");\n });\n\n test(\"should be able to log a view property\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{log view.value}}'),\n value: 'one'\n });\n\n appendView();\n\n equal(view.$().text(), \"\", \"shouldn't render any text\");\n equal(logCalls[0], 'one', \"should call log with value\");\n });\n\n test(\"should be able to log `this`\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#each view.items}}{{log this}}{{/each}}'),\n items: A(['one', 'two'])\n });\n\n appendView();\n\n equal(view.$().text(), \"\", \"shouldn't render any text\");\n equal(logCalls[0], 'one', \"should call log with item one\");\n equal(logCalls[1], 'two', \"should call log with item two\");\n });\n\n var MyApp;\n\n module(\"Templates redrawing and bindings\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n MyApp = lookup.MyApp = EmberObject.create({});\n },\n teardown: function() {\n run(function() {\n if (view) view.destroy();\n });\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"should be able to update when bound property updates\", function() {\n MyApp.set('controller', EmberObject.create({name: 'first'}));\n\n var View = EmberView.extend({\n template: EmberHandlebars.compile('{{view.value.name}}, {{view.computed}}'),\n valueBinding: 'MyApp.controller',\n computed: computed(function() {\n return this.get('value.name') + ' - computed';\n }).property('value')\n });\n\n run(function() {\n view = View.create();\n });\n\n appendView();\n\n run(function() {\n MyApp.set('controller', EmberObject.create({\n name: 'second'\n }));\n });\n\n equal(view.get('computed'), \"second - computed\", \"view computed properties correctly update\");\n equal(view.$('i').text(), 'second, second - computed', \"view rerenders when bound properties change\");\n });\n\n test(\"properties within an if statement should not fail on re-render\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#if view.value}}{{view.value}}{{/if}}'),\n value: null\n });\n\n appendView();\n\n equal(view.$().text(), '');\n\n run(function() {\n view.set('value', 'test');\n });\n\n equal(view.$().text(), 'test');\n\n run(function() {\n view.set('value', null);\n });\n\n equal(view.$().text(), '');\n });\n\n test('should cleanup bound properties on rerender', function() {\n view = EmberView.create({\n controller: EmberObject.create({name: 'wycats'}),\n template: EmberHandlebars.compile('{{name}}')\n });\n\n appendView();\n\n equal(view.$().text(), 'wycats', 'rendered binding');\n\n run(view, 'rerender');\n\n equal(view._childViews.length, 1);\n });\n\n test(\"views within an if statement should be sane on re-render\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#if view.display}}{{view Ember.TextField}}{{/if}}'),\n display: false\n });\n\n appendView();\n\n equal(view.$('input').length, 0);\n\n run(function() {\n // Setting twice will trigger the observer twice, this is intentional\n view.set('display', true);\n view.set('display', 'yes');\n });\n\n var textfield = view.$('input');\n equal(textfield.length, 1);\n\n // Make sure the view is still registered in View.views\n ok(EmberView.views[textfield.attr('id')]);\n });\n\n test(\"the {{this}} helper should not fail on removal\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#if view.show}}{{#each view.list}}{{this}}{{/each}}{{/if}}'),\n show: true,\n list: A(['a', 'b', 'c'])\n });\n\n appendView();\n\n equal(view.$().text(), 'abc', \"should start property - precond\");\n\n run(function() {\n view.set('show', false);\n });\n\n equal(view.$().text(), '');\n });\n\n test(\"bindings should be relative to the current context\", function() {\n view = EmberView.create({\n museumOpen: true,\n\n museumDetails: EmberObject.create({\n name: \"SFMoMA\",\n price: 20\n }),\n\n museumView: EmberView.extend({\n template: EmberHandlebars.compile('Name: {{view.name}} Price: ${{view.dollars}}')\n }),\n\n template: EmberHandlebars.compile('{{#if view.museumOpen}} {{view view.museumView nameBinding=\"view.museumDetails.name\" dollarsBinding=\"view.museumDetails.price\"}} {{/if}}')\n });\n\n appendView();\n\n equal(trim(view.$().text()), \"Name: SFMoMA Price: $20\", \"should print baz twice\");\n });\n\n test(\"bindings should respect keywords\", function() {\n view = EmberView.create({\n museumOpen: true,\n\n controller: {\n museumOpen: true,\n museumDetails: EmberObject.create({\n name: \"SFMoMA\",\n price: 20\n })\n },\n\n museumView: EmberView.extend({\n template: EmberHandlebars.compile('Name: {{view.name}} Price: ${{view.dollars}}')\n }),\n\n template: EmberHandlebars.compile('{{#if view.museumOpen}}{{view view.museumView nameBinding=\"controller.museumDetails.name\" dollarsBinding=\"controller.museumDetails.price\"}}{{/if}}')\n });\n\n appendView();\n\n equal(trim(view.$().text()), \"Name: SFMoMA Price: $20\", \"should print baz twice\");\n });\n\n test(\"bindings can be 'this', in which case they *are* the current context\", function() {\n view = EmberView.create({\n museumOpen: true,\n\n museumDetails: EmberObject.create({\n name: \"SFMoMA\",\n price: 20,\n museumView: EmberView.extend({\n template: EmberHandlebars.compile('Name: {{view.museum.name}} Price: ${{view.museum.price}}')\n })\n }),\n\n\n template: EmberHandlebars.compile('{{#if view.museumOpen}} {{#with view.museumDetails}}{{view museumView museumBinding=\"this\"}} {{/with}}{{/if}}')\n });\n\n appendView();\n\n equal(trim(view.$().text()), \"Name: SFMoMA Price: $20\", \"should print baz twice\");\n });\n\n // https://github.com/emberjs/ember.js/issues/120\n\n test(\"should not enter an infinite loop when binding an attribute in Handlebars\", function() {\n var App;\n\n run(function() {\n lookup.App = App = Namespace.create();\n });\n\n App.test = EmberObject.create({ href: 'test' });\n App.Link = EmberView.extend({\n classNames: ['app-link'],\n tagName: 'a',\n attributeBindings: ['href'],\n href: '#none',\n\n click: function() {\n return false;\n }\n });\n\n var parentView = EmberView.create({\n template: EmberHandlebars.compile('{{#view App.Link hrefBinding=\"App.test.href\"}} Test {{/view}}')\n });\n\n\n run(function() {\n parentView.appendTo('#qunit-fixture');\n });\n\n // Use match, since old IE appends the whole URL\n var href = parentView.$('a').attr('href');\n ok(href.match(/(^|\\/)test$/), \"Expected href to be 'test' but got '\"+href+\"'\");\n\n run(function() {\n parentView.destroy();\n });\n\n run(function() {\n lookup.App.destroy();\n });\n });\n\n test(\"should update bound values after the view is removed and then re-appended\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile(\"{{#if view.showStuff}}{{view.boundValue}}{{else}}Not true.{{/if}}\"),\n showStuff: true,\n boundValue: \"foo\"\n });\n\n appendView();\n\n equal(trim(view.$().text()), \"foo\");\n run(function() {\n set(view, 'showStuff', false);\n });\n equal(trim(view.$().text()), \"Not true.\");\n\n run(function() {\n set(view, 'showStuff', true);\n });\n equal(trim(view.$().text()), \"foo\");\n\n run(function() {\n view.remove();\n set(view, 'showStuff', false);\n });\n run(function() {\n set(view, 'showStuff', true);\n });\n appendView();\n\n run(function() {\n set(view, 'boundValue', \"bar\");\n });\n equal(trim(view.$().text()), \"bar\");\n });\n\n test(\"should update bound values after view's parent is removed and then re-appended\", function() {\n var controller = EmberObject.create();\n\n var parentView = ContainerView.create({\n childViews: ['testView'],\n\n controller: controller,\n\n testView: EmberView.create({\n template: EmberHandlebars.compile(\"{{#if showStuff}}{{boundValue}}{{else}}Not true.{{/if}}\")\n })\n });\n\n controller.setProperties({\n showStuff: true,\n boundValue: \"foo\"\n });\n\n run(function() {\n parentView.appendTo('#qunit-fixture');\n });\n view = parentView.get('testView');\n\n equal(trim(view.$().text()), \"foo\");\n run(function() {\n set(controller, 'showStuff', false);\n });\n equal(trim(view.$().text()), \"Not true.\");\n\n run(function() {\n set(controller, 'showStuff', true);\n });\n equal(trim(view.$().text()), \"foo\");\n\n\n run(function() {\n parentView.remove();\n set(controller, 'showStuff', false);\n });\n run(function() {\n set(controller, 'showStuff', true);\n });\n run(function() {\n parentView.appendTo('#qunit-fixture');\n });\n\n run(function() {\n set(controller, 'boundValue', \"bar\");\n });\n equal(trim(view.$().text()), \"bar\");\n\n run(function() {\n parentView.destroy();\n });\n });\n\n test(\"should call a registered helper for mustache without parameters\", function() {\n EmberHandlebars.registerHelper('foobar', function() {\n return 'foobar';\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile(\"{{foobar}}\")\n });\n\n appendView();\n\n ok(view.$().text() === 'foobar', \"Regular helper was invoked correctly\");\n });\n\n test(\"should bind to the property if no registered helper found for a mustache without parameters\", function() {\n view = EmberView.createWithMixins({\n template: EmberHandlebars.compile(\"{{view.foobarProperty}}\"),\n foobarProperty: computed(function() {\n return 'foobarProperty';\n })\n });\n\n appendView();\n\n ok(view.$().text() === 'foobarProperty', \"Property was bound to correctly\");\n });\n\n test(\"should accept bindings as a string or an Ember.Binding\", function() {\n var viewClass = EmberView.extend({\n template: EmberHandlebars.compile(\"binding: {{view.bindingTest}}, string: {{view.stringTest}}\")\n });\n\n EmberHandlebars.registerHelper('boogie', function(id, options) {\n options.hash = options.hash || {};\n options.hash.bindingTestBinding = Binding.oneWay('context.' + id);\n options.hash.stringTestBinding = id;\n return EmberHandlebars.ViewHelper.helper(this, viewClass, options);\n });\n\n view = EmberView.create({\n context: EmberObject.create({\n direction: 'down'\n }),\n template: EmberHandlebars.compile(\"{{boogie direction}}\")\n });\n\n appendView();\n\n equal(trim(view.$().text()), \"binding: down, string: down\");\n });\n\n test(\"should teardown observers from bound properties on rerender\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile(\"{{view.foo}}\"),\n foo: 'bar'\n });\n\n appendView();\n\n equal(observersFor(view, 'foo').length, 1);\n\n run(function() {\n view.rerender();\n });\n\n equal(observersFor(view, 'foo').length, 1);\n });\n\n test(\"should teardown observers from bind-attr on rerender\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('wat'),\n foo: 'bar'\n });\n\n appendView();\n\n equal(observersFor(view, 'foo').length, 2);\n\n run(function() {\n view.rerender();\n });\n\n equal(observersFor(view, 'foo').length, 2);\n });\n });\ndefine(\"ember-handlebars/tests/helpers/bound_helper_test\",\n [\"ember-views/views/view\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-runtime/system/namespace\",\"ember-runtime/system/native_array\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-handlebars-compiler\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n /*globals TemplateTests*/\n /*jshint newcap:false*/\n var EmberView = __dependency1__.View;\n var run = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var Namespace = __dependency4__[\"default\"];\n var A = __dependency5__.A;\n\n // import {expectAssertion} from \"ember-metal/tests/debug_helpers\";\n\n var get = __dependency6__.get;\n var set = __dependency7__.set;\n\n var EmberHandlebars = __dependency8__[\"default\"];\n var compile = EmberHandlebars.compile;\n\n var view;\n\n var appendView = function() {\n run(function() { view.appendTo('#qunit-fixture'); });\n };\n\n var registerRepeatHelper = function() {\n EmberHandlebars.helper('repeat', function(value, options) {\n var count = options.hash.count;\n var a = [];\n while(a.length < count) {\n a.push(value);\n }\n return a.join('');\n });\n };\n\n module(\"Handlebars bound helpers\", {\n setup: function() {\n window.TemplateTests = Namespace.create();\n },\n teardown: function() {\n run(function() {\n if (view) {\n view.destroy();\n }\n });\n window.TemplateTests = undefined;\n }\n });\n\n test(\"should update bound helpers when properties change\", function() {\n EmberHandlebars.helper('capitalize', function(value) {\n return value.toUpperCase();\n });\n\n view = EmberView.create({\n controller: EmberObject.create({name: \"Brogrammer\"}),\n template: EmberHandlebars.compile(\"{{capitalize name}}\")\n });\n\n appendView();\n\n equal(view.$().text(), 'BROGRAMMER', \"helper output is correct\");\n\n run(function() {\n set(view.controller, 'name', 'wes');\n });\n\n equal(view.$().text(), 'WES', \"helper output updated\");\n });\n\n test(\"should allow for computed properties with dependencies\", function() {\n EmberHandlebars.helper('capitalizeName', function(value) {\n return get(value, 'name').toUpperCase();\n }, 'name');\n\n view = EmberView.create({\n controller: EmberObject.create({\n person: EmberObject.create({\n name: 'Brogrammer'\n })\n }),\n template: EmberHandlebars.compile(\"{{capitalizeName person}}\")\n });\n\n appendView();\n\n equal(view.$().text(), 'BROGRAMMER', \"helper output is correct\");\n\n run(function() {\n set(view.controller.person, 'name', 'wes');\n });\n\n equal(view.$().text(), 'WES', \"helper output updated\");\n });\n\n test(\"bound helpers should support options\", function() {\n\n registerRepeatHelper();\n\n view = EmberView.create({\n controller: EmberObject.create({text: 'ab'}),\n template: EmberHandlebars.compile(\"{{repeat text count=3}}\")\n });\n\n appendView();\n\n ok(view.$().text() === 'ababab', \"helper output is correct\");\n });\n\n test(\"bound helpers should support keywords\", function() {\n EmberHandlebars.helper('capitalize', function(value) {\n return value.toUpperCase();\n });\n\n view = EmberView.create({\n text: 'ab',\n template: EmberHandlebars.compile(\"{{capitalize view.text}}\")\n });\n\n appendView();\n\n ok(view.$().text() === 'AB', \"helper output is correct\");\n });\n\n test(\"bound helpers should support global paths\", function() {\n EmberHandlebars.helper('capitalize', function(value) {\n return value.toUpperCase();\n });\n\n TemplateTests.text = 'ab';\n\n view = EmberView.create({\n template: EmberHandlebars.compile(\"{{capitalize TemplateTests.text}}\")\n });\n\n appendView();\n\n ok(view.$().text() === 'AB', \"helper output is correct\");\n });\n\n test(\"bound helper should support this keyword\", function() {\n EmberHandlebars.helper('capitalize', function(value) {\n return get(value, 'text').toUpperCase();\n });\n\n view = EmberView.create({\n controller: EmberObject.create({text: 'ab'}),\n template: EmberHandlebars.compile(\"{{capitalize this}}\")\n });\n\n appendView();\n\n ok(view.$().text() === 'AB', \"helper output is correct\");\n });\n\n test(\"bound helpers should support bound options\", function() {\n\n registerRepeatHelper();\n\n view = EmberView.create({\n controller: EmberObject.create({text: 'ab', numRepeats: 3}),\n template: EmberHandlebars.compile('{{repeat text countBinding=\"numRepeats\"}}')\n });\n\n appendView();\n\n equal(view.$().text(), 'ababab', \"helper output is correct\");\n\n run(function() {\n view.set('controller.numRepeats', 4);\n });\n\n equal(view.$().text(), 'abababab', \"helper correctly re-rendered after bound option was changed\");\n\n run(function() {\n view.set('controller.numRepeats', 2);\n view.set('controller.text', \"YES\");\n });\n\n equal(view.$().text(), 'YESYES', \"helper correctly re-rendered after both bound option and property changed\");\n });\n\n\n test(\"bound helpers should support multiple bound properties\", function() {\n\n EmberHandlebars.helper('concat', function() {\n return [].slice.call(arguments, 0, -1).join('');\n });\n\n view = EmberView.create({\n controller: EmberObject.create({thing1: 'ZOID', thing2: 'BERG'}),\n template: EmberHandlebars.compile('{{concat thing1 thing2}}')\n });\n\n appendView();\n\n equal(view.$().text(), 'ZOIDBERG', \"helper output is correct\");\n\n run(function() {\n view.set('controller.thing2', \"NERD\");\n });\n\n equal(view.$().text(), 'ZOIDNERD', \"helper correctly re-rendered after second bound helper property changed\");\n\n run(function() {\n view.controller.setProperties({\n thing1: \"WOOT\",\n thing2: \"YEAH\"\n });\n });\n\n equal(view.$().text(), 'WOOTYEAH', \"helper correctly re-rendered after both bound helper properties changed\");\n });\n\n test(\"bound helpers should expose property names in options.data.properties\", function() {\n EmberHandlebars.helper('echo', function() {\n var options = arguments[arguments.length - 1];\n var values = [].slice.call(arguments, 0, -1);\n var a = [];\n for(var i = 0; i < values.length; ++i) {\n var propertyName = options.data.properties[i];\n a.push(propertyName);\n }\n return a.join(' ');\n });\n\n view = EmberView.create({\n controller: EmberObject.create({\n thing1: 'ZOID',\n thing2: 'BERG',\n thing3: EmberObject.create({\n foo: 123\n })\n }),\n template: EmberHandlebars.compile('{{echo thing1 thing2 thing3.foo}}')\n });\n\n appendView();\n\n equal(view.$().text(), 'thing1 thing2 thing3.foo', \"helper output is correct\");\n });\n\n test(\"bound helpers can be invoked with zero args\", function() {\n EmberHandlebars.helper('troll', function(options) {\n return options.hash.text || \"TROLOLOL\";\n });\n\n view = EmberView.create({\n controller: EmberObject.create({trollText: \"yumad\"}),\n template: EmberHandlebars.compile('{{troll}} and {{troll text=\"bork\"}}')\n });\n\n appendView();\n\n equal(view.$().text(), 'TROLOLOL and bork', \"helper output is correct\");\n });\n\n test(\"bound helpers should not be invoked with blocks\", function() {\n registerRepeatHelper();\n view = EmberView.create({\n controller: EmberObject.create({}),\n template: EmberHandlebars.compile(\"{{#repeat}}Sorry, Charlie{{/repeat}}\")\n });\n\n expectAssertion(function() {\n appendView();\n }, /registerBoundHelper-generated helpers do not support use with Handlebars blocks/i);\n });\n\n test(\"should observe dependent keys passed to registerBoundHelper\", function() {\n try {\n expect(2);\n\n var SimplyObject = EmberObject.create({\n firstName: 'Jim',\n lastName: 'Owen'\n });\n\n EmberHandlebars.registerBoundHelper('fullName', function(value){\n return value.get('firstName') + ' ' + value.get('lastName');\n }, 'firstName', 'lastName');\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{fullName this}}'),\n context: SimplyObject\n });\n appendView(view);\n\n equal(view.$().text(), 'Jim Owen', 'simply render the helper');\n\n run(SimplyObject, SimplyObject.set, 'firstName', 'Tom');\n\n equal(view.$().text(), 'Tom Owen', 'simply render the helper');\n } finally {\n delete EmberHandlebars.helpers['fullName'];\n }\n });\n\n test(\"shouldn't treat raw numbers as bound paths\", function() {\n EmberHandlebars.helper('sum', function(a, b) {\n return a + b;\n });\n\n view = EmberView.create({\n controller: EmberObject.create({aNumber: 1}),\n template: EmberHandlebars.compile(\"{{sum aNumber 1}} {{sum 0 aNumber}} {{sum 5 6}}\")\n });\n\n appendView();\n\n equal(view.$().text(), '2 1 11', \"helper output is correct\");\n\n run(view.controller, 'set', 'aNumber', 5);\n\n equal(view.$().text(), '6 5 11', \"helper still updates as expected\");\n });\n\n test(\"shouldn't treat quoted strings as bound paths\", function() {\n var helperCount = 0;\n EmberHandlebars.helper('concat', function(a, b, opt) {\n helperCount++;\n return a + b;\n });\n\n view = EmberView.create({\n controller: EmberObject.create({word: \"jerkwater\", loo: \"unused\"}),\n template: EmberHandlebars.compile(\"{{concat word 'loo'}} {{concat '' word}} {{concat 'will' \\\"didi\\\"}}\")\n });\n\n appendView();\n\n equal(view.$().text(), 'jerkwaterloo jerkwater willdidi', \"helper output is correct\");\n\n run(view.controller, 'set', 'word', 'bird');\n equal(view.$().text(), 'birdloo bird willdidi', \"helper still updates as expected\");\n\n run(view.controller, 'set', 'loo', 'soup-de-doo');\n equal(view.$().text(), 'birdloo bird willdidi', \"helper still updates as expected\");\n equal(helperCount, 5, \"changing controller property with same name as quoted string doesn't re-render helper\");\n });\n\n test(\"bound helpers can handle nulls in array (with primitives)\", function() {\n EmberHandlebars.helper('reverse', function(val) {\n return val ? val.split('').reverse().join('') : \"NOPE\";\n });\n\n view = EmberView.create({\n controller: EmberObject.create({\n things: A([ null, 0, undefined, false, \"OMG\" ])\n }),\n template: EmberHandlebars.compile(\"{{#each things}}{{this}}|{{reverse this}} {{/each}}{{#each thing in things}}{{thing}}|{{reverse thing}} {{/each}}\")\n });\n\n appendView();\n\n equal(view.$().text(), '|NOPE 0|NOPE |NOPE false|NOPE OMG|GMO |NOPE 0|NOPE |NOPE false|NOPE OMG|GMO ', \"helper output is correct\");\n\n run(function() {\n view.controller.things.pushObject('blorg');\n view.controller.things.shiftObject();\n });\n\n equal(view.$().text(), '0|NOPE |NOPE false|NOPE OMG|GMO blorg|grolb 0|NOPE |NOPE false|NOPE OMG|GMO blorg|grolb ', \"helper output is still correct\");\n });\n\n test(\"bound helpers can handle nulls in array (with objects)\", function() {\n EmberHandlebars.helper('print-foo', function(val) {\n return val ? get(val, 'foo') : \"NOPE\";\n });\n\n view = EmberView.create({\n controller: EmberObject.create({\n things: A([ null, { foo: 5 } ])\n }),\n template: EmberHandlebars.compile(\"{{#each things}}{{foo}}|{{print-foo this}} {{/each}}{{#each thing in things}}{{thing.foo}}|{{print-foo thing}} {{/each}}\")\n });\n\n appendView();\n\n equal(view.$().text(), '|NOPE 5|5 |NOPE 5|5 ', \"helper output is correct\");\n\n run(view.controller.things, 'pushObject', { foo: 6 });\n\n equal(view.$().text(), '|NOPE 5|5 6|6 |NOPE 5|5 6|6 ', \"helper output is correct\");\n });\n\n test(\"bound helpers can handle `this` keyword when it's a non-object\", function() {\n\n EmberHandlebars.helper(\"shout\", function(value) {\n return value + '!';\n });\n\n view = EmberView.create({\n controller: EmberObject.create({\n things: A(['alex'])\n }),\n template: EmberHandlebars.compile(\"{{#each things}}{{shout this}}{{/each}}\")\n });\n\n appendView();\n\n equal(view.$().text(), 'alex!', \"helper output is correct\");\n\n run(view.controller.things, 'shiftObject');\n equal(view.$().text(), '', \"helper output is correct\");\n\n run(view.controller.things, 'pushObject', 'wallace');\n equal(view.$().text(), 'wallace!', \"helper output is correct\");\n });\n });\ndefine(\"ember-handlebars/tests/helpers/custom_view_helper_test\",\n [\"ember-views/views/view\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-runtime/system/namespace\",\"ember-handlebars-compiler\",\"ember-metal/property_get\",\"ember-metal/property_set\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__) {\n \"use strict\";\n /*globals TemplateTests*/\n var EmberView = __dependency1__.View;\n var run = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var Namespace = __dependency4__[\"default\"];\n var EmberHandlebars = __dependency5__[\"default\"];\n\n var get = __dependency6__.get;\n var set = __dependency7__.set;\n\n var appendView = function() {\n run(function() { view.appendTo('#qunit-fixture'); });\n };\n\n var view;\n\n\n module(\"Handlebars custom view helpers\", {\n setup: function() {\n window.TemplateTests = Namespace.create();\n },\n teardown: function() {\n run(function() {\n if (view) {\n view.destroy();\n }\n });\n window.TemplateTests = undefined;\n }\n });\n\n test(\"should render an instance of the specified view\", function() {\n TemplateTests.OceanView = EmberView.extend({\n template: EmberHandlebars.compile('zomg, nice view')\n });\n\n EmberHandlebars.helper('oceanView', TemplateTests.OceanView);\n\n view = EmberView.create({\n controller: EmberObject.create(),\n template: EmberHandlebars.compile('{{oceanView tagName=\"strong\"}}')\n });\n\n appendView();\n\n var oceanViews = view.$().find(\"strong:contains('zomg, nice view')\");\n\n equal(oceanViews.length, 1, \"helper rendered an instance of the view\");\n });\n\n test(\"Should bind to this keyword\", function() {\n TemplateTests.OceanView = EmberView.extend({\n model: null,\n template: EmberHandlebars.compile('{{view.model}}')\n });\n\n EmberHandlebars.helper('oceanView', TemplateTests.OceanView);\n\n view = EmberView.create({\n context: 'foo',\n controller: EmberObject.create(),\n template: EmberHandlebars.compile('{{oceanView tagName=\"strong\" viewName=\"ocean\" model=this}}')\n });\n\n appendView();\n\n var oceanViews = view.$().find(\"strong:contains('foo')\");\n\n equal(oceanViews.length, 1, \"helper rendered an instance of the view\");\n\n run(function() {\n set(view, 'ocean.model', 'bar');\n });\n\n oceanViews = view.$().find(\"strong:contains('bar')\");\n\n equal(oceanViews.length, 1, \"helper rendered an instance of the view\");\n });\n });\ndefine(\"ember-handlebars/tests/helpers/debug_test\",\n [\"ember-metal/core\",\"ember-metal/logger\",\"ember-metal/run_loop\",\"ember-views/views/view\",\"ember-handlebars-compiler\",\"ember-handlebars/helpers/debug\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // Ember.lookup\n var EmberLogger = __dependency2__[\"default\"];\n var run = __dependency3__[\"default\"];\n var EmberView = __dependency4__.View;\n var EmberHandlebars = __dependency5__[\"default\"];\n var logHelper = __dependency6__.logHelper;\n\n var originalLookup = Ember.lookup, lookup;\n var originalLog, logCalls;\n var originalLogHelper;\n var view;\n\n var appendView = function() {\n run(function() { view.appendTo('#qunit-fixture'); });\n };\n\n\n module(\"Handlebars {{log}} helper\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n\n originalLogHelper = EmberHandlebars.helpers.log;\n EmberHandlebars.registerHelper(\"log\", logHelper);\n\n originalLog = EmberLogger.log;\n logCalls = [];\n EmberLogger.log = function() { logCalls.push.apply(logCalls, arguments); };\n },\n\n teardown: function() {\n if (view) {\n run(function() {\n view.destroy();\n });\n view = null;\n }\n\n EmberLogger.log = originalLog;\n EmberHandlebars.helpers.log = originalLogHelper;\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"should be able to log multiple properties\", function() {\n var context = {\n value: 'one',\n valueTwo: 'two'\n };\n\n view = EmberView.create({\n context: context,\n template: EmberHandlebars.compile('{{log value valueTwo}}')\n });\n\n appendView();\n\n equal(view.$().text(), \"\", \"shouldn't render any text\");\n equal(logCalls[0], 'one');\n equal(logCalls[1], 'two');\n });\n\n test(\"should be able to log primitives\", function() {\n var context = {\n value: 'one',\n valueTwo: 'two'\n };\n\n view = EmberView.create({\n context: context,\n template: EmberHandlebars.compile('{{log value \"foo\" 0 valueTwo true}}')\n });\n\n appendView();\n\n equal(view.$().text(), \"\", \"shouldn't render any text\");\n strictEqual(logCalls[0], 'one');\n strictEqual(logCalls[1], 'foo');\n strictEqual(logCalls[2], 0);\n strictEqual(logCalls[3], 'two');\n strictEqual(logCalls[4], true);\n });\n });\ndefine(\"ember-handlebars/tests/helpers/each_test\",\n [\"ember-metal/core\",\"ember-runtime/system/object\",\"ember-metal/run_loop\",\"ember-views/views/view\",\"ember-metal/computed\",\"ember-runtime/controllers/array_controller\",\"ember-handlebars-compiler\",\"ember-runtime/system/native_array\",\"ember-runtime/controllers/controller\",\"ember-runtime/controllers/object_controller\",\"ember-runtime/system/container\",\"ember-metal/property_get\",\"ember-metal/property_set\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__) {\n \"use strict\";\n /*jshint newcap:false*/\n var Ember = __dependency1__[\"default\"];\n // Ember.lookup;\n var EmberObject = __dependency2__[\"default\"];\n var run = __dependency3__[\"default\"];\n var EmberView = __dependency4__.View;\n var computed = __dependency5__.computed;\n var ArrayController = __dependency6__[\"default\"];\n var EmberHandlebars = __dependency7__[\"default\"];\n // import {expectAssertion} from \"ember-metal/tests/debug_helpers\";\n var A = __dependency8__.A;\n var EmberController = __dependency9__.Controller;\n var ObjectController = __dependency10__[\"default\"];\n var Container = __dependency11__[\"default\"];\n\n var get = __dependency12__.get;\n var set = __dependency13__.set;\n\n var people, view;\n var template, templateMyView;\n var templateFor = function(template) {\n return EmberHandlebars.compile(template);\n };\n\n var originalLookup = Ember.lookup, lookup;\n\n module(\"the #each helper\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n\n template = templateFor(\"{{#each view.people}}{{name}}{{/each}}\");\n people = A([{ name: \"Steve Holt\" }, { name: \"Annabelle\" }]);\n\n view = EmberView.create({\n template: template,\n people: people\n });\n\n\n templateMyView = templateFor(\"{{name}}\");\n lookup.MyView = EmberView.extend({\n template: templateMyView\n });\n\n append(view);\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n view = null;\n });\n Ember.lookup = originalLookup;\n }\n });\n\n\n var append = function(view) {\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n };\n\n var assertHTML = function(view, expectedHTML) {\n var html = view.$().html();\n\n // IE 8 (and prior?) adds the \\r\\n\n html = html.replace(/]*><\\/script>/ig, '').replace(/[\\r\\n]/g, '');\n\n equal(html, expectedHTML);\n };\n\n var assertText = function(view, expectedText) {\n equal(view.$().text(), expectedText);\n };\n\n test(\"it renders the template for each item in an array\", function() {\n assertHTML(view, \"Steve HoltAnnabelle\");\n });\n\n test(\"it updates the view if an item is added\", function() {\n run(function() {\n people.pushObject({ name: \"Tom Dale\" });\n });\n\n assertHTML(view, \"Steve HoltAnnabelleTom Dale\");\n });\n\n test(\"it allows you to access the current context using {{this}}\", function() {\n run(function() { view.destroy(); }); // destroy existing view\n view = EmberView.create({\n template: templateFor(\"{{#each view.people}}{{this}}{{/each}}\"),\n people: A(['Black Francis', 'Joey Santiago', 'Kim Deal', 'David Lovering'])\n });\n\n append(view);\n\n assertHTML(view, \"Black FrancisJoey SantiagoKim DealDavid Lovering\");\n });\n\n test(\"it updates the view if an item is removed\", function() {\n run(function() {\n people.removeAt(0);\n });\n\n assertHTML(view, \"Annabelle\");\n });\n\n test(\"it updates the view if an item is replaced\", function() {\n run(function() {\n people.removeAt(0);\n people.insertAt(0, { name: \"Kazuki\" });\n });\n\n assertHTML(view, \"KazukiAnnabelle\");\n });\n\n test(\"can add and replace in the same runloop\", function() {\n run(function() {\n people.pushObject({ name: \"Tom Dale\" });\n people.removeAt(0);\n people.insertAt(0, { name: \"Kazuki\" });\n });\n\n assertHTML(view, \"KazukiAnnabelleTom Dale\");\n });\n\n test(\"can add and replace the object before the add in the same runloop\", function() {\n run(function() {\n people.pushObject({ name: \"Tom Dale\" });\n people.removeAt(1);\n people.insertAt(1, { name: \"Kazuki\" });\n });\n\n assertHTML(view, \"Steve HoltKazukiTom Dale\");\n });\n\n test(\"can add and replace complicatedly\", function() {\n run(function() {\n people.pushObject({ name: \"Tom Dale\" });\n people.removeAt(1);\n people.insertAt(1, { name: \"Kazuki\" });\n people.pushObject({ name: \"Firestone\" });\n people.pushObject({ name: \"McMunch\" });\n people.removeAt(3);\n });\n\n assertHTML(view, \"Steve HoltKazukiTom DaleMcMunch\");\n });\n\n test(\"can add and replace complicatedly harder\", function() {\n run(function() {\n people.pushObject({ name: \"Tom Dale\" });\n people.removeAt(1);\n people.insertAt(1, { name: \"Kazuki\" });\n people.pushObject({ name: \"Firestone\" });\n people.pushObject({ name: \"McMunch\" });\n people.removeAt(2);\n });\n\n assertHTML(view, \"Steve HoltKazukiFirestoneMcMunch\");\n });\n\n test(\"it works inside a ul element\", function() {\n var ulView = EmberView.create({\n template: templateFor('
      {{#each view.people}}
    • {{name}}
    • {{/each}}
    '),\n people: people\n });\n\n append(ulView);\n\n equal(ulView.$('li').length, 2, \"renders two
  • elements\");\n\n run(function() {\n people.pushObject({name: \"Black Francis\"});\n });\n\n equal(ulView.$('li').length, 3, \"renders an additional
  • element when an object is added\");\n\n run(function() {\n ulView.destroy();\n });\n });\n\n test(\"it works inside a table element\", function() {\n var tableView = EmberView.create({\n template: templateFor('{{#each view.people}}{{/each}}
    {{name}}
    '),\n people: people\n });\n\n append(tableView);\n\n equal(tableView.$('td').length, 2, \"renders two elements\");\n\n run(function() {\n people.pushObject({name: \"Black Francis\"});\n });\n\n equal(tableView.$('td').length, 3, \"renders an additional element when an object is added\");\n\n run(function() {\n people.insertAt(0, {name: \"Kim Deal\"});\n });\n\n equal(tableView.$('td').length, 4, \"renders an additional when an object is inserted at the beginning of the array\");\n\n run(function() {\n tableView.destroy();\n });\n });\n\n test(\"it supports itemController\", function() {\n var Controller = EmberController.extend({\n controllerName: computed(function() {\n return \"controller:\"+this.get('content.name');\n })\n });\n\n var container = new Container();\n\n run(function() { view.destroy(); }); // destroy existing view\n\n var parentController = {\n container: container\n };\n\n container.register('controller:array', ArrayController.extend());\n\n view = EmberView.create({\n container: container,\n template: templateFor('{{#each view.people itemController=\"person\"}}{{controllerName}}{{/each}}'),\n people: people,\n controller: parentController\n });\n\n container.register('controller:person', Controller);\n\n append(view);\n\n equal(view.$().text(), \"controller:Steve Holtcontroller:Annabelle\");\n\n run(function() {\n view.rerender();\n });\n\n assertText(view, \"controller:Steve Holtcontroller:Annabelle\");\n\n run(function() {\n people.pushObject({ name: \"Yehuda Katz\" });\n });\n\n assertText(view, \"controller:Steve Holtcontroller:Annabellecontroller:Yehuda Katz\");\n\n run(function() {\n set(view, 'people', A([{ name: \"Trek Glowacki\" }, { name: \"Geoffrey Grosenbach\" }]));\n });\n\n assertText(view, \"controller:Trek Glowackicontroller:Geoffrey Grosenbach\");\n\n var controller = view.get('_childViews')[0].get('controller');\n strictEqual(view.get('_childViews')[0].get('_arrayController.target'), parentController, \"the target property of the child controllers are set correctly\");\n });\n\n test(\"itemController specified in template gets a parentController property\", function() {\n // using an ObjectController for this test to verify that parentController does accidentally get set\n // on the proxied model.\n var Controller = ObjectController.extend({\n controllerName: computed(function() {\n return \"controller:\" + get(this, 'content.name') + ' of ' + get(this, 'parentController.company');\n })\n }),\n container = new Container(),\n parentController = {\n container: container,\n company: 'Yapp'\n };\n\n container.register('controller:array', ArrayController.extend());\n run(function() { view.destroy(); }); // destroy existing view\n\n view = EmberView.create({\n container: container,\n template: templateFor('{{#each view.people itemController=\"person\"}}{{controllerName}}{{/each}}'),\n people: people,\n controller: parentController\n });\n\n container.register('controller:person', Controller);\n\n append(view);\n\n equal(view.$().text(), \"controller:Steve Holt of Yappcontroller:Annabelle of Yapp\");\n });\n\n test(\"itemController specified in ArrayController gets a parentController property\", function() {\n var PersonController = ObjectController.extend({\n controllerName: computed(function() {\n return \"controller:\" + get(this, 'content.name') + ' of ' + get(this, 'parentController.company');\n })\n }),\n PeopleController = ArrayController.extend({\n content: people,\n itemController: 'person',\n company: 'Yapp'\n }),\n container = new Container();\n\n container.register('controller:people', PeopleController);\n container.register('controller:person', PersonController);\n run(function() { view.destroy(); }); // destroy existing view\n\n view = EmberView.create({\n container: container,\n template: templateFor('{{#each}}{{controllerName}}{{/each}}'),\n controller: container.lookup('controller:people')\n });\n\n\n append(view);\n\n equal(view.$().text(), \"controller:Steve Holt of Yappcontroller:Annabelle of Yapp\");\n });\n\n test(\"itemController's parentController property, when the ArrayController has a parentController\", function() {\n var PersonController = ObjectController.extend({\n controllerName: computed(function() {\n return \"controller:\" + get(this, 'content.name') + ' of ' + get(this, 'parentController.company');\n })\n }),\n PeopleController = ArrayController.extend({\n content: people,\n itemController: 'person',\n parentController: computed(function(){\n return this.container.lookup('controller:company');\n }),\n company: 'Yapp'\n }),\n CompanyController = EmberController.extend(),\n container = new Container();\n\n container.register('controller:company', CompanyController);\n container.register('controller:people', PeopleController);\n container.register('controller:person', PersonController);\n\n run(function() { view.destroy(); }); // destroy existing view\n view = EmberView.create({\n container: container,\n template: templateFor('{{#each}}{{controllerName}}{{/each}}'),\n controller: container.lookup('controller:people')\n });\n\n\n append(view);\n\n equal(view.$().text(), \"controller:Steve Holt of Yappcontroller:Annabelle of Yapp\");\n });\n\n test(\"it supports itemController when using a custom keyword\", function() {\n var Controller = EmberController.extend({\n controllerName: computed(function() {\n return \"controller:\"+this.get('content.name');\n })\n });\n\n var container = new Container();\n container.register('controller:array', ArrayController.extend());\n\n run(function() { view.destroy(); }); // destroy existing view\n view = EmberView.create({\n container: container,\n template: templateFor('{{#each person in view.people itemController=\"person\"}}{{person.controllerName}}{{/each}}'),\n people: people,\n controller: {\n container: container\n }\n });\n\n container.register('controller:person', Controller);\n\n append(view);\n\n equal(view.$().text(), \"controller:Steve Holtcontroller:Annabelle\");\n\n run(function() {\n view.rerender();\n });\n\n equal(view.$().text(), \"controller:Steve Holtcontroller:Annabelle\");\n });\n\n test(\"it supports {{itemView=}}\", function() {\n var container = new Container();\n\n var itemView = EmberView.extend({\n template: templateFor('itemView:{{name}}')\n });\n\n run(function() { view.destroy(); }); // destroy existing view\n view = EmberView.create({\n template: templateFor('{{each view.people itemView=\"anItemView\"}}'),\n people: people,\n controller: {\n container: container\n }\n });\n\n container.register('view:anItemView', itemView);\n\n append(view);\n\n assertText(view, \"itemView:Steve HoltitemView:Annabelle\");\n });\n\n\n test(\"it defers all normalization of itemView names to the resolver\", function() {\n var container = new Container();\n\n var itemView = EmberView.extend({\n template: templateFor('itemView:{{name}}')\n });\n\n run(function() { view.destroy(); }); // destroy existing view\n view = EmberView.create({\n template: templateFor('{{each view.people itemView=\"an-item-view\"}}'),\n people: people,\n controller: {\n container: container\n }\n });\n\n container.register('view:an-item-view', itemView);\n container.resolve = function(fullname) {\n equal(fullname, \"view:an-item-view\", \"leaves fullname untouched\");\n return Container.prototype.resolve.call(this, fullname);\n };\n append(view);\n\n });\n\n test(\"it supports {{itemViewClass=}}\", function() {\n run(function() { view.destroy(); }); // destroy existing view\n view = EmberView.create({\n template: templateFor('{{each view.people itemViewClass=\"MyView\"}}'),\n people: people\n });\n\n append(view);\n\n assertText(view, \"Steve HoltAnnabelle\");\n });\n\n test(\"it supports {{itemViewClass=}} with tagName (DEPRECATED)\", function() {\n run(function() { view.destroy(); }); // destroy existing view\n view = EmberView.create({\n template: templateFor('{{each view.people itemViewClass=\"MyView\" tagName=\"ul\"}}'),\n people: people\n });\n\n expectDeprecation(/Supplying a tagName to Metamorph views is unreliable and is deprecated./);\n\n append(view);\n\n var html = view.$().html();\n\n // IE 8 (and prior?) adds the \\r\\n\n html = html.replace(/]*><\\/script>/ig, '').replace(/[\\r\\n]/g, '');\n html = html.replace(/]*><\\/div>/ig, '').replace(/[\\r\\n]/g, '');\n html = html.replace(/]*/ig, '
  • steve holt
  • annabelle
  • \");\n });\n\n test(\"it supports {{itemViewClass=}} with in format\", function() {\n\n lookup.MyView = EmberView.extend({\n template: templateFor(\"{{person.name}}\")\n });\n\n run(function() { view.destroy(); }); // destroy existing view\n view = EmberView.create({\n template: templateFor('{{each person in view.people itemViewClass=\"MyView\"}}'),\n people: people\n });\n\n append(view);\n\n assertText(view, \"Steve HoltAnnabelle\");\n\n });\n\n test(\"it supports {{else}}\", function() {\n run(function() { view.destroy(); }); // destroy existing view\n view = EmberView.create({\n template: templateFor(\"{{#each view.items}}{{this}}{{else}}Nothing{{/each}}\"),\n items: A(['one', 'two'])\n });\n\n append(view);\n\n assertHTML(view, \"onetwo\");\n\n run(function() {\n view.set('items', A());\n });\n\n assertHTML(view, \"Nothing\");\n });\n\n test(\"it works with the controller keyword\", function() {\n var controller = ArrayController.create({\n content: A([\"foo\", \"bar\", \"baz\"])\n });\n\n run(function() { view.destroy(); }); // destroy existing view\n view = EmberView.create({\n controller: controller,\n template: templateFor(\"{{#view}}{{#each controller}}{{this}}{{/each}}{{/view}}\")\n });\n\n append(view);\n\n equal(view.$().text(), \"foobarbaz\");\n });\n\n module(\"{{#each foo in bar}}\", {\n teardown: function() {\n run(function() {\n view.destroy();\n });\n }\n });\n\n test(\"#each accepts a name binding\", function() {\n view = EmberView.create({\n template: templateFor(\"{{#each item in view.items}}{{view.title}} {{item}}{{/each}}\"),\n title: \"My Cool Each Test\",\n items: A([1, 2])\n });\n\n append(view);\n\n equal(view.$().text(), \"My Cool Each Test 1My Cool Each Test 2\");\n });\n\n test(\"#each accepts a name binding and does not change the context\", function() {\n var controller = EmberController.create({\n name: 'bob the controller'\n }),\n obj = EmberObject.create({\n name: 'henry the item'\n });\n\n view = EmberView.create({\n template: templateFor(\"{{#each item in view.items}}{{name}}{{/each}}\"),\n title: \"My Cool Each Test\",\n items: A([obj]),\n controller: controller\n });\n\n append(view);\n\n equal(view.$().text(), \"bob the controller\");\n });\n\n\n test(\"#each accepts a name binding and can display child properties\", function() {\n view = EmberView.create({\n template: templateFor(\"{{#each item in view.items}}{{view.title}} {{item.name}}{{/each}}\"),\n title: \"My Cool Each Test\",\n items: A([{ name: 1 }, { name: 2 }])\n });\n\n append(view);\n\n equal(view.$().text(), \"My Cool Each Test 1My Cool Each Test 2\");\n });\n\n test(\"#each accepts 'this' as the right hand side\", function() {\n view = EmberView.create({\n template: templateFor(\"{{#each item in this}}{{view.title}} {{item.name}}{{/each}}\"),\n title: \"My Cool Each Test\",\n controller: A([{ name: 1 }, { name: 2 }])\n });\n\n append(view);\n\n equal(view.$().text(), \"My Cool Each Test 1My Cool Each Test 2\");\n });\n\n test(\"views inside #each preserve the new context\", function() {\n var controller = A([ { name: \"Adam\" }, { name: \"Steve\" } ]);\n\n view = EmberView.create({\n controller: controller,\n template: templateFor('{{#each controller}}{{#view}}{{name}}{{/view}}{{/each}}')\n });\n\n append(view);\n\n equal(view.$().text(), \"AdamSteve\");\n });\n\n test(\"controller is assignable inside an #each\", function() {\n var controller = ArrayController.create({\n content: A([ { name: \"Adam\" }, { name: \"Steve\" } ])\n });\n\n view = EmberView.create({\n controller: controller,\n template: templateFor('{{#each personController in this}}{{#view controllerBinding=\"personController\"}}{{name}}{{/view}}{{/each}}')\n });\n\n append(view);\n\n equal(view.$().text(), \"AdamSteve\");\n });\n\n test(\"single-arg each defaults to current context\", function() {\n view = EmberView.create({\n context: A([ { name: \"Adam\" }, { name: \"Steve\" } ]),\n template: templateFor('{{#each}}{{name}}{{/each}}')\n });\n\n append(view);\n\n equal(view.$().text(), \"AdamSteve\");\n });\n\n test(\"single-arg each will iterate over controller if present\", function() {\n view = EmberView.create({\n controller: A([ { name: \"Adam\" }, { name: \"Steve\" } ]),\n template: templateFor('{{#each}}{{name}}{{/each}}')\n });\n\n append(view);\n\n equal(view.$().text(), \"AdamSteve\");\n });\n\n test(\"it asserts when the morph tags disagree on their parentage\", function() {\n view = EmberView.create({\n controller: A(['Cyril', 'David']),\n template: templateFor('{{#each}}{{/each}}
    {{this}}
    ')\n });\n\n expectAssertion(function() {\n append(view);\n }, /The metamorph tags, metamorph-\\d+-start and metamorph-\\d+-end, have different parents.\\nThe browser has fixed your template to output valid HTML \\(for example, check that you have properly closed all tags and have used a TBODY tag when creating a table with '\\{\\{#each\\}\\}'\\)/);\n });\n\n test(\"it doesn't assert when the morph tags have the same parent\", function() {\n view = EmberView.create({\n controller: A(['Cyril', 'David']),\n template: templateFor('{{#each}}{{/each}}
    {{this}}
    ')\n });\n\n append(view);\n\n ok(true, \"No assertion from valid template\");\n });\n\n test(\"itemController specified in template with name binding does not change context\", function() {\n var Controller = EmberController.extend({\n controllerName: computed(function() {\n return \"controller:\"+this.get('content.name');\n })\n });\n\n var container = new Container();\n\n people = A([{ name: \"Steve Holt\" }, { name: \"Annabelle\" }]);\n\n var parentController = {\n container: container,\n people: people,\n controllerName: 'controller:parentController'\n };\n\n container.register('controller:array', ArrayController.extend());\n\n view = EmberView.create({\n container: container,\n template: templateFor('{{#each person in people itemController=\"person\"}}{{controllerName}} - {{person.controllerName}} - {{/each}}'),\n controller: parentController\n });\n\n container.register('controller:person', Controller);\n\n append(view);\n\n equal(view.$().text(), \"controller:parentController - controller:Steve Holt - controller:parentController - controller:Annabelle - \");\n\n run(function() {\n people.pushObject({ name: \"Yehuda Katz\" });\n });\n\n assertText(view, \"controller:parentController - controller:Steve Holt - controller:parentController - controller:Annabelle - controller:parentController - controller:Yehuda Katz - \");\n\n run(function() {\n set(parentController, 'people', A([{ name: \"Trek Glowacki\" }, { name: \"Geoffrey Grosenbach\" }]));\n });\n\n assertText(view, \"controller:parentController - controller:Trek Glowacki - controller:parentController - controller:Geoffrey Grosenbach - \");\n\n var controller = view.get('_childViews')[0].get('controller');\n strictEqual(view.get('_childViews')[0].get('_arrayController.target'), parentController, \"the target property of the child controllers are set correctly\");\n });\n\n test(\"itemController specified in ArrayController with name binding does not change context\", function() {\n people = A([{ name: \"Steve Holt\" }, { name: \"Annabelle\" }]);\n\n var PersonController = ObjectController.extend({\n controllerName: computed(function() {\n return \"controller:\" + get(this, 'content.name') + ' of ' + get(this, 'parentController.company');\n })\n }),\n PeopleController = ArrayController.extend({\n content: people,\n itemController: 'person',\n company: 'Yapp',\n controllerName: 'controller:people'\n }),\n container = new Container();\n\n container.register('controller:people', PeopleController);\n container.register('controller:person', PersonController);\n\n view = EmberView.create({\n container: container,\n template: templateFor('{{#each person in this}}{{controllerName}} - {{person.controllerName}} - {{/each}}'),\n controller: container.lookup('controller:people')\n });\n\n\n append(view);\n\n equal(view.$().text(), \"controller:people - controller:Steve Holt of Yapp - controller:people - controller:Annabelle of Yapp - \");\n });\n });\ndefine(\"ember-handlebars/tests/helpers/group_test\",\n [\"ember-metal/run_loop\",\"ember-views/system/jquery\",\"ember-views/views/view\",\"ember-handlebars-compiler\",\"ember-runtime/system/array_proxy\",\"ember-runtime/system/native_array\",\"ember-metal/property_get\",\"ember-metal/property_set\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n /*jshint newcap:false*/\n\n var run = __dependency1__[\"default\"];\n var jQuery = __dependency2__[\"default\"];\n var EmberView = __dependency3__.View;\n var EmberHandlebars = __dependency4__[\"default\"];\n var ArrayProxy = __dependency5__[\"default\"];\n var A = __dependency6__.A;\n\n var trim = jQuery.trim;\n\n var get = __dependency7__.get;\n var set = __dependency8__.set;\n\n var view;\n\n module(\"EmberHandlebars - group flag\", {\n setup: function() {},\n\n teardown: function() {\n run(function() {\n view.destroy();\n });\n run.cancelTimers();\n }\n });\n\n function createGroupedView(template, context) {\n var options = {\n context: context,\n template: EmberHandlebars.compile(template),\n templateData: {insideGroup: true, keywords: {}}\n };\n run(function() {\n view = EmberView.create(options);\n });\n }\n\n function appendView() {\n run(function() { view.appendTo('#qunit-fixture'); });\n }\n\n test(\"should properly modify behavior inside the block\", function() {\n createGroupedView(\"{{msg}}\", {msg: 'ohai'});\n appendView();\n\n equal(view.$('script').length, 0, \"No Metamorph markers are output\");\n equal(view.$().text(), 'ohai', 'Original value was rendered');\n\n run(function() {\n view.set('context.msg', 'ohbai');\n });\n equal(view.$().text(), 'ohbai', 'Updated value was rendered');\n\n run(function() {\n view.set('context.msg', null);\n });\n equal(view.$().text(), '', 'null value properly rendered as a blank');\n\n run(function() {\n view.set('context.msg', undefined);\n });\n equal(view.$().text(), '', 'undefined value properly rendered as a blank');\n });\n\n test(\"property changes inside views should only rerender their view\", function() {\n createGroupedView(\n '{{#view}}{{msg}}{{/view}}',\n {msg: 'ohai'}\n );\n var rerenderWasCalled = false;\n view.reopen({\n rerender: function() { rerenderWasCalled = true; this._super(); }\n });\n appendView();\n equal(view.$('script').length, 0, \"No Metamorph markers are output\");\n equal(trim(view.$().text()), 'ohai', 'Original value was rendered');\n\n run(function() {\n view.set('context.msg', 'ohbai');\n });\n ok(!rerenderWasCalled, \"The GroupView rerender method was not called\");\n equal(trim(view.$().text()), 'ohbai', \"The updated value was rendered\");\n });\n\n test(\"should work with bind-attr\", function() {\n createGroupedView(\n '',\n {innerClass: 'magic'}\n );\n appendView();\n equal(view.$('.magic').length, 1);\n\n run(function() {\n view.set('context.innerClass', 'bindings');\n });\n equal(view.$('.bindings').length, 1);\n\n run(function() {\n view.rerender();\n });\n equal(view.$('.bindings').length, 1);\n });\n\n test(\"should work with the #if helper\", function() {\n createGroupedView(\n '{{#if something}}hooray{{else}}boo{{/if}}',\n {something: true}\n );\n appendView();\n\n equal(view.$('script').length, 0, \"No Metamorph markers are output\");\n equal(trim(view.$().text()), 'hooray', 'Truthy text was rendered');\n\n run(function() {\n view.set('context.something', false);\n });\n equal(trim(view.$().text()), 'boo', \"The falsy value was rendered\");\n });\n\n test(\"#each with no content\", function() {\n expect(0);\n createGroupedView(\n \"{{#each missing}}{{this}}{{/each}}\"\n );\n appendView();\n });\n\n test(\"#each's content can be changed right before a destroy\", function() {\n expect(0);\n\n createGroupedView(\n \"{{#each numbers}}{{this}}{{/each}}\",\n {numbers: A([1,2,3])}\n );\n appendView();\n\n run(function() {\n view.set('context.numbers', A([3,2,1]));\n view.destroy();\n });\n });\n\n test(\"#each can be nested\", function() {\n createGroupedView(\n \"{{#each numbers}}{{this}}{{/each}}\",\n {numbers: A([1, 2, 3])}\n );\n appendView();\n equal(view.$('script').length, 0, \"No Metamorph markers are output\");\n equal(view.$().text(), '123', \"The content was rendered\");\n\n run(function() {\n view.get('context.numbers').pushObject(4);\n });\n\n equal(view.$().text(), '1234', \"The array observer properly updated the rendered output\");\n\n run(function() {\n view.set('context.numbers', A(['a', 'b', 'c']));\n });\n\n equal(view.$().text(), 'abc', \"Replacing the array properly updated the rendered output\");\n });\n\n test(\"#each can be used with an ArrayProxy\", function() {\n createGroupedView(\n \"{{#each numbers}}{{this}}{{/each}}\",\n {numbers: ArrayProxy.create({content: A([1, 2, 3])})}\n );\n appendView();\n equal(view.$('script').length, 0, \"No Metamorph markers are output\");\n equal(view.$().text(), '123', \"The content was rendered\");\n });\n\n test(\"an #each can be nested with a view inside\", function() {\n var yehuda = {name: 'Yehuda'};\n createGroupedView(\n '{{#each people}}{{#view}}{{name}}{{/view}}{{/each}}',\n {people: A([yehuda, {name: 'Tom'}])}\n );\n appendView();\n equal(view.$('script').length, 0, \"No Metamorph markers are output\");\n equal(view.$().text(), 'YehudaTom', \"The content was rendered\");\n\n run(function() {\n set(yehuda, 'name', 'Erik');\n });\n\n equal(view.$().text(), 'ErikTom', \"The updated object's view was rerendered\");\n });\n\n test(\"#each with groupedRows=true behaves like a normal bound #each\", function() {\n createGroupedView(\n '{{#each numbers groupedRows=true}}{{this}}{{/each}}',\n {numbers: A([1, 2, 3])}\n );\n appendView();\n equal(view.$('script').length, 8, \"Correct number of Metamorph markers are output\");\n equal(view.$().text(), '123');\n\n run(function() {\n view.get('context.numbers').pushObject(4);\n });\n\n equal(view.$('script').length, 10, \"Correct number of Metamorph markers are output\");\n equal(view.$().text(), '1234');\n });\n\n test(\"#each with itemViewClass behaves like a normal bound #each\", function() {\n createGroupedView(\n '{{#each people itemViewClass=\"Ember.View\"}}{{name}}{{/each}}',\n {people: A([{name: 'Erik'}, {name: 'Peter'}])}\n );\n appendView();\n equal(view.$('script').length, 2, \"Correct number of Metamorph markers are output\");\n equal(view.$('.ember-view').length, 2, \"Correct number of views are output\");\n equal(view.$().text(), 'ErikPeter');\n\n run(function() {\n view.get('context.people').pushObject({name: 'Tom'});\n });\n\n equal(view.$('script').length, 2, \"Correct number of Metamorph markers are output\");\n equal(view.$('.ember-view').length, 3, \"Correct number of views are output\");\n // IE likes to add newlines\n equal(trim(view.$().text()), 'ErikPeterTom');\n });\n\n test(\"should escape HTML in normal mustaches\", function() {\n createGroupedView(\n '{{msg}}', {msg: 'you need to be more bold'}\n );\n appendView();\n equal(view.$('b').length, 0, \"does not create an element\");\n equal(view.$().text(), 'you need to be more bold', \"inserts entities, not elements\");\n });\n\n test(\"should not escape HTML in triple mustaches\", function() {\n createGroupedView(\n '{{{msg}}}', {msg: 'you need to be more bold'}\n );\n appendView();\n equal(view.$('b').length, 1, \"creates an element\");\n });\n });\ndefine(\"ember-handlebars/tests/helpers/if_unless_test\",\n [\"ember-runtime/system/object\",\"ember-metal/run_loop\",\"ember-views/views/view\",\"ember-runtime/system/object_proxy\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var EmberView = __dependency3__.View;\n var ObjectProxy = __dependency4__[\"default\"];\n\n var appendView = function(view) {\n run(function() { view.appendTo('#qunit-fixture'); });\n };\n\n var compile = Ember.Handlebars.compile;\n\n var view;\n\n module(\"Handlebars {{#if}} and {{#unless}} helpers\", {\n teardown: function() {\n run(function() {\n if (view) {\n view.destroy();\n }\n });\n }\n });\n\n test(\"unless should keep the current context (#784)\", function() {\n view = EmberView.create({\n o: EmberObject.create({foo: '42'}),\n\n template: compile('{{#with view.o}}{{#view Ember.View}}{{#unless view.doesNotExist}}foo: {{foo}}{{/unless}}{{/view}}{{/with}}')\n });\n\n appendView(view);\n\n equal(view.$().text(), 'foo: 42');\n });\n\n test(\"The `if` helper tests for `isTruthy` if available\", function() {\n view = EmberView.create({\n truthy: EmberObject.create({ isTruthy: true }),\n falsy: EmberObject.create({ isTruthy: false }),\n\n template: compile('{{#if view.truthy}}Yep{{/if}}{{#if view.falsy}}Nope{{/if}}')\n });\n\n appendView(view);\n\n equal(view.$().text(), 'Yep');\n });\n\n test(\"The `if` helper does not print the contents for an object proxy without content\", function() {\n view = EmberView.create({\n truthy: ObjectProxy.create({ content: {} }),\n falsy: ObjectProxy.create({ content: null }),\n\n template: compile('{{#if view.truthy}}Yep{{/if}}{{#if view.falsy}}Nope{{/if}}')\n });\n\n appendView(view);\n\n equal(view.$().text(), 'Yep');\n });\n\n test(\"The `if` helper updates if an object proxy gains or loses context\", function() {\n view = EmberView.create({\n proxy: ObjectProxy.create({ content: null }),\n\n template: compile('{{#if view.proxy}}Yep{{/if}}')\n });\n\n appendView(view);\n\n equal(view.$().text(), '');\n\n run(function() {\n view.set('proxy.content', {});\n });\n\n equal(view.$().text(), 'Yep');\n\n run(function() {\n view.set('proxy.content', null);\n });\n\n equal(view.$().text(), '');\n });\n\n test(\"The `if` helper updates if an array is empty or not\", function() {\n view = EmberView.create({\n array: Ember.A(),\n\n template: compile('{{#if view.array}}Yep{{/if}}')\n });\n\n appendView(view);\n\n equal(view.$().text(), '');\n\n run(function() {\n view.get('array').pushObject(1);\n });\n\n equal(view.$().text(), 'Yep');\n\n run(function() {\n view.get('array').removeObject(1);\n });\n\n equal(view.$().text(), '');\n });\n\n test(\"The `if` helper updates when the value changes\", function() {\n view = EmberView.create({\n conditional: true,\n template: compile('{{#if view.conditional}}Yep{{/if}}')\n });\n appendView(view);\n equal(view.$().text(), 'Yep');\n run(function(){\n view.set('conditional', false);\n });\n equal(view.$().text(), '');\n });\n\n test(\"The `unbound if` helper does not update when the value changes\", function() {\n view = EmberView.create({\n conditional: true,\n template: compile('{{#unbound if view.conditional}}Yep{{/unbound}}')\n });\n appendView(view);\n equal(view.$().text(), 'Yep');\n run(function(){\n view.set('conditional', false);\n });\n equal(view.$().text(), 'Yep');\n });\n\n test(\"The `unless` helper updates when the value changes\", function() {\n view = EmberView.create({\n conditional: false,\n template: compile('{{#unless view.conditional}}Nope{{/unless}}')\n });\n appendView(view);\n equal(view.$().text(), 'Nope');\n run(function(){\n view.set('conditional', true);\n });\n equal(view.$().text(), '');\n });\n\n test(\"The `unbound if` helper does not update when the value changes\", function() {\n view = EmberView.create({\n conditional: false,\n template: compile('{{#unbound unless view.conditional}}Nope{{/unbound}}')\n });\n appendView(view);\n equal(view.$().text(), 'Nope');\n run(function(){\n view.set('conditional', true);\n });\n equal(view.$().text(), 'Nope');\n });\n });\ndefine(\"ember-handlebars/tests/helpers/loc_test\",\n [\"ember-metal/run_loop\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var EmberView = __dependency2__.View;\n var buildView = function(template, context) {\n return EmberView.create({\n template: Ember.Handlebars.compile(template),\n context: (context || {})\n });\n };\n\n var appendView = function(view) {\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n };\n\n var destroyView = function(view) {\n run(function() {\n view.destroy();\n });\n };\n\n var oldString;\n\n module('Handlebars {{loc valueToLocalize}} helper', {\n setup: function() {\n oldString = Ember.STRINGS;\n Ember.STRINGS = {\n '_Howdy Friend': 'Hallo Freund'\n };\n },\n\n teardown: function() {\n Ember.STRINGS = oldString;\n }\n });\n\n test(\"let the original value through by default\", function() {\n var view = buildView('{{loc \"Hiya buddy!\"}}');\n appendView(view);\n\n equal(view.$().text(), \"Hiya buddy!\");\n\n destroyView(view);\n });\n\n test(\"localize a simple string\", function() {\n var view = buildView('{{loc \"_Howdy Friend\"}}');\n appendView(view);\n\n equal(view.$().text(), \"Hallo Freund\");\n\n destroyView(view);\n });\n });\ndefine(\"ember-handlebars/tests/helpers/partial_test\",\n [\"ember-runtime/system/object\",\"ember-metal/run_loop\",\"ember-views/views/view\",\"ember-views/system/jquery\",\"ember-runtime/system/container\",\"ember-handlebars-compiler\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var EmberView = __dependency3__.View;\n var jQuery = __dependency4__[\"default\"];\n var trim = jQuery.trim;\n var Container = __dependency5__[\"default\"];\n var EmberHandlebars = __dependency6__[\"default\"];\n var compile = EmberHandlebars.compile;\n\n var MyApp;\n var originalLookup = Ember.lookup, lookup, TemplateTests, view, container;\n\n module(\"Support for {{partial}} helper\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n MyApp = lookup.MyApp = EmberObject.create({});\n container = new Container();\n container.optionsForType('template', { instantiate: false });\n },\n teardown: function() {\n run(function() {\n if (view) {\n view.destroy();\n }\n });\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"should render other templates registered with the container\", function() {\n container.register('template:_subTemplateFromContainer', EmberHandlebars.compile('sub-template'));\n\n view = EmberView.create({\n container: container,\n template: EmberHandlebars.compile('This {{partial \"subTemplateFromContainer\"}} is pretty great.')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(trim(view.$().text()), \"This sub-template is pretty great.\");\n });\n\n test(\"should render other slash-separated templates registered with the container\", function() {\n container.register('template:child/_subTemplateFromContainer', EmberHandlebars.compile(\"sub-template\"));\n\n view = EmberView.create({\n container: container,\n template: EmberHandlebars.compile('This {{partial \"child/subTemplateFromContainer\"}} is pretty great.')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(trim(view.$().text()), \"This sub-template is pretty great.\");\n });\n\n test(\"should use the current view's context\", function() {\n container.register('template:_person_name', EmberHandlebars.compile(\"{{firstName}} {{lastName}}\"));\n\n view = EmberView.create({\n container: container,\n template: EmberHandlebars.compile('Who is {{partial \"person_name\"}}?')\n });\n view.set('controller', EmberObject.create({\n firstName: 'Kris',\n lastName: 'Selden'\n }));\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(trim(view.$().text()), \"Who is Kris Selden?\");\n });\n\n test(\"Quoteless parameters passed to {{template}} perform a bound property lookup of the partial name\", function() {\n container.register('template:_subTemplate', EmberHandlebars.compile(\"sub-template\"));\n container.register('template:_otherTemplate', EmberHandlebars.compile(\"other-template\"));\n\n view = EmberView.create({\n container: container,\n template: EmberHandlebars.compile('This {{partial view.partialName}} is pretty {{partial nonexistent}}great.'),\n partialName: 'subTemplate'\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(trim(view.$().text()), \"This sub-template is pretty great.\");\n\n run(function() {\n view.set('partialName', 'otherTemplate');\n });\n\n equal(trim(view.$().text()), \"This other-template is pretty great.\");\n\n run(function() {\n view.set('partialName', null);\n });\n\n equal(trim(view.$().text()), \"This is pretty great.\");\n });\n });\ndefine(\"ember-handlebars/tests/helpers/template_test\",\n [\"ember-metal/run_loop\",\"ember-views/views/view\",\"ember-runtime/system/object\",\"ember-views/system/jquery\",\"ember-runtime/system/container\",\"ember-handlebars-compiler\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var EmberView = __dependency2__.View;\n var EmberObject = __dependency3__[\"default\"];\n var jQuery = __dependency4__[\"default\"];\n var trim = jQuery.trim;\n\n var Container = __dependency5__[\"default\"];\n var EmberHandlebars = __dependency6__[\"default\"];\n\n var MyApp;\n var originalLookup = Ember.lookup, lookup, TemplateTests, view, container;\n\n module(\"Support for {{template}} helper\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n MyApp = lookup.MyApp = EmberObject.create({});\n container = new Container();\n container.optionsForType('template', { instantiate: false });\n },\n teardown: function() {\n run(function() {\n if (view) {\n view.destroy();\n }\n });\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"should render other templates via the container (DEPRECATED)\", function() {\n container.register('template:sub_template_from_container', EmberHandlebars.compile('sub-template'));\n\n view = EmberView.create({\n container: container,\n template: EmberHandlebars.compile('This {{template \"sub_template_from_container\"}} is pretty great.')\n });\n\n expectDeprecation(/The `template` helper has been deprecated in favor of the `partial` helper./);\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(trim(view.$().text()), \"This sub-template is pretty great.\");\n });\n\n test(\"should use the current view's context (DEPRECATED)\", function() {\n container.register('template:person_name', EmberHandlebars.compile(\"{{firstName}} {{lastName}}\"));\n\n view = EmberView.create({\n container: container,\n template: EmberHandlebars.compile('Who is {{template \"person_name\"}}?')\n });\n view.set('controller', EmberObject.create({\n firstName: 'Kris',\n lastName: 'Selden'\n }));\n\n expectDeprecation(/The `template` helper has been deprecated in favor of the `partial` helper./);\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(trim(view.$().text()), \"Who is Kris Selden?\");\n });\n });\ndefine(\"ember-handlebars/tests/helpers/unbound_test\",\n [\"ember-views/views/view\",\"ember-runtime/system/object\",\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-handlebars-compiler\",\"ember-metal/error\",\"ember-runtime/system/container\",\"ember-handlebars/ext\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__) {\n \"use strict\";\n /*globals Foo */\n var EmberView = __dependency1__.View;\n var EmberObject = __dependency2__[\"default\"];\n\n var Ember = __dependency3__[\"default\"];\n var get = __dependency4__.get;\n var set = __dependency5__.set;\n var run = __dependency6__[\"default\"];\n var EmberHandlebars = __dependency7__[\"default\"];\n var EmberError = __dependency8__[\"default\"];\n\n var Container = __dependency9__[\"default\"];\n\n var makeBoundHelper = __dependency10__.makeBoundHelper;\n\n var appendView = function(view) {\n run(function() { view.appendTo('#qunit-fixture'); });\n };\n\n var view;\n var originalLookup = Ember.lookup, lookup;\n var container;\n\n module(\"Handlebars {{#unbound}} helper -- classic single-property usage\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n\n view = EmberView.create({\n template: Ember.Handlebars.compile(\"{{unbound foo}} {{unbound bar}}\"),\n context: EmberObject.create({\n foo: \"BORK\",\n barBinding: 'foo'\n })\n });\n\n appendView(view);\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n });\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"it should render the current value of a property on the context\", function() {\n equal(view.$().text(), \"BORK BORK\", \"should render the current value of a property\");\n });\n\n test(\"it should not re-render if the property changes\", function() {\n run(function() {\n view.set('context.foo', 'OOF');\n });\n equal(view.$().text(), \"BORK BORK\", \"should not re-render if the property changes\");\n });\n\n test(\"it should throw the helper missing error if multiple properties are provided\", function() {\n throws(function() {\n appendView(EmberView.create({\n template: EmberHandlebars.compile('{{unbound foo bar}}'),\n context: EmberObject.create({\n foo: \"BORK\",\n bar: 'foo'\n })\n }));\n }, EmberError);\n });\n\n module(\"Handlebars {{#unbound boundHelper arg1 arg2... argN}} form: render unbound helper invocations\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n\n Ember.Handlebars.registerBoundHelper('surround', function(prefix, value, suffix) {\n return prefix + '-' + value + '-' + suffix;\n });\n\n Ember.Handlebars.registerBoundHelper('capitalize', function(value) {\n return value.toUpperCase();\n });\n\n Ember.Handlebars.registerBoundHelper('capitalizeName', function(value) {\n return get(value, 'firstName').toUpperCase();\n }, 'firstName');\n\n Ember.Handlebars.registerBoundHelper('concat', function(value) {\n return [].slice.call(arguments, 0, -1).join('');\n });\n\n Ember.Handlebars.registerBoundHelper('concatNames', function(value) {\n return get(value, 'firstName') + get(value, 'lastName');\n }, 'firstName', 'lastName');\n },\n\n teardown: function() {\n delete Ember.Handlebars.helpers['surround'];\n delete Ember.Handlebars.helpers['capitalize'];\n delete Ember.Handlebars.helpers['capitalizeName'];\n delete Ember.Handlebars.helpers['concat'];\n delete Ember.Handlebars.helpers['concatNames'];\n\n run(function() {\n view.destroy();\n });\n Ember.lookup = originalLookup;\n }\n });\n\n\n test(\"should be able to render an unbound helper invocation\", function() {\n try {\n Ember.Handlebars.registerBoundHelper('repeat', function(value, options) {\n var count = options.hash.count;\n var a = [];\n while(a.length < count) {\n a.push(value);\n }\n return a.join('');\n });\n\n view = EmberView.create({\n template: Ember.Handlebars.compile('{{unbound repeat foo countBinding=\"bar\"}} {{repeat foo countBinding=\"bar\"}} {{unbound repeat foo count=2}} {{repeat foo count=4}}'),\n context: EmberObject.create({\n foo: \"X\",\n numRepeatsBinding: \"bar\",\n bar: 5\n })\n });\n appendView(view);\n\n equal(view.$().text(), \"XXXXX XXXXX XX XXXX\", \"first render is correct\");\n\n run(function() {\n set(view, 'context.bar', 1);\n });\n\n equal(view.$().text(), \"XXXXX X XX XXXX\", \"only unbound bound options changed\");\n } finally {\n delete Ember.Handlebars.helpers['repeat'];\n }\n });\n\n test(\"should be able to render an bound helper invocation mixed with static values\", function() {\n view = EmberView.create({\n template: Ember.Handlebars.compile('{{unbound surround prefix value \"bar\"}} {{surround prefix value \"bar\"}} {{unbound surround \"bar\" value suffix}} {{surround \"bar\" value suffix}}'),\n context: EmberObject.create({\n prefix: \"before\",\n value: \"core\",\n suffix: \"after\"\n })\n });\n appendView(view);\n\n equal(view.$().text(), \"before-core-bar before-core-bar bar-core-after bar-core-after\", \"first render is correct\");\n run(function() {\n set(view, 'context.prefix', 'beforeChanged');\n set(view, 'context.value', 'coreChanged');\n set(view, 'context.suffix', 'afterChanged');\n });\n equal(view.$().text(), \"before-core-bar beforeChanged-coreChanged-bar bar-core-after bar-coreChanged-afterChanged\", \"only bound values change\");\n });\n\n test(\"should be able to render unbound forms of multi-arg helpers\", function() {\n view = EmberView.create({\n template: Ember.Handlebars.compile(\"{{concat foo bar bing}} {{unbound concat foo bar bing}}\"),\n context: EmberObject.create({\n foo: \"a\",\n bar: \"b\",\n bing: \"c\"\n })\n });\n appendView(view);\n\n equal(view.$().text(), \"abc abc\", \"first render is correct\");\n\n run(function() {\n set(view, 'context.bar', 'X');\n });\n\n equal(view.$().text(), \"aXc abc\", \"unbound helpers/properties stayed the same\");\n });\n\n\n test(\"should be able to render an unbound helper invocation for helpers with dependent keys\", function() {\n view = EmberView.create({\n template: Ember.Handlebars.compile(\"{{capitalizeName person}} {{unbound capitalizeName person}} {{concatNames person}} {{unbound concatNames person}}\"),\n context: EmberObject.create({\n person: EmberObject.create({\n firstName: 'shooby',\n lastName: 'taylor'\n })\n })\n });\n appendView(view);\n\n equal(view.$().text(), \"SHOOBY SHOOBY shoobytaylor shoobytaylor\", \"first render is correct\");\n\n run(function() {\n set(view, 'context.person.firstName', 'sally');\n });\n\n equal(view.$().text(), \"SALLY SHOOBY sallytaylor shoobytaylor\", \"only bound values change\");\n });\n\n\n test(\"should be able to render an unbound helper invocation in #each helper\", function() {\n view = EmberView.create({\n template: Ember.Handlebars.compile(\n [ \"{{#each person in people}}\",\n \"{{capitalize person.firstName}} {{unbound capitalize person.firstName}}\",\n \"{{/each}}\"].join(\"\")),\n context: {\n people: Ember.A([\n {\n firstName: 'shooby',\n lastName: 'taylor'\n },\n {\n firstName: 'cindy',\n lastName: 'taylor'\n }\n ])}\n });\n appendView(view);\n\n equal(view.$().text(), \"SHOOBY SHOOBYCINDY CINDY\", \"unbound rendered correctly\");\n });\n\n\n test(\"should be able to render an unbound helper invocation with bound hash options\", function() {\n try {\n Ember.Handlebars.registerBoundHelper('repeat', function(value) {\n return [].slice.call(arguments, 0, -1).join('');\n });\n\n\n view = EmberView.create({\n template: Ember.Handlebars.compile(\"{{capitalizeName person}} {{unbound capitalizeName person}} {{concatNames person}} {{unbound concatNames person}}\"),\n context: EmberObject.create({\n person: EmberObject.create({\n firstName: 'shooby',\n lastName: 'taylor'\n })\n })\n });\n appendView(view);\n\n equal(view.$().text(), \"SHOOBY SHOOBY shoobytaylor shoobytaylor\", \"first render is correct\");\n\n run(function() {\n set(view, 'context.person.firstName', 'sally');\n });\n\n equal(view.$().text(), \"SALLY SHOOBY sallytaylor shoobytaylor\", \"only bound values change\");\n } finally {\n delete Ember.Handlebars.registerBoundHelper['repeat'];\n }\n });\n\n module(\"Handlebars {{#unbound}} helper -- Container Lookup\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n container = new Container();\n container.optionsForType('helper', { instantiate: false });\n },\n\n teardown: function() {\n if (view) {\n run(view, 'destroy');\n }\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"should lookup helpers in the container\", function() {\n container.register('helper:up-case', makeBoundHelper(function(value) {\n return value.toUpperCase();\n }));\n\n view = EmberView.create({\n template: Ember.Handlebars.compile(\"{{unbound up-case displayText}}\"),\n container: container,\n context: {\n displayText: 'such awesome'\n }\n });\n\n appendView(view);\n\n equal(view.$().text(), \"SUCH AWESOME\", \"proper values were rendered\");\n\n run(function() {\n set(view, 'context.displayText', 'no changes');\n });\n\n equal(view.$().text(), \"SUCH AWESOME\", \"only bound values change\");\n });\n });\ndefine(\"ember-handlebars/tests/helpers/view_test\",\n [\"ember-views/views/view\",\"ember-metal/run_loop\",\"ember-views/system/jquery\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n /*globals EmberDev */\n var EmberView = __dependency1__.View;\n var run = __dependency2__[\"default\"];\n var jQuery = __dependency3__[\"default\"];\n\n var view, originalLookup;\n\n var container = {\n lookupFactory: function() { }\n };\n\n function viewClass(options) {\n options.container = options.container || container;\n return EmberView.extend(options);\n }\n\n module(\"Handlebars {{#view}} helper\", {\n setup: function() {\n originalLookup = Ember.lookup;\n\n },\n\n teardown: function() {\n Ember.lookup = originalLookup;\n\n if (view) {\n run(view, 'destroy');\n }\n }\n });\n\n\n test(\"View lookup - App.FuView\", function() {\n Ember.lookup = {\n App: {\n FuView: viewClass({\n elementId: \"fu\",\n template: Ember.Handlebars.compile(\"bro\")\n })\n }\n };\n\n view = viewClass({\n template: Ember.Handlebars.compile(\"{{view App.FuView}}\")\n }).create();\n\n run(view, 'appendTo', '#qunit-fixture');\n\n equal(jQuery('#fu').text(), 'bro');\n });\n\n test(\"View lookup - 'App.FuView'\", function() {\n Ember.lookup = {\n App: {\n FuView: viewClass({\n elementId: \"fu\",\n template: Ember.Handlebars.compile(\"bro\")\n })\n }\n };\n\n view = viewClass({\n template: Ember.Handlebars.compile(\"{{view 'App.FuView'}}\")\n }).create();\n\n run(view, 'appendTo', '#qunit-fixture');\n\n equal(jQuery('#fu').text(), 'bro');\n });\n\n test(\"View lookup - 'fu'\", function() {\n var FuView = viewClass({\n elementId: \"fu\",\n template: Ember.Handlebars.compile(\"bro\")\n });\n\n var container = {\n lookupFactory: lookupFactory\n };\n\n view = EmberView.extend({\n template: Ember.Handlebars.compile(\"{{view 'fu'}}\"),\n container: container\n }).create();\n\n run(view, 'appendTo', '#qunit-fixture');\n\n equal(jQuery('#fu').text(), 'bro');\n\n function lookupFactory(fullName) {\n equal(fullName, 'view:fu');\n\n return FuView;\n }\n });\n\n test(\"id bindings downgrade to one-time property lookup\", function() {\n view = EmberView.extend({\n template: Ember.Handlebars.compile(\"{{#view Ember.View id=view.meshuggah}}{{view.parentView.meshuggah}}{{/view}}\"),\n meshuggah: 'stengah'\n }).create();\n\n run(view, 'appendTo', '#qunit-fixture');\n\n equal(jQuery('#stengah').text(), 'stengah', \"id binding performed property lookup\");\n run(view, 'set', 'meshuggah', 'omg');\n equal(jQuery('#stengah').text(), 'omg', \"id didn't change\");\n });\n\n test(\"mixing old and new styles of property binding fires a warning, treats value as if it were quoted\", function() {\n if (EmberDev && EmberDev.runningProdBuild){\n ok(true, 'Logging does not occur in production builds');\n return;\n }\n\n expect(2);\n\n var oldWarn = Ember.warn;\n\n Ember.warn = function(msg) {\n equal(msg, \"You're attempting to render a view by passing borfBinding=view.snork to a view helper, but this syntax is ambiguous. You should either surround view.snork in quotes or remove `Binding` from borfBinding.\");\n };\n\n view = EmberView.extend({\n template: Ember.Handlebars.compile(\"{{#view Ember.View borfBinding=view.snork}}

    {{view.borf}}

    {{/view}}\"),\n snork: \"nerd\"\n }).create();\n\n run(view, 'appendTo', '#qunit-fixture');\n\n equal(jQuery('#lol').text(), \"nerd\", \"awkward mixed syntax treated like binding\");\n\n Ember.warn = oldWarn;\n });\n });\ndefine(\"ember-handlebars/tests/helpers/with_test\",\n [\"ember-views/views/view\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-metal/computed\",\"ember-handlebars-compiler\",\"ember-metal/property_set\",\"ember-runtime/controllers/object_controller\",\"ember-runtime/system/container\",\"ember-runtime/system/native_array\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__) {\n \"use strict\";\n /*globals Foo */\n /*jshint newcap:false*/\n var EmberView = __dependency1__.View;\n var run = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var computed = __dependency4__.computed;\n var EmberHandlebars = __dependency5__[\"default\"];\n var set = __dependency6__.set;\n var ObjectController = __dependency7__[\"default\"];\n var Container = __dependency8__[\"default\"];\n var A = __dependency9__.A;\n\n var appendView = function(view) {\n run(function() { view.appendTo('#qunit-fixture'); });\n };\n\n var view;\n var originalLookup = Ember.lookup, lookup;\n\n module(\"Handlebars {{#with}} helper\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n\n view = EmberView.create({\n template: EmberHandlebars.compile(\"{{#with person as tom}}{{title}}: {{tom.name}}{{/with}}\"),\n context: {\n title: \"Señor Engineer\",\n person: { name: \"Tom Dale\" }\n }\n });\n\n appendView(view);\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n });\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"it should support #with foo as bar\", function() {\n equal(view.$().text(), \"Señor Engineer: Tom Dale\", \"should be properly scoped\");\n });\n\n test(\"updating the context should update the alias\", function() {\n run(function() {\n view.set('context.person', {\n name: \"Yehuda Katz\"\n });\n });\n\n equal(view.$().text(), \"Señor Engineer: Yehuda Katz\", \"should be properly scoped after updating\");\n });\n\n test(\"updating a property on the context should update the HTML\", function() {\n run(function() {\n set(view, 'context.person.name', \"Yehuda Katz\");\n });\n\n equal(view.$().text(), \"Señor Engineer: Yehuda Katz\", \"should be properly scoped after updating\");\n });\n\n test(\"updating a property on the view should update the HTML\", function() {\n run(function() {\n view.set('context.title', \"Señorette Engineer\");\n });\n\n equal(view.$().text(), \"Señorette Engineer: Tom Dale\", \"should be properly scoped after updating\");\n });\n\n module(\"Multiple Handlebars {{with}} helpers with 'as'\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n\n view = EmberView.create({\n template: EmberHandlebars.compile(\"Admin: {{#with admin as person}}{{person.name}}{{/with}} User: {{#with user as person}}{{person.name}}{{/with}}\"),\n context: {\n admin: { name: \"Tom Dale\" },\n user: { name: \"Yehuda Katz\"}\n }\n });\n\n appendView(view);\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n });\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"re-using the same variable with different #with blocks does not override each other\", function(){\n equal(view.$().text(), \"Admin: Tom Dale User: Yehuda Katz\", \"should be properly scoped\");\n });\n\n test(\"the scoped variable is not available outside the {{with}} block.\", function(){\n run(function() {\n view.set('template', EmberHandlebars.compile(\"{{name}}-{{#with other as name}}{{name}}{{/with}}-{{name}}\"));\n view.set('context', {\n name: 'Stef',\n other: 'Yehuda'\n });\n });\n\n equal(view.$().text(), \"Stef-Yehuda-Stef\", \"should be properly scoped after updating\");\n });\n\n test(\"nested {{with}} blocks shadow the outer scoped variable properly.\", function(){\n run(function() {\n view.set('template', EmberHandlebars.compile(\"{{#with first as ring}}{{ring}}-{{#with fifth as ring}}{{ring}}-{{#with ninth as ring}}{{ring}}-{{/with}}{{ring}}-{{/with}}{{ring}}{{/with}}\"));\n view.set('context', {\n first: 'Limbo',\n fifth: 'Wrath',\n ninth: 'Treachery'\n });\n });\n\n equal(view.$().text(), \"Limbo-Wrath-Treachery-Wrath-Limbo\", \"should be properly scoped after updating\");\n });\n module(\"Handlebars {{#with}} globals helper\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n\n lookup.Foo = { bar: 'baz' };\n view = EmberView.create({\n template: EmberHandlebars.compile(\"{{#with Foo.bar as qux}}{{qux}}{{/with}}\")\n });\n\n appendView(view);\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n });\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"it should support #with Foo.bar as qux\", function() {\n equal(view.$().text(), \"baz\", \"should be properly scoped\");\n\n run(function() {\n set(lookup.Foo, 'bar', 'updated');\n });\n\n equal(view.$().text(), \"updated\", \"should update\");\n });\n\n module(\"Handlebars {{#with keyword as foo}}\");\n\n test(\"it should support #with view as foo\", function() {\n var view = EmberView.create({\n template: EmberHandlebars.compile(\"{{#with view as myView}}{{myView.name}}{{/with}}\"),\n name: \"Sonics\"\n });\n\n appendView(view);\n equal(view.$().text(), \"Sonics\", \"should be properly scoped\");\n\n run(function() {\n set(view, 'name', \"Thunder\");\n });\n\n equal(view.$().text(), \"Thunder\", \"should update\");\n\n run(function() {\n view.destroy();\n });\n });\n\n test(\"it should support #with name as food, then #with foo as bar\", function() {\n var view = EmberView.create({\n template: EmberHandlebars.compile(\"{{#with name as foo}}{{#with foo as bar}}{{bar}}{{/with}}{{/with}}\"),\n context: { name: \"caterpillar\" }\n });\n\n appendView(view);\n equal(view.$().text(), \"caterpillar\", \"should be properly scoped\");\n\n run(function() {\n set(view, 'context.name', \"butterfly\");\n });\n\n equal(view.$().text(), \"butterfly\", \"should update\");\n\n run(function() {\n view.destroy();\n });\n });\n\n module(\"Handlebars {{#with this as foo}}\");\n\n test(\"it should support #with this as qux\", function() {\n var view = EmberView.create({\n template: EmberHandlebars.compile(\"{{#with this as person}}{{person.name}}{{/with}}\"),\n controller: EmberObject.create({ name: \"Los Pivots\" })\n });\n\n appendView(view);\n equal(view.$().text(), \"Los Pivots\", \"should be properly scoped\");\n\n run(function() {\n set(view, 'controller.name', \"l'Pivots\");\n });\n\n equal(view.$().text(), \"l'Pivots\", \"should update\");\n\n run(function() {\n view.destroy();\n });\n });\n\n module(\"Handlebars {{#with foo}} insideGroup\");\n\n test(\"it should render without fail\", function() {\n var View = EmberView.extend({\n template: EmberHandlebars.compile(\"{{#view view.childView}}{{#with person}}{{name}}{{/with}}{{/view}}\"),\n controller: EmberObject.create({ person: { name: \"Ivan IV Vasilyevich\" } }),\n childView: EmberView.extend({\n render: function(){\n this.set('templateData.insideGroup', true);\n return this._super.apply(this, arguments);\n }\n })\n });\n\n var view = View.create();\n appendView(view);\n equal(view.$().text(), \"Ivan IV Vasilyevich\", \"should be properly scoped\");\n\n run(function() {\n set(view, 'controller.person.name', \"Ivan the Terrible\");\n });\n\n equal(view.$().text(), \"Ivan the Terrible\", \"should update\");\n\n run(function() {\n view.destroy();\n });\n });\n\n module(\"Handlebars {{#with foo}} with defined controller\");\n\n test(\"it should wrap context with object controller\", function() {\n var Controller = ObjectController.extend({\n controllerName: computed(function() {\n return \"controller:\"+this.get('content.name') + ' and ' + this.get('parentController.name');\n })\n });\n\n var person = EmberObject.create({name: 'Steve Holt'});\n var container = new Container();\n\n var parentController = EmberObject.create({\n container: container,\n name: 'Bob Loblaw'\n });\n\n view = EmberView.create({\n container: container,\n template: EmberHandlebars.compile('{{#with view.person controller=\"person\"}}{{controllerName}}{{/with}}'),\n person: person,\n controller: parentController\n });\n\n container.register('controller:person', Controller);\n\n appendView(view);\n\n equal(view.$().text(), \"controller:Steve Holt and Bob Loblaw\");\n\n run(function() {\n view.rerender();\n });\n\n equal(view.$().text(), \"controller:Steve Holt and Bob Loblaw\");\n\n run(function() {\n parentController.set('name', 'Carl Weathers');\n view.rerender();\n });\n\n equal(view.$().text(), \"controller:Steve Holt and Carl Weathers\");\n\n run(function() {\n person.set('name', 'Gob');\n view.rerender();\n });\n\n equal(view.$().text(), \"controller:Gob and Carl Weathers\");\n\n strictEqual(view.get('_childViews')[0].get('_contextController.target'), parentController, \"the target property of the child controllers are set correctly\");\n\n run(function() { view.destroy(); }); // destroy existing view\n });\n\n test(\"it should still have access to original parentController within an {{#each}}\", function() {\n var Controller = ObjectController.extend({\n controllerName: computed(function() {\n return \"controller:\"+this.get('content.name') + ' and ' + this.get('parentController.name');\n })\n });\n\n var people = A([{ name: \"Steve Holt\" }, { name: \"Carl Weathers\" }]);\n var container = new Container();\n\n var parentController = EmberObject.create({\n container: container,\n name: 'Bob Loblaw',\n people: people\n });\n\n view = EmberView.create({\n container: container,\n template: EmberHandlebars.compile('{{#each person in people}}{{#with person controller=\"person\"}}{{controllerName}}{{/with}}{{/each}}'),\n controller: parentController\n });\n\n container.register('controller:person', Controller);\n\n appendView(view);\n\n equal(view.$().text(), \"controller:Steve Holt and Bob Loblawcontroller:Carl Weathers and Bob Loblaw\");\n\n run(function() { view.destroy(); }); // destroy existing view\n });\n });\ndefine(\"ember-handlebars/tests/helpers/yield_test\",\n [\"ember-metal/run_loop\",\"ember-views/views/view\",\"ember-metal/computed\",\"ember-runtime/system/namespace\",\"ember-runtime/system/container\",\"ember-handlebars-compiler\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-runtime/system/native_array\",\"ember-views/views/component\",\"ember-metal/error\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__) {\n \"use strict\";\n /*jshint newcap:false*/\n var run = __dependency1__[\"default\"];\n var EmberView = __dependency2__.View;\n var computed = __dependency3__.computed;\n var Namespace = __dependency4__[\"default\"];\n var Container = __dependency5__[\"default\"];\n var EmberHandlebars = __dependency6__[\"default\"];\n var get = __dependency7__.get;\n var set = __dependency8__.set;\n var A = __dependency9__.A;\n var Component = __dependency10__[\"default\"];\n var EmberError = __dependency11__[\"default\"];\n\n var originalLookup = Ember.lookup, lookup, TemplateTests, view, container;\n\n module(\"Support for {{yield}} helper\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n\n lookup.TemplateTests = TemplateTests = Namespace.create();\n\n container = new Container();\n container.optionsForType('template', { instantiate: false });\n },\n teardown: function() {\n run(function() {\n Ember.TEMPLATES = {};\n if (view) {\n view.destroy();\n }\n });\n\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"a view with a layout set renders its template where the {{yield}} helper appears\", function() {\n TemplateTests.ViewWithLayout = EmberView.extend({\n layout: EmberHandlebars.compile('

    {{title}}

    {{yield}}
    ')\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#view TemplateTests.ViewWithLayout title=\"My Fancy Page\"}}
    Show something interesting here
    {{/view}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div.wrapper div.page-body').length, 1, 'page-body is embedded within wrapping my-page');\n });\n\n test(\"block should work properly even when templates are not hard-coded\", function() {\n container.register('template:nester', EmberHandlebars.compile('

    {{title}}

    {{yield}}
    '));\n container.register('template:nested', EmberHandlebars.compile('{{#view TemplateTests.ViewWithLayout title=\"My Fancy Page\"}}
    Show something interesting here
    {{/view}}'));\n\n TemplateTests.ViewWithLayout = EmberView.extend({\n container: container,\n layoutName: 'nester'\n });\n\n view = EmberView.create({\n container: container,\n templateName: 'nested'\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div.wrapper div.page-body').length, 1, 'page-body is embedded within wrapping my-page');\n\n });\n\n test(\"templates should yield to block, when the yield is embedded in a hierarchy of virtual views\", function() {\n TemplateTests.TimesView = EmberView.extend({\n layout: EmberHandlebars.compile('
    {{#each view.index}}{{yield}}{{/each}}
    '),\n n: null,\n index: computed(function() {\n var n = get(this, 'n'), indexArray = A();\n for (var i=0; i < n; i++) {\n indexArray[i] = i;\n }\n return indexArray;\n })\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('
    Counting to 5
    {{#view TemplateTests.TimesView n=5}}
    Hello
    {{/view}}
    ')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div#container div.times-item').length, 5, 'times-item is embedded within wrapping container 5 times, as expected');\n });\n\n test(\"templates should yield to block, when the yield is embedded in a hierarchy of non-virtual views\", function() {\n TemplateTests.NestingView = EmberView.extend({\n layout: EmberHandlebars.compile('{{#view Ember.View tagName=\"div\" classNames=\"nesting\"}}{{yield}}{{/view}}')\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('
    {{#view TemplateTests.NestingView}}
    Hello
    {{/view}}
    ')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div#container div.nesting div#block').length, 1, 'nesting view yields correctly even within a view hierarchy in the nesting view');\n });\n\n test(\"block should not be required\", function() {\n TemplateTests.YieldingView = EmberView.extend({\n layout: EmberHandlebars.compile('{{#view Ember.View tagName=\"div\" classNames=\"yielding\"}}{{yield}}{{/view}}')\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('
    {{view TemplateTests.YieldingView}}
    ')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div#container div.yielding').length, 1, 'yielding view is rendered as expected');\n });\n\n test(\"yield uses the outer context\", function() {\n var component = Component.extend({\n boundText: \"inner\",\n layout: EmberHandlebars.compile(\"

    {{boundText}}

    {{yield}}

    \")\n });\n\n view = EmberView.create({\n controller: { boundText: \"outer\", component: component },\n template: EmberHandlebars.compile('{{#view component}}{{boundText}}{{/view}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div p:contains(inner) + p:contains(outer)').length, 1, \"Yield points at the right context\");\n });\n\n test(\"yield inside a conditional uses the outer context\", function() {\n var component = Component.extend({\n boundText: \"inner\",\n truthy: true,\n obj: {},\n layout: EmberHandlebars.compile(\"

    {{boundText}}

    {{#if truthy}}{{#with obj}}{{yield}}{{/with}}{{/if}}

    \")\n });\n\n view = EmberView.create({\n controller: { boundText: \"outer\", truthy: true, obj: { component: component, truthy: true, boundText: 'insideWith' } },\n template: EmberHandlebars.compile('{{#with obj}}{{#if truthy}}{{#view component}}{{#if truthy}}{{boundText}}{{/if}}{{/view}}{{/if}}{{/with}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div p:contains(inner) + p:contains(insideWith)').length, 1, \"Yield points at the right context\");\n });\n\n test(\"outer keyword doesn't mask inner component property\", function () {\n var component = Component.extend({\n item: \"inner\",\n layout: EmberHandlebars.compile(\"

    {{item}}

    {{yield}}

    \")\n });\n\n view = EmberView.create({\n controller: { boundText: \"outer\", component: component },\n template: EmberHandlebars.compile('{{#with boundText as item}}{{#view component}}{{item}}{{/view}}{{/with}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div p:contains(inner) + p:contains(outer)').length, 1, \"inner component property isn't masked by outer keyword\");\n });\n\n test(\"inner keyword doesn't mask yield property\", function() {\n var component = Component.extend({\n boundText: \"inner\",\n layout: EmberHandlebars.compile(\"{{#with boundText as item}}

    {{item}}

    {{yield}}

    {{/with}}\")\n });\n\n view = EmberView.create({\n controller: { item: \"outer\", component: component },\n template: EmberHandlebars.compile('{{#view component}}{{item}}{{/view}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div p:contains(inner) + p:contains(outer)').length, 1, \"outer property isn't masked by inner keyword\");\n });\n\n test(\"can bind a keyword to a component and use it in yield\", function() {\n var component = Component.extend({\n content: null,\n layout: EmberHandlebars.compile(\"

    {{content}}

    {{yield}}

    \")\n });\n\n view = EmberView.create({\n controller: { boundText: \"outer\", component: component },\n template: EmberHandlebars.compile('{{#with boundText as item}}{{#view component contentBinding=\"item\"}}{{item}}{{/view}}{{/with}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div p:contains(outer) + p:contains(outer)').length, 1, \"component and yield have keyword\");\n\n run(function() {\n view.set('controller.boundText', 'update');\n });\n\n equal(view.$('div p:contains(update) + p:contains(update)').length, 1, \"keyword has correctly propagated update\");\n });\n\n test(\"yield uses the layout context for non component\", function() {\n view = EmberView.create({\n controller: {\n boundText: \"outer\",\n inner: {\n boundText: \"inner\"\n }\n },\n layout: EmberHandlebars.compile(\"

    {{boundText}}

    {{#with inner}}

    {{yield}}

    {{/with}}\"),\n template: EmberHandlebars.compile('{{boundText}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal('outerinner', view.$('p').text(), \"Yield points at the right context\");\n });\n\n test(\"yield view should be a virtual view\", function() {\n var component = Component.extend({\n isParentComponent: true,\n\n layout: EmberHandlebars.compile('{{yield}}')\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#view component}}{{view includedComponent}}{{/view}}'),\n controller: {\n component: component,\n includedComponent: Component.extend({\n didInsertElement: function() {\n var parentView = this.get('parentView');\n\n ok(parentView.get('isParentComponent'), \"parent view is the parent component\");\n }\n })\n }\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n });\n\n\n test(\"adding a layout should not affect the context of normal views\", function() {\n var parentView = EmberView.create({\n context: \"ParentContext\"\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile(\"View context: {{this}}\"),\n context: \"ViewContext\",\n _parentView: parentView\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(view.$().text(), \"View context: ViewContext\");\n\n\n set(view, 'layout', EmberHandlebars.compile(\"Layout: {{yield}}\"));\n\n run(function() {\n view.destroyElement();\n view.createElement();\n });\n\n equal(view.$().text(), \"Layout: View context: ViewContext\");\n\n run(function() {\n parentView.destroy();\n });\n });\n\n test(\"yield should work for views even if _parentView is null\", function() {\n view = EmberView.create({\n layout: EmberHandlebars.compile('Layout: {{yield}}'),\n template: EmberHandlebars.compile(\"View Content\")\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(view.$().text(), \"Layout: View Content\");\n\n });\n\n module(\"Component {{yield}}\", {\n setup: function() {},\n teardown: function() {\n run(function() {\n if (view) {\n view.destroy();\n }\n delete EmberHandlebars.helpers['inner-component'];\n delete EmberHandlebars.helpers['outer-component'];\n });\n }\n });\n\n test(\"yield with nested components (#3220)\", function(){\n var count = 0;\n var InnerComponent = Component.extend({\n layout: EmberHandlebars.compile(\"{{yield}}\"),\n _yield: function (context, options) {\n count++;\n if (count > 1) throw new EmberError('is looping');\n return this._super(context, options);\n }\n });\n\n EmberHandlebars.helper('inner-component', InnerComponent);\n\n var OuterComponent = Component.extend({\n layout: EmberHandlebars.compile(\"{{#inner-component}}{{yield}}{{/inner-component}}\")\n });\n\n EmberHandlebars.helper('outer-component', OuterComponent);\n\n view = EmberView.create({\n template: EmberHandlebars.compile(\n \"{{#outer-component}}Hello world{{/outer-component}}\"\n )\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('div > span').text(), \"Hello world\");\n });\n\n test(\"yield works inside a conditional in a component that has Ember._Metamorph mixed in\", function() {\n var component = Component.extend(Ember._Metamorph, {\n item: \"inner\",\n layout: Ember.Handlebars.compile(\"

    {{item}}

    {{#if item}}

    {{yield}}

    {{/if}}\")\n });\n\n view = Ember.View.create({\n controller: { item: \"outer\", component: component },\n template: Ember.Handlebars.compile('{{#view component}}{{item}}{{/view}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$().text(), 'innerouter', \"{{yield}} renders yielded content inside metamorph component\");\n });\n });\ndefine(\"ember-handlebars/tests/loader_test\",\n [\"ember-views/system/jquery\",\"ember-metal/run_loop\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var jQuery = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var EmberView = __dependency3__.View;\n var trim = jQuery.trim;\n\n var originalLookup = Ember.lookup, lookup, Tobias, App, view;\n\n module(\"test Ember.Handlebars.bootstrap\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n },\n teardown: function() {\n Ember.TEMPLATES = {};\n Ember.lookup = originalLookup;\n if(App) { run(App, 'destroy'); }\n if (view) { run(view, 'destroy'); }\n }\n });\n\n function checkTemplate(templateName) {\n run(function() {\n Ember.Handlebars.bootstrap(jQuery('#qunit-fixture'));\n });\n var template = Ember.TEMPLATES[templateName];\n ok(template, 'template is available on Ember.TEMPLATES');\n equal(jQuery('#qunit-fixture script').length, 0, 'script removed');\n var view = EmberView.create({\n template: template,\n context: {\n firstName: 'Tobias',\n drug: 'teamocil'\n }\n });\n run(function() {\n view.createElement();\n });\n equal(trim(view.$().text()), 'Tobias takes teamocil', 'template works');\n run(function() {\n view.destroy();\n });\n }\n\n test('template with data-template-name should add a new template to Ember.TEMPLATES', function() {\n jQuery('#qunit-fixture').html('');\n\n checkTemplate('funkyTemplate');\n });\n\n test('template with id instead of data-template-name should add a new template to Ember.TEMPLATES', function() {\n jQuery('#qunit-fixture').html('');\n\n checkTemplate('funkyTemplate');\n });\n\n test('template without data-template-name or id should default to application', function() {\n jQuery('#qunit-fixture').html('');\n\n checkTemplate('application');\n });\n\n test('template with type text/x-raw-handlebars should be parsed', function() {\n jQuery('#qunit-fixture').html('');\n\n run(function() {\n Ember.Handlebars.bootstrap(jQuery('#qunit-fixture'));\n });\n\n ok(Ember.TEMPLATES['funkyTemplate'], 'template with name funkyTemplate available');\n\n // This won't even work with Ember templates\n equal(trim(Ember.TEMPLATES['funkyTemplate']({ name: 'Tobias' })), \"Tobias\");\n });\n\n test('duplicated default application templates should throw exception', function() {\n jQuery('#qunit-fixture').html('');\n\n throws(function () {\n Ember.Handlebars.bootstrap(jQuery('#qunit-fixture'));\n },\n /Template named \"[^\"]+\" already exists\\./,\n \"duplicate templates should not be allowed\");\n });\n\n test('default application template and id application template present should throw exception', function() {\n jQuery('#qunit-fixture').html('');\n\n throws(function () {\n Ember.Handlebars.bootstrap(jQuery('#qunit-fixture'));\n },\n /Template named \"[^\"]+\" already exists\\./,\n \"duplicate templates should not be allowed\");\n });\n\n test('default application template and data-template-name application template present should throw exception', function() {\n jQuery('#qunit-fixture').html('');\n\n throws(function () {\n Ember.Handlebars.bootstrap(jQuery('#qunit-fixture'));\n },\n /Template named \"[^\"]+\" already exists\\./,\n \"duplicate templates should not be allowed\");\n });\n\n test('duplicated template id should throw exception', function() {\n jQuery('#qunit-fixture').html('');\n\n throws(function () {\n Ember.Handlebars.bootstrap(jQuery('#qunit-fixture'));\n },\n /Template named \"[^\"]+\" already exists\\./,\n \"duplicate templates should not be allowed\");\n });\n\n test('duplicated template data-template-name should throw exception', function() {\n jQuery('#qunit-fixture').html('');\n\n throws(function () {\n Ember.Handlebars.bootstrap(jQuery('#qunit-fixture'));\n },\n /Template named \"[^\"]+\" already exists\\./,\n \"duplicate templates should not be allowed\");\n });\n\n if (Ember.component) {\n test('registerComponents initializer', function(){\n Ember.TEMPLATES['components/x-apple'] = 'asdf';\n\n App = run(Ember.Application, 'create');\n\n ok(Ember.Handlebars.helpers['x-apple'], 'x-apple helper is present');\n ok(App.__container__.has('component:x-apple'), 'the container is aware of x-apple');\n });\n\n test('registerComponents and generated components', function(){\n Ember.TEMPLATES['components/x-apple'] = 'asdf';\n\n App = run(Ember.Application, 'create');\n view = App.__container__.lookup('component:x-apple');\n equal(view.get('layoutName'), 'components/x-apple', 'has correct layout name');\n });\n\n test('registerComponents and non-geneated components', function(){\n Ember.TEMPLATES['components/x-apple'] = 'asdf';\n\n run(function(){\n App = Ember.Application.create();\n\n // currently Component code must be loaded before initializers\n // this is mostly due to how they are bootstrapped. We will hopefully\n // sort this out soon.\n App.XAppleComponent = Ember.Component.extend({\n isCorrect: true\n });\n });\n\n view = App.__container__.lookup('component:x-apple');\n equal(view.get('layoutName'), 'components/x-apple', 'has correct layout name');\n ok(view.get('isCorrect'), 'ensure a non-generated component');\n });\n }\n });\ndefine(\"ember-handlebars/tests/lookup_test\",\n [],\n function() {\n \"use strict\";\n module(\"Ember.Handlebars.resolveParams\");\n\n test(\"Raw string parameters should be returned as Strings\", function() {\n var params = Ember.Handlebars.resolveParams({}, [\"foo\", \"bar\", \"baz\"], { types: [\"STRING\", \"STRING\", \"STRING\"] });\n deepEqual(params, [\"foo\", \"bar\", \"baz\"]);\n });\n\n test(\"Raw boolean parameters should be returned as Booleans\", function() {\n var params = Ember.Handlebars.resolveParams({}, [true, false], { types: [\"BOOLEAN\", \"BOOLEAN\"] });\n deepEqual(params, [true, false]);\n });\n\n test(\"Raw numeric parameters should be returned as Numbers\", function() {\n var params = Ember.Handlebars.resolveParams({}, [1, 1.0, 1.5, 0.5], { types: [\"NUMBER\", \"NUMBER\", \"NUMBER\", \"NUMBER\"] });\n deepEqual(params, [1, 1, 1.5, 0.5]);\n });\n\n test(\"ID parameters should be looked up on the context\", function() {\n var context = {\n salutation: \"Mr\",\n name: {\n first: \"Tom\",\n last: \"Dale\"\n }\n };\n\n var params = Ember.Handlebars.resolveParams(context, [\"salutation\", \"name.first\", \"name.last\"], { types: [\"ID\", \"ID\", \"ID\"] });\n deepEqual(params, [\"Mr\", \"Tom\", \"Dale\"]);\n });\n\n if (Ember.FEATURES.isEnabled(\"ember-handlebars-caps-lookup\")) {\n test(\"ID parameters that start with capital letters use Ember.lookup as their context\", function() {\n Ember.lookup.FOO = \"BAR\";\n\n var context = { FOO: \"BAZ\" };\n\n var params = Ember.Handlebars.resolveParams(context, [\"FOO\"], { types: [\"ID\"] });\n deepEqual(params, [\"BAR\"]);\n });\n }\n\n test(\"ID parameters can look up keywords\", function() {\n var controller = {\n salutation: \"Mr\"\n };\n\n var view = {\n name: { first: \"Tom\", last: \"Dale\" }\n };\n\n var context = {\n yuno: \"State Charts\"\n };\n\n var options = {\n types: [\"ID\", \"ID\", \"ID\", \"ID\"],\n data: {\n keywords: {\n controller: controller,\n view: view\n }\n }\n };\n\n var params = Ember.Handlebars.resolveParams(context, [\"controller.salutation\", \"view.name.first\", \"view.name.last\", \"yuno\"], options);\n deepEqual(params, [\"Mr\", \"Tom\", \"Dale\", \"State Charts\"]);\n });\n\n module(\"Ember.Handlebars.resolveHash\");\n\n test(\"Raw string parameters should be returned as Strings\", function() {\n var hash = Ember.Handlebars.resolveHash({}, { string: \"foo\" }, { hashTypes: { string: \"STRING\" } });\n deepEqual(hash, { string: \"foo\" });\n });\n\n test(\"Raw boolean parameters should be returned as Booleans\", function() {\n var hash = Ember.Handlebars.resolveHash({}, { yes: true, no: false }, { hashTypes: { yes: \"BOOLEAN\", no: \"BOOLEAN\" } });\n deepEqual(hash, { yes: true, no: false });\n });\n\n test(\"Raw numeric parameters should be returned as Numbers\", function() {\n var hash = Ember.Handlebars.resolveHash({}, { one: 1, oneFive: 1.5, ohFive: 0.5 }, { hashTypes: { one: \"NUMBER\", oneFive: \"NUMBER\", ohFive: \"NUMBER\" } });\n deepEqual(hash, { one: 1, oneFive: 1.5, ohFive: 0.5 });\n });\n\n test(\"ID parameters should be looked up on the context\", function() {\n var context = {\n salutation: \"Mr\",\n name: {\n first: \"Tom\",\n last: \"Dale\"\n }\n };\n\n var hash = Ember.Handlebars.resolveHash(context, { mr: \"salutation\", firstName: \"name.first\", lastName: \"name.last\" }, { hashTypes: { mr: \"ID\", firstName: \"ID\", lastName: \"ID\" } });\n deepEqual(hash, { mr: \"Mr\", firstName: \"Tom\", lastName: \"Dale\" });\n });\n\n test(\"ID parameters can look up keywords\", function() {\n var controller = {\n salutation: \"Mr\"\n };\n\n var view = {\n name: { first: \"Tom\", last: \"Dale\" }\n };\n\n var context = {\n yuno: \"State Charts\"\n };\n\n var options = {\n hashTypes: { mr: \"ID\", firstName: \"ID\", lastName: \"ID\", yuno: \"ID\" },\n data: {\n keywords: {\n controller: controller,\n view: view\n }\n }\n };\n\n var hash = Ember.Handlebars.resolveHash(context, { mr: \"controller.salutation\", firstName: \"view.name.first\", lastName: \"view.name.last\", yuno: \"yuno\" }, options);\n deepEqual(hash, { mr: \"Mr\", firstName: \"Tom\", lastName: \"Dale\", yuno: \"State Charts\" });\n });\n });\ndefine(\"ember-handlebars/tests/views/collection_view_test\",\n [\"ember-views/views/view\",\"ember-metal/run_loop\",\"ember-views/system/jquery\",\"ember-runtime/system/object\",\"ember-metal/computed\",\"ember-runtime/system/namespace\",\"ember-runtime/system/array_proxy\",\"ember-views/views/collection_view\",\"ember-runtime/system/native_array\",\"ember-runtime/system/container\",\"ember-handlebars-compiler\",\"ember-metal/property_get\",\"ember-metal/property_set\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__) {\n \"use strict\";\n /*globals TemplateTests:true App:true */\n /*jshint newcap:false*/\n\n var EmberView = __dependency1__.View;\n var run = __dependency2__[\"default\"];\n var jQuery = __dependency3__[\"default\"];\n var EmberObject = __dependency4__[\"default\"];\n var computed = __dependency5__.computed;\n var Namespace = __dependency6__[\"default\"];\n var ArrayProxy = __dependency7__[\"default\"];\n var CollectionView = __dependency8__[\"default\"];\n var A = __dependency9__.A;\n var Container = __dependency10__[\"default\"];\n var EmberHandlebars = __dependency11__[\"default\"];\n\n var trim = jQuery.trim;\n\n var get = __dependency12__.get;\n var set = __dependency13__.set;\n\n var firstGrandchild = function(view) {\n return get(get(view, 'childViews').objectAt(0), 'childViews').objectAt(0);\n };\n var nthChild = function(view, nth) {\n return get(view, 'childViews').objectAt(nth || 0);\n };\n var firstChild = nthChild;\n\n var originalLookup = Ember.lookup, lookup, TemplateTests, view;\n\n module(\"ember-handlebars/tests/views/collection_view_test\", {\n setup: function() {\n Ember.lookup = lookup = { Ember: Ember };\n lookup.TemplateTests = TemplateTests = Namespace.create();\n },\n teardown: function() {\n run(function() {\n if (view) {\n view.destroy();\n }\n });\n\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"passing a block to the collection helper sets it as the template for example views\", function() {\n TemplateTests.CollectionTestView = CollectionView.extend({\n tagName: 'ul',\n content: A(['foo', 'bar', 'baz'])\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection TemplateTests.CollectionTestView}} {{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('label').length, 3, 'one label element is created for each content item');\n });\n\n test(\"collection helper should try to use container to resolve view\", function() {\n var container = new Container();\n\n var ACollectionView = CollectionView.extend({\n tagName: 'ul',\n content: A(['foo', 'bar', 'baz'])\n });\n\n container.register('view:collectionTest', ACollectionView);\n\n var controller = {container: container};\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('{{#collection \"collectionTest\"}} {{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('label').length, 3, 'one label element is created for each content item');\n });\n\n test(\"collection helper should accept relative paths\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection view.collection}} {{/collection}}'),\n collection: CollectionView.extend({\n tagName: 'ul',\n content: A(['foo', 'bar', 'baz'])\n })\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('label').length, 3, 'one label element is created for each content item');\n });\n\n test(\"empty views should be removed when content is added to the collection (regression, ht: msofaer)\", function() {\n var App;\n\n run(function() {\n lookup.App = App = Namespace.create();\n });\n\n App.EmptyView = EmberView.extend({\n template : EmberHandlebars.compile(\"No Rows Yet\")\n });\n\n App.ListView = CollectionView.extend({\n emptyView: App.EmptyView\n });\n\n App.listController = ArrayProxy.create({\n content : A()\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection App.ListView contentBinding=\"App.listController\" tagName=\"table\"}} {{view.content.title}} {{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('tr').length, 1, 'Make sure the empty view is there (regression)');\n\n run(function() {\n App.listController.pushObject({title : \"Go Away, Placeholder Row!\"});\n });\n\n equal(view.$('tr').length, 1, 'has one row');\n equal(view.$('tr:nth-child(1) td').text(), 'Go Away, Placeholder Row!', 'The content is the updated data.');\n\n run(function() { App.destroy(); });\n });\n\n test(\"should be able to specify which class should be used for the empty view\", function() {\n var App;\n\n run(function() {\n lookup.App = App = Namespace.create();\n });\n\n App.EmptyView = EmberView.extend({\n template: EmberHandlebars.compile('This is an empty view')\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{collection emptyViewClass=\"App.EmptyView\"}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$().text(), 'This is an empty view', \"Empty view should be rendered.\");\n\n run(function() {\n App.destroy();\n });\n });\n\n test(\"if no content is passed, and no 'else' is specified, nothing is rendered\", function() {\n TemplateTests.CollectionTestView = CollectionView.extend({\n tagName: 'ul',\n content: A()\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection \"TemplateTests.CollectionTestView\"}} {{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('li').length, 0, 'if no \"else\" is specified, nothing is rendered');\n });\n\n test(\"if no content is passed, and 'else' is specified, the else block is rendered\", function() {\n TemplateTests.CollectionTestView = CollectionView.extend({\n tagName: 'ul',\n content: A()\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection \"TemplateTests.CollectionTestView\"}} {{ else }} {{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('li:has(del)').length, 1, 'the else block is rendered');\n });\n\n test(\"a block passed to a collection helper defaults to the content property of the context\", function() {\n TemplateTests.CollectionTestView = CollectionView.extend({\n tagName: 'ul',\n content: A(['foo', 'bar', 'baz'])\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection \"TemplateTests.CollectionTestView\"}} {{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('li:nth-child(1) label').length, 1);\n equal(view.$('li:nth-child(1) label').text(), 'foo');\n equal(view.$('li:nth-child(2) label').length, 1);\n equal(view.$('li:nth-child(2) label').text(), 'bar');\n equal(view.$('li:nth-child(3) label').length, 1);\n equal(view.$('li:nth-child(3) label').text(), 'baz');\n });\n\n test(\"a block passed to a collection helper defaults to the view\", function() {\n TemplateTests.CollectionTestView = CollectionView.extend({\n tagName: 'ul',\n content: A(['foo', 'bar', 'baz'])\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection \"TemplateTests.CollectionTestView\"}} {{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n // Preconds\n equal(view.$('li:nth-child(1) label').length, 1);\n equal(view.$('li:nth-child(1) label').text(), 'foo');\n equal(view.$('li:nth-child(2) label').length, 1);\n equal(view.$('li:nth-child(2) label').text(), 'bar');\n equal(view.$('li:nth-child(3) label').length, 1);\n equal(view.$('li:nth-child(3) label').text(), 'baz');\n\n run(function() {\n set(firstChild(view), 'content', A());\n });\n equal(view.$('label').length, 0, \"all list item views should be removed from DOM\");\n });\n\n test(\"should include an id attribute if id is set in the options hash\", function() {\n TemplateTests.CollectionTestView = CollectionView.extend({\n tagName: 'ul',\n content: A(['foo', 'bar', 'baz'])\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection \"TemplateTests.CollectionTestView\" id=\"baz\"}}foo{{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('ul#baz').length, 1, \"adds an id attribute\");\n });\n\n test(\"should give its item views the class specified by itemClass\", function() {\n TemplateTests.itemClassTestCollectionView = CollectionView.extend({\n tagName: 'ul',\n content: A(['foo', 'bar', 'baz'])\n });\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection \"TemplateTests.itemClassTestCollectionView\" itemClass=\"baz\"}}foo{{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('ul li.baz').length, 3, \"adds class attribute\");\n });\n\n test(\"should give its item views the classBinding specified by itemClassBinding\", function() {\n TemplateTests.itemClassBindingTestCollectionView = CollectionView.extend({\n tagName: 'ul',\n content: A([EmberObject.create({ isBaz: false }), EmberObject.create({ isBaz: true }), EmberObject.create({ isBaz: true })])\n });\n\n view = EmberView.create({\n isBar: true,\n template: EmberHandlebars.compile('{{#collection \"TemplateTests.itemClassBindingTestCollectionView\" itemClassBinding=\"view.isBar\"}}foo{{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('ul li.is-bar').length, 3, \"adds class on initial rendering\");\n\n // NOTE: in order to bind an item's class to a property of the item itself (e.g. `isBaz` above), it will be necessary\n // to introduce a new keyword that could be used from within `itemClassBinding`. For instance, `itemClassBinding=\"item.isBaz\"`.\n });\n\n test(\"should give its item views the property specified by itemPropertyBinding\", function() {\n TemplateTests.itemPropertyBindingTestItemView = EmberView.extend({\n tagName: 'li'\n });\n\n // Use preserveContext=false so the itemView handlebars context is the view context\n // Set itemView bindings using item*\n view = EmberView.create({\n baz: \"baz\",\n content: A([EmberObject.create(), EmberObject.create(), EmberObject.create()]),\n template: EmberHandlebars.compile('{{#collection contentBinding=\"view.content\" tagName=\"ul\" itemViewClass=\"TemplateTests.itemPropertyBindingTestItemView\" itemPropertyBinding=\"view.baz\" preserveContext=false}}{{view.property}}{{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('ul li').length, 3, \"adds 3 itemView\");\n\n view.$('ul li').each(function(i, li) {\n equal(jQuery(li).text(), \"baz\", \"creates the li with the property = baz\");\n });\n\n run(function() {\n set(view, 'baz', \"yobaz\");\n });\n\n equal(view.$('ul li:first').text(), \"yobaz\", \"change property of sub view\");\n });\n\n test(\"should work inside a bound {{#if}}\", function() {\n var testData = A([EmberObject.create({ isBaz: false }), EmberObject.create({ isBaz: true }), EmberObject.create({ isBaz: true })]);\n TemplateTests.ifTestCollectionView = CollectionView.extend({\n tagName: 'ul',\n content: testData\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#if view.shouldDisplay}}{{#collection \"TemplateTests.ifTestCollectionView\"}}{{content.isBaz}}{{/collection}}{{/if}}'),\n shouldDisplay: true\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('ul li').length, 3, \"renders collection when conditional is true\");\n\n run(function() { set(view, 'shouldDisplay', false); });\n equal(view.$('ul li').length, 0, \"removes collection when conditional changes to false\");\n\n run(function() { set(view, 'shouldDisplay', true); });\n equal(view.$('ul li').length, 3, \"collection renders when conditional changes to true\");\n });\n\n test(\"should pass content as context when using {{#each}} helper\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#each view.releases}}Mac OS X {{version}}: {{name}} {{/each}}'),\n\n releases: A([\n { version: '10.7',\n name: 'Lion' },\n { version: '10.6',\n name: 'Snow Leopard' },\n { version: '10.5',\n name: 'Leopard' }\n ])\n });\n\n run(function() { view.appendTo('#qunit-fixture'); });\n\n equal(view.$().text(), \"Mac OS X 10.7: Lion Mac OS X 10.6: Snow Leopard Mac OS X 10.5: Leopard \", \"prints each item in sequence\");\n });\n\n test(\"should re-render when the content object changes\", function() {\n TemplateTests.RerenderTest = CollectionView.extend({\n tagName: 'ul',\n content: A()\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection TemplateTests.RerenderTest}}{{view.content}}{{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n run(function() {\n set(firstChild(view), 'content', A(['bing', 'bat', 'bang']));\n });\n\n run(function() {\n set(firstChild(view), 'content', A(['ramalamadingdong']));\n });\n\n equal(view.$('li').length, 1, \"rerenders with correct number of items\");\n equal(trim(view.$('li:eq(0)').text()), \"ramalamadingdong\");\n\n });\n\n test(\"select tagName on collection helper automatically sets child tagName to option\", function() {\n TemplateTests.RerenderTest = CollectionView.extend({\n content: A(['foo'])\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection TemplateTests.RerenderTest tagName=\"select\"}}{{view.content}}{{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('option').length, 1, \"renders the correct child tag name\");\n\n });\n\n test(\"tagName works in the #collection helper\", function() {\n TemplateTests.RerenderTest = CollectionView.extend({\n content: A(['foo', 'bar'])\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection TemplateTests.RerenderTest tagName=\"ol\"}}{{view.content}}{{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('ol').length, 1, \"renders the correct tag name\");\n equal(view.$('li').length, 2, \"rerenders with correct number of items\");\n\n run(function() {\n set(firstChild(view), 'content', A(['bing', 'bat', 'bang']));\n });\n\n equal(view.$('li').length, 3, \"rerenders with correct number of items\");\n equal(trim(view.$('li:eq(0)').text()), \"bing\");\n });\n\n test(\"should render nested collections\", function() {\n\n TemplateTests.InnerList = CollectionView.extend({\n tagName: 'ul',\n content: A(['one','two','three'])\n });\n\n TemplateTests.OuterList = CollectionView.extend({\n tagName: 'ul',\n content: A(['foo'])\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#collection TemplateTests.OuterList class=\"outer\"}}{{content}}{{#collection TemplateTests.InnerList class=\"inner\"}}{{content}}{{/collection}}{{/collection}}')\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('ul.outer > li').length, 1, \"renders the outer list with correct number of items\");\n equal(view.$('ul.inner').length, 1, \"the inner list exsits\");\n equal(view.$('ul.inner > li').length, 3, \"renders the inner list with correct number of items\");\n\n });\n\n test(\"should render multiple, bound nested collections (#68)\", function() {\n var view;\n\n run(function() {\n TemplateTests.contentController = ArrayProxy.create({\n content: A(['foo','bar'])\n });\n\n TemplateTests.InnerList = CollectionView.extend({\n tagName: 'ul',\n contentBinding: 'parentView.innerListContent'\n });\n\n TemplateTests.OuterListItem = EmberView.extend({\n template: EmberHandlebars.compile('{{#collection TemplateTests.InnerList class=\"inner\"}}{{content}}{{/collection}}{{content}}'),\n innerListContent: computed(function() {\n return A([1,2,3]);\n })\n });\n\n TemplateTests.OuterList = CollectionView.extend({\n tagName: 'ul',\n contentBinding: 'TemplateTests.contentController',\n itemViewClass: TemplateTests.OuterListItem\n });\n\n view = EmberView.create({\n template: EmberHandlebars.compile('{{collection TemplateTests.OuterList class=\"outer\"}}')\n });\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('ul.outer > li').length, 2, \"renders the outer list with correct number of items\");\n equal(view.$('ul.inner').length, 2, \"renders the correct number of inner lists\");\n equal(view.$('ul.inner:first > li').length, 3, \"renders the first inner list with correct number of items\");\n equal(view.$('ul.inner:last > li').length, 3, \"renders the second list with correct number of items\");\n\n run(function() {\n view.destroy();\n });\n });\n\n test(\"should allow view objects to be swapped out without throwing an error (#78)\", function() {\n var view, dataset, secondDataset;\n\n run(function() {\n TemplateTests.datasetController = EmberObject.create();\n\n TemplateTests.ReportingView = EmberView.extend({\n datasetBinding: 'TemplateTests.datasetController.dataset',\n readyBinding: 'dataset.ready',\n itemsBinding: 'dataset.items',\n template: EmberHandlebars.compile(\"{{#if view.ready}}{{collection TemplateTests.CollectionView}}{{else}}Loading{{/if}}\")\n });\n\n TemplateTests.CollectionView = CollectionView.extend({\n contentBinding: 'parentView.items',\n tagName: 'ul',\n template: EmberHandlebars.compile(\"{{view.content}}\")\n });\n\n view = TemplateTests.ReportingView.create();\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$().text(), \"Loading\", \"renders the loading text when the dataset is not ready\");\n\n run(function() {\n dataset = EmberObject.create({\n ready: true,\n items: A([1,2,3])\n });\n TemplateTests.datasetController.set('dataset',dataset);\n });\n\n equal(view.$('ul > li').length, 3, \"renders the collection with the correct number of items when the dataset is ready\");\n\n run(function() {\n secondDataset = EmberObject.create({ready: false});\n TemplateTests.datasetController.set('dataset',secondDataset);\n });\n\n equal(view.$().text(), \"Loading\", \"renders the loading text when the second dataset is not ready\");\n\n run(function() {\n view.destroy();\n });\n });\n\n test(\"context should be content\", function() {\n var App, view;\n\n run(function() {\n lookup.App = App = Namespace.create();\n });\n\n App.items = A([\n EmberObject.create({name: 'Dave'}),\n EmberObject.create({name: 'Mary'}),\n EmberObject.create({name: 'Sara'})\n ]);\n\n App.AnItemView = EmberView.extend({\n template: EmberHandlebars.compile(\"Greetings {{name}}\")\n });\n\n App.AView = EmberView.extend({\n template: EmberHandlebars.compile('{{collection contentBinding=\"App.items\" itemViewClass=\"App.AnItemView\"}}')\n });\n\n run(function() {\n view = App.AView.create();\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$().text(), \"Greetings DaveGreetings MaryGreetings Sara\");\n\n run(function() {\n view.destroy();\n App.destroy();\n });\n });\n });\ndefine(\"ember-handlebars/tests/views/metamorph_view_test\",\n [\"ember-views/system/jquery\",\"ember-metal/run_loop\",\"ember-views/views/view\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/mixin\",\"ember-handlebars-compiler\",\"ember-handlebars/views/metamorph_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var jQuery = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var EmberView = __dependency3__.View;\n var get = __dependency4__.get;\n var set = __dependency5__.set;\n var observer = __dependency6__.observer;\n var EmberHandlebars = __dependency7__[\"default\"];\n\n var _MetamorphView = __dependency8__._MetamorphView;\n\n var view, childView, metamorphView;\n\n module(\"Metamorph views\", {\n setup: function() {\n view = EmberView.create({\n render: function(buffer) {\n buffer.push(\"

    View

    \");\n this.appendChild(metamorphView);\n }\n });\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n if (childView && !childView.isDestroyed) {\n childView.destroy();\n }\n\n if (metamorphView && !metamorphView.isDestroyed) {\n metamorphView.destroy();\n }\n });\n }\n });\n\n test(\"a Metamorph view is not a view's parentView\", function() {\n childView = EmberView.create({\n render: function(buffer) {\n buffer.push(\"

    Bye bros

    \");\n }\n });\n\n metamorphView = _MetamorphView.create({\n render: function(buffer) {\n buffer.push(\"

    Meta

    \");\n this.appendChild(childView);\n }\n });\n\n run(function() {\n view.appendTo(\"#qunit-fixture\");\n });\n\n equal(get(childView, 'parentView'), view, \"A child of a metamorph view cannot see the metamorph view as its parent\");\n\n var children = get(view, 'childViews');\n\n equal(get(children, 'length'), 1, \"precond - there is only one child of the main node\");\n equal(children.objectAt(0), childView, \"... and it is not the metamorph\");\n });\n\n module(\"Metamorph views correctly handle DOM\", {\n setup: function() {\n view = EmberView.create({\n render: function(buffer) {\n buffer.push(\"

    View

    \");\n this.appendChild(metamorphView);\n }\n });\n\n metamorphView = _MetamorphView.create({\n powerRanger: \"Jason\",\n\n render: function(buffer) {\n buffer.push(\"

    \"+get(this, 'powerRanger')+\"

    \");\n }\n });\n\n run(function() {\n view.appendTo(\"#qunit-fixture\");\n });\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n if (!metamorphView.isDestroyed) {\n metamorphView.destroy();\n }\n });\n }\n });\n\n test(\"a metamorph view generates without a DOM node\", function() {\n var meta = jQuery(\"> h2\", \"#\" + get(view, 'elementId'));\n\n equal(meta.length, 1, \"The metamorph element should be directly inside its parent\");\n });\n\n test(\"a metamorph view can be removed from the DOM\", function() {\n run(function() {\n metamorphView.destroy();\n });\n\n var meta = jQuery('#from-morph');\n equal(meta.length, 0, \"the associated DOM was removed\");\n });\n\n test(\"a metamorph view can be rerendered\", function() {\n equal(jQuery('#from-meta').text(), \"Jason\", \"precond - renders to the DOM\");\n\n set(metamorphView, 'powerRanger', 'Trini');\n run(function() {\n metamorphView.rerender();\n });\n\n equal(jQuery('#from-meta').text(), \"Trini\", \"updates value when re-rendering\");\n });\n\n\n // Redefining without setup/teardown\n module(\"Metamorph views correctly handle DOM\");\n\n test(\"a metamorph view calls its childrens' willInsertElement and didInsertElement\", function() {\n var parentView;\n var willInsertElementCalled = false;\n var didInsertElementCalled = false;\n var didInsertElementSawElement = false;\n\n parentView = EmberView.create({\n ViewWithCallback: EmberView.extend({\n template: EmberHandlebars.compile('
    '),\n\n willInsertElement: function() {\n willInsertElementCalled = true;\n },\n didInsertElement: function() {\n didInsertElementCalled = true;\n didInsertElementSawElement = (this.$('div').length === 1);\n }\n }),\n\n template: EmberHandlebars.compile('{{#if view.condition}}{{view \"view.ViewWithCallback\"}}{{/if}}'),\n condition: false\n });\n\n run(function() {\n parentView.append();\n });\n run(function() {\n parentView.set('condition', true);\n });\n\n ok(willInsertElementCalled, \"willInsertElement called\");\n ok(didInsertElementCalled, \"didInsertElement called\");\n ok(didInsertElementSawElement, \"didInsertElement saw element\");\n\n run(function() {\n parentView.destroy();\n });\n\n });\n\n test(\"replacing a Metamorph should invalidate childView elements\", function() {\n var elementOnDidChange, elementOnDidInsert;\n\n view = EmberView.create({\n show: false,\n\n CustomView: EmberView.extend({\n init: function() {\n this._super();\n // This will be called in preRender\n // We want it to cache a null value\n // Hopefully it will be invalidated when `show` is toggled\n this.get('element');\n },\n\n elementDidChange: observer('element', function() {\n elementOnDidChange = this.get('element');\n }),\n\n didInsertElement: function() {\n elementOnDidInsert = this.get('element');\n }\n }),\n\n template: EmberHandlebars.compile(\"{{#if view.show}}{{view view.CustomView}}{{/if}}\")\n });\n\n run(function() { view.append(); });\n\n run(function() { view.set('show', true); });\n\n ok(elementOnDidChange, \"should have an element on change\");\n ok(elementOnDidInsert, \"should have an element on insert\");\n\n run(function() { view.destroy(); });\n });\n\n test(\"trigger rerender of parent and SimpleHandlebarsView\", function () {\n var view = EmberView.create({\n show: true,\n foo: 'bar',\n template: EmberHandlebars.compile(\"{{#if view.show}}{{#if view.foo}}{{view.foo}}{{/if}}{{/if}}\")\n });\n\n run(function() { view.append(); });\n\n equal(view.$().text(), 'bar');\n\n run(function() {\n view.set('foo', 'baz'); // schedule render of simple bound\n view.set('show', false); // destroy tree\n });\n\n equal(view.$().text(), '');\n\n run(function() {\n view.destroy();\n });\n });\n\n test(\"re-rendering and then changing the property does not raise an exception\", function() {\n view = EmberView.create({\n show: true,\n foo: 'bar',\n metamorphView: _MetamorphView,\n template: EmberHandlebars.compile(\"{{#view view.metamorphView}}truth{{/view}}\")\n });\n\n run(function() { view.appendTo('#qunit-fixture'); });\n\n equal(view.$().text(), 'truth');\n\n run(function() {\n view.get('_childViews')[0].rerender();\n view.get('_childViews')[0].rerender();\n });\n\n equal(view.$().text(), 'truth');\n\n run(function() {\n view.destroy();\n });\n });\n });\n})();\n//@ sourceURL=ember-handlebars/~tests/ember-handlebars");minispade.register('ember-handlebars/~tests/ember-handlebars_test', "(function() {minispade.require(\"ember-metal/~tests/ember-metal\");\nminispade.require(\"ember-handlebars/~tests/ember-handlebars\");\nrequireModule(\"ember-handlebars/tests/controls/checkbox_test\");\nrequireModule(\"ember-handlebars/tests/controls/select_test\");\nrequireModule(\"ember-handlebars/tests/controls/text_area_test\");\nrequireModule(\"ember-handlebars/tests/controls/text_field_test\");\nrequireModule(\"ember-handlebars/tests/handlebars_test\");\nrequireModule(\"ember-handlebars/tests/helpers/bound_helper_test\");\nrequireModule(\"ember-handlebars/tests/helpers/custom_view_helper_test\");\nrequireModule(\"ember-handlebars/tests/helpers/debug_test\");\nrequireModule(\"ember-handlebars/tests/helpers/each_test\");\nrequireModule(\"ember-handlebars/tests/helpers/group_test\");\nrequireModule(\"ember-handlebars/tests/helpers/if_unless_test\");\nrequireModule(\"ember-handlebars/tests/helpers/loc_test\");\nrequireModule(\"ember-handlebars/tests/helpers/partial_test\");\nrequireModule(\"ember-handlebars/tests/helpers/template_test\");\nrequireModule(\"ember-handlebars/tests/helpers/unbound_test\");\nrequireModule(\"ember-handlebars/tests/helpers/view_test\");\nrequireModule(\"ember-handlebars/tests/helpers/with_test\");\nrequireModule(\"ember-handlebars/tests/helpers/yield_test\");\nrequireModule(\"ember-handlebars/tests/loader_test\");\nrequireModule(\"ember-handlebars/tests/lookup_test\");\nrequireModule(\"ember-handlebars/tests/views/collection_view_test\");\nrequireModule(\"ember-handlebars/tests/views/metamorph_view_test\");\n})();\n//@ sourceURL=ember-handlebars/~tests/ember-handlebars_test");minispade.register('ember-metal/~tests/ember-metal', "(function() {define(\"ember-metal/tests/accessors/getPath_test\",\n [\"ember-metal/property_get\"],\n function(__dependency1__) {\n \"use strict\";\n /*globals Foo:true $foo:true */\n\n var get = __dependency1__.get;\n\n var obj, moduleOpts = {\n setup: function() {\n obj = {\n foo: {\n bar: {\n baz: { biff: 'BIFF' }\n }\n },\n falseValue: false\n };\n\n window.Foo = {\n bar: {\n baz: { biff: 'FooBiff' }\n }\n };\n\n window.$foo = {\n bar: {\n baz: { biff: '$FOOBIFF' }\n }\n };\n },\n\n teardown: function() {\n obj = undefined;\n window.Foo = undefined;\n window.$foo = undefined;\n }\n };\n\n module('Ember.get with path', moduleOpts);\n\n // ..........................................................\n // LOCAL PATHS\n //\n\n test('[obj, foo] -> obj.foo', function() {\n deepEqual(get(obj, 'foo'), obj.foo);\n });\n\n test('[obj, foo.bar] -> obj.foo.bar', function() {\n deepEqual(get(obj, 'foo.bar'), obj.foo.bar);\n });\n\n test('[obj, this.foo] -> obj.foo', function() {\n deepEqual(get(obj, 'this.foo'), obj.foo);\n });\n\n test('[obj, this.foo.bar] -> obj.foo.bar', function() {\n deepEqual(get(obj, 'this.foo.bar'), obj.foo.bar);\n });\n\n test('[obj, this.Foo.bar] -> (null)', function() {\n deepEqual(get(obj, 'this.Foo.bar'), undefined);\n });\n\n test('[obj, falseValue.notDefined] -> (null)', function() {\n deepEqual(get(obj, 'falseValue.notDefined'), undefined);\n });\n\n // ..........................................................\n // NO TARGET\n //\n\n test('[null, Foo] -> Foo', function() {\n deepEqual(get('Foo'), Foo);\n });\n\n test('[null, Foo.bar] -> Foo.bar', function() {\n deepEqual(get('Foo.bar'), Foo.bar);\n });\n });\ndefine(\"ember-metal/tests/accessors/getProperties_test\",\n [\"ember-metal/get_properties\"],\n function(__dependency1__) {\n \"use strict\";\n var getProperties = __dependency1__[\"default\"];\n\n module('Ember.getProperties');\n\n test('can retrieve a hash of properties from an object via an argument list or array of property names', function() {\n var obj = {\n firstName: \"Steve\",\n lastName: \"Jobs\",\n companyName: \"Apple, Inc.\"\n };\n\n deepEqual(getProperties(obj, \"firstName\", \"lastName\"), { firstName: 'Steve', lastName: 'Jobs' });\n deepEqual(getProperties(obj, \"firstName\", \"lastName\"), { firstName: 'Steve', lastName: 'Jobs' });\n deepEqual(getProperties(obj, \"lastName\"), { lastName: 'Jobs' });\n deepEqual(getProperties(obj), {});\n deepEqual(getProperties(obj, [\"firstName\", \"lastName\"]), { firstName: 'Steve', lastName: 'Jobs' });\n deepEqual(getProperties(obj, [\"firstName\"]), { firstName: 'Steve' });\n deepEqual(getProperties(obj, []), {});\n });\n });\ndefine(\"ember-metal/tests/accessors/get_test\",\n [\"ember-metal/tests/props_helper\",\"ember-metal/property_get\",\"ember-metal/mixin\",\"ember-metal/observer\",\"ember-metal/platform\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var testBoth = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var getWithDefault = __dependency2__.getWithDefault;\n var Mixin = __dependency3__.Mixin;\n var observer = __dependency3__.observer;\n var addObserver = __dependency4__.addObserver;\n var create = __dependency5__.create;\n\n module('Ember.get');\n\n test('should get arbitrary properties on an object', function() {\n var obj = {\n string: 'string',\n number: 23,\n boolTrue: true,\n boolFalse: false,\n nullValue: null\n };\n\n for(var key in obj) {\n if (!obj.hasOwnProperty(key)) continue;\n equal(get(obj, key), obj[key], key);\n }\n\n });\n\n testBoth(\"should call unknownProperty on watched values if the value is undefined\", function(get, set) {\n var obj = {\n count: 0,\n unknownProperty: function(key) {\n equal(key, 'foo', \"should pass key\");\n this.count++;\n return \"FOO\";\n }\n };\n\n var count = 0;\n addObserver(obj, 'foo', function() {\n count++;\n });\n\n equal(get(obj, 'foo'), 'FOO', 'should return value from unknown');\n });\n\n test('warn on attempts to get a property of undefined', function() {\n expectAssertion(function() {\n get(undefined, 'aProperty');\n }, /Cannot call get with 'aProperty' on an undefined object/i);\n });\n\n test('warn on attempts to get a property path of undefined', function() {\n expectAssertion(function() {\n get(undefined, 'aProperty.on.aPath');\n }, /Cannot call get with 'aProperty.on.aPath' on an undefined object/);\n });\n\n test('warn on attemps to get a falsy property', function() {\n var obj = {};\n expectAssertion(function() {\n get(obj, null);\n }, /Cannot call get with null key/);\n expectAssertion(function() {\n get(obj, NaN);\n }, /Cannot call get with NaN key/);\n expectAssertion(function() {\n get(obj, undefined);\n }, /Cannot call get with undefined key/);\n expectAssertion(function() {\n get(obj, false);\n }, /Cannot call get with false key/);\n });\n\n // ..........................................................\n // BUGS\n //\n\n test('(regression) watched properties on unmodified inherited objects should still return their original value', function() {\n\n var MyMixin = Mixin.create({\n someProperty: 'foo',\n propertyDidChange: observer('someProperty', function() {\n // NOTHING TO DO\n })\n });\n\n var baseObject = MyMixin.apply({});\n var theRealObject = create(baseObject);\n\n equal(get(theRealObject, 'someProperty'), 'foo', 'should return the set value, not false');\n });\n\n module(\"Ember.getWithDefault\");\n\n test('should get arbitrary properties on an object', function() {\n var obj = {\n string: 'string',\n number: 23,\n boolTrue: true,\n boolFalse: false,\n nullValue: null\n };\n\n for(var key in obj) {\n if (!obj.hasOwnProperty(key)) continue;\n equal(getWithDefault(obj, key, \"fail\"), obj[key], key);\n }\n\n obj = {\n undef: undefined\n };\n\n equal(getWithDefault(obj, \"undef\", \"default\"), \"default\", \"explicit undefined retrieves the default\");\n equal(getWithDefault(obj, \"not-present\", \"default\"), \"default\", \"non-present key retrieves the default\");\n });\n\n test('should call unknownProperty if defined and value is undefined', function() {\n\n var obj = {\n count: 0,\n unknownProperty: function(key) {\n equal(key, 'foo', 'should pass key');\n this.count++;\n return 'FOO';\n }\n };\n\n equal(get(obj, 'foo'), 'FOO', 'should return value from unknown');\n equal(obj.count, 1, 'should have invoked');\n });\n\n testBoth(\"if unknownProperty is present, it is called\", function(get, set) {\n var obj = {\n count: 0,\n unknownProperty: function(key) {\n if (key === \"foo\") {\n equal(key, 'foo', \"should pass key\");\n this.count++;\n return \"FOO\";\n }\n }\n };\n\n var count = 0;\n addObserver(obj, 'foo', function() {\n count++;\n });\n\n equal(getWithDefault(obj, 'foo', \"fail\"), 'FOO', 'should return value from unknownProperty');\n equal(getWithDefault(obj, 'bar', \"default\"), 'default', 'should convert undefined from unknownProperty into default');\n });\n\n // ..........................................................\n // BUGS\n //\n\n test('(regression) watched properties on unmodified inherited objects should still return their original value', function() {\n\n var MyMixin = Mixin.create({\n someProperty: 'foo',\n propertyDidChange: observer('someProperty', function() {\n // NOTHING TO DO\n })\n });\n\n var baseObject = MyMixin.apply({});\n var theRealObject = create(baseObject);\n\n equal(getWithDefault(theRealObject, 'someProperty', \"fail\"), 'foo', 'should return the set value, not false');\n });\n });\ndefine(\"ember-metal/tests/accessors/isGlobalPath_test\",\n [\"ember-metal/binding\"],\n function(__dependency1__) {\n \"use strict\";\n var isGlobalPath = __dependency1__.isGlobalPath;\n\n module('Ember.isGlobalPath');\n\n test(\"global path's are recognized\", function() {\n ok( isGlobalPath('App.myProperty') );\n ok( isGlobalPath('App.myProperty.subProperty') );\n });\n\n test(\"if there is a 'this' in the path, it's not a global path\", function() {\n ok( !isGlobalPath('this.myProperty') );\n ok( !isGlobalPath('this') );\n });\n\n test(\"if the path starts with a lowercase character, it is not a global path\", function() {\n ok( !isGlobalPath('myObj') );\n ok( !isGlobalPath('myObj.SecondProperty') );\n });\n });\ndefine(\"ember-metal/tests/accessors/normalizeTuple_test\",\n [\"ember-metal/property_get\"],\n function(__dependency1__) {\n \"use strict\";\n /*globals Foo:true, $foo:true */\n var normalizeTuple = __dependency1__.normalizeTuple;\n\n var obj, moduleOpts = {\n setup: function() {\n obj = {\n foo: {\n bar: {\n baz: {}\n }\n }\n };\n\n window.Foo = {\n bar: {\n baz: {}\n }\n };\n\n window.$foo = {\n bar: {\n baz: {}\n }\n };\n },\n\n teardown: function() {\n obj = undefined;\n window.Foo = undefined;\n window.$foo = undefined;\n }\n };\n\n module('normalizeTuple', moduleOpts);\n\n // ..........................................................\n // LOCAL PATHS\n //\n\n test('[obj, foo] -> [obj, foo]', function() {\n deepEqual(normalizeTuple(obj, 'foo'), [obj, 'foo']);\n });\n\n test('[obj, *] -> [obj, *]', function() {\n deepEqual(normalizeTuple(obj, '*'), [obj, '*']);\n });\n\n test('[obj, foo.bar] -> [obj, foo.bar]', function() {\n deepEqual(normalizeTuple(obj, 'foo.bar'), [obj, 'foo.bar']);\n });\n\n test('[obj, foo.*] -> [obj, foo.*]', function() {\n deepEqual(normalizeTuple(obj, 'foo.*'), [obj, 'foo.*']);\n });\n\n test('[obj, foo.*.baz] -> [obj, foo.*.baz]', function() {\n deepEqual(normalizeTuple(obj, 'foo.*.baz'), [obj, 'foo.*.baz']);\n });\n\n test('[obj, this.foo] -> [obj, foo]', function() {\n deepEqual(normalizeTuple(obj, 'this.foo'), [obj, 'foo']);\n });\n\n test('[obj, this.foo.bar] -> [obj, foo.bar]', function() {\n deepEqual(normalizeTuple(obj, 'this.foo.bar'), [obj, 'foo.bar']);\n });\n\n test('[obj, this.Foo.bar] -> [obj, Foo.bar]', function() {\n deepEqual(normalizeTuple(obj, 'this.Foo.bar'), [obj, 'Foo.bar']);\n });\n\n // ..........................................................\n // GLOBAL PATHS\n //\n\n test('[obj, Foo] -> [obj, Foo]', function() {\n deepEqual(normalizeTuple(obj, 'Foo'), [obj, 'Foo']);\n });\n\n test('[obj, Foo.bar] -> [Foo, bar]', function() {\n deepEqual(normalizeTuple(obj, 'Foo.bar'), [Foo, 'bar']);\n });\n\n test('[obj, $foo.bar.baz] -> [$foo, bar.baz]', function() {\n deepEqual(normalizeTuple(obj, '$foo.bar.baz'), [$foo, 'bar.baz']);\n });\n\n // ..........................................................\n // NO TARGET\n //\n\n test('[null, Foo] -> EXCEPTION', function() {\n raises(function() {\n normalizeTuple(null, 'Foo');\n }, Error);\n });\n\n test('[null, Foo.bar] -> [Foo, bar]', function() {\n deepEqual(normalizeTuple(null, 'Foo.bar'), [Foo, 'bar']);\n });\n });\ndefine(\"ember-metal/tests/accessors/setPath_test\",\n [\"ember-metal/property_set\",\"ember-metal/property_get\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var set = __dependency1__.set;\n var trySet = __dependency1__.trySet;\n var get = __dependency2__.get;\n\n var originalLookup = Ember.lookup;\n\n var obj, moduleOpts = {\n setup: function() {\n obj = {\n foo: {\n bar: {\n baz: { biff: 'BIFF' }\n }\n }\n };\n\n Ember.lookup = {\n Foo: {\n bar: {\n baz: { biff: 'FooBiff' }\n }\n },\n\n $foo: {\n bar: {\n baz: { biff: '$FOOBIFF' }\n }\n }\n };\n },\n\n teardown: function() {\n obj = null;\n Ember.lookup = originalLookup;\n }\n };\n\n module('set with path', moduleOpts);\n\n test('[Foo, bar] -> Foo.bar', function() {\n Ember.lookup.Foo = {toString: function() { return 'Foo'; }}; // Behave like an Ember.Namespace\n\n set(Ember.lookup.Foo, 'bar', 'baz');\n equal(get(Ember.lookup.Foo, 'bar'), 'baz');\n });\n\n // ..........................................................\n //\n // LOCAL PATHS\n\n test('[obj, foo] -> obj.foo', function() {\n set(obj, 'foo', \"BAM\");\n equal(get(obj, 'foo'), \"BAM\");\n });\n\n test('[obj, foo.bar] -> obj.foo.bar', function() {\n set(obj, 'foo.bar', \"BAM\");\n equal(get(obj, 'foo.bar'), \"BAM\");\n });\n\n test('[obj, this.foo] -> obj.foo', function() {\n set(obj, 'this.foo', \"BAM\");\n equal(get(obj, 'foo'), \"BAM\");\n });\n\n test('[obj, this.foo.bar] -> obj.foo.bar', function() {\n set(obj, 'this.foo.bar', \"BAM\");\n equal(get(obj, 'foo.bar'), \"BAM\");\n });\n\n // ..........................................................\n // NO TARGET\n //\n\n test('[null, Foo.bar] -> Foo.bar', function() {\n set(null, 'Foo.bar', \"BAM\");\n equal(get(Ember.lookup.Foo, 'bar'), \"BAM\");\n });\n\n // ..........................................................\n // DEPRECATED\n //\n\n module(\"set with path - deprecated\", {\n setup: function() {\n moduleOpts.setup();\n },\n teardown: function() {\n moduleOpts.teardown();\n }\n });\n\n test('[null, bla] gives a proper exception message', function() {\n var exceptionMessage = 'Property set failed: object in path \\\"bla\\\" could not be found or was destroyed.';\n try {\n set(null, 'bla', \"BAM\");\n } catch(ex) {\n equal(ex.message, exceptionMessage);\n }\n });\n\n test('[obj, bla.bla] gives a proper exception message', function() {\n var exceptionMessage = 'Property set failed: object in path \\\"bla\\\" could not be found or was destroyed.';\n try {\n set(obj, 'bla.bla', \"BAM\");\n } catch(ex) {\n equal(ex.message, exceptionMessage);\n }\n });\n\n test('[obj, foo.baz.bat] -> EXCEPTION', function() {\n raises(function() {\n set(obj, 'foo.baz.bat', \"BAM\");\n }, Error);\n });\n\n test('[obj, foo.baz.bat] -> EXCEPTION', function() {\n trySet(obj, 'foo.baz.bat', \"BAM\");\n ok(true, \"does not raise\");\n });\n });\ndefine(\"ember-metal/tests/accessors/set_test\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n\n module('set');\n\n test('should set arbitrary properties on an object', function() {\n var obj = {\n string: 'string',\n number: 23,\n boolTrue: true,\n boolFalse: false,\n nullValue: null,\n undefinedValue: undefined\n };\n\n var newObj = {\n undefinedValue: 'emberjs'\n };\n\n for(var key in obj) {\n if (!obj.hasOwnProperty(key)) continue;\n equal(set(newObj, key, obj[key]), obj[key], 'should return value');\n equal(get(newObj, key), obj[key], 'should set value');\n }\n });\n\n test('should call setUnknownProperty if defined and value is undefined', function() {\n\n var obj = {\n count: 0,\n\n unknownProperty: function(key, value) {\n ok(false, 'should not invoke unknownProperty if setUnknownProperty is defined');\n },\n\n setUnknownProperty: function(key, value) {\n equal(key, 'foo', 'should pass key');\n equal(value, 'BAR', 'should pass key');\n this.count++;\n return 'FOO';\n }\n };\n\n equal(set(obj, 'foo', \"BAR\"), 'BAR', 'should return set value');\n equal(obj.count, 1, 'should have invoked');\n });\n });\ndefine(\"ember-metal/tests/binding/connect_test\",\n [\"ember-metal/core\",\"ember-metal/tests/props_helper\",\"ember-metal/binding\",\"ember-metal/run_loop\",\"ember-metal/platform\",\"ember-metal/property_set\",\"ember-metal/property_get\",\"ember-metal/watching\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var testBoth = __dependency2__[\"default\"];\n var Binding = __dependency3__.Binding;\n var bind = __dependency3__.bind;\n var run = __dependency4__[\"default\"];\n var create = __dependency5__.create;\n var set = __dependency6__.set;\n var get = __dependency7__.get;\n var rewatch = __dependency8__.rewatch;\n\n function performTest(binding, a, b, get, set, connect) {\n if (connect === undefined) connect = function() {binding.connect(a);};\n\n ok(!run.currentRunLoop, 'performTest should not have a currentRunLoop');\n\n equal(get(a, 'foo'), 'FOO', 'a should not have changed');\n equal(get(b, 'bar'), 'BAR', 'b should not have changed');\n\n connect();\n\n equal(get(a, 'foo'), 'BAR', 'a should have changed');\n equal(get(b, 'bar'), 'BAR', 'b should have changed');\n //\n // make sure changes sync both ways\n run(function () {\n set(b, 'bar', 'BAZZ');\n });\n equal(get(a, 'foo'), 'BAZZ', 'a should have changed');\n\n run(function () {\n set(a, 'foo', 'BARF');\n });\n equal(get(b, 'bar'), 'BARF', 'a should have changed');\n }\n\n var originalLookup, lookup, GlobalB;\n\n module(\"Ember.Binding\", {\n setup: function(){\n originalLookup = Ember.lookup;\n Ember.lookup = lookup = {};\n },\n teardown: function(){\n lookup = null;\n Ember.lookup = originalLookup;\n }\n });\n\n testBoth('Connecting a binding between two properties', function(get, set) {\n var a = { foo: 'FOO', bar: 'BAR' };\n\n // a.bar -> a.foo\n var binding = new Binding('foo', 'bar');\n\n performTest(binding, a, a, get, set);\n });\n\n testBoth('Connecting a binding between two objects', function(get, set) {\n var b = { bar: 'BAR' };\n var a = { foo: 'FOO', b: b };\n\n // b.bar -> a.foo\n var binding = new Binding('foo', 'b.bar');\n\n performTest(binding, a, b, get, set);\n });\n\n testBoth('Connecting a binding to path', function(get, set) {\n var a = { foo: 'FOO' };\n lookup['GlobalB'] = GlobalB = {\n b: { bar: 'BAR' }\n };\n\n var b = get(GlobalB, 'b');\n\n // globalB.b.bar -> a.foo\n var binding = new Binding('foo', 'GlobalB.b.bar');\n\n performTest(binding, a, b, get, set);\n\n // make sure modifications update\n b = { bar: 'BIFF' };\n\n run(function() {\n set(GlobalB, 'b', b);\n });\n\n equal(get(a, 'foo'), 'BIFF', 'a should have changed');\n });\n\n testBoth('Calling connect more than once', function(get, set) {\n var b = { bar: 'BAR' };\n var a = { foo: 'FOO', b: b };\n\n // b.bar -> a.foo\n var binding = new Binding('foo', 'b.bar');\n\n performTest(binding, a, b, get, set, function () {\n binding.connect(a);\n\n binding.connect(a);\n });\n });\n\n testBoth('Bindings should be inherited', function(get, set) {\n\n var a = { foo: 'FOO', b: { bar: 'BAR' } };\n var binding = new Binding('foo', 'b.bar');\n var a2;\n\n run(function () {\n binding.connect(a);\n\n a2 = create(a);\n rewatch(a2);\n });\n\n equal(get(a2, 'foo'), \"BAR\", \"Should have synced binding on child\");\n equal(get(a, 'foo'), \"BAR\", \"Should NOT have synced binding on parent\");\n\n run(function () {\n set(a2, 'b', { bar: 'BAZZ' });\n });\n\n equal(get(a2, 'foo'), \"BAZZ\", \"Should have synced binding on child\");\n equal(get(a, 'foo'), \"BAR\", \"Should NOT have synced binding on parent\");\n\n });\n\n test('inherited bindings should sync on create', function() {\n var a;\n run(function () {\n var A = function() {\n bind(this, 'foo', 'bar.baz');\n };\n\n a = new A();\n set(a, 'bar', { baz: 'BAZ' });\n });\n\n equal(get(a, 'foo'), 'BAZ', 'should have synced binding on new obj');\n });\n });\ndefine(\"ember-metal/tests/binding/oneWay_test\",\n [\"ember-metal/property_set\",\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-metal/binding\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var set = __dependency1__.set;\n var get = __dependency2__.get;\n var run = __dependency3__[\"default\"];\n var oneWay = __dependency4__.oneWay;\n\n\n var MyApp;\n\n module('system/mixin/binding/oneWay_test', {\n setup: function() {\n MyApp = {\n foo: { value: 'FOO' },\n bar: { value: 'BAR' }\n };\n },\n\n teardown: function() {\n MyApp = null;\n }\n });\n\n test('oneWay(true) should only sync one way', function() {\n var binding;\n run(function() {\n binding = oneWay(MyApp, 'bar.value', 'foo.value');\n });\n\n equal(get(MyApp, 'foo.value'), 'FOO', 'foo synced');\n equal(get(MyApp, 'bar.value'), 'FOO', 'bar synced');\n\n run(function() {\n set(MyApp, 'bar.value', 'BAZ');\n });\n\n equal(get(MyApp, 'foo.value'), 'FOO', 'foo synced');\n equal(get(MyApp, 'bar.value'), 'BAZ', 'bar not synced');\n\n run(function() {\n set(MyApp, 'foo.value', 'BIFF');\n });\n\n equal(get(MyApp, 'foo.value'), 'BIFF', 'foo synced');\n equal(get(MyApp, 'bar.value'), 'BIFF', 'foo synced');\n\n });\n });\ndefine(\"ember-metal/tests/binding/sync_test\",\n [\"ember-metal/tests/props_helper\",\"ember-metal/run_loop\",\"ember-metal/observer\",\"ember-metal/platform\",\"ember-metal/binding\",\"ember-metal/watching\",\"ember-metal/computed\",\"ember-metal/properties\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var testBoth = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var addObserver = __dependency3__.addObserver;\n var removeObserver = __dependency3__.removeObserver;\n var _suspendObserver = __dependency3__._suspendObserver;\n var create = __dependency4__.create;\n var bind = __dependency5__.bind;\n var rewatch = __dependency6__.rewatch;\n var computed = __dependency7__.computed;\n var defineProperty = __dependency8__.defineProperty;\n\n module(\"system/binding/sync_test.js\");\n\n testBoth(\"bindings should not sync twice in a single run loop\", function(get, set) {\n var a, b, setValue, setCalled=0, getCalled=0;\n\n run(function() {\n a = {};\n\n defineProperty(a, 'foo', computed(function(key, value) {\n if (arguments.length === 2) {\n setCalled++;\n setValue = value;\n return value;\n } else {\n getCalled++;\n return setValue;\n }\n }).volatile());\n\n b = {\n a: a\n };\n bind(b, 'foo', 'a.foo');\n });\n\n // reset after initial binding synchronization\n getCalled = 0;\n\n run(function() {\n set(a, 'foo', 'trollface');\n });\n\n equal(get(b, 'foo'), \"trollface\", \"the binding should sync\");\n equal(setCalled, 1, \"Set should only be called once\");\n equal(getCalled, 1, \"Get should only be called once\");\n });\n\n testBoth(\"bindings should not infinite loop if computed properties return objects\", function(get, set) {\n var a, b, getCalled=0;\n\n run(function() {\n a = {};\n\n defineProperty(a, 'foo', computed(function() {\n getCalled++;\n if (getCalled > 1000) {\n throw 'infinite loop detected';\n }\n return ['foo', 'bar'];\n }));\n\n b = {\n a: a\n };\n bind(b, 'foo', 'a.foo');\n });\n\n deepEqual(get(b, 'foo'), ['foo', 'bar'], \"the binding should sync\");\n equal(getCalled, 1, \"Get should only be called once\");\n });\n\n testBoth(\"bindings should do the right thing when observers trigger bindings in the opposite direction\", function(get, set) {\n var a, b, c;\n\n run(function() {\n a = {\n foo: 'trololol'\n };\n\n b = {\n a: a\n };\n bind(b, 'foo', 'a.foo');\n\n c = {\n a: a\n };\n bind(c, 'foo', 'a.foo');\n });\n\n addObserver(b, 'foo', function() {\n set(c, 'foo', \"what is going on\");\n });\n\n run(function() {\n set(a, 'foo', 'trollface');\n });\n\n equal(get(a, 'foo'), \"what is going on\");\n });\n\n testBoth(\"bindings should do the right thing when binding is in prototype\", function(get, set) {\n var obj, proto, a, b, selectionChanged;\n run(function() {\n obj = {\n selection: null\n };\n\n selectionChanged = 0;\n\n addObserver(obj, 'selection', function () {\n selectionChanged++;\n });\n\n proto = {\n obj: obj,\n changeSelection: function (value) {\n set(this, 'selection', value);\n }\n };\n bind(proto, 'selection', 'obj.selection');\n\n a = create(proto);\n b = create(proto);\n rewatch(a);\n rewatch(b);\n });\n\n run(function () {\n set(a, 'selection', 'a');\n });\n\n run(function () {\n set(b, 'selection', 'b');\n });\n\n run(function () {\n set(a, 'selection', 'a');\n });\n\n equal(selectionChanged, 3);\n equal(get(obj, 'selection'), 'a');\n });\n\n testBoth(\"bindings should not try to sync destroyed objects\", function(get, set) {\n var a, b;\n\n run(function() {\n a = {\n foo: 'trololol'\n };\n\n b = {\n a: a\n };\n bind(b, 'foo', 'a.foo');\n });\n\n run(function() {\n set(a, 'foo', 'trollface');\n set(b, 'isDestroyed', true);\n ok(true, \"should not raise\");\n });\n\n run(function() {\n a = {\n foo: 'trololol'\n };\n\n b = {\n a: a\n };\n bind(b, 'foo', 'a.foo');\n });\n\n run(function() {\n set(b, 'foo', 'trollface');\n set(a, 'isDestroyed', true);\n ok(true, \"should not raise\");\n });\n });\n });\ndefine(\"ember-metal/tests/chains_test\",\n [\"ember-metal/utils\",\"ember-metal/observer\",\"ember-metal/chains\",\"ember-metal/platform\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var META_KEY = __dependency1__.META_KEY;\n var addObserver = __dependency2__.addObserver;\n var finishChains = __dependency3__.finishChains;\n var create = __dependency4__.create;\n\n module(\"Chains\");\n\n test(\"finishChains should properly copy chains from prototypes to instances\", function() {\n function didChange() {}\n\n var obj = {};\n addObserver(obj, 'foo.bar', null, didChange);\n\n var childObj = create(obj);\n finishChains(childObj);\n\n ok(obj[META_KEY].chains !== childObj[META_KEY].chains, \"The chains object is copied\");\n });\n });\ndefine(\"ember-metal/tests/computed_test\",\n [\"ember-metal/core\",\"ember-metal/tests/props_helper\",\"ember-metal/platform\",\"ember-metal/computed\",\"ember-metal/properties\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/utils\",\"ember-metal/watching\",\"ember-metal/observer\",\"ember-metal/enumerable_utils\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var testBoth = __dependency2__[\"default\"];\n var create = __dependency3__.create;\n var ComputedProperty = __dependency4__.ComputedProperty;\n var computed = __dependency4__.computed;\n var cacheFor = __dependency4__.cacheFor;\n var Descriptor = __dependency5__.Descriptor;\n var defineProperty = __dependency5__.defineProperty;\n var get = __dependency6__.get;\n var set = __dependency7__.set;\n var meta = __dependency8__.meta;\n var isWatching = __dependency9__.isWatching;\n var addObserver = __dependency10__.addObserver;\n var addBeforeObserver = __dependency10__.addBeforeObserver;\n var EnumerableUtils = __dependency11__[\"default\"];\n\n var originalLookup = Ember.lookup, lookup;\n var obj, count, Global;\n\n module('computed');\n\n test('computed property should be an instance of descriptor', function() {\n ok(computed(function() {}) instanceof Descriptor);\n });\n\n test('defining computed property should invoke property on get', function() {\n\n var obj = {};\n var count = 0;\n defineProperty(obj, 'foo', computed(function(key) {\n count++;\n return 'computed '+key;\n }));\n\n equal(get(obj, 'foo'), 'computed foo', 'should return value');\n equal(count, 1, 'should have invoked computed property');\n });\n\n test('defining computed property should invoke property on set', function() {\n\n var obj = {};\n var count = 0;\n defineProperty(obj, 'foo', computed(function(key, value) {\n if (value !== undefined) {\n count++;\n this['__'+key] = 'computed '+value;\n }\n return this['__'+key];\n }));\n\n equal(set(obj, 'foo', 'bar'), 'bar', 'should return set value');\n equal(count, 1, 'should have invoked computed property');\n equal(get(obj, 'foo'), 'computed bar', 'should return new value');\n });\n\n var objA, objB;\n module('computed should inherit through prototype', {\n setup: function() {\n objA = { __foo: 'FOO' } ;\n defineProperty(objA, 'foo', computed(function(key, value) {\n if (value !== undefined) {\n this['__'+key] = 'computed '+value;\n }\n return this['__'+key];\n }));\n\n objB = create(objA);\n objB.__foo = 'FOO'; // make a copy;\n },\n\n teardown: function() {\n objA = objB = null;\n }\n });\n\n testBoth('using get() and set()', function(get, set) {\n equal(get(objA, 'foo'), 'FOO', 'should get FOO from A');\n equal(get(objB, 'foo'), 'FOO', 'should get FOO from B');\n\n set(objA, 'foo', 'BIFF');\n equal(get(objA, 'foo'), 'computed BIFF', 'should change A');\n equal(get(objB, 'foo'), 'FOO', 'should NOT change B');\n\n set(objB, 'foo', 'bar');\n equal(get(objB, 'foo'), 'computed bar', 'should change B');\n equal(get(objA, 'foo'), 'computed BIFF', 'should NOT change A');\n\n set(objA, 'foo', 'BAZ');\n equal(get(objA, 'foo'), 'computed BAZ', 'should change A');\n equal(get(objB, 'foo'), 'computed bar', 'should NOT change B');\n });\n\n module('redefining computed property to normal', {\n setup: function() {\n objA = { __foo: 'FOO' } ;\n defineProperty(objA, 'foo', computed(function(key, value) {\n if (value !== undefined) {\n this['__'+key] = 'computed '+value;\n }\n return this['__'+key];\n }));\n\n objB = create(objA);\n defineProperty(objB, 'foo'); // make this just a normal property.\n },\n\n teardown: function() {\n objA = objB = null;\n }\n });\n\n testBoth('using get() and set()', function(get, set) {\n equal(get(objA, 'foo'), 'FOO', 'should get FOO from A');\n equal(get(objB, 'foo'), undefined, 'should get undefined from B');\n\n set(objA, 'foo', 'BIFF');\n equal(get(objA, 'foo'), 'computed BIFF', 'should change A');\n equal(get(objB, 'foo'), undefined, 'should NOT change B');\n\n set(objB, 'foo', 'bar');\n equal(get(objB, 'foo'), 'bar', 'should change B');\n equal(get(objA, 'foo'), 'computed BIFF', 'should NOT change A');\n\n set(objA, 'foo', 'BAZ');\n equal(get(objA, 'foo'), 'computed BAZ', 'should change A');\n equal(get(objB, 'foo'), 'bar', 'should NOT change B');\n });\n\n module('redefining computed property to another property', {\n setup: function() {\n objA = { __foo: 'FOO' } ;\n defineProperty(objA, 'foo', computed(function(key, value) {\n if (value !== undefined) {\n this['__'+key] = 'A '+value;\n }\n return this['__'+key];\n }));\n\n objB = create(objA);\n objB.__foo = 'FOO';\n defineProperty(objB, 'foo', computed(function(key, value) {\n if (value !== undefined) {\n this['__'+key] = 'B '+value;\n }\n return this['__'+key];\n }));\n },\n\n teardown: function() {\n objA = objB = null;\n }\n });\n\n testBoth('using get() and set()', function(get, set) {\n equal(get(objA, 'foo'), 'FOO', 'should get FOO from A');\n equal(get(objB, 'foo'), 'FOO', 'should get FOO from B');\n\n set(objA, 'foo', 'BIFF');\n equal(get(objA, 'foo'), 'A BIFF', 'should change A');\n equal(get(objB, 'foo'), 'FOO', 'should NOT change B');\n\n set(objB, 'foo', 'bar');\n equal(get(objB, 'foo'), 'B bar', 'should change B');\n equal(get(objA, 'foo'), 'A BIFF', 'should NOT change A');\n\n set(objA, 'foo', 'BAZ');\n equal(get(objA, 'foo'), 'A BAZ', 'should change A');\n equal(get(objB, 'foo'), 'B bar', 'should NOT change B');\n });\n\n module('computed - metadata');\n\n test(\"can set metadata on a computed property\", function() {\n var computedProperty = computed(function() { });\n computedProperty.meta({ key: 'keyValue' });\n\n equal(computedProperty.meta().key, 'keyValue', \"saves passed meta hash to the _meta property\");\n });\n\n test(\"meta should return an empty hash if no meta is set\", function() {\n var computedProperty = computed(function() { });\n deepEqual(computedProperty.meta(), {}, \"returned value is an empty hash\");\n });\n\n // ..........................................................\n // CACHEABLE\n //\n\n module('computed - cacheable', {\n setup: function() {\n obj = {};\n count = 0;\n defineProperty(obj, 'foo', computed(function(key, value) {\n count++;\n return 'bar '+count;\n }));\n },\n\n teardown: function() {\n obj = count = null;\n }\n });\n\n testBoth('cacheable should cache', function(get, set) {\n equal(get(obj, 'foo'), 'bar 1', 'first get');\n equal(get(obj, 'foo'), 'bar 1', 'second get');\n equal(count, 1, 'should only invoke once');\n });\n\n testBoth('modifying a cacheable property should update cache', function(get, set) {\n equal(get(obj, 'foo'), 'bar 1', 'first get');\n equal(get(obj, 'foo'), 'bar 1', 'second get');\n\n equal(set(obj, 'foo', 'baz'), 'baz', 'setting');\n equal(get(obj, 'foo'), 'bar 2', 'third get');\n equal(count, 2, 'should not invoke again');\n });\n\n testBoth('inherited property should not pick up cache', function(get, set) {\n var objB = create(obj);\n\n equal(get(obj, 'foo'), 'bar 1', 'obj first get');\n equal(get(objB, 'foo'), 'bar 2', 'objB first get');\n\n equal(get(obj, 'foo'), 'bar 1', 'obj second get');\n equal(get(objB, 'foo'), 'bar 2', 'objB second get');\n\n set(obj, 'foo', 'baz'); // modify A\n equal(get(obj, 'foo'), 'bar 3', 'obj third get');\n equal(get(objB, 'foo'), 'bar 2', 'objB third get');\n });\n\n testBoth('cacheFor should return the cached value', function(get, set) {\n equal(cacheFor(obj, 'foo'), undefined, \"should not yet be a cached value\");\n\n get(obj, 'foo');\n\n equal(cacheFor(obj, 'foo'), \"bar 1\", \"should retrieve cached value\");\n });\n\n testBoth('cacheFor should return falsy cached values', function(get, set) {\n\n defineProperty(obj, 'falsy', computed(function() {\n return false;\n }));\n\n equal(cacheFor(obj, 'falsy'), undefined, \"should not yet be a cached value\");\n\n get(obj, 'falsy');\n\n equal(cacheFor(obj, 'falsy'), false, \"should retrieve cached value\");\n });\n\n testBoth(\"setting a cached computed property passes the old value as the third argument\", function(get, set) {\n var obj = {\n foo: 0\n };\n\n var receivedOldValue;\n\n defineProperty(obj, 'plusOne', computed(\n function(key, value, oldValue) {\n receivedOldValue = oldValue;\n return value;\n }).property('foo')\n );\n\n set(obj, 'plusOne', 1);\n strictEqual(receivedOldValue, undefined, \"oldValue should be undefined\");\n\n set(obj, 'plusOne', 2);\n strictEqual(receivedOldValue, 1, \"oldValue should be 1\");\n\n set(obj, 'plusOne', 3);\n strictEqual(receivedOldValue, 2, \"oldValue should be 2\");\n });\n\n testBoth(\"the old value is only passed in if the computed property specifies three arguments\", function(get, set) {\n var obj = {\n foo: 0\n };\n\n var receivedOldValue;\n\n defineProperty(obj, 'plusOne', computed(\n function(key, value) {\n equal(arguments.length, 2, \"computed property is only invoked with two arguments\");\n return value;\n }).property('foo')\n );\n\n set(obj, 'plusOne', 1);\n set(obj, 'plusOne', 2);\n set(obj, 'plusOne', 3);\n });\n\n // ..........................................................\n // DEPENDENT KEYS\n //\n\n module('computed - dependentkey', {\n setup: function() {\n obj = { bar: 'baz' };\n count = 0;\n defineProperty(obj, 'foo', computed(function(key, value) {\n count++;\n get(this, 'bar');\n return 'bar '+count;\n }).property('bar'));\n },\n\n teardown: function() {\n obj = count = null;\n }\n });\n\n testBoth('should lazily watch dependent keys on set', function (get, set) {\n equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key');\n set(obj, 'foo', 'bar');\n equal(isWatching(obj, 'bar'), true, 'lazily watching dependent key');\n });\n\n testBoth('should lazily watch dependent keys on get', function (get, set) {\n equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key');\n get(obj, 'foo');\n equal(isWatching(obj, 'bar'), true, 'lazily watching dependent key');\n });\n\n testBoth('local dependent key should invalidate cache', function(get, set) {\n equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key');\n equal(get(obj, 'foo'), 'bar 1', 'get once');\n equal(isWatching(obj, 'bar'), true, 'lazily setup watching dependent key');\n equal(get(obj, 'foo'), 'bar 1', 'cached retrieve');\n\n set(obj, 'bar', 'BIFF'); // should invalidate foo\n\n equal(get(obj, 'foo'), 'bar 2', 'should recache');\n equal(get(obj, 'foo'), 'bar 2', 'cached retrieve');\n });\n\n testBoth('should invalidate multiple nested dependent keys', function(get, set) {\n var count = 0;\n defineProperty(obj, 'bar', computed(function() {\n count++;\n get(this, 'baz');\n return 'baz '+count;\n }).property('baz'));\n\n equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key');\n equal(isWatching(obj, 'baz'), false, 'precond not watching dependent key');\n equal(get(obj, 'foo'), 'bar 1', 'get once');\n equal(isWatching(obj, 'bar'), true, 'lazily setup watching dependent key');\n equal(isWatching(obj, 'baz'), true, 'lazily setup watching dependent key');\n equal(get(obj, 'foo'), 'bar 1', 'cached retrieve');\n\n set(obj, 'baz', 'BIFF'); // should invalidate bar -> foo\n equal(isWatching(obj, 'bar'), false, 'should not be watching dependent key after cache cleared');\n equal(isWatching(obj, 'baz'), false, 'should not be watching dependent key after cache cleared');\n\n equal(get(obj, 'foo'), 'bar 2', 'should recache');\n equal(get(obj, 'foo'), 'bar 2', 'cached retrieve');\n equal(isWatching(obj, 'bar'), true, 'lazily setup watching dependent key');\n equal(isWatching(obj, 'baz'), true, 'lazily setup watching dependent key');\n });\n\n testBoth('circular keys should not blow up', function(get, set) {\n\n defineProperty(obj, 'bar', computed(function(key, value) {\n count++;\n return 'bar '+count;\n }).property('foo'));\n\n defineProperty(obj, 'foo', computed(function(key, value) {\n count++;\n return 'foo '+count;\n }).property('bar'));\n\n equal(get(obj, 'foo'), 'foo 1', 'get once');\n equal(get(obj, 'foo'), 'foo 1', 'cached retrieve');\n\n set(obj, 'bar', 'BIFF'); // should invalidate bar -> foo -> bar\n\n equal(get(obj, 'foo'), 'foo 3', 'should recache');\n equal(get(obj, 'foo'), 'foo 3', 'cached retrieve');\n });\n\n testBoth('redefining a property should undo old depenent keys', function(get ,set) {\n\n equal(isWatching(obj, 'bar'), false, 'precond not watching dependent key');\n equal(get(obj, 'foo'), 'bar 1');\n equal(isWatching(obj, 'bar'), true, 'lazily watching dependent key');\n\n defineProperty(obj, 'foo', computed(function() {\n count++;\n return 'baz '+count;\n }).property('baz'));\n\n equal(isWatching(obj, 'bar'), false, 'after redefining should not be watching dependent key');\n\n equal(get(obj, 'foo'), 'baz 2');\n\n set(obj, 'bar', 'BIFF'); // should not kill cache\n equal(get(obj, 'foo'), 'baz 2');\n\n set(obj, 'baz', 'BOP');\n equal(get(obj, 'foo'), 'baz 3');\n });\n\n testBoth('can watch multiple dependent keys specified declaratively via brace expansion', function (get, set) {\n defineProperty(obj, 'foo', computed(function(key, value) {\n count++;\n return 'foo '+count;\n }).property('qux.{bar,baz}'));\n\n equal(get(obj, 'foo'), 'foo 1', \"get once\");\n equal(get(obj, 'foo'), 'foo 1', \"cached retrieve\");\n\n set(obj, 'qux', {});\n set(obj, 'qux.bar', 'bar'); // invalidate foo\n\n equal(get(obj, 'foo'), 'foo 2', \"foo invalidated from bar\");\n\n set(obj, 'qux.baz', 'baz'); // invalidate foo\n\n equal(get(obj, 'foo'), 'foo 3', \"foo invalidated from baz\");\n\n set(obj, 'qux.quux', 'quux'); // do not invalidate foo\n\n equal(get(obj, 'foo'), 'foo 3', \"foo not invalidated by quux\");\n });\n\n // ..........................................................\n // CHAINED DEPENDENT KEYS\n //\n\n\n var func, moduleOpts = {\n setup: function() {\n originalLookup = Ember.lookup;\n lookup = Ember.lookup = {};\n\n obj = {\n foo: {\n bar: {\n baz: {\n biff: \"BIFF\"\n }\n }\n }\n };\n\n Global = {\n foo: {\n bar: {\n baz: {\n biff: \"BIFF\"\n }\n }\n }\n };\n\n lookup['Global'] = Global;\n\n count = 0;\n func = function() {\n count++;\n return get(obj, 'foo.bar.baz.biff')+' '+count;\n };\n },\n\n teardown: function() {\n obj = count = func = Global = null;\n Ember.lookup = originalLookup;\n }\n };\n\n module('computed - dependentkey with chained properties', moduleOpts);\n\n testBoth('depending on simple chain', function(get, set) {\n\n // assign computed property\n defineProperty(obj, 'prop',\n computed(func).property('foo.bar.baz.biff'));\n\n equal(get(obj, 'prop'), 'BIFF 1');\n\n set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(get(obj, 'prop'), 'BUZZ 2');\n equal(get(obj, 'prop'), 'BUZZ 2');\n\n set(get(obj, 'foo.bar'), 'baz', { biff: 'BLOB' });\n equal(get(obj, 'prop'), 'BLOB 3');\n equal(get(obj, 'prop'), 'BLOB 3');\n\n set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(get(obj, 'prop'), 'BUZZ 4');\n equal(get(obj, 'prop'), 'BUZZ 4');\n\n set(get(obj, 'foo'), 'bar', { baz: { biff: 'BOOM' } });\n equal(get(obj, 'prop'), 'BOOM 5');\n equal(get(obj, 'prop'), 'BOOM 5');\n\n set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(get(obj, 'prop'), 'BUZZ 6');\n equal(get(obj, 'prop'), 'BUZZ 6');\n\n set(obj, 'foo', { bar: { baz: { biff: 'BLARG' } } });\n equal(get(obj, 'prop'), 'BLARG 7');\n equal(get(obj, 'prop'), 'BLARG 7');\n\n set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(get(obj, 'prop'), 'BUZZ 8');\n equal(get(obj, 'prop'), 'BUZZ 8');\n\n defineProperty(obj, 'prop');\n set(obj, 'prop', 'NONE');\n equal(get(obj, 'prop'), 'NONE');\n\n set(obj, 'foo', { bar: { baz: { biff: 'BLARG' } } });\n equal(get(obj, 'prop'), 'NONE'); // should do nothing\n equal(count, 8, 'should be not have invoked computed again');\n\n });\n\n testBoth('depending on Global chain', function(get, set) {\n\n // assign computed property\n defineProperty(obj, 'prop', computed(function() {\n count++;\n return get('Global.foo.bar.baz.biff')+' '+count;\n }).property('Global.foo.bar.baz.biff'));\n\n equal(get(obj, 'prop'), 'BIFF 1');\n\n set(get(Global, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(get(obj, 'prop'), 'BUZZ 2');\n equal(get(obj, 'prop'), 'BUZZ 2');\n\n set(get(Global, 'foo.bar'), 'baz', { biff: 'BLOB' });\n equal(get(obj, 'prop'), 'BLOB 3');\n equal(get(obj, 'prop'), 'BLOB 3');\n\n set(get(Global, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(get(obj, 'prop'), 'BUZZ 4');\n equal(get(obj, 'prop'), 'BUZZ 4');\n\n set(get(Global, 'foo'), 'bar', { baz: { biff: 'BOOM' } });\n equal(get(obj, 'prop'), 'BOOM 5');\n equal(get(obj, 'prop'), 'BOOM 5');\n\n set(get(Global, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(get(obj, 'prop'), 'BUZZ 6');\n equal(get(obj, 'prop'), 'BUZZ 6');\n\n set(Global, 'foo', { bar: { baz: { biff: 'BLARG' } } });\n equal(get(obj, 'prop'), 'BLARG 7');\n equal(get(obj, 'prop'), 'BLARG 7');\n\n set(get(Global, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(get(obj, 'prop'), 'BUZZ 8');\n equal(get(obj, 'prop'), 'BUZZ 8');\n\n defineProperty(obj, 'prop');\n set(obj, 'prop', 'NONE');\n equal(get(obj, 'prop'), 'NONE');\n\n set(Global, 'foo', { bar: { baz: { biff: 'BLARG' } } });\n equal(get(obj, 'prop'), 'NONE'); // should do nothing\n equal(count, 8, 'should be not have invoked computed again');\n\n });\n\n testBoth('chained dependent keys should evaluate computed properties lazily', function(get,set) {\n defineProperty(obj.foo.bar, 'b', computed(func));\n defineProperty(obj.foo, 'c', computed(function() {}).property('bar.b'));\n equal(count, 0, 'b should not run');\n });\n\n\n // ..........................................................\n // BUGS\n //\n\n module('computed edge cases');\n\n test('adding a computed property should show up in key iteration',function() {\n\n var obj = {};\n defineProperty(obj, 'foo', computed(function() {}));\n\n var found = [];\n for(var key in obj) found.push(key);\n ok(EnumerableUtils.indexOf(found, 'foo')>=0, 'should find computed property in iteration found='+found);\n ok('foo' in obj, 'foo in obj should pass');\n });\n\n\n module('computed - setter');\n\n testBoth('setting a watched computed property', function(get, set) {\n var obj = {\n firstName: 'Yehuda',\n lastName: 'Katz'\n };\n defineProperty(obj, 'fullName', computed(\n function(key, value) {\n if (arguments.length > 1) {\n var values = value.split(' ');\n set(this, 'firstName', values[0]);\n set(this, 'lastName', values[1]);\n return value;\n }\n return get(this, 'firstName') + ' ' + get(this, 'lastName');\n }).property('firstName', 'lastName')\n );\n var fullNameWillChange = 0,\n fullNameDidChange = 0,\n firstNameWillChange = 0,\n firstNameDidChange = 0,\n lastNameWillChange = 0,\n lastNameDidChange = 0;\n addBeforeObserver(obj, 'fullName', function () {\n fullNameWillChange++;\n });\n addObserver(obj, 'fullName', function () {\n fullNameDidChange++;\n });\n addBeforeObserver(obj, 'firstName', function () {\n firstNameWillChange++;\n });\n addObserver(obj, 'firstName', function () {\n firstNameDidChange++;\n });\n addBeforeObserver(obj, 'lastName', function () {\n lastNameWillChange++;\n });\n addObserver(obj, 'lastName', function () {\n lastNameDidChange++;\n });\n\n equal(get(obj, 'fullName'), 'Yehuda Katz');\n\n set(obj, 'fullName', 'Yehuda Katz');\n\n set(obj, 'fullName', 'Kris Selden');\n\n equal(get(obj, 'fullName'), 'Kris Selden');\n equal(get(obj, 'firstName'), 'Kris');\n equal(get(obj, 'lastName'), 'Selden');\n\n equal(fullNameWillChange, 1);\n equal(fullNameDidChange, 1);\n equal(firstNameWillChange, 1);\n equal(firstNameDidChange, 1);\n equal(lastNameWillChange, 1);\n equal(lastNameDidChange, 1);\n });\n\n testBoth('setting a cached computed property that modifies the value you give it', function(get, set) {\n var obj = {\n foo: 0\n };\n defineProperty(obj, 'plusOne', computed(\n function(key, value) {\n if (arguments.length > 1) {\n set(this, 'foo', value);\n return value + 1;\n }\n return get(this, 'foo') + 1;\n }).property('foo')\n );\n var plusOneWillChange = 0,\n plusOneDidChange = 0;\n addBeforeObserver(obj, 'plusOne', function () {\n plusOneWillChange++;\n });\n addObserver(obj, 'plusOne', function () {\n plusOneDidChange++;\n });\n\n equal(get(obj, 'plusOne'), 1);\n set(obj, 'plusOne', 1);\n equal(get(obj, 'plusOne'), 2);\n set(obj, 'plusOne', 1);\n equal(get(obj, 'plusOne'), 2);\n\n equal(plusOneWillChange, 1);\n equal(plusOneDidChange, 1);\n\n set(obj, 'foo', 5);\n equal(get(obj, 'plusOne'), 6);\n\n equal(plusOneWillChange, 2);\n equal(plusOneDidChange, 2);\n });\n\n module('computed - default setter');\n\n testBoth(\"when setting a value on a computed property that doesn't handle sets\", function(get, set) {\n var obj = {}, observerFired = false;\n\n defineProperty(obj, 'foo', computed(function() {\n return 'foo';\n }));\n\n addObserver(obj, 'foo', null, function() {\n observerFired = true;\n });\n\n set(obj, 'foo', 'bar');\n\n equal(get(obj, 'foo'), 'bar', 'The set value is properly returned');\n ok(!meta(obj).descs.foo, 'The computed property was removed');\n ok(observerFired, 'The observer was still notified');\n });\n\n module('computed - readOnly');\n\n test('is chainable', function() {\n var cp = computed(function() {}).readOnly();\n\n ok(cp instanceof Descriptor);\n ok(cp instanceof ComputedProperty);\n });\n\n testBoth('protects against setting', function(get, set) {\n var obj = { };\n\n defineProperty(obj, 'bar', computed(function(key) {\n return 'barValue';\n }).readOnly());\n\n equal(get(obj, 'bar'), 'barValue');\n\n raises(function() {\n set(obj, 'bar', 'newBar');\n }, /Cannot set read\\-only property \"bar\" on object:/ );\n\n equal(get(obj, 'bar'), 'barValue');\n });\n\n module('CP macros');\n\n testBoth('computed.not', function(get, set) {\n var obj = {foo: true};\n defineProperty(obj, 'notFoo', computed.not('foo'));\n equal(get(obj, 'notFoo'), false);\n\n obj = {foo: {bar: true}};\n defineProperty(obj, 'notFoo', computed.not('foo.bar'));\n equal(get(obj, 'notFoo'), false);\n });\n\n testBoth('computed.empty', function(get, set) {\n var obj = {foo: [], bar: undefined, baz: null, quz: ''};\n defineProperty(obj, 'fooEmpty', computed.empty('foo'));\n defineProperty(obj, 'barEmpty', computed.empty('bar'));\n defineProperty(obj, 'bazEmpty', computed.empty('baz'));\n defineProperty(obj, 'quzEmpty', computed.empty('quz'));\n\n equal(get(obj, 'fooEmpty'), true);\n set(obj, 'foo', [1]);\n equal(get(obj, 'fooEmpty'), false);\n equal(get(obj, 'barEmpty'), true);\n equal(get(obj, 'bazEmpty'), true);\n equal(get(obj, 'quzEmpty'), true);\n set(obj, 'quz', 'asdf');\n equal(get(obj, 'quzEmpty'), false);\n });\n\n testBoth('computed.bool', function(get, set) {\n var obj = {foo: function() {}, bar: 'asdf', baz: null, quz: false};\n defineProperty(obj, 'fooBool', computed.bool('foo'));\n defineProperty(obj, 'barBool', computed.bool('bar'));\n defineProperty(obj, 'bazBool', computed.bool('baz'));\n defineProperty(obj, 'quzBool', computed.bool('quz'));\n equal(get(obj, 'fooBool'), true);\n equal(get(obj, 'barBool'), true);\n equal(get(obj, 'bazBool'), false);\n equal(get(obj, 'quzBool'), false);\n });\n\n testBoth('computed.alias', function(get, set) {\n var obj = { bar: 'asdf', baz: null, quz: false};\n defineProperty(obj, 'bay', computed(function(key) {\n return 'apple';\n }));\n\n defineProperty(obj, 'barAlias', computed.alias('bar'));\n defineProperty(obj, 'bazAlias', computed.alias('baz'));\n defineProperty(obj, 'quzAlias', computed.alias('quz'));\n defineProperty(obj, 'bayAlias', computed.alias('bay'));\n\n equal(get(obj, 'barAlias'), 'asdf');\n equal(get(obj, 'bazAlias'), null);\n equal(get(obj, 'quzAlias'), false);\n equal(get(obj, 'bayAlias'), 'apple');\n\n set(obj, 'barAlias', 'newBar');\n set(obj, 'bazAlias', 'newBaz');\n set(obj, 'quzAlias', null);\n\n equal(get(obj, 'barAlias'), 'newBar');\n equal(get(obj, 'bazAlias'), 'newBaz');\n equal(get(obj, 'quzAlias'), null);\n\n equal(get(obj, 'bar'), 'newBar');\n equal(get(obj, 'baz'), 'newBaz');\n equal(get(obj, 'quz'), null);\n });\n\n testBoth('computed.defaultTo', function(get, set) {\n var obj = { source: 'original source value' };\n defineProperty(obj, 'copy', computed.defaultTo('source'));\n\n equal(get(obj, 'copy'), 'original source value');\n\n set(obj, 'copy', 'new copy value');\n equal(get(obj, 'source'), 'original source value');\n equal(get(obj, 'copy'), 'new copy value');\n\n set(obj, 'source', 'new source value');\n equal(get(obj, 'copy'), 'new copy value');\n\n set(obj, 'copy', null);\n equal(get(obj, 'copy'), 'new source value');\n });\n\n testBoth('computed.match', function(get, set) {\n var obj = { name: 'Paul' };\n defineProperty(obj, 'isPaul', computed.match('name', /Paul/));\n\n equal(get(obj, 'isPaul'), true, 'is Paul');\n\n set(obj, 'name', 'Pierre');\n\n equal(get(obj, 'isPaul'), false, 'is not Paul anymore');\n });\n\n testBoth('computed.notEmpty', function(get, set) {\n var obj = { items: [1] };\n defineProperty(obj, 'hasItems', computed.notEmpty('items'));\n\n equal(get(obj, 'hasItems'), true, 'is not empty');\n\n set(obj, 'items', []);\n\n equal(get(obj, 'hasItems'), false, 'is empty');\n });\n\n testBoth('computed.equal', function(get, set) {\n var obj = { name: 'Paul' };\n defineProperty(obj, 'isPaul', computed.equal('name', 'Paul'));\n\n equal(get(obj, 'isPaul'), true, 'is Paul');\n\n set(obj, 'name', 'Pierre');\n\n equal(get(obj, 'isPaul'), false, 'is not Paul anymore');\n });\n\n testBoth('computed.gt', function(get, set) {\n var obj = { number: 2 };\n defineProperty(obj, 'isGreaterThenOne', computed.gt('number', 1));\n\n equal(get(obj, 'isGreaterThenOne'), true, 'is gt');\n\n set(obj, 'number', 1);\n\n equal(get(obj, 'isGreaterThenOne'), false, 'is not gt');\n\n set(obj, 'number', 0);\n\n equal(get(obj, 'isGreaterThenOne'), false, 'is not gt');\n });\n\n testBoth('computed.gte', function(get, set) {\n var obj = { number: 2 };\n defineProperty(obj, 'isGreaterOrEqualThenOne', computed.gte('number', 1));\n\n equal(get(obj, 'isGreaterOrEqualThenOne'), true, 'is gte');\n\n set(obj, 'number', 1);\n\n equal(get(obj, 'isGreaterOrEqualThenOne'), true, 'is gte');\n\n set(obj, 'number', 0);\n\n equal(get(obj, 'isGreaterOrEqualThenOne'), false, 'is not gte');\n });\n\n testBoth('computed.lt', function(get, set) {\n var obj = { number: 0 };\n defineProperty(obj, 'isLesserThenOne', computed.lt('number', 1));\n\n equal(get(obj, 'isLesserThenOne'), true, 'is lt');\n\n set(obj, 'number', 1);\n\n equal(get(obj, 'isLesserThenOne'), false, 'is not lt');\n\n set(obj, 'number', 2);\n\n equal(get(obj, 'isLesserThenOne'), false, 'is not lt');\n });\n\n testBoth('computed.lte', function(get, set) {\n var obj = { number: 0 };\n defineProperty(obj, 'isLesserOrEqualThenOne', computed.lte('number', 1));\n\n equal(get(obj, 'isLesserOrEqualThenOne'), true, 'is lte');\n\n set(obj, 'number', 1);\n\n equal(get(obj, 'isLesserOrEqualThenOne'), true, 'is lte');\n\n set(obj, 'number', 2);\n\n equal(get(obj, 'isLesserOrEqualThenOne'), false, 'is not lte');\n });\n\n testBoth('computed.and', function(get, set) {\n var obj = { one: true, two: true };\n defineProperty(obj, 'oneAndTwo', computed.and('one', 'two'));\n\n equal(get(obj, 'oneAndTwo'), true, 'one and two');\n\n set(obj, 'one', false);\n\n equal(get(obj, 'oneAndTwo'), false, 'one and not two');\n });\n\n testBoth('computed.or', function(get, set) {\n var obj = { one: true, two: true };\n defineProperty(obj, 'oneOrTwo', computed.or('one', 'two'));\n\n equal(get(obj, 'oneOrTwo'), true, 'one or two');\n\n set(obj, 'one', false);\n\n equal(get(obj, 'oneOrTwo'), true, 'one or two');\n\n set(obj, 'two', false);\n\n equal(get(obj, 'oneOrTwo'), false, 'nore one nore two');\n\n set(obj, 'one', true);\n\n equal(get(obj, 'oneOrTwo'), true, 'one or two');\n });\n\n testBoth('computed.any', function(get, set) {\n var obj = { one: 'foo', two: 'bar' };\n defineProperty(obj, 'anyOf', computed.any('one', 'two'));\n\n equal(get(obj, 'anyOf'), 'foo', 'is foo');\n\n set(obj, 'one', false);\n\n equal(get(obj, 'anyOf'), 'bar', 'is bar');\n });\n\n testBoth('computed.collect', function(get, set) {\n var obj = { one: 'foo', two: 'bar', three: null };\n defineProperty(obj, 'all', computed.collect('one', 'two', 'three', 'four'));\n\n deepEqual(get(obj, 'all'), ['foo', 'bar', null, null], 'have all of them');\n\n set(obj, 'four', true);\n\n deepEqual(get(obj, 'all'), ['foo', 'bar', null, true], 'have all of them');\n\n var a = [];\n set(obj, 'one', 0);\n set(obj, 'three', a);\n\n deepEqual(get(obj, 'all'), [0, 'bar', a, true], 'have all of them');\n });\n\n function oneWayTest(methodName) {\n return function(get, set) {\n var obj = {\n firstName: 'Teddy',\n lastName: 'Zeenny'\n };\n\n defineProperty(obj, 'nickName', computed[methodName]('firstName'));\n\n equal(get(obj, 'firstName'), 'Teddy');\n equal(get(obj, 'lastName'), 'Zeenny');\n equal(get(obj, 'nickName'), 'Teddy');\n\n set(obj, 'nickName', 'TeddyBear');\n\n equal(get(obj, 'firstName'), 'Teddy');\n equal(get(obj, 'lastName'), 'Zeenny');\n\n equal(get(obj, 'nickName'), 'TeddyBear');\n\n set(obj, 'firstName', 'TEDDDDDDDDYYY');\n\n equal(get(obj, 'nickName'), 'TeddyBear');\n };\n }\n\n testBoth('computed.oneWay', oneWayTest('oneWay'));\n\n if (Ember.FEATURES.isEnabled('query-params-new')) {\n testBoth('computed.reads', oneWayTest('reads'));\n }\n\n testBoth('computed.readOnly', function(get, set) {\n var obj = {\n firstName: 'Teddy',\n lastName: 'Zeenny'\n };\n\n defineProperty(obj, 'nickName', computed.readOnly('firstName'));\n\n equal(get(obj, 'firstName'), 'Teddy');\n equal(get(obj, 'lastName'), 'Zeenny');\n equal(get(obj, 'nickName'), 'Teddy');\n\n throws(function(){\n set(obj, 'nickName', 'TeddyBear');\n }, / /);\n\n equal(get(obj, 'firstName'), 'Teddy');\n equal(get(obj, 'lastName'), 'Zeenny');\n\n equal(get(obj, 'nickName'), 'Teddy');\n\n set(obj, 'firstName', 'TEDDDDDDDDYYY');\n\n equal(get(obj, 'nickName'), 'TEDDDDDDDDYYY');\n });\n });\ndefine(\"ember-metal/tests/core/inspect_test\",\n [\"ember-metal/utils\",\"ember-metal/core\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var inspect = __dependency1__.inspect;\n var Ember = __dependency2__[\"default\"];\n\n module(\"Ember.inspect\");\n\n test(\"strings\", function() {\n equal(inspect(\"foo\"), \"foo\");\n });\n\n test(\"numbers\", function() {\n equal(inspect(2.6), \"2.6\");\n });\n\n test(\"null\", function() {\n equal(inspect(null), \"null\");\n });\n\n test(\"undefined\", function() {\n equal(inspect(undefined), \"undefined\");\n });\n\n test(\"true\", function() {\n equal(inspect(true), \"true\");\n });\n\n test(\"false\", function() {\n equal(inspect(false), \"false\");\n });\n\n test(\"object\", function() {\n equal(inspect({}), \"{}\");\n equal(inspect({ foo: 'bar' }), \"{foo: bar}\");\n equal(inspect({ foo: Ember.K }), \"{foo: function() { ... }}\");\n });\n\n test(\"array\", function() {\n equal(inspect([1,2,3]), \"[1,2,3]\");\n });\n\n test(\"regexp\", function() {\n equal(inspect(/regexp/), \"/regexp/\");\n });\n\n test(\"date\", function() {\n var inspected = inspect(new Date(\"Sat Apr 30 2011 13:24:11\"));\n ok(inspected.match(/Sat Apr 30/), \"The inspected date has its date\");\n ok(inspected.match(/2011/), \"The inspected date has its year\");\n ok(inspected.match(/13:24:11/), \"The inspected date has its time\");\n });\n });\ndefine(\"ember-metal/tests/enumerable_utils_test\",\n [\"ember-metal/enumerable_utils\"],\n function(__dependency1__) {\n \"use strict\";\n var EnumerableUtils = __dependency1__[\"default\"];\n\n module('Ember.EnumerableUtils.intersection');\n\n test('returns an array of objects that appear in both enumerables', function() {\n var a = [1,2,3], b = [2,3,4], result;\n\n result = EnumerableUtils.intersection(a, b);\n\n deepEqual(result, [2,3]);\n });\n\n test(\"large replace\", function() {\n expect(0);\n\n // https://code.google.com/p/chromium/issues/detail?id=56588\n EnumerableUtils.replace([], 0, undefined, new Array(62401)); // max + 1 in Chrome 28.0.1500.71\n EnumerableUtils.replace([], 0, undefined, new Array(65535)); // max + 1 in Safari 6.0.5 (8536.30.1)\n EnumerableUtils.replace([], 0, undefined, new Array(491519)); // max + 1 in FireFox 22.0\n });\n });\ndefine(\"ember-metal/tests/error_test\",\n [],\n function() {\n \"use strict\";\n module(\"Ember Error Throwing\");\n\n test(\"new Ember.Error displays provided message\", function() {\n raises( function() {\n throw new Ember.Error('A Message');\n }, function(e) {\n return e.message === 'A Message';\n }, 'the assigned message was displayed' );\n });\n });\ndefine(\"ember-metal/tests/events_test\",\n [\"ember-metal/mixin\",\"ember-metal/platform\",\"ember-metal/utils\",\"ember-metal/events\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var Mixin = __dependency1__.Mixin;\n var create = __dependency2__.create;\n var meta = __dependency3__.meta;\n\n var on = __dependency4__.on;\n var addListener = __dependency4__.addListener;\n var removeListener = __dependency4__.removeListener;\n var suspendListener = __dependency4__.suspendListener;\n var suspendListeners = __dependency4__.suspendListeners;\n var sendEvent = __dependency4__.sendEvent;\n var hasListeners = __dependency4__.hasListeners;\n var watchedEvents = __dependency4__.watchedEvents;\n var listenersFor = __dependency4__.listenersFor;\n var actionsDiff = __dependency4__.actionsDiff;\n var actionsUnion = __dependency4__.actionsUnion;\n\n module('system/props/events_test');\n\n test('listener should receive event - removing should remove', function() {\n var obj = {}, count = 0;\n var F = function() { count++; };\n\n addListener(obj, 'event!', F);\n equal(count, 0, 'nothing yet');\n\n sendEvent(obj, 'event!');\n equal(count, 1, 'received event');\n\n removeListener(obj, 'event!', F);\n\n count = 0;\n sendEvent(obj, 'event!');\n equal(count, 0, 'received event');\n });\n\n test('listeners should be inherited', function() {\n var obj = {}, count = 0;\n var F = function() { count++; };\n\n addListener(obj, 'event!', F);\n\n var obj2 = create(obj);\n\n equal(count, 0, 'nothing yet');\n\n sendEvent(obj2, 'event!');\n equal(count, 1, 'received event');\n\n removeListener(obj2, 'event!', F);\n\n count = 0;\n sendEvent(obj2, 'event!');\n equal(count, 0, 'did not receive event');\n\n sendEvent(obj, 'event!');\n equal(count, 1, 'should still invoke on parent');\n\n });\n\n\n test('adding a listener more than once should only invoke once', function() {\n\n var obj = {}, count = 0;\n var F = function() { count++; };\n addListener(obj, 'event!', F);\n addListener(obj, 'event!', F);\n\n sendEvent(obj, 'event!');\n equal(count, 1, 'should only invoke once');\n });\n\n test('adding a listener with a target should invoke with target', function() {\n var obj = {}, target;\n\n target = {\n count: 0,\n method: function() { this.count++; }\n };\n\n addListener(obj, 'event!', target, target.method);\n sendEvent(obj, 'event!');\n equal(target.count, 1, 'should invoke');\n });\n\n test('suspending a listener should not invoke during callback', function() {\n var obj = {}, target, otherTarget;\n\n target = {\n count: 0,\n method: function() { this.count++; }\n };\n\n otherTarget = {\n count: 0,\n method: function() { this.count++; }\n };\n\n addListener(obj, 'event!', target, target.method);\n addListener(obj, 'event!', otherTarget, otherTarget.method);\n\n function callback() {\n /*jshint validthis:true */\n equal(this, target);\n\n sendEvent(obj, 'event!');\n\n return 'result';\n }\n\n sendEvent(obj, 'event!');\n\n equal(suspendListener(obj, 'event!', target, target.method, callback), 'result');\n\n sendEvent(obj, 'event!');\n\n equal(target.count, 2, 'should invoke');\n equal(otherTarget.count, 3, 'should invoke');\n });\n\n test('adding a listener with string method should lookup method on event delivery', function() {\n var obj = {}, target;\n\n target = {\n count: 0,\n method: function() {}\n };\n\n addListener(obj, 'event!', target, 'method');\n sendEvent(obj, 'event!');\n equal(target.count, 0, 'should invoke but do nothing');\n\n target.method = function() { this.count++; };\n sendEvent(obj, 'event!');\n equal(target.count, 1, 'should invoke now');\n });\n\n test('calling sendEvent with extra params should be passed to listeners', function() {\n\n var obj = {}, params = null;\n addListener(obj, 'event!', function() {\n params = Array.prototype.slice.call(arguments);\n });\n\n sendEvent(obj, 'event!', ['foo', 'bar']);\n deepEqual(params, ['foo', 'bar'], 'params should be saved');\n });\n\n test('implementing sendEvent on object should invoke', function() {\n var obj = {\n sendEvent: function(eventName, params) {\n equal(eventName, 'event!', 'eventName');\n deepEqual(params, ['foo', 'bar']);\n this.count++;\n },\n\n count: 0\n };\n\n addListener(obj, 'event!', obj, function() { this.count++; });\n\n sendEvent(obj, 'event!', ['foo', 'bar']);\n equal(obj.count, 2, 'should have invoked method & listener');\n });\n\n test('hasListeners tells you if there are listeners for a given event', function() {\n\n var obj = {}, F = function() {}, F2 = function() {};\n\n equal(hasListeners(obj, 'event!'), false, 'no listeners at first');\n\n addListener(obj, 'event!', F);\n addListener(obj, 'event!', F2);\n\n equal(hasListeners(obj, 'event!'), true, 'has listeners');\n\n removeListener(obj, 'event!', F);\n equal(hasListeners(obj, 'event!'), true, 'has listeners');\n\n removeListener(obj, 'event!', F2);\n equal(hasListeners(obj, 'event!'), false, 'has no more listeners');\n\n addListener(obj, 'event!', F);\n equal(hasListeners(obj, 'event!'), true, 'has listeners');\n });\n\n test('calling removeListener without method should remove all listeners', function() {\n var obj = {}, F = function() {}, F2 = function() {};\n\n equal(hasListeners(obj, 'event!'), false, 'no listeners at first');\n\n addListener(obj, 'event!', F);\n addListener(obj, 'event!', F2);\n\n equal(hasListeners(obj, 'event!'), true, 'has listeners');\n\n removeListener(obj, 'event!');\n\n equal(hasListeners(obj, 'event!'), false, 'has no more listeners');\n });\n\n test('while suspended, it should not be possible to add a duplicate listener', function() {\n var obj = {}, target;\n\n target = {\n count: 0,\n method: function() { this.count++; }\n };\n\n addListener(obj, 'event!', target, target.method);\n\n function callback() {\n addListener(obj, 'event!', target, target.method);\n }\n\n sendEvent(obj, 'event!');\n\n suspendListener(obj, 'event!', target, target.method, callback);\n\n equal(target.count, 1, 'should invoke');\n equal(meta(obj).listeners['event!'].length, 3, \"a duplicate listener wasn't added\");\n\n // now test suspendListeners...\n\n sendEvent(obj, 'event!');\n\n suspendListeners(obj, ['event!'], target, target.method, callback);\n\n equal(target.count, 2, 'should have invoked again');\n equal(meta(obj).listeners['event!'].length, 3, \"a duplicate listener wasn't added\");\n });\n\n test('a listener can be added as part of a mixin', function() {\n var triggered = 0;\n var MyMixin = Mixin.create({\n foo1: on('bar', function() {\n triggered++;\n }),\n\n foo2: on('bar', function() {\n triggered++;\n })\n });\n\n var obj = {};\n MyMixin.apply(obj);\n\n sendEvent(obj, 'bar');\n equal(triggered, 2, 'should invoke listeners');\n });\n\n test('a listener added as part of a mixin may be overridden', function() {\n\n var triggered = 0;\n var FirstMixin = Mixin.create({\n foo: on('bar', function() {\n triggered++;\n })\n });\n var SecondMixin = Mixin.create({\n foo: on('baz', function() {\n triggered++;\n })\n });\n\n var obj = {};\n FirstMixin.apply(obj);\n SecondMixin.apply(obj);\n\n sendEvent(obj, 'bar');\n equal(triggered, 0, 'should not invoke from overriden property');\n\n sendEvent(obj, 'baz');\n equal(triggered, 1, 'should invoke from subclass property');\n });\n });\ndefine(\"ember-metal/tests/features_test\",\n [\"ember-metal/core\"],\n function(__dependency1__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n\n var isEnabled = Ember.FEATURES.isEnabled,\n origFeatures, origEnableAll, origEnableOptional;\n\n module(\"Ember.FEATURES.isEnabled\", {\n setup: function(){\n origFeatures = Ember.FEATURES;\n origEnableAll = Ember.ENV.ENABLE_ALL_FEATURES;\n origEnableOptional = Ember.ENV.ENABLE_OPTIONAL_FEATURES;\n },\n\n teardown: function(){\n Ember.FEATURES = origFeatures;\n Ember.ENV.ENABLE_ALL_FEATURES = origEnableAll;\n Ember.ENV.ENABLE_OPTIONAL_FEATURES = origEnableOptional;\n }\n });\n\n test(\"ENV.ENABLE_ALL_FEATURES\", function() {\n Ember.ENV.ENABLE_ALL_FEATURES = true;\n Ember.FEATURES['fred'] = false;\n Ember.FEATURES['wilma'] = null;\n\n equal(isEnabled('fred'), true, \"overrides features set to false\");\n equal(isEnabled('wilma'), true, \"enables optional features\");\n equal(isEnabled('betty'), true, \"enables non-specified features\");\n });\n\n test(\"ENV.ENABLE_OPTIONAL_FEATURES\", function() {\n Ember.ENV.ENABLE_OPTIONAL_FEATURES = true;\n Ember.FEATURES['fred'] = false;\n Ember.FEATURES['barney'] = true;\n Ember.FEATURES['wilma'] = null;\n\n equal(isEnabled('fred'), false, \"returns flag value if false\");\n equal(isEnabled('barney'), true, \"returns flag value if true\");\n equal(isEnabled('wilma'), true, \"returns true if flag is not true|false|undefined\");\n equal(isEnabled('betty'), undefined, \"returns flag value if undefined\");\n });\n\n test(\"isEnabled without ENV options\", function(){\n Ember.ENV.ENABLE_ALL_FEATURES = false;\n Ember.ENV.ENABLE_OPTIONAL_FEATURES = false;\n\n Ember.FEATURES['fred'] = false;\n Ember.FEATURES['barney'] = true;\n Ember.FEATURES['wilma'] = null;\n\n equal(isEnabled('fred'), false, \"returns flag value if false\");\n equal(isEnabled('barney'), true, \"returns flag value if true\");\n equal(isEnabled('wilma'), false, \"returns false if flag is not set\");\n equal(isEnabled('betty'), undefined, \"returns flag value if undefined\");\n });\n });\ndefine(\"ember-metal/tests/instrumentation_test\",\n [\"ember-metal/instrumentation\"],\n function(__dependency1__) {\n \"use strict\";\n var instrument = __dependency1__.instrument;\n var subscribe = __dependency1__.subscribe;\n var unsubscribe = __dependency1__.unsubscribe;\n var reset = __dependency1__.reset;\n\n module(\"Ember Instrumentation\", {\n setup: function() {\n\n },\n teardown: function() {\n reset();\n }\n });\n\n test(\"subscribing to a simple path receives the listener\", function() {\n expect(12);\n\n var sentPayload = {}, count = 0;\n\n subscribe(\"render\", {\n before: function(name, timestamp, payload) {\n if (count === 0) {\n strictEqual(name, \"render\");\n } else {\n strictEqual(name, \"render.handlebars\");\n }\n\n ok(typeof timestamp === 'number');\n strictEqual(payload, sentPayload);\n },\n\n after: function(name, timestamp, payload) {\n if (count === 0) {\n strictEqual(name, \"render\");\n } else {\n strictEqual(name, \"render.handlebars\");\n }\n\n ok(typeof timestamp === 'number');\n strictEqual(payload, sentPayload);\n\n count++;\n }\n });\n\n instrument(\"render\", sentPayload, function() {\n\n });\n\n instrument(\"render.handlebars\", sentPayload, function() {\n\n });\n });\n\n test(\"returning a value from the before callback passes it to the after callback\", function() {\n expect(2);\n\n var passthru1 = {}, passthru2 = {};\n\n subscribe(\"render\", {\n before: function(name, timestamp, payload) {\n return passthru1;\n },\n after: function(name, timestamp, payload, beforeValue) {\n strictEqual(beforeValue, passthru1);\n }\n });\n\n subscribe(\"render\", {\n before: function(name, timestamp, payload) {\n return passthru2;\n },\n after: function(name, timestamp, payload, beforeValue) {\n strictEqual(beforeValue, passthru2);\n }\n });\n\n instrument(\"render\", null, function() {});\n });\n\n test(\"raising an exception in the instrumentation attaches it to the payload\", function() {\n expect(2);\n\n var error = new Error(\"Instrumentation\");\n\n subscribe(\"render\", {\n before: function() {},\n after: function(name, timestamp, payload) {\n strictEqual(payload.exception, error);\n }\n });\n\n subscribe(\"render\", {\n before: function() {},\n after: function(name, timestamp, payload) {\n strictEqual(payload.exception, error);\n }\n });\n\n instrument(\"render.handlebars\", null, function() {\n throw error;\n });\n });\n\n test(\"it is possible to add a new subscriber after the first instrument\", function() {\n instrument(\"render.handlebars\", null, function() {});\n\n subscribe(\"render\", {\n before: function() {\n ok(true, \"Before callback was called\");\n },\n after: function() {\n ok(true, \"After callback was called\");\n }\n });\n\n instrument(\"render.handlebars\", null, function() {});\n });\n\n test(\"it is possible to remove a subscriber\", function() {\n expect(4);\n\n var count = 0;\n\n var subscriber = subscribe(\"render\", {\n before: function() {\n equal(count, 0);\n ok(true, \"Before callback was called\");\n },\n after: function() {\n equal(count, 0);\n ok(true, \"After callback was called\");\n count++;\n }\n });\n\n instrument(\"render.handlebars\", null, function() {});\n\n unsubscribe(subscriber);\n\n instrument(\"render.handlebars\", null, function() {});\n });\n });\ndefine(\"ember-metal/tests/is_blank_test\",\n [\"ember-metal/is_blank\"],\n function(__dependency1__) {\n \"use strict\";\n var isBlank = __dependency1__[\"default\"];\n\n module(\"Ember.isBlank\");\n\n test(\"Ember.isBlank\", function() {\n var string = \"string\", fn = function() {},\n object = {length: 0};\n\n equal(true, isBlank(null), \"for null\");\n equal(true, isBlank(undefined), \"for undefined\");\n equal(true, isBlank(\"\"), \"for an empty String\");\n equal(true, isBlank(\" \"), \"for a whitespace String\");\n equal(true, isBlank(\"\\n\\t\"), \"for another whitespace String\");\n equal(false, isBlank(\"\\n\\t Hi\"), \"for a String with whitespaces\");\n equal(false, isBlank(true), \"for true\");\n equal(false, isBlank(false), \"for false\");\n equal(false, isBlank(string), \"for a String\");\n equal(false, isBlank(fn), \"for a Function\");\n equal(false, isBlank(0), \"for 0\");\n equal(true, isBlank([]), \"for an empty Array\");\n equal(false, isBlank({}), \"for an empty Object\");\n equal(true, isBlank(object), \"for an Object that has zero 'length'\");\n equal(false, isBlank([1,2,3]), \"for a non-empty array\");\n });\n });\ndefine(\"ember-metal/tests/is_empty_test\",\n [\"ember-metal/is_empty\"],\n function(__dependency1__) {\n \"use strict\";\n var isEmpty = __dependency1__[\"default\"];\n\n module(\"Ember.isEmpty\");\n\n test(\"Ember.isEmpty\", function() {\n var string = \"string\", fn = function() {},\n object = {length: 0};\n\n equal(true, isEmpty(null), \"for null\");\n equal(true, isEmpty(undefined), \"for undefined\");\n equal(true, isEmpty(\"\"), \"for an empty String\");\n equal(false, isEmpty(true), \"for true\");\n equal(false, isEmpty(false), \"for false\");\n equal(false, isEmpty(string), \"for a String\");\n equal(false, isEmpty(fn), \"for a Function\");\n equal(false, isEmpty(0), \"for 0\");\n equal(true, isEmpty([]), \"for an empty Array\");\n equal(false, isEmpty({}), \"for an empty Object\");\n equal(true, isEmpty(object), \"for an Object that has zero 'length'\");\n });\n });\ndefine(\"ember-metal/tests/is_none_test\",\n [\"ember-metal/is_none\"],\n function(__dependency1__) {\n \"use strict\";\n var isNone = __dependency1__[\"default\"];\n\n module(\"Ember.isNone\");\n\n test(\"Ember.isNone\", function() {\n var string = \"string\", fn = function() {};\n\n equal(true, isNone(null), \"for null\");\n equal(true, isNone(undefined), \"for undefined\");\n equal(false, isNone(\"\"), \"for an empty String\");\n equal(false, isNone(true), \"for true\");\n equal(false, isNone(false), \"for false\");\n equal(false, isNone(string), \"for a String\");\n equal(false, isNone(fn), \"for a Function\");\n equal(false, isNone(0), \"for 0\");\n equal(false, isNone([]), \"for an empty Array\");\n equal(false, isNone({}), \"for an empty Object\");\n });\n });\ndefine(\"ember-metal/tests/libraries_test\",\n [\"ember-metal\",\"ember-metal/libraries\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var libraries = __dependency2__[\"default\"];\n\n var libs = libraries;\n\n test('Ember registers itself', function() {\n equal(libs[0].name, \"Ember\");\n });\n\n test('core libraries come before other libraries', function() {\n var l = libs.length;\n\n libs.register(\"my-lib\", \"2.0.0a\");\n libs.registerCoreLibrary(\"DS\", \"1.0.0-beta.2\");\n\n equal(libs[l].name, \"DS\");\n equal(libs[l+1].name, \"my-lib\");\n\n libs.deRegister(\"my-lib\");\n libs.deRegister(\"DS\");\n });\n\n test('only the first registration of a library is stored', function() {\n var l = libs.length;\n\n libs.register(\"magic\", 1.23);\n libs.register(\"magic\", 2.23);\n libs.register(\"magic\", 3.23);\n\n equal(libs[l].name, \"magic\");\n equal(libs[l].version, 1.23);\n equal(libs.length, l+1);\n\n libs.deRegister(\"magic\");\n });\n\n test('libraries can be de-registered', function() {\n var l = libs.length;\n\n libs.register(\"lib1\", \"1.0.0b\");\n libs.register(\"lib2\", \"1.0.0b\");\n libs.register(\"lib3\", \"1.0.0b\");\n\n libs.deRegister(\"lib1\");\n libs.deRegister(\"lib3\");\n\n equal(libs[l].name, \"lib2\");\n equal(libs.length, l+1);\n\n libs.deRegister(\"lib2\");\n });\n });\ndefine(\"ember-metal/tests/map_test\",\n [\"ember-metal/map\"],\n function(__dependency1__) {\n \"use strict\";\n var OrderedSet = __dependency1__.OrderedSet;\n var Map = __dependency1__.Map;\n var MapWithDefault = __dependency1__.MapWithDefault;\n\n var object, number, string, map;\n\n var varieties = [['Map', Map], ['MapWithDefault', MapWithDefault]], variety;\n\n function testMap(nameAndFunc) {\n variety = nameAndFunc[0];\n\n module(\"Ember.\" + variety + \" (forEach and get are implicitly tested)\", {\n setup: function() {\n object = {};\n number = 42;\n string = \"foo\";\n\n map = nameAndFunc[1].create();\n }\n });\n\n var mapHasLength = function(expected, theMap) {\n theMap = theMap || map;\n\n var length = 0;\n theMap.forEach(function() {\n length++;\n });\n\n equal(length, expected, \"map should contain \" + expected + \" items\");\n };\n\n var mapHasEntries = function(entries, theMap) {\n theMap = theMap || map;\n\n for (var i = 0, l = entries.length; i < l; i++) {\n equal(theMap.get(entries[i][0]), entries[i][1]);\n equal(theMap.has(entries[i][0]), true);\n }\n\n mapHasLength(entries.length, theMap);\n };\n\n test(\"add\", function() {\n map.set(object, \"winning\");\n map.set(number, \"winning\");\n map.set(string, \"winning\");\n\n mapHasEntries([\n [ object, \"winning\" ],\n [ number, \"winning\" ],\n [ string, \"winning\" ]\n ]);\n\n map.set(object, \"losing\");\n map.set(number, \"losing\");\n map.set(string, \"losing\");\n\n mapHasEntries([\n [ object, \"losing\" ],\n [ number, \"losing\" ],\n [ string, \"losing\" ]\n ]);\n\n equal(map.has(\"nope\"), false);\n equal(map.has({}), false);\n });\n\n test(\"remove\", function() {\n map.set(object, \"winning\");\n map.set(number, \"winning\");\n map.set(string, \"winning\");\n\n map.remove(object);\n map.remove(number);\n map.remove(string);\n\n // doesn't explode\n map.remove({});\n\n mapHasEntries([]);\n });\n\n test(\"copy and then update\", function() {\n map.set(object, \"winning\");\n map.set(number, \"winning\");\n map.set(string, \"winning\");\n\n var map2 = map.copy();\n\n map2.set(object, \"losing\");\n map2.set(number, \"losing\");\n map2.set(string, \"losing\");\n\n mapHasEntries([\n [ object, \"winning\" ],\n [ number, \"winning\" ],\n [ string, \"winning\" ]\n ]);\n\n mapHasEntries([\n [ object, \"losing\" ],\n [ number, \"losing\" ],\n [ string, \"losing\" ]\n ], map2);\n });\n\n test(\"copy and then remove\", function() {\n map.set(object, \"winning\");\n map.set(number, \"winning\");\n map.set(string, \"winning\");\n\n var map2 = map.copy();\n\n map2.remove(object);\n map2.remove(number);\n map2.remove(string);\n\n mapHasEntries([\n [ object, \"winning\" ],\n [ number, \"winning\" ],\n [ string, \"winning\" ]\n ]);\n\n mapHasEntries([ ], map2);\n });\n\n test(\"length\", function() {\n //Add a key twice\n equal(map.length, 0);\n map.set(string, \"a string\");\n equal(map.length, 1);\n map.set(string, \"the same string\");\n equal(map.length, 1);\n\n //Add another\n map.set(number, \"a number\");\n equal(map.length, 2);\n\n //Remove one that doesn't exist\n map.remove('does not exist');\n equal(map.length, 2);\n\n //Check copy\n var copy = map.copy();\n equal(copy.length, 2);\n\n //Remove a key twice\n map.remove(number);\n equal(map.length, 1);\n map.remove(number);\n equal(map.length, 1);\n\n //Remove the last key\n map.remove(string);\n equal(map.length, 0);\n map.remove(string);\n equal(map.length, 0);\n });\n }\n\n for (var i = 0; i < varieties.length; i++) {\n testMap(varieties[i]);\n }\n\n module(\"MapWithDefault - default values\");\n\n test(\"Retrieving a value that has not been set returns and sets a default value\", function() {\n var map = MapWithDefault.create({\n defaultValue: function(key) {\n return [key];\n }\n });\n\n var value = map.get('ohai');\n deepEqual(value, [ 'ohai' ]);\n\n strictEqual(value, map.get('ohai'));\n });\n\n test(\"Copying a MapWithDefault copies the default value\", function() {\n var map = MapWithDefault.create({\n defaultValue: function(key) {\n return [key];\n }\n });\n\n map.set('ohai', 1);\n map.get('bai');\n\n var map2 = map.copy();\n\n equal(map2.get('ohai'), 1);\n deepEqual(map2.get('bai'), ['bai']);\n\n map2.set('kthx', 3);\n\n deepEqual(map.get('kthx'), ['kthx']);\n equal(map2.get('kthx'), 3);\n\n deepEqual(map2.get('default'), ['default']);\n\n map2.defaultValue = function(key) {\n return ['tom is on', key];\n };\n\n deepEqual(map2.get('drugs'), ['tom is on', 'drugs']);\n });\n });\ndefine(\"ember-metal/tests/mixin/alias_method_test\",\n [],\n function() {\n \"use strict\";\n module('Ember.aliasMethod');\n\n function validateAliasMethod(obj) {\n equal(obj.fooMethod(), 'FOO', 'obj.fooMethod()');\n equal(obj.barMethod(), 'FOO', 'obj.barMethod should be a copy of foo');\n }\n\n test('methods of another name are aliased when the mixin is applied', function() {\n\n var MyMixin = Ember.Mixin.create({\n fooMethod: function() { return 'FOO'; },\n barMethod: Ember.aliasMethod('fooMethod')\n });\n\n var obj = MyMixin.apply({});\n validateAliasMethod(obj);\n });\n\n test('should follow aliasMethods all the way down', function() {\n var MyMixin = Ember.Mixin.create({\n bar: Ember.aliasMethod('foo'), // put first to break ordered iteration\n baz: function() { return 'baz'; },\n foo: Ember.aliasMethod('baz')\n });\n\n var obj = MyMixin.apply({});\n equal(Ember.get(obj, 'bar')(), 'baz', 'should have followed aliasMethods');\n });\n\n test('should alias methods from other dependent mixins', function() {\n\n var BaseMixin = Ember.Mixin.create({\n fooMethod: function() { return 'FOO'; }\n });\n\n var MyMixin = Ember.Mixin.create(BaseMixin, {\n barMethod: Ember.aliasMethod('fooMethod')\n });\n\n var obj = MyMixin.apply({});\n validateAliasMethod(obj);\n });\n\n test('should alias methods from other mixins applied at same time', function() {\n\n var BaseMixin = Ember.Mixin.create({\n fooMethod: function() { return 'FOO'; }\n });\n\n var MyMixin = Ember.Mixin.create({\n barMethod: Ember.aliasMethod('fooMethod')\n });\n\n var obj = Ember.mixin({}, BaseMixin, MyMixin);\n validateAliasMethod(obj);\n });\n\n test('should alias methods from mixins already applied on object', function() {\n\n var BaseMixin = Ember.Mixin.create({\n quxMethod: function() { return 'qux'; }\n });\n\n var MyMixin = Ember.Mixin.create({\n bar: Ember.aliasMethod('foo'),\n barMethod: Ember.aliasMethod('fooMethod')\n });\n\n var obj = {\n fooMethod: function() { return 'FOO'; }\n };\n\n BaseMixin.apply(obj);\n MyMixin.apply(obj);\n\n validateAliasMethod(obj);\n });\n });\ndefine(\"ember-metal/tests/mixin/apply_test\",\n [],\n function() {\n \"use strict\";\n /*globals raises */\n\n module('Ember.Mixin.apply');\n\n function K() {}\n\n test('using apply() should apply properties', function() {\n var MixinA = Ember.Mixin.create({ foo: 'FOO', baz: K });\n var obj = {};\n Ember.mixin(obj, MixinA);\n\n equal(Ember.get(obj, 'foo'), \"FOO\", 'should apply foo');\n equal(Ember.get(obj, 'baz'), K, 'should apply foo');\n });\n\n test('applying anonymous properties', function() {\n var obj = {};\n Ember.mixin(obj, {\n foo: 'FOO',\n baz: K\n });\n\n equal(Ember.get(obj, 'foo'), \"FOO\", 'should apply foo');\n equal(Ember.get(obj, 'baz'), K, 'should apply foo');\n });\n\n test('applying null values', function() {\n expectAssertion(function() {\n Ember.mixin({}, null);\n });\n });\n\n test('applying a property with an undefined value', function() {\n var obj = { tagName: '' };\n Ember.mixin(obj, { tagName: undefined });\n\n strictEqual(Ember.get(obj, 'tagName'), '');\n });\n });\ndefine(\"ember-metal/tests/mixin/computed_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/mixin\",\"ember-metal/computed\",\"ember-metal/properties\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // Ember.K\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var Mixin = __dependency4__.Mixin;\n var computed = __dependency5__.computed;\n var defineProperty = __dependency6__.defineProperty;\n\n module('Mixin Computed Properties');\n\n test('overriding computed properties', function() {\n var MixinA, MixinB, MixinC, MixinD;\n var obj;\n\n MixinA = Mixin.create({\n aProp: computed(function() {\n return 'A';\n })\n });\n\n MixinB = Mixin.create(MixinA, {\n aProp: computed(function() {\n return this._super()+'B';\n })\n });\n\n MixinC = Mixin.create(MixinA, {\n aProp: computed(function() {\n return this._super()+'C';\n })\n });\n\n MixinD = Mixin.create({\n aProp: computed(function() {\n return this._super()+'D';\n })\n });\n\n obj = {};\n MixinB.apply(obj);\n equal(get(obj, 'aProp'), 'AB', \"should expose super for B\");\n\n obj = {};\n MixinC.apply(obj);\n equal(get(obj, 'aProp'), 'AC', \"should expose super for C\");\n\n obj = {};\n\n MixinA.apply(obj);\n MixinD.apply(obj);\n equal(get(obj, 'aProp'), 'AD', \"should define super for D\");\n\n obj = { };\n defineProperty(obj, 'aProp', computed(function(key, value) {\n return 'obj';\n }));\n MixinD.apply(obj);\n equal(get(obj, 'aProp'), \"objD\", \"should preserve original computed property\");\n });\n\n test('calling set on overridden computed properties', function() {\n var SuperMixin, SubMixin;\n var obj;\n\n var superGetOccurred = false,\n superSetOccurred = false;\n\n SuperMixin = Mixin.create({\n aProp: computed(function(key, val) {\n if (arguments.length === 1) {\n superGetOccurred = true;\n } else {\n superSetOccurred = true;\n }\n return true;\n })\n });\n\n SubMixin = Mixin.create(SuperMixin, {\n aProp: computed(function(key, val) {\n return this._super.apply(this, arguments);\n })\n });\n\n obj = {};\n SubMixin.apply(obj);\n\n set(obj, 'aProp', 'set thyself');\n ok(superSetOccurred, 'should pass set to _super');\n\n superSetOccurred = false; // reset the set assertion\n\n obj = {};\n SubMixin.apply(obj);\n\n get(obj, 'aProp');\n ok(superGetOccurred, 'should pass get to _super');\n\n set(obj, 'aProp', 'set thyself');\n ok(superSetOccurred, 'should pass set to _super after getting');\n });\n\n test('setter behavior works properly when overriding computed properties', function() {\n var obj = {};\n\n var MixinA = Mixin.create({\n cpWithSetter2: computed(Ember.K),\n cpWithSetter3: computed(Ember.K),\n cpWithoutSetter: computed(Ember.K)\n });\n\n var cpWasCalled = false;\n\n var MixinB = Mixin.create({\n cpWithSetter2: computed(function(k, v) {\n cpWasCalled = true;\n }),\n\n cpWithSetter3: computed(function(k, v) {\n cpWasCalled = true;\n }),\n\n cpWithoutSetter: computed(function(k) {\n cpWasCalled = true;\n })\n });\n\n MixinA.apply(obj);\n MixinB.apply(obj);\n\n set(obj, 'cpWithSetter2', 'test');\n ok(cpWasCalled, \"The computed property setter was called when defined with two args\");\n cpWasCalled = false;\n\n set(obj, 'cpWithSetter3', 'test');\n ok(cpWasCalled, \"The computed property setter was called when defined with three args\");\n cpWasCalled = false;\n\n set(obj, 'cpWithoutSetter', 'test');\n equal(get(obj, 'cpWithoutSetter'), 'test', \"The default setter was called, the value is correct\");\n ok(!cpWasCalled, \"The default setter was called, not the CP itself\");\n });\n });\ndefine(\"ember-metal/tests/mixin/concatenatedProperties_test\",\n [],\n function() {\n \"use strict\";\n /*globals setup */\n\n module('Ember.Mixin concatenatedProperties');\n\n test('defining concatenated properties should concat future version', function() {\n\n var MixinA = Ember.Mixin.create({\n concatenatedProperties: ['foo'],\n foo: ['a', 'b', 'c']\n });\n\n var MixinB = Ember.Mixin.create({\n foo: ['d', 'e', 'f']\n });\n\n var obj = Ember.mixin({}, MixinA, MixinB);\n deepEqual(Ember.get(obj, 'foo'), ['a', 'b', 'c', 'd', 'e', 'f']);\n });\n\n test('concatenatedProperties should be concatenated', function() {\n\n var MixinA = Ember.Mixin.create({\n concatenatedProperties: ['foo'],\n foo: ['a', 'b', 'c']\n });\n\n var MixinB = Ember.Mixin.create({\n concatenatedProperties: 'bar',\n foo: ['d', 'e', 'f'],\n bar: [1,2,3]\n });\n\n var MixinC = Ember.Mixin.create({\n bar: [4,5,6]\n });\n\n var obj = Ember.mixin({}, MixinA, MixinB, MixinC);\n deepEqual(Ember.get(obj, 'concatenatedProperties'), ['foo', 'bar'], 'get concatenatedProperties');\n deepEqual(Ember.get(obj, 'foo'), ['a', 'b', 'c', 'd', 'e', 'f'], 'get foo');\n deepEqual(Ember.get(obj, 'bar'), [1,2,3,4,5,6], 'get bar');\n });\n\n test('adding a prop that is not an array should make array', function() {\n\n var MixinA = Ember.Mixin.create({\n concatenatedProperties: ['foo'],\n foo: [1,2,3]\n });\n\n var MixinB = Ember.Mixin.create({\n foo: 4\n });\n\n var obj = Ember.mixin({}, MixinA, MixinB);\n deepEqual(Ember.get(obj, 'foo'), [1,2,3,4]);\n });\n\n test('adding a prop that is not an array should make array', function() {\n\n var MixinA = Ember.Mixin.create({\n concatenatedProperties: ['foo'],\n foo: 'bar'\n });\n\n var obj = Ember.mixin({}, MixinA);\n deepEqual(Ember.get(obj, 'foo'), ['bar']);\n });\n\n test('adding a non-concatenable property that already has a defined value should result in an array with both values', function() {\n\n var mixinA = Ember.Mixin.create({\n foo: 1\n });\n\n var mixinB = Ember.Mixin.create({\n concatenatedProperties: ['foo'],\n foo: 2\n });\n\n var obj = Ember.mixin({}, mixinA, mixinB);\n deepEqual(Ember.get(obj, 'foo'), [1, 2]);\n });\n\n test('adding a concatenable property that already has a defined value should result in a concatenated value', function() {\n\n var mixinA = Ember.Mixin.create({\n foobar: 'foo'\n });\n\n var mixinB = Ember.Mixin.create({\n concatenatedProperties: ['foobar'],\n foobar: 'bar'\n });\n\n var obj = Ember.mixin({}, mixinA, mixinB);\n equal(Ember.get(obj, 'foobar'), 'foobar');\n });\n });\ndefine(\"ember-metal/tests/mixin/detect_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/mixin\",\"ember-metal/computed\",\"ember-metal/properties\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // Ember.K\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var Mixin = __dependency4__.Mixin;\n var computed = __dependency5__.computed;\n var defineProperty = __dependency6__.defineProperty;\n\n module('Mixin.detect');\n\n test('detect() finds a directly applied mixin', function() {\n\n var MixinA = Mixin.create();\n var obj = {};\n\n equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()');\n\n MixinA.apply(obj);\n equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()');\n });\n\n test('detect() finds nested mixins', function() {\n var MixinA = Mixin.create({});\n var MixinB = Mixin.create(MixinA);\n var obj = {};\n\n equal(MixinA.detect(obj), false, 'MixinA.detect(obj) before apply()');\n\n MixinB.apply(obj);\n equal(MixinA.detect(obj), true, 'MixinA.detect(obj) after apply()');\n });\n\n test('detect() finds mixins on other mixins', function() {\n var MixinA = Mixin.create({});\n var MixinB = Mixin.create(MixinA);\n equal(MixinA.detect(MixinB), true, 'MixinA is part of MixinB');\n equal(MixinB.detect(MixinA), false, 'MixinB is not part of MixinA');\n });\n\n test('detect handles null values', function() {\n var MixinA = Mixin.create();\n equal(MixinA.detect(null), false);\n });\n });\ndefine(\"ember-metal/tests/mixin/introspection_test\",\n [\"ember-metal/utils\",\"ember-metal/mixin\",\"ember-metal/enumerable_utils\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n // NOTE: A previous iteration differentiated between public and private props\n // as well as methods vs props. We are just keeping these for testing; the\n // current impl doesn't care about the differences as much...\n\n var guidFor = __dependency1__.guidFor;\n var mixin = __dependency2__.mixin;\n var Mixin = __dependency2__.Mixin;\n var EnumerableUtils = __dependency3__[\"default\"];\n\n var PrivateProperty = Mixin.create({\n _foo: '_FOO'\n });\n\n var PublicProperty = Mixin.create({\n foo: 'FOO'\n });\n\n var PrivateMethod = Mixin.create({\n _fooMethod: function() {}\n });\n\n var PublicMethod = Mixin.create({\n fooMethod: function() {}\n });\n\n var BarProperties = Mixin.create({\n _bar: '_BAR',\n bar: 'bar'\n });\n\n var BarMethods = Mixin.create({\n _barMethod: function() {},\n barMethod: function() {}\n });\n\n var Combined = Mixin.create(BarProperties, BarMethods);\n\n var obj ;\n\n module('Basic introspection', {\n setup: function() {\n obj = {};\n mixin(obj, PrivateProperty, PublicProperty, PrivateMethod, PublicMethod, Combined);\n }\n });\n\n test('Ember.mixins()', function() {\n\n function mapGuids(ary) {\n return EnumerableUtils.map(ary, function(x) { return guidFor(x); });\n }\n\n deepEqual(mapGuids(Mixin.mixins(obj)), mapGuids([PrivateProperty, PublicProperty, PrivateMethod, PublicMethod, Combined, BarProperties, BarMethods]), 'should return included mixins');\n });\n });\ndefine(\"ember-metal/tests/mixin/mergedProperties_test\",\n [\"ember-metal/property_get\",\"ember-metal/mixin\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n /*globals setup */\n\n var get = __dependency1__.get;\n var mixin = __dependency2__.mixin;\n var Mixin = __dependency2__.Mixin;\n\n module('Mixin mergedProperties');\n\n test('defining mergedProperties should merge future version', function() {\n\n var MixinA = Mixin.create({\n mergedProperties: ['foo'],\n foo: { a: true, b: true, c: true }\n });\n\n var MixinB = Mixin.create({\n foo: { d: true, e: true, f: true }\n });\n\n var obj = mixin({}, MixinA, MixinB);\n deepEqual(get(obj, 'foo'),\n { a: true, b: true, c: true, d: true, e: true, f: true });\n });\n\n test('defining mergedProperties on future mixin should merged into past', function() {\n\n var MixinA = Mixin.create({\n foo: { a: true, b: true, c: true }\n });\n\n var MixinB = Mixin.create({\n mergedProperties: ['foo'],\n foo: { d: true, e: true, f: true }\n });\n\n var obj = mixin({}, MixinA, MixinB);\n deepEqual(get(obj, 'foo'),\n { a: true, b: true, c: true, d: true, e: true, f: true });\n });\n\n test('defining mergedProperties with null properties should keep properties null', function() {\n\n var MixinA = Mixin.create({\n mergedProperties: ['foo'],\n foo: null\n });\n\n var MixinB = Mixin.create({\n foo: null\n });\n\n var obj = mixin({}, MixinA, MixinB);\n equal(get(obj, 'foo'), null);\n });\n\n test(\"mergedProperties' properties can get overwritten\", function() {\n\n var MixinA = Mixin.create({\n mergedProperties: ['foo'],\n foo: { a: 1 }\n });\n\n var MixinB = Mixin.create({\n foo: { a: 2 }\n });\n\n var obj = mixin({}, MixinA, MixinB);\n deepEqual(get(obj, 'foo'), { a: 2 });\n });\n\n test('mergedProperties should be concatenated', function() {\n\n var MixinA = Mixin.create({\n mergedProperties: ['foo'],\n foo: { a: true, b: true, c: true }\n });\n\n var MixinB = Mixin.create({\n mergedProperties: 'bar',\n foo: { d: true, e: true, f: true },\n bar: { a: true, l: true }\n });\n\n var MixinC = Mixin.create({\n bar: { e: true, x: true }\n });\n\n var obj = mixin({}, MixinA, MixinB, MixinC);\n deepEqual(get(obj, 'mergedProperties'), ['foo', 'bar'], 'get mergedProperties');\n deepEqual(get(obj, 'foo'), { a: true, b: true, c: true, d: true, e: true, f: true }, \"get foo\");\n deepEqual(get(obj, 'bar'), { a: true, l: true, e: true, x: true }, \"get bar\");\n });\n\n test(\"mergedProperties' overwriting methods can call _super\", function() {\n\n expect(4);\n\n var MixinA = Mixin.create({\n mergedProperties: ['foo'],\n foo: {\n meth: function(a) {\n equal(a, \"WOOT\", \"_super successfully called MixinA's `foo.meth` method\");\n return \"WAT\";\n }\n }\n });\n\n var MixinB = Mixin.create({\n foo: {\n meth: function(a) {\n ok(true, \"MixinB's `foo.meth` method called\");\n return this._super.apply(this, arguments);\n }\n }\n });\n\n var MixinC = Mixin.create({\n foo: {\n meth: function(a) {\n ok(true, \"MixinC's `foo.meth` method called\");\n return this._super(a);\n }\n }\n });\n\n var obj = mixin({}, MixinA, MixinB, MixinC);\n equal(obj.foo.meth(\"WOOT\"), \"WAT\");\n });\n });\ndefine(\"ember-metal/tests/mixin/method_test\",\n [\"ember-metal/property_get\",\"ember-metal/platform\",\"ember-metal/mixin\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n /*globals raises */\n\n var get = __dependency1__.get;\n var create = __dependency2__.create;\n var mixin = __dependency3__.mixin;\n var Mixin = __dependency3__.Mixin;\n\n module('Mixin Methods');\n\n test('defining simple methods', function() {\n\n var MixinA, obj, props;\n\n props = {\n publicMethod: function() { return 'publicMethod'; },\n _privateMethod: function() { return 'privateMethod'; }\n };\n\n MixinA = Mixin.create(props);\n obj = {};\n MixinA.apply(obj);\n\n // but should be defined\n equal(props.publicMethod(), 'publicMethod', 'publicMethod is func');\n equal(props._privateMethod(), 'privateMethod', 'privateMethod is func');\n });\n\n test('overriding public methods', function() {\n var MixinA, MixinB, MixinC, MixinD, MixinE, MixinF, obj;\n\n MixinA = Mixin.create({\n publicMethod: function() { return 'A'; }\n });\n\n MixinB = Mixin.create(MixinA, {\n publicMethod: function() { return this._super()+'B'; }\n });\n\n MixinD = Mixin.create(MixinA, {\n publicMethod: function() { return this._super()+'D'; }\n });\n\n MixinF = Mixin.create({\n publicMethod: function() { return this._super()+'F'; }\n });\n\n obj = {};\n MixinB.apply(obj);\n equal(obj.publicMethod(), 'AB', 'should define super for A and B');\n\n obj = {};\n MixinD.apply(obj);\n equal(obj.publicMethod(), 'AD', 'should define super for A and B');\n\n obj = {};\n MixinA.apply(obj);\n MixinF.apply(obj);\n equal(obj.publicMethod(), 'AF', 'should define super for A and F');\n\n obj = { publicMethod: function() { return 'obj'; } };\n MixinF.apply(obj);\n equal(obj.publicMethod(), 'objF', 'should define super for F');\n });\n\n\n test('overriding inherited objects', function() {\n\n var cnt = 0;\n var MixinA = Mixin.create({\n foo: function() { cnt++; }\n });\n\n var MixinB = Mixin.create({\n foo: function() { this._super(); cnt++; }\n });\n\n var objA = {};\n MixinA.apply(objA);\n\n var objB = create(objA);\n MixinB.apply(objB);\n\n cnt = 0;\n objB.foo();\n equal(cnt, 2, 'should invoke both methods');\n\n cnt = 0;\n objA.foo();\n equal(cnt, 1, 'should not screw w/ parent obj');\n });\n\n test('Including the same mixin more than once will only run once', function() {\n var cnt = 0;\n var MixinA = Mixin.create({\n foo: function() { cnt++; }\n });\n\n var MixinB = Mixin.create(MixinA, {\n foo: function() { this._super(); }\n });\n\n var MixinC = Mixin.create(MixinA, {\n foo: function() { this._super(); }\n });\n\n var MixinD = Mixin.create(MixinB, MixinC, MixinA, {\n foo: function() { this._super(); }\n });\n\n var obj = {};\n MixinD.apply(obj);\n MixinA.apply(obj); // try to apply again..\n\n cnt = 0;\n obj.foo();\n\n equal(cnt, 1, 'should invoke MixinA.foo one time');\n });\n\n test('_super from a single mixin with no superclass does not error', function() {\n var MixinA = Mixin.create({\n foo: function() {\n this._super();\n }\n });\n\n var obj = {};\n MixinA.apply(obj);\n\n obj.foo();\n ok(true);\n });\n\n test('_super from a first-of-two mixins with no superclass function does not error', function() {\n // _super was previously calling itself in the second assertion.\n // Use remaining count of calls to ensure it doesn't loop indefinitely.\n var remaining = 3;\n var MixinA = Mixin.create({\n foo: function() {\n if (remaining-- > 0) this._super();\n }\n });\n\n var MixinB = Mixin.create({\n foo: function() { this._super(); }\n });\n\n var obj = {};\n MixinA.apply(obj);\n MixinB.apply(obj);\n\n obj.foo();\n ok(true);\n });\n\n // ..........................................................\n // CONFLICTS\n //\n\n module('Method Conflicts');\n\n\n test('overriding toString', function() {\n var MixinA = Mixin.create({\n toString: function() { return 'FOO'; }\n });\n\n var obj = {};\n MixinA.apply(obj);\n equal(obj.toString(), 'FOO', 'should override toString w/o error');\n\n obj = {};\n mixin(obj, { toString: function() { return 'FOO'; } });\n equal(obj.toString(), 'FOO', 'should override toString w/o error');\n });\n\n // ..........................................................\n // BUGS\n //\n\n module('system/mixin/method_test BUGS');\n\n test('applying several mixins at once with sup already defined causes infinite loop', function() {\n\n var cnt = 0;\n var MixinA = Mixin.create({\n foo: function() { cnt++; }\n });\n\n var MixinB = Mixin.create({\n foo: function() { this._super(); cnt++; }\n });\n\n var MixinC = Mixin.create({\n foo: function() { this._super(); cnt++; }\n });\n\n var obj = {};\n mixin(obj, MixinA); // sup already exists\n mixin(obj, MixinB, MixinC); // must be more than one mixin\n\n cnt = 0;\n obj.foo();\n equal(cnt, 3, 'should invoke all 3 methods');\n });\n });\ndefine(\"ember-metal/tests/mixin/observer_test\",\n [\"ember-metal/tests/props_helper\",\"ember-metal/property_get\",\"ember-metal/platform\",\"ember-metal/mixin\",\"ember-metal/watching\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n /*globals testBoth */\n\n var testBoth = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var create = __dependency3__.create;\n var observer = __dependency4__.observer;\n var mixin = __dependency4__.mixin;\n var Mixin = __dependency4__.Mixin;\n var isWatching = __dependency5__.isWatching;\n\n module('Mixin observer');\n\n testBoth('global observer helper', function(get, set) {\n\n var MyMixin = Mixin.create({\n\n count: 0,\n\n foo: observer('bar', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n\n });\n\n var obj = mixin({}, MyMixin);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj, 'bar', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n });\n\n testBoth('global observer helper takes multiple params', function(get, set) {\n\n var MyMixin = Mixin.create({\n\n count: 0,\n\n foo: observer('bar', 'baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n\n });\n\n var obj = mixin({}, MyMixin);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj, 'bar', \"BAZ\");\n set(obj, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 2, 'should invoke observer after change');\n });\n\n\n testBoth('replacing observer should remove old observer', function(get, set) {\n\n var MyMixin = Mixin.create({\n\n count: 0,\n\n foo: observer('bar', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n\n });\n\n var Mixin2 = Mixin.create({\n foo: observer('baz', function() {\n set(this, 'count', get(this, 'count')+10);\n })\n });\n\n var obj = mixin({}, MyMixin, Mixin2);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj, 'bar', \"BAZ\");\n equal(get(obj, 'count'), 0, 'should not invoke observer after change');\n\n set(obj, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 10, 'should invoke observer after change');\n\n });\n\n testBoth('observing chain with property before', function(get, set) {\n var obj2 = {baz: 'baz'};\n\n var MyMixin = Mixin.create({\n count: 0,\n bar: obj2,\n foo: observer('bar.baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n var obj = mixin({}, MyMixin);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj2, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n });\n\n testBoth('observing chain with property after', function(get, set) {\n var obj2 = {baz: 'baz'};\n\n var MyMixin = Mixin.create({\n count: 0,\n foo: observer('bar.baz', function() {\n set(this, 'count', get(this, 'count')+1);\n }),\n bar: obj2\n });\n\n var obj = mixin({}, MyMixin);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj2, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n });\n\n testBoth('observing chain with property in mixin applied later', function(get, set) {\n var obj2 = {baz: 'baz'};\n\n var MyMixin = Mixin.create({\n\n count: 0,\n foo: observer('bar.baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n var MyMixin2 = Mixin.create({bar: obj2});\n\n var obj = mixin({}, MyMixin);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n MyMixin2.apply(obj);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj2, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n });\n\n testBoth('observing chain with existing property', function(get, set) {\n var obj2 = {baz: 'baz'};\n\n var MyMixin = Mixin.create({\n count: 0,\n foo: observer('bar.baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n var obj = mixin({bar: obj2}, MyMixin);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj2, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n });\n\n testBoth('observing chain with property in mixin before', function(get, set) {\n var obj2 = {baz: 'baz'};\n var MyMixin2 = Mixin.create({bar: obj2});\n\n var MyMixin = Mixin.create({\n count: 0,\n foo: observer('bar.baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n var obj = mixin({}, MyMixin2, MyMixin);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj2, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n });\n\n testBoth('observing chain with property in mixin after', function(get, set) {\n var obj2 = {baz: 'baz'};\n var MyMixin2 = Mixin.create({bar: obj2});\n\n var MyMixin = Mixin.create({\n count: 0,\n foo: observer('bar.baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n var obj = mixin({}, MyMixin, MyMixin2);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj2, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n });\n\n testBoth('observing chain with overriden property', function(get, set) {\n var obj2 = {baz: 'baz'};\n var obj3 = {baz: 'foo'};\n\n var MyMixin2 = Mixin.create({bar: obj3});\n\n var MyMixin = Mixin.create({\n count: 0,\n foo: observer('bar.baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n var obj = mixin({bar: obj2}, MyMixin, MyMixin2);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n equal(isWatching(obj2, 'baz'), false, 'should not be watching baz');\n equal(isWatching(obj3, 'baz'), true, 'should be watching baz');\n\n set(obj2, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 0, 'should not invoke observer after change');\n\n set(obj3, 'baz', \"BEAR\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n });\n });\ndefine(\"ember-metal/tests/mixin/reopen_test\",\n [\"ember-metal/mixin\"],\n function(__dependency1__) {\n \"use strict\";\n var Mixin = __dependency1__.Mixin;\n\n module('Ember.Mixin#reopen');\n\n test('using reopen() to add more properties to a simple', function() {\n var MixinA = Mixin.create({ foo: 'FOO', baz: 'BAZ' });\n MixinA.reopen({ bar: 'BAR', foo: 'FOO2' });\n var obj = {};\n MixinA.apply(obj);\n\n equal(Ember.get(obj, 'foo'), 'FOO2', 'mixin() should override');\n equal(Ember.get(obj, 'baz'), 'BAZ', 'preserve MixinA props');\n equal(Ember.get(obj, 'bar'), 'BAR', 'include MixinB props');\n });\n });\ndefine(\"ember-metal/tests/mixin/required_test\",\n [\"ember-metal/mixin\",\"ember-metal/property_get\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n /*globals setup raises */\n var mixin = __dependency1__.mixin;\n var Mixin = __dependency1__.Mixin;\n var required = __dependency1__.required;\n var get = __dependency2__.get;\n\n var PartialMixin, FinalMixin, obj;\n\n module('Module.required', {\n setup: function() {\n PartialMixin = Mixin.create({\n foo: required(),\n bar: 'BAR'\n });\n\n FinalMixin = Mixin.create({\n foo: 'FOO'\n });\n\n obj = {};\n },\n\n teardown: function() {\n PartialMixin = FinalMixin = obj = null;\n }\n });\n\n test('applying a mixin to meet requirement', function() {\n FinalMixin.apply(obj);\n PartialMixin.apply(obj);\n equal(get(obj, 'foo'), 'FOO', 'should now be defined');\n });\n\n test('combined mixins to meet requirement', function() {\n Mixin.create(PartialMixin, FinalMixin).apply(obj);\n equal(get(obj, 'foo'), 'FOO', 'should now be defined');\n });\n\n test('merged mixin', function() {\n Mixin.create(PartialMixin, { foo: 'FOO' }).apply(obj);\n equal(get(obj, 'foo'), 'FOO', 'should now be defined');\n });\n\n test('define property on source object', function() {\n obj.foo = 'FOO';\n PartialMixin.apply(obj);\n equal(get(obj, 'foo'), 'FOO', 'should now be defined');\n });\n\n test('using apply', function() {\n mixin(obj, PartialMixin, { foo: 'FOO' });\n equal(get(obj, 'foo'), 'FOO', 'should now be defined');\n });\n });\ndefine(\"ember-metal/tests/mixin/without_test\",\n [\"ember-metal/mixin\"],\n function(__dependency1__) {\n \"use strict\";\n var Mixin = __dependency1__.Mixin;\n\n test('without should create a new mixin excluding named properties', function() {\n\n var MixinA = Mixin.create({\n foo: 'FOO',\n bar: 'BAR'\n });\n\n var MixinB = MixinA.without('bar');\n\n var obj = {};\n MixinB.apply(obj);\n\n equal(obj.foo, 'FOO', 'should defined foo');\n equal(obj.bar, undefined, 'should not define bar');\n\n });\n });\ndefine(\"ember-metal/tests/observer_test\",\n [\"ember-metal/core\",\"ember-metal/tests/props_helper\",\"ember-metal/observer\",\"ember-metal/property_events\",\"ember-metal/platform\",\"ember-metal/properties\",\"ember-metal/computed\",\"ember-metal/mixin\",\"ember-metal/run_loop\",\"ember-metal/property_get\",\"ember-metal/property_set\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__) {\n \"use strict\";\n /*globals Global:true */\n\n var Ember = __dependency1__[\"default\"];\n var testBoth = __dependency2__[\"default\"];\n var addObserver = __dependency3__.addObserver;\n var removeObserver = __dependency3__.removeObserver;\n var addBeforeObserver = __dependency3__.addBeforeObserver;\n var _suspendObserver = __dependency3__._suspendObserver;\n var _suspendObservers = __dependency3__._suspendObservers;\n var removeBeforeObserver = __dependency3__.removeBeforeObserver;\n var propertyWillChange = __dependency4__.propertyWillChange;\n var propertyDidChange = __dependency4__.propertyDidChange;var create = __dependency5__.create;\n var defineProperty = __dependency6__.defineProperty;\n var computed = __dependency7__.computed;\n var cacheFor = __dependency7__.cacheFor;\n var Mixin = __dependency8__.Mixin;\n var mixin = __dependency8__.mixin;\n var observer = __dependency8__.observer;\n var beforeObserver = __dependency8__.beforeObserver;\n var immediateObserver = __dependency8__.immediateObserver;\n var run = __dependency9__[\"default\"];\n var beginPropertyChanges = __dependency4__.beginPropertyChanges;\n var endPropertyChanges = __dependency4__.endPropertyChanges;\n var changeProperties = __dependency4__.changeProperties;\n var get = __dependency10__.get;\n var set = __dependency11__.set;\n\n // ..........................................................\n // ADD OBSERVER\n //\n\n module('addObserver');\n\n testBoth('observer should fire when property is modified', function(get,set) {\n\n var obj = {};\n var count = 0;\n\n addObserver(obj, 'foo', function() {\n equal(get(obj, 'foo'), 'bar', 'should invoke AFTER value changed');\n count++;\n });\n\n set(obj, 'foo', 'bar');\n equal(count, 1, 'should have invoked observer');\n });\n\n testBoth('observer should fire when dependent property is modified', function(get, set) {\n var obj = { bar: 'bar' };\n defineProperty(obj, 'foo', computed(function() {\n return get(this,'bar').toUpperCase();\n }).property('bar'));\n\n get(obj, 'foo');\n\n var count = 0;\n addObserver(obj, 'foo', function() {\n equal(get(obj, 'foo'), 'BAZ', 'should have invoked after prop change');\n count++;\n });\n\n set(obj, 'bar', 'baz');\n equal(count, 1, 'should have invoked observer');\n });\n\n testBoth('observer should continue to fire after dependent properties are accessed', function(get, set) {\n var observerCount = 0, obj = {};\n\n defineProperty(obj, 'prop', Ember.computed(function () { return Math.random(); }));\n defineProperty(obj, 'anotherProp', Ember.computed('prop', function () { return get(this, 'prop') + Math.random(); }));\n\n addObserver(obj, 'prop', function () { observerCount++; });\n\n get(obj, 'anotherProp');\n\n for (var i = 0; i < 10; i++) {\n propertyWillChange(obj, 'prop');\n propertyDidChange(obj, 'prop');\n }\n\n equal(observerCount, 10, 'should continue to fire indefinitely');\n });\n\n if (Ember.EXTEND_PROTOTYPES) {\n testBoth('observer added declaratively via brace expansion should fire when property changes', function (get, set) {\n var obj = { };\n var count = 0;\n\n mixin(obj, {\n observeFooAndBar: function () {\n count++;\n }.observes('{foo,bar}')\n });\n\n set(obj, 'foo', 'foo');\n equal(count, 1, 'observer specified via brace expansion invoked on property change');\n\n set(obj, 'bar', 'bar');\n equal(count, 2, 'observer specified via brace expansion invoked on property change');\n\n set(obj, 'baz', 'baz');\n equal(count, 2, 'observer not invoked on unspecified property');\n });\n\n testBoth('observer specified declaratively via brace expansion should fire when dependent property changes', function (get, set) {\n var obj = { baz: 'Initial' };\n var count = 0;\n\n defineProperty(obj, 'foo', computed(function() {\n return get(this,'bar').toLowerCase();\n }).property('bar'));\n\n defineProperty(obj, 'bar', computed(function() {\n return get(this,'baz').toUpperCase();\n }).property('baz'));\n\n mixin(obj, {\n fooAndBarWatcher: function () {\n count++;\n }.observes('{foo,bar}')\n });\n\n get(obj, 'foo');\n set(obj, 'baz', 'Baz');\n // fire once for foo, once for bar\n equal(count, 2, 'observer specified via brace expansion invoked on dependent property change');\n\n set(obj, 'quux', 'Quux');\n equal(count, 2, 'observer not fired on unspecified property');\n });\n }\n\n testBoth('observers watching multiple properties via brace expansion should fire when the properties change', function (get, set) {\n var obj = { };\n var count = 0;\n\n mixin(obj, {\n observeFooAndBar: observer('{foo,bar}', function () {\n count++;\n })\n });\n\n set(obj, 'foo', 'foo');\n equal(count, 1, 'observer specified via brace expansion invoked on property change');\n\n set(obj, 'bar', 'bar');\n equal(count, 2, 'observer specified via brace expansion invoked on property change');\n\n set(obj, 'baz', 'baz');\n equal(count, 2, 'observer not invoked on unspecified property');\n });\n\n testBoth('observers watching multiple properties via brace expansion should fire when dependent properties change', function (get, set) {\n var obj = { baz: 'Initial' };\n var count = 0;\n\n defineProperty(obj, 'foo', computed(function() {\n return get(this,'bar').toLowerCase();\n }).property('bar'));\n\n defineProperty(obj, 'bar', computed(function() {\n return get(this,'baz').toUpperCase();\n }).property('baz'));\n\n mixin(obj, {\n fooAndBarWatcher: observer('{foo,bar}', function () {\n count++;\n })\n });\n\n get(obj, 'foo');\n set(obj, 'baz', 'Baz');\n // fire once for foo, once for bar\n equal(count, 2, 'observer specified via brace expansion invoked on dependent property change');\n\n set(obj, 'quux', 'Quux');\n equal(count, 2, 'observer not fired on unspecified property');\n });\n\n testBoth('nested observers should fire in order', function(get,set) {\n var obj = { foo: 'foo', bar: 'bar' };\n var fooCount = 0, barCount = 0;\n\n addObserver(obj, 'foo' ,function() { fooCount++; });\n addObserver(obj, 'bar', function() {\n set(obj, 'foo', 'BAZ');\n equal(fooCount, 1, 'fooCount should have fired already');\n barCount++;\n });\n\n set(obj, 'bar', 'BIFF');\n equal(barCount, 1, 'barCount should have fired');\n equal(fooCount, 1, 'foo should have fired');\n\n });\n\n testBoth('removing an chain observer on change should not fail', function(get,set) {\n var foo = { bar: 'bar' },\n obj1 = { foo: foo }, obj2 = { foo: foo }, obj3 = { foo: foo }, obj4 = { foo: foo },\n count1=0, count2=0, count3=0, count4=0;\n function observer1() { count1++; }\n function observer2() { count2++; }\n function observer3() {\n count3++;\n removeObserver(obj1, 'foo.bar', observer1);\n removeObserver(obj2, 'foo.bar', observer2);\n removeObserver(obj4, 'foo.bar', observer4);\n }\n function observer4() { count4++; }\n\n addObserver(obj1, 'foo.bar' , observer1);\n addObserver(obj2, 'foo.bar' , observer2);\n addObserver(obj3, 'foo.bar' , observer3);\n addObserver(obj4, 'foo.bar' , observer4);\n\n set(foo, 'bar', 'baz');\n\n equal(count1, 1, 'observer1 fired');\n equal(count2, 1, 'observer2 fired');\n equal(count3, 1, 'observer3 fired');\n equal(count4, 0, 'observer4 did not fire');\n });\n\n testBoth('removing an chain before observer on change should not fail', function(get,set) {\n var foo = { bar: 'bar' },\n obj1 = { foo: foo }, obj2 = { foo: foo }, obj3 = { foo: foo }, obj4 = { foo: foo },\n count1=0, count2=0, count3=0, count4=0;\n function observer1() { count1++; }\n function observer2() { count2++; }\n function observer3() {\n count3++;\n removeBeforeObserver(obj1, 'foo.bar', observer1);\n removeBeforeObserver(obj2, 'foo.bar', observer2);\n removeBeforeObserver(obj4, 'foo.bar', observer4);\n }\n function observer4() { count4++; }\n\n addBeforeObserver(obj1, 'foo.bar' , observer1);\n addBeforeObserver(obj2, 'foo.bar' , observer2);\n addBeforeObserver(obj3, 'foo.bar' , observer3);\n addBeforeObserver(obj4, 'foo.bar' , observer4);\n\n set(foo, 'bar', 'baz');\n\n equal(count1, 1, 'observer1 fired');\n equal(count2, 1, 'observer2 fired');\n equal(count3, 1, 'observer3 fired');\n equal(count4, 0, 'observer4 did not fire');\n });\n\n testBoth('suspending an observer should not fire during callback', function(get,set) {\n var obj = {}, target, otherTarget;\n\n target = {\n values: [],\n method: function() { this.values.push(get(obj, 'foo')); }\n };\n\n otherTarget = {\n values: [],\n method: function() { this.values.push(get(obj, 'foo')); }\n };\n\n addObserver(obj, 'foo', target, target.method);\n addObserver(obj, 'foo', otherTarget, otherTarget.method);\n\n function callback() {\n /*jshint validthis:true */\n equal(this, target);\n\n set(obj, 'foo', '2');\n\n return 'result';\n }\n\n set(obj, 'foo', '1');\n\n equal(_suspendObserver(obj, 'foo', target, target.method, callback), 'result');\n\n set(obj, 'foo', '3');\n\n deepEqual(target.values, ['1', '3'], 'should invoke');\n deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke');\n });\n\n\n testBoth('suspending an observer should not defer change notifications during callback', function(get,set) {\n var obj = {}, target, otherTarget;\n\n target = {\n values: [],\n method: function() { this.values.push(get(obj, 'foo')); }\n };\n\n otherTarget = {\n values: [],\n method: function() { this.values.push(get(obj, 'foo')); }\n };\n\n addObserver(obj, 'foo', target, target.method);\n addObserver(obj, 'foo', otherTarget, otherTarget.method);\n\n function callback() {\n /*jshint validthis:true */\n equal(this, target);\n\n set(obj, 'foo', '2');\n\n return 'result';\n }\n\n set(obj, 'foo', '1');\n\n beginPropertyChanges();\n equal(_suspendObserver(obj, 'foo', target, target.method, callback), 'result');\n endPropertyChanges();\n\n set(obj, 'foo', '3');\n\n deepEqual(target.values, ['1', '3'], 'should invoke');\n deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke');\n });\n\n testBoth('suspending observers should not fire during callback', function(get,set) {\n var obj = {}, target, otherTarget;\n\n target = {\n values: [],\n method: function() { this.values.push(get(obj, 'foo')); }\n };\n\n otherTarget = {\n values: [],\n method: function() { this.values.push(get(obj, 'foo')); }\n };\n\n addObserver(obj, 'foo', target, target.method);\n addObserver(obj, 'foo', otherTarget, otherTarget.method);\n\n function callback() {\n /*jshint validthis:true */\n equal(this, target);\n\n set(obj, 'foo', '2');\n\n return 'result';\n }\n\n set(obj, 'foo', '1');\n\n equal(_suspendObservers(obj, ['foo'], target, target.method, callback), 'result');\n\n set(obj, 'foo', '3');\n\n deepEqual(target.values, ['1', '3'], 'should invoke');\n deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke');\n });\n\n\n testBoth('suspending observers should not defer change notifications during callback', function(get,set) {\n var obj = {}, target, otherTarget;\n\n target = {\n values: [],\n method: function() { this.values.push(get(obj, 'foo')); }\n };\n\n otherTarget = {\n values: [],\n method: function() { this.values.push(get(obj, 'foo')); }\n };\n\n addObserver(obj, 'foo', target, target.method);\n addObserver(obj, 'foo', otherTarget, otherTarget.method);\n\n function callback() {\n /*jshint validthis:true */\n equal(this, target);\n\n set(obj, 'foo', '2');\n\n return 'result';\n }\n\n set(obj, 'foo', '1');\n\n beginPropertyChanges();\n equal(_suspendObservers(obj, ['foo'], target, target.method, callback), 'result');\n endPropertyChanges();\n\n set(obj, 'foo', '3');\n\n deepEqual(target.values, ['1', '3'], 'should invoke');\n deepEqual(otherTarget.values, ['1', '2', '3'], 'should invoke');\n });\n\n testBoth('deferring property change notifications', function(get,set) {\n var obj = { foo: 'foo' };\n var fooCount = 0;\n\n addObserver(obj, 'foo' ,function() { fooCount++; });\n\n beginPropertyChanges(obj);\n set(obj, 'foo', 'BIFF');\n set(obj, 'foo', 'BAZ');\n endPropertyChanges(obj);\n\n equal(fooCount, 1, 'foo should have fired once');\n });\n\n testBoth('deferring property change notifications safely despite exceptions', function(get,set) {\n var obj = { foo: 'foo' };\n var fooCount = 0;\n var exc = new Error(\"Something unexpected happened!\");\n\n expect(2);\n addObserver(obj, 'foo' ,function() { fooCount++; });\n\n try {\n changeProperties(function() {\n set(obj, 'foo', 'BIFF');\n set(obj, 'foo', 'BAZ');\n throw exc;\n });\n } catch(err) {\n if (err !== exc)\n throw err;\n }\n\n equal(fooCount, 1, 'foo should have fired once');\n\n changeProperties(function() {\n set(obj, 'foo', 'BIFF2');\n set(obj, 'foo', 'BAZ2');\n });\n\n equal(fooCount, 2, 'foo should have fired again once');\n });\n\n testBoth('deferring property change notifications will not defer before observers', function(get,set) {\n var obj = { foo: 'foo' };\n var fooCount = 0;\n\n addBeforeObserver(obj, 'foo' ,function() { fooCount++; });\n\n beginPropertyChanges(obj);\n set(obj, 'foo', 'BIFF');\n equal(fooCount, 1, 'should fire before observer immediately');\n set(obj, 'foo', 'BAZ');\n endPropertyChanges(obj);\n\n equal(fooCount, 1, 'should not fire before observer twice');\n });\n\n testBoth('implementing sendEvent on object should invoke when deferring property change notifications ends', function(get, set) {\n var count = 0, events = [];\n var obj = {\n sendEvent: function(eventName) {\n events.push(eventName);\n },\n foo: 'baz'\n };\n\n addObserver(obj, 'foo', function() { count++; });\n\n beginPropertyChanges(obj);\n set(obj, 'foo', 'BAZ');\n\n equal(count, 0, 'should have not invoked observer');\n equal(events.length, 1, 'should have invoked sendEvent for before');\n\n endPropertyChanges(obj);\n\n equal(count, 1, 'should have invoked observer');\n equal(events.length, 2, 'should have invoked sendEvent');\n equal(events[0], 'foo:before');\n equal(events[1], 'foo:change');\n });\n\n testBoth('addObserver should propagate through prototype', function(get,set) {\n var obj = { foo: 'foo', count: 0 }, obj2;\n\n addObserver(obj, 'foo', function() { this.count++; });\n obj2 = create(obj);\n\n set(obj2, 'foo', 'bar');\n\n equal(obj2.count, 1, 'should have invoked observer on inherited');\n equal(obj.count, 0, 'should not have invoked observer on parent');\n\n obj2.count = 0;\n set(obj, 'foo', 'baz');\n equal(obj.count, 1, 'should have invoked observer on parent');\n equal(obj2.count, 0, 'should not have invoked observer on inherited');\n });\n\n testBoth('addObserver should respect targets with methods', function(get,set) {\n var observed = { foo: 'foo' };\n\n var target1 = {\n count: 0,\n\n didChange: function(obj, keyName) {\n var value = get(obj, keyName);\n equal(this, target1, 'should invoke with this');\n equal(obj, observed, 'param1 should be observed object');\n equal(keyName, 'foo', 'param2 should be keyName');\n equal(value, 'BAZ', 'param3 should new value');\n this.count++;\n }\n };\n\n var target2 = {\n count: 0,\n\n didChange: function(obj, keyName) {\n var value = get(obj, keyName);\n equal(this, target2, 'should invoke with this');\n equal(obj, observed, 'param1 should be observed object');\n equal(keyName, 'foo', 'param2 should be keyName');\n equal(value, 'BAZ', 'param3 should new value');\n this.count++;\n }\n };\n\n addObserver(observed, 'foo', target1, 'didChange');\n addObserver(observed, 'foo', target2, target2.didChange);\n\n set(observed, 'foo', 'BAZ');\n equal(target1.count, 1, 'target1 observer should have fired');\n equal(target2.count, 1, 'target2 observer should have fired');\n\n });\n\n testBoth('addObserver should allow multiple objects to observe a property', function(get, set) { var observed = { foo: 'foo' };\n\n var target1 = {\n count: 0,\n\n didChange: function(obj, keyName, value) {\n this.count++;\n }\n };\n\n var target2 = {\n count: 0,\n\n didChange: function(obj, keyName, value) {\n this.count++;\n }\n };\n\n addObserver(observed, 'foo', target1, 'didChange');\n addObserver(observed, 'foo', target2, 'didChange');\n\n set(observed, 'foo', 'BAZ');\n equal(target1.count, 1, 'target1 observer should have fired');\n equal(target2.count, 1, 'target2 observer should have fired');\n });\n\n // ..........................................................\n // REMOVE OBSERVER\n //\n\n module('removeObserver');\n\n testBoth('removing observer should stop firing', function(get,set) {\n\n var obj = {};\n var count = 0;\n function F() { count++; }\n addObserver(obj, 'foo', F);\n\n set(obj, 'foo', 'bar');\n equal(count, 1, 'should have invoked observer');\n\n removeObserver(obj, 'foo', F);\n\n set(obj, 'foo', 'baz');\n equal(count, 1, \"removed observer shouldn't fire\");\n });\n\n testBoth('local observers can be removed', function(get, set) {\n var barObserved = 0;\n\n var MyMixin = Mixin.create({\n foo1: observer('bar', function() {\n barObserved++;\n }),\n\n foo2: observer('bar', function() {\n barObserved++;\n })\n });\n\n var obj = {};\n MyMixin.apply(obj);\n\n set(obj, 'bar', 'HI!');\n equal(barObserved, 2, 'precond - observers should be fired');\n\n removeObserver(obj, 'bar', null, 'foo1');\n\n barObserved = 0;\n set(obj, 'bar', 'HI AGAIN!');\n\n equal(barObserved, 1, 'removed observers should not be called');\n });\n\n testBoth('removeObserver should respect targets with methods', function(get,set) {\n var observed = { foo: 'foo' };\n\n var target1 = {\n count: 0,\n\n didChange: function() {\n this.count++;\n }\n };\n\n var target2 = {\n count: 0,\n\n didChange: function() {\n this.count++;\n }\n };\n\n addObserver(observed, 'foo', target1, 'didChange');\n addObserver(observed, 'foo', target2, target2.didChange);\n\n set(observed, 'foo', 'BAZ');\n equal(target1.count, 1, 'target1 observer should have fired');\n equal(target2.count, 1, 'target2 observer should have fired');\n\n removeObserver(observed, 'foo', target1, 'didChange');\n removeObserver(observed, 'foo', target2, target2.didChange);\n\n target1.count = target2.count = 0;\n set(observed, 'foo', 'BAZ');\n equal(target1.count, 0, 'target1 observer should not fire again');\n equal(target2.count, 0, 'target2 observer should not fire again');\n });\n\n // ..........................................................\n // BEFORE OBSERVER\n //\n\n module('addBeforeObserver');\n\n testBoth('observer should fire before a property is modified', function(get,set) {\n\n var obj = { foo: 'foo' };\n var count = 0;\n\n addBeforeObserver(obj, 'foo', function() {\n equal(get(obj, 'foo'), 'foo', 'should invoke before value changed');\n count++;\n });\n\n set(obj, 'foo', 'bar');\n equal(count, 1, 'should have invoked observer');\n });\n\n testBoth('observer should fire before dependent property is modified', function(get, set) {\n var obj = { bar: 'bar' };\n defineProperty(obj, 'foo', computed(function() {\n return get(this,'bar').toUpperCase();\n }).property('bar'));\n\n get(obj, 'foo');\n\n var count = 0;\n addBeforeObserver(obj, 'foo', function() {\n equal(get(obj, 'foo'), 'BAR', 'should have invoked after prop change');\n count++;\n });\n\n set(obj, 'bar', 'baz');\n equal(count, 1, 'should have invoked observer');\n });\n\n if (Ember.EXTEND_PROTOTYPES) {\n testBoth('before observer added declaratively via brace expansion should fire when property changes', function (get, set) {\n var obj = {};\n var count = 0;\n\n mixin(obj, {\n fooAndBarWatcher: function () {\n count++;\n }.observesBefore('{foo,bar}')\n });\n\n set(obj, 'foo', 'foo');\n equal(count, 1, 'observer specified via brace expansion invoked on property change');\n\n set(obj, 'bar', 'bar');\n equal(count, 2, 'observer specified via brace expansion invoked on property change');\n\n set(obj, 'baz', 'baz');\n equal(count, 2, 'observer not invoked on unspecified property');\n });\n\n testBoth('before observer specified declaratively via brace expansion should fire when dependent property changes', function (get, set) {\n var obj = { baz: 'Initial' };\n var count = 0;\n\n defineProperty(obj, 'foo', computed(function() {\n return get(this,'bar').toLowerCase();\n }).property('bar'));\n\n defineProperty(obj, 'bar', computed(function() {\n return get(this,'baz').toUpperCase();\n }).property('baz'));\n\n mixin(obj, {\n fooAndBarWatcher: function () {\n count++;\n }.observesBefore('{foo,bar}')\n });\n\n get(obj, 'foo');\n set(obj, 'baz', 'Baz');\n // fire once for foo, once for bar\n equal(count, 2, 'observer specified via brace expansion invoked on dependent property change');\n\n set(obj, 'quux', 'Quux');\n equal(count, 2, 'observer not fired on unspecified property');\n });\n }\n\n testBoth('before observer watching multiple properties via brce expansion should fire when properties change', function (get, set) {\n var obj = {};\n var count = 0;\n\n mixin(obj, {\n fooAndBarWatcher: beforeObserver('{foo,bar}', function () {\n count++;\n })\n });\n\n set(obj, 'foo', 'foo');\n equal(count, 1, 'observer specified via brace expansion invoked on property change');\n\n set(obj, 'bar', 'bar');\n equal(count, 2, 'observer specified via brace expansion invoked on property change');\n\n set(obj, 'baz', 'baz');\n equal(count, 2, 'observer not invoked on unspecified property');\n });\n\n testBoth('before observer watching multiple properties via brace expansion should fire when dependent property changes', function (get, set) {\n var obj = { baz: 'Initial' };\n var count = 0;\n\n defineProperty(obj, 'foo', computed(function() {\n return get(this,'bar').toLowerCase();\n }).property('bar'));\n\n defineProperty(obj, 'bar', computed(function() {\n return get(this,'baz').toUpperCase();\n }).property('baz'));\n\n mixin(obj, {\n fooAndBarWatcher: beforeObserver('{foo,bar}', function () {\n count++;\n })\n });\n\n get(obj, 'foo');\n set(obj, 'baz', 'Baz');\n // fire once for foo, once for bar\n equal(count, 2, 'observer specified via brace expansion invoked on dependent property change');\n\n set(obj, 'quux', 'Quux');\n equal(count, 2, 'observer not fired on unspecified property');\n });\n\n testBoth('addBeforeObserver should propagate through prototype', function(get,set) {\n var obj = { foo: 'foo', count: 0 }, obj2;\n\n addBeforeObserver(obj, 'foo', function() { this.count++; });\n obj2 = create(obj);\n\n set(obj2, 'foo', 'bar');\n equal(obj2.count, 1, 'should have invoked observer on inherited');\n equal(obj.count, 0, 'should not have invoked observer on parent');\n\n obj2.count = 0;\n set(obj, 'foo', 'baz');\n equal(obj.count, 1, 'should have invoked oberver on parent');\n equal(obj2.count, 0, 'should not have invoked observer on inherited');\n });\n\n testBoth('addBeforeObserver should respect targets with methods', function(get,set) {\n var observed = { foo: 'foo' };\n\n var target1 = {\n count: 0,\n\n willChange: function(obj, keyName) {\n var value = get(obj, keyName);\n equal(this, target1, 'should invoke with this');\n equal(obj, observed, 'param1 should be observed object');\n equal(keyName, 'foo', 'param2 should be keyName');\n equal(value, 'foo', 'param3 should old value');\n this.count++;\n }\n };\n\n var target2 = {\n count: 0,\n\n willChange: function(obj, keyName) {\n var value = get(obj, keyName);\n equal(this, target2, 'should invoke with this');\n equal(obj, observed, 'param1 should be observed object');\n equal(keyName, 'foo', 'param2 should be keyName');\n equal(value, 'foo', 'param3 should old value');\n this.count++;\n }\n };\n\n addBeforeObserver(observed, 'foo', target1, 'willChange');\n addBeforeObserver(observed, 'foo', target2, target2.willChange);\n\n set(observed, 'foo', 'BAZ');\n equal(target1.count, 1, 'target1 observer should have fired');\n equal(target2.count, 1, 'target2 observer should have fired');\n\n });\n\n // ..........................................................\n // CHAINED OBSERVERS\n //\n\n var obj, count;\n var originalLookup = Ember.lookup, lookup;\n\n module('addObserver - dependentkey with chained properties', {\n setup: function() {\n obj = {\n foo: {\n bar: {\n baz: {\n biff: \"BIFF\"\n }\n }\n }\n };\n\n Ember.lookup = lookup = {\n Global: {\n foo: {\n bar: {\n baz: {\n biff: \"BIFF\"\n }\n }\n }\n }\n };\n\n count = 0;\n },\n\n teardown: function() {\n obj = count = null;\n Ember.lookup = originalLookup;\n }\n });\n\n\n testBoth('depending on a chain with a computed property', function (get, set){\n defineProperty(obj, 'computed', computed(function () {\n return {foo: 'bar'};\n }));\n\n var changed = 0;\n addObserver(obj, 'computed.foo', function () {\n changed++;\n });\n\n equal(undefined, cacheFor(obj, 'computed'), 'addObserver should not compute CP');\n\n set(obj, 'computed.foo', 'baz');\n\n equal(changed, 1, 'should fire observer');\n });\n\n testBoth('depending on a simple chain', function(get, set) {\n\n var val ;\n addObserver(obj, 'foo.bar.baz.biff', function(target, key) {\n val = get(target, key);\n count++;\n });\n\n set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(val, 'BUZZ');\n equal(count, 1);\n\n set(get(obj, 'foo.bar'), 'baz', { biff: 'BLARG' });\n equal(val, 'BLARG');\n equal(count, 2);\n\n set(get(obj, 'foo'), 'bar', { baz: { biff: 'BOOM' } });\n equal(val, 'BOOM');\n equal(count, 3);\n\n set(obj, 'foo', { bar: { baz: { biff: 'BLARG' } } });\n equal(val, 'BLARG');\n equal(count, 4);\n\n set(get(obj, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(val, 'BUZZ');\n equal(count, 5);\n\n var foo = get(obj, 'foo');\n\n set(obj, 'foo', 'BOO');\n equal(val, undefined);\n equal(count, 6);\n\n set(foo.bar.baz, 'biff', \"BOOM\");\n equal(count, 6, 'should be not have invoked observer');\n });\n\n testBoth('depending on a Global chain', function(get, set) {\n var Global = lookup.Global, val;\n\n addObserver(obj, 'Global.foo.bar.baz.biff', function(target, key) {\n val = get(lookup, key);\n count++;\n });\n\n set(get(Global, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(val, 'BUZZ');\n equal(count, 1);\n\n set(get(Global, 'foo.bar'), 'baz', { biff: 'BLARG' });\n equal(val, 'BLARG');\n equal(count, 2);\n\n set(get(Global, 'foo'), 'bar', { baz: { biff: 'BOOM' } });\n equal(val, 'BOOM');\n equal(count, 3);\n\n set(Global, 'foo', { bar: { baz: { biff: 'BLARG' } } });\n equal(val, 'BLARG');\n equal(count, 4);\n\n set(get(Global, 'foo.bar.baz'), 'biff', 'BUZZ');\n equal(val, 'BUZZ');\n equal(count, 5);\n\n var foo = get(obj, 'foo');\n\n set(Global, 'foo', 'BOO');\n equal(val, undefined);\n equal(count, 6);\n\n set(foo.bar.baz, 'biff', \"BOOM\");\n equal(count, 6, 'should be not have invoked observer');\n });\n\n module('removeBeforeObserver');\n\n // ..........................................................\n // SETTING IDENTICAL VALUES\n //\n\n module('props/observer_test - setting identical values');\n\n testBoth('setting simple prop should not trigger', function(get, set) {\n\n var obj = { foo: 'bar' };\n var count = 0;\n\n addObserver(obj, 'foo', function() { count++; });\n\n set(obj, 'foo', 'bar');\n equal(count, 0, 'should not trigger observer');\n\n set(obj, 'foo', 'baz');\n equal(count, 1, 'should trigger observer');\n\n set(obj, 'foo', 'baz');\n equal(count, 1, 'should not trigger observer again');\n });\n\n // The issue here is when a computed property is directly set with a value, then has a\n // dependent key change (which triggers a cache expiration and recomputation), observers will\n // not be fired if the CP setter is called with the last set value.\n testBoth('setting a cached computed property whose value has changed should trigger', function(get, set) {\n var obj = {};\n\n defineProperty(obj, 'foo', computed(function(key, value) {\n if (arguments.length === 2) { return value; }\n return get(this, 'baz');\n }).property('baz'));\n\n var count = 0;\n\n addObserver(obj, 'foo', function() { count++; });\n\n set(obj, 'foo', 'bar');\n equal(count, 1);\n equal(get(obj, 'foo'), 'bar');\n\n set(obj, 'baz', 'qux');\n equal(count, 2);\n equal(get(obj, 'foo'), 'qux');\n\n get(obj, 'foo');\n set(obj, 'foo', 'bar');\n equal(count, 3);\n equal(get(obj, 'foo'), 'bar');\n });\n\n module(\"Ember.immediateObserver\");\n\n testBoth(\"immediate observers should fire synchronously\", function(get, set) {\n var obj = {},\n observerCalled = 0,\n mixin;\n\n // explicitly create a run loop so we do not inadvertently\n // trigger deferred behavior\n run(function() {\n mixin = Mixin.create({\n fooDidChange: immediateObserver('foo', function() {\n observerCalled++;\n equal(get(this, 'foo'), \"barbaz\", \"newly set value is immediately available\");\n })\n });\n\n mixin.apply(obj);\n\n defineProperty(obj, 'foo', computed(function(key, value) {\n if (arguments.length > 1) {\n return value;\n }\n return \"yes hello this is foo\";\n }));\n\n equal(get(obj, 'foo'), \"yes hello this is foo\", \"precond - computed property returns a value\");\n equal(observerCalled, 0, \"observer has not yet been called\");\n\n set(obj, 'foo', 'barbaz');\n\n equal(observerCalled, 1, \"observer was called once\");\n });\n });\n\n\n if (Ember.EXTEND_PROTOTYPES) {\n testBoth('immediate observers added declaratively via brace expansion fire synchronously', function (get, set) {\n var obj = {},\n observerCalled = 0,\n mixin;\n\n // explicitly create a run loop so we do not inadvertently\n // trigger deferred behavior\n run(function() {\n mixin = Mixin.create({\n fooDidChange: function() {\n observerCalled++;\n equal(get(this, 'foo'), \"barbaz\", \"newly set value is immediately available\");\n }.observesImmediately('{foo,bar}')\n });\n\n mixin.apply(obj);\n\n defineProperty(obj, 'foo', computed(function(key, value) {\n if (arguments.length > 1) {\n return value;\n }\n return \"yes hello this is foo\";\n }));\n\n equal(get(obj, 'foo'), \"yes hello this is foo\", \"precond - computed property returns a value\");\n equal(observerCalled, 0, \"observer has not yet been called\");\n\n set(obj, 'foo', 'barbaz');\n\n equal(observerCalled, 1, \"observer was called once\");\n });\n });\n }\n\n testBoth('immediate observers watching multiple properties via brace expansion fire synchronously', function (get, set) {\n var obj = {},\n observerCalled = 0,\n mixin;\n\n // explicitly create a run loop so we do not inadvertently\n // trigger deferred behavior\n run(function() {\n mixin = Mixin.create({\n fooDidChange: immediateObserver('{foo,bar}', function() {\n observerCalled++;\n equal(get(this, 'foo'), \"barbaz\", \"newly set value is immediately available\");\n })\n });\n\n mixin.apply(obj);\n\n defineProperty(obj, 'foo', computed(function(key, value) {\n if (arguments.length > 1) {\n return value;\n }\n return \"yes hello this is foo\";\n }));\n\n equal(get(obj, 'foo'), \"yes hello this is foo\", \"precond - computed property returns a value\");\n equal(observerCalled, 0, \"observer has not yet been called\");\n\n set(obj, 'foo', 'barbaz');\n\n equal(observerCalled, 1, \"observer was called once\");\n });\n });\n\n testBoth(\"immediate observers are for internal properties only\", function(get, set) {\n expectAssertion(function() {\n immediateObserver('foo.bar', Ember.K);\n }, 'Immediate observers must observe internal properties only, not properties on other objects.');\n });\n\n module(\"changeProperties\");\n\n testBoth(\"observers added/removed during changeProperties should do the right thing.\", function(get,set) {\n var obj = {\n foo: 0\n };\n function Observer() {\n this.willChangeCount = 0;\n this.didChangeCount = 0;\n }\n Observer.prototype = {\n add: function () {\n addBeforeObserver(obj, 'foo', this, 'willChange');\n addObserver(obj, 'foo', this, 'didChange');\n },\n remove: function() {\n removeBeforeObserver(obj, 'foo', this, 'willChange');\n removeObserver(obj, 'foo', this, 'didChange');\n },\n willChange: function () {\n this.willChangeCount++;\n },\n didChange: function () {\n this.didChangeCount++;\n }\n };\n var addedBeforeFirstChangeObserver = new Observer();\n var addedAfterFirstChangeObserver = new Observer();\n var addedAfterLastChangeObserver = new Observer();\n var removedBeforeFirstChangeObserver = new Observer();\n var removedBeforeLastChangeObserver = new Observer();\n var removedAfterLastChangeObserver = new Observer();\n removedBeforeFirstChangeObserver.add();\n removedBeforeLastChangeObserver.add();\n removedAfterLastChangeObserver.add();\n changeProperties(function () {\n removedBeforeFirstChangeObserver.remove();\n addedBeforeFirstChangeObserver.add();\n\n set(obj, 'foo', 1);\n\n equal(addedBeforeFirstChangeObserver.willChangeCount, 1, 'addBeforeObserver called before the first change invoked immediately');\n equal(addedBeforeFirstChangeObserver.didChangeCount, 0, 'addObserver called before the first change is deferred');\n\n addedAfterFirstChangeObserver.add();\n removedBeforeLastChangeObserver.remove();\n\n set(obj, 'foo', 2);\n\n equal(addedAfterFirstChangeObserver.willChangeCount, 1, 'addBeforeObserver called after the first change invoked immediately');\n equal(addedAfterFirstChangeObserver.didChangeCount, 0, 'addObserver called after the first change is deferred');\n\n addedAfterLastChangeObserver.add();\n removedAfterLastChangeObserver.remove();\n });\n\n equal(removedBeforeFirstChangeObserver.willChangeCount, 0, 'removeBeforeObserver called before the first change sees none');\n equal(removedBeforeFirstChangeObserver.didChangeCount, 0, 'removeObserver called before the first change sees none');\n equal(addedBeforeFirstChangeObserver.willChangeCount, 1, 'addBeforeObserver called before the first change sees only 1');\n equal(addedBeforeFirstChangeObserver.didChangeCount, 1, 'addObserver called before the first change sees only 1');\n equal(addedAfterFirstChangeObserver.willChangeCount, 1, 'addBeforeObserver called after the first change sees 1');\n equal(addedAfterFirstChangeObserver.didChangeCount, 1, 'addObserver called after the first change sees 1');\n equal(addedAfterLastChangeObserver.willChangeCount, 0, 'addBeforeObserver called after the last change sees none');\n equal(addedAfterLastChangeObserver.didChangeCount, 0, 'addObserver called after the last change sees none');\n equal(removedBeforeLastChangeObserver.willChangeCount, 1, 'removeBeforeObserver called before the last change still sees 1');\n equal(removedBeforeLastChangeObserver.didChangeCount, 1, 'removeObserver called before the last change still sees 1');\n equal(removedAfterLastChangeObserver.willChangeCount, 1, 'removeBeforeObserver called after the last change still sees 1');\n equal(removedAfterLastChangeObserver.didChangeCount, 1, 'removeObserver called after the last change still sees 1');\n });\n });\ndefine(\"ember-metal/tests/performance_test\",\n [\"ember-metal/property_set\",\"ember-metal/property_get\",\"ember-metal/computed\",\"ember-metal/properties\",\"ember-metal/property_events\",\"ember-metal/observer\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var set = __dependency1__.set;\n var get = __dependency2__.get;\n var computed = __dependency3__.computed;\n var defineProperty = __dependency4__.defineProperty;\n var propertyDidChange = __dependency5__.propertyDidChange;\n var beginPropertyChanges = __dependency5__.beginPropertyChanges;\n var endPropertyChanges = __dependency5__.endPropertyChanges;\n var addObserver = __dependency6__.addObserver;\n\n /*\n This test file is designed to capture performance regressions related to\n deferred computation. Things like run loops, computed properties, and bindings\n should run the minimum amount of times to achieve best performance, so any\n bugs that cause them to get evaluated more than necessary should be put here.\n */\n\n module(\"Computed Properties - Number of times evaluated\");\n\n test(\"computed properties that depend on multiple properties should run only once per run loop\", function() {\n var obj = {a: 'a', b: 'b', c: 'c'};\n var cpCount = 0, obsCount = 0;\n\n defineProperty(obj, 'abc', computed(function(key) {\n cpCount++;\n return 'computed '+key;\n }).property('a', 'b', 'c'));\n\n get(obj, 'abc');\n\n cpCount = 0;\n\n addObserver(obj, 'abc', function() {\n obsCount++;\n });\n\n beginPropertyChanges();\n set(obj, 'a', 'aa');\n set(obj, 'b', 'bb');\n set(obj, 'c', 'cc');\n endPropertyChanges();\n\n get(obj, 'abc');\n\n equal(cpCount, 1, \"The computed property is only invoked once\");\n equal(obsCount, 1, \"The observer is only invoked once\");\n });\n\n test(\"computed properties are not executed if they are the last segment of an observer chain pain\", function() {\n var foo = { bar: { baz: { } } };\n\n var count = 0;\n\n defineProperty(foo.bar.baz, 'bam', computed(function() {\n count++;\n }));\n\n addObserver(foo, 'bar.baz.bam', function() {});\n\n propertyDidChange(get(foo, 'bar.baz'), 'bam');\n\n equal(count, 0, \"should not have recomputed property\");\n });\n });\ndefine(\"ember-metal/tests/platform/create_test\",\n [\"ember-metal/platform\"],\n function(__dependency1__) {\n \"use strict\";\n var create = __dependency1__.create;\n\n module(\"Ember.create()\");\n\n test(\"should inherit the properties from the parent object\", function() {\n var obj = { foo: 'FOO' };\n var obj2 = create(obj);\n ok(obj !== obj2, 'should be a new instance');\n equal(obj2.foo, obj.foo, 'should inherit from parent');\n\n obj2.foo = 'BAR';\n equal(obj2.foo, 'BAR', 'should change foo');\n equal(obj.foo, 'FOO', 'modifying obj2 should not modify obj');\n });\n\n // NOTE: jshint may interfere with this test since it defines its own Object.create if missing\n test(\"passing additional property descriptors should define\", function() {\n var obj = { foo: 'FOO', repl: 'obj' };\n var obj2 = create(obj, {\n bar: {\n value: 'BAR'\n },\n\n repl: {\n value: 'obj2'\n }\n });\n\n equal(obj2.bar, 'BAR', 'should have defined');\n equal(obj2.repl, 'obj2', 'should have replaced parent');\n });\n\n test(\"passing additional property descriptors should not pollute parent object\", function() {\n var obj = { foo: 'FOO', repl: 'obj' };\n var obj2 = create(obj, {\n repl: {\n value: 'obj2'\n }\n });\n\n notEqual(obj.repl, obj2.repl, 'should not pollute parent object');\n });\n });\ndefine(\"ember-metal/tests/platform/defineProperty_test\",\n [\"ember-metal/platform\",\"ember-metal/enumerable_utils\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var platform = __dependency1__.platform;\n var EnumerableUtils = __dependency2__[\"default\"];\n\n function isEnumerable(obj, keyName) {\n var keys = [];\n for(var key in obj) {\n if (obj.hasOwnProperty(key)) keys.push(key);\n }\n return EnumerableUtils.indexOf(keys, keyName)>=0;\n }\n\n module(\"platform.defineProperty()\");\n\n test(\"defining a simple property\", function() {\n var obj = {};\n platform.defineProperty(obj, 'foo', {\n enumerable: true,\n writable: true,\n value: 'FOO'\n });\n\n equal(obj.foo, 'FOO', 'should have added property');\n\n obj.foo = \"BAR\";\n equal(obj.foo, 'BAR', 'writable defined property should be writable');\n equal(isEnumerable(obj, 'foo'), true, 'foo should be enumerable');\n });\n\n test('defining a read only property', function() {\n var obj = {};\n platform.defineProperty(obj, 'foo', {\n enumerable: true,\n writable: false,\n value: 'FOO'\n });\n\n equal(obj.foo, 'FOO', 'should have added property');\n\n if (platform.defineProperty.isSimulated) {\n obj.foo = \"BAR\";\n equal(obj.foo, 'BAR', 'simulated defineProperty should silently work');\n } else {\n // cannot set read-only property in strict-mode\n try {\n obj.foo = \"BAR\";\n } catch(e) {\n // do nothing (assertion still happens in finally)\n }finally {\n equal(obj.foo, 'FOO', 'real defined property should not be writable');\n }\n }\n\n });\n\n test('defining a non enumerable property', function() {\n var obj = {};\n platform.defineProperty(obj, 'foo', {\n enumerable: false,\n writable: true,\n value: 'FOO'\n });\n\n if (platform.defineProperty.isSimulated) {\n equal(isEnumerable(obj, 'foo'), true, 'simulated defineProperty will leave properties enumerable');\n } else {\n equal(isEnumerable(obj, 'foo'), false, 'real defineProperty will make property not-enumerable');\n }\n });\n\n // If accessors don't exist, behavior that relies on getters\n // and setters don't do anything\n if (platform.hasPropertyAccessors) {\n test('defining a getter/setter', function() {\n var obj = {}, getCnt = 0, setCnt = 0, v = 'FOO';\n\n var desc = {\n enumerable: true,\n get: function() { getCnt++; return v; },\n set: function(val) { setCnt++; v = val; }\n };\n\n if (platform.hasPropertyAccessors) {\n platform.defineProperty(obj, 'foo', desc);\n equal(obj.foo, 'FOO', 'should return getter');\n equal(getCnt, 1, 'should have invoked getter');\n\n obj.foo = 'BAR';\n equal(obj.foo, 'BAR', 'setter should have worked');\n equal(setCnt, 1, 'should have invoked setter');\n\n }\n\n });\n\n test('defining getter/setter along with writable', function() {\n var obj ={};\n raises(function() {\n platform.defineProperty(obj, 'foo', {\n enumerable: true,\n get: function() {},\n set: function() {},\n writable: true\n });\n }, Error, 'defining writable and get/set should throw exception');\n });\n\n test('defining getter/setter along with value', function() {\n var obj ={};\n raises(function() {\n platform.defineProperty(obj, 'foo', {\n enumerable: true,\n get: function() {},\n set: function() {},\n value: 'FOO'\n });\n }, Error, 'defining value and get/set should throw exception');\n });\n }\n });\ndefine(\"ember-metal/tests/properties_test\",\n [\"ember-metal/core\",\"ember-metal/property_set\",\"ember-metal/property_get\",\"ember-metal/computed\",\"ember-metal/properties\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var set = __dependency2__.set;\n var get = __dependency3__.get;\n var computed = __dependency4__.computed;\n var defineProperty = __dependency5__.defineProperty;\n\n module('Ember.defineProperty');\n\n test('toString', function() {\n\n var obj = {};\n defineProperty(obj, 'toString', undefined, function() { return 'FOO'; });\n equal(obj.toString(), 'FOO', 'should replace toString');\n });\n\n test(\"for data properties, didDefineProperty hook should be called if implemented\", function() {\n expect(2);\n\n var obj = {\n didDefineProperty: function(obj, keyName, value) {\n equal(keyName, 'foo', \"key name should be foo\");\n equal(value, 'bar', \"value should be bar\");\n }\n };\n\n defineProperty(obj, 'foo', undefined, \"bar\");\n });\n\n test(\"for descriptor properties, didDefineProperty hook should be called if implemented\", function() {\n expect(2);\n\n var computedProperty = computed(Ember.K);\n\n var obj = {\n didDefineProperty: function(obj, keyName, value) {\n equal(keyName, 'foo', \"key name should be foo\");\n strictEqual(value, computedProperty, \"value should be passed descriptor\");\n }\n };\n\n defineProperty(obj, 'foo', computedProperty);\n });\n });\ndefine(\"ember-metal/tests/props_helper\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n /*global testBoth:true */\n\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n\n // used by unit tests to test both accessor mode and non-accessor mode\n __exports__[\"default\"] = function(testname, callback) {\n test(testname+' using Ember.get()/Ember.set()', function() {\n callback(get, set);\n });\n\n // test(testname+' using accessors', function() {\n // if (Ember.USES_ACCESSORS) callback(aget, aset);\n // else ok('SKIPPING ACCESSORS');\n // });\n };\n });\ndefine(\"ember-metal/tests/run_loop/add_queue_test\",\n [\"ember-metal/run_loop\",\"ember-metal/array\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var indexOf = __dependency2__.indexOf;\n\n var originalQueues = run.queues, queues;\n\n module('system/run_loop/add_queue_test',{\n setup: function(){\n run.queues = queues = ['blork', 'bleep'];\n },\n teardown: function(){\n run.queues = originalQueues;\n }\n });\n\n test('adds a queue after a specified one', function() {\n run._addQueue('testeroo', 'blork');\n\n equal(indexOf.call(queues, 'testeroo'), 1, \"new queue was added after specified queue\");\n });\n\n test('does not add the queue if it already exists', function(){\n run._addQueue('testeroo', 'blork');\n run._addQueue('testeroo', 'blork');\n\n equal(queues.length, 3, \"queue was not added twice\");\n });\n });\ndefine(\"ember-metal/tests/run_loop/debounce_test\",\n [\"ember-metal/run_loop\"],\n function(__dependency1__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n\n var originalDebounce = run.backburner.debounce;\n var wasCalled = false;\n module('Ember.run.debounce',{\n setup: function() {\n run.backburner.debounce = function() { wasCalled = true; };\n },\n teardown: function() {\n run.backburner.debounce = originalDebounce;\n }\n });\n\n test('Ember.run.debounce uses Backburner.debounce', function() {\n run.debounce(function() {});\n ok(wasCalled, 'Ember.run.debounce used');\n });\n });\ndefine(\"ember-metal/tests/run_loop/join_test\",\n [\"ember-metal/run_loop\"],\n function(__dependency1__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n\n module('system/run_loop/join_test');\n\n test('run.join brings its own run loop if none provided', function() {\n ok(!run.currentRunLoop, 'expects no existing run-loop');\n\n run.join(function() {\n ok(run.currentRunLoop, 'brings its own run loop');\n });\n });\n\n test('run.join joins and existing run-loop, and fires its action queue.', function() {\n var outerRunLoop, wasInvoked;\n\n run(function() {\n outerRunLoop = run.currentRunLoop;\n\n run.join(function() {\n wasInvoked = true;\n deepEqual(outerRunLoop, run.currentRunLoop, 'joined the existing run-loop');\n });\n\n ok(!wasInvoked, 'expected the joined callback not be invoked yet');\n });\n ok(wasInvoked, 'expected the joined callback to have invoked');\n });\n\n test('run.join returns a value if creating a new run-loop', function() {\n var value = 'returned value';\n\n var result = run.join(function() {\n return value;\n });\n\n equal(value, result, 'returns expected output');\n });\n\n test('run.join returns undefined if joining another run-loop', function() {\n var value = 'returned value',\n result;\n\n run(function() {\n var result = run.join(function() {\n return value;\n });\n });\n\n equal(result, undefined, 'returns nothing');\n });\n });\ndefine(\"ember-metal/tests/run_loop/later_test\",\n [\"ember-metal/is_none\",\"ember-metal/run_loop\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var isNone = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n\n var originalSetTimeout = window.setTimeout,\n originalDateValueOf = Date.prototype.valueOf;\n\n var wait = function(callback, maxWaitCount) {\n maxWaitCount = isNone(maxWaitCount) ? 100 : maxWaitCount;\n\n originalSetTimeout(function() {\n if (maxWaitCount > 0 && (run.hasScheduledTimers() || run.currentRunLoop)) {\n wait(callback, maxWaitCount - 1);\n\n return;\n }\n\n callback();\n }, 10);\n };\n\n module('run.later', {\n teardown: function() {\n window.setTimeout = originalSetTimeout;\n Date.prototype.valueOf = originalDateValueOf;\n }\n });\n\n asyncTest('should invoke after specified period of time - function only', function() {\n\n var invoked = false;\n\n run(function() {\n run.later(function() { invoked = true; }, 100);\n });\n\n wait(function() {\n QUnit.start();\n equal(invoked, true, 'should have invoked later item');\n });\n });\n\n asyncTest('should invoke after specified period of time - target/method', function() {\n\n var obj = { invoked: false } ;\n\n run(function() {\n run.later(obj, function() { this.invoked = true; }, 100);\n });\n\n wait(function() {\n QUnit.start();\n equal(obj.invoked, true, 'should have invoked later item');\n });\n });\n\n asyncTest('should invoke after specified period of time - target/method/args', function() {\n\n var obj = { invoked: 0 } ;\n\n run(function() {\n run.later(obj, function(amt) { this.invoked += amt; }, 10, 100);\n });\n\n wait(function() {\n QUnit.start();\n equal(obj.invoked, 10, 'should have invoked later item');\n });\n });\n\n asyncTest('should always invoke within a separate runloop', function() {\n var obj = { invoked: 0 }, firstRunLoop, secondRunLoop;\n\n run(function() {\n firstRunLoop = run.currentRunLoop;\n\n run.later(obj, function(amt) {\n this.invoked += amt;\n secondRunLoop = run.currentRunLoop;\n }, 10, 1);\n\n // Synchronous \"sleep\". This simulates work being done\n // after run.later was called but before the run loop\n // has flushed. In previous versions, this would have\n // caused the run.later callback to have run from\n // within the run loop flush, since by the time the\n // run loop has to flush, it would have considered\n // the timer already expired.\n var pauseUntil = +new Date() + 100;\n while(+new Date() < pauseUntil) { /* do nothing - sleeping */ }\n });\n\n ok(firstRunLoop, \"first run loop captured\");\n ok(!run.currentRunLoop, \"shouldn't be in a run loop after flush\");\n equal(obj.invoked, 0, \"shouldn't have invoked later item yet\");\n\n wait(function() {\n QUnit.start();\n equal(obj.invoked, 10, \"should have invoked later item\");\n ok(secondRunLoop, \"second run loop took place\");\n ok(secondRunLoop !== firstRunLoop, \"two different run loops took place\");\n });\n });\n\n // Our current implementation doesn't allow us to correctly enforce this ordering.\n // We should probably implement a queue to provide this guarantee.\n // See https://github.com/emberjs/ember.js/issues/3526 for more information.\n\n // asyncTest('callback order', function() {\n // var array = [];\n // function fn(val) { array.push(val); }\n\n // run(function() {\n // run.later(this, fn, 4, 5);\n // run.later(this, fn, 1, 1);\n // run.later(this, fn, 5, 10);\n // run.later(this, fn, 2, 3);\n // run.later(this, fn, 3, 3);\n // });\n\n // deepEqual(array, []);\n\n // wait(function() {\n // QUnit.start();\n // deepEqual(array, [1,2,3,4,5], 'callbacks were called in expected order');\n // });\n // });\n\n\n // Out current implementation doesn't allow us to properly enforce what is tested here.\n // We should probably fix it, but it's not technically a bug right now.\n // See https://github.com/emberjs/ember.js/issues/3522 for more information.\n\n // asyncTest('callbacks coalesce into same run loop if expiring at the same time', function() {\n // var array = [];\n // function fn(val) { array.push(run.currentRunLoop); }\n\n // run(function() {\n\n // // Force +new Date to return the same result while scheduling\n // // run.later timers. Otherwise: non-determinism!\n // var now = +new Date();\n // Date.prototype.valueOf = function() { return now; };\n\n // run.later(this, fn, 10);\n // run.later(this, fn, 200);\n // run.later(this, fn, 200);\n\n // Date.prototype.valueOf = originalDateValueOf;\n // });\n\n // deepEqual(array, []);\n\n // wait(function() {\n // QUnit.start();\n // equal(array.length, 3, 'all callbacks called');\n // ok(array[0] !== array[1], 'first two callbacks have different run loops');\n // ok(array[0], 'first runloop present');\n // ok(array[1], 'second runloop present');\n // equal(array[1], array[2], 'last two callbacks got the same run loop');\n // });\n // });\n\n asyncTest('inception calls to run.later should run callbacks in separate run loops', function() {\n\n var runLoop, finished;\n\n run(function() {\n runLoop = run.currentRunLoop;\n ok(runLoop);\n\n run.later(function() {\n ok(run.currentRunLoop && run.currentRunLoop !== runLoop,\n 'first later callback has own run loop');\n runLoop = run.currentRunLoop;\n\n run.later(function() {\n ok(run.currentRunLoop && run.currentRunLoop !== runLoop,\n 'second later callback has own run loop');\n finished = true;\n }, 40);\n }, 40);\n });\n\n wait(function() {\n QUnit.start();\n ok(finished, 'all .later callbacks run');\n });\n });\n\n asyncTest('setTimeout should never run with a negative wait', function() {\n\n // Rationale: The old run loop code was susceptible to an occasional\n // bug where invokeLaterTimers would be scheduled with a setTimeout\n // with a negative wait. Modern browsers normalize this to 0, but\n // older browsers (IE <= 8) break with a negative wait, which\n // happens when an expired timer callback takes a while to run,\n // which is what we simulate here.\n var newSetTimeoutUsed;\n window.setTimeout = function() {\n var wait = arguments[arguments.length - 1];\n newSetTimeoutUsed = true;\n ok(!isNaN(wait) && wait >= 0, 'wait is a non-negative number');\n // In IE8, `setTimeout.apply` is `undefined`.\n var apply = Function.prototype.apply;\n return apply.apply(originalSetTimeout, [this, arguments]);\n };\n\n var count = 0;\n run(function() {\n\n run.later(function() {\n count++;\n\n // This will get run first. Waste some time.\n // This is intended to break invokeLaterTimers code by taking a\n // long enough time that other timers should technically expire. It's\n // fine that they're not called in this run loop; just need to\n // make sure that invokeLaterTimers doesn't end up scheduling\n // a negative setTimeout.\n var pauseUntil = +new Date() + 60;\n while(+new Date() < pauseUntil) { /* do nothing - sleeping */ }\n }, 1);\n\n run.later(function() {\n equal(count, 1, 'callbacks called in order');\n }, 50);\n });\n\n wait(function() {\n window.setTimeout = originalSetTimeout;\n QUnit.start();\n ok(newSetTimeoutUsed, 'stub setTimeout was used');\n });\n });\n });\ndefine(\"ember-metal/tests/run_loop/next_test\",\n [\"ember-metal/run_loop\"],\n function(__dependency1__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n\n module('run.next');\n\n asyncTest('should invoke immediately on next timeout', function() {\n\n var invoked = false;\n\n run(function() {\n run.next(function() { invoked = true; });\n });\n\n equal(invoked, false, 'should not have invoked yet');\n\n\n setTimeout(function() {\n QUnit.start();\n equal(invoked, true, 'should have invoked later item');\n }, 20);\n\n });\n\n asyncTest('callback should be called from within separate loop', function() {\n var firstRunLoop, secondRunLoop;\n run(function() {\n firstRunLoop = run.currentRunLoop;\n run.next(function() { secondRunLoop = run.currentRunLoop; });\n });\n\n setTimeout(function() {\n QUnit.start();\n ok(secondRunLoop, 'callback was called from within run loop');\n ok(firstRunLoop && secondRunLoop !== firstRunLoop, 'two seperate run loops were invoked');\n }, 20);\n });\n\n asyncTest('multiple calls to run.next share coalesce callbacks into same run loop', function() {\n var firstRunLoop, secondRunLoop, thirdRunLoop;\n run(function() {\n firstRunLoop = run.currentRunLoop;\n run.next(function() { secondRunLoop = run.currentRunLoop; });\n run.next(function() { thirdRunLoop = run.currentRunLoop; });\n });\n\n setTimeout(function() {\n QUnit.start();\n ok(secondRunLoop && secondRunLoop === thirdRunLoop, 'callbacks coalesced into same run loop');\n }, 20);\n });\n });\ndefine(\"ember-metal/tests/run_loop/once_test\",\n [\"ember-metal/run_loop\"],\n function(__dependency1__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n\n module('system/run_loop/once_test');\n\n test('calling invokeOnce more than once invokes only once', function() {\n\n var count = 0;\n run(function() {\n var F = function() { count++; };\n run.once(F);\n run.once(F);\n run.once(F);\n });\n\n equal(count, 1, 'should have invoked once');\n });\n\n test('should differentiate based on target', function() {\n\n var A = { count: 0 }, B = { count: 0 };\n run(function() {\n var F = function() { this.count++; };\n run.once(A, F);\n run.once(B, F);\n run.once(A, F);\n run.once(B, F);\n });\n\n equal(A.count, 1, 'should have invoked once on A');\n equal(B.count, 1, 'should have invoked once on B');\n });\n\n\n test('should ignore other arguments - replacing previous ones', function() {\n\n var A = { count: 0 }, B = { count: 0 };\n run(function() {\n var F = function(amt) { this.count += amt; };\n run.once(A, F, 10);\n run.once(B, F, 20);\n run.once(A, F, 30);\n run.once(B, F, 40);\n });\n\n equal(A.count, 30, 'should have invoked once on A');\n equal(B.count, 40, 'should have invoked once on B');\n });\n\n test('should be inside of a runloop when running', function() {\n\n run(function() {\n run.once(function() {\n ok(!!run.currentRunLoop, 'should have a runloop');\n });\n });\n });\n });\ndefine(\"ember-metal/tests/run_loop/onerror_test\",\n [\"ember-metal\",\"ember-metal/run_loop\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n\n module('system/run_loop/onerror_test');\n\n test('With Ember.onerror undefined, errors in Ember.run are thrown', function () {\n var thrown = new Error('Boom!'),\n caught;\n\n try {\n run(function() { throw thrown; });\n } catch (error) {\n caught = error;\n }\n\n deepEqual(caught, thrown);\n });\n\n test('With Ember.onerror set, errors in Ember.run are caught', function () {\n var thrown = new Error('Boom!'),\n caught;\n\n Ember.onerror = function(error) { caught = error; };\n\n run(function() { throw thrown; });\n\n deepEqual(caught, thrown);\n\n Ember.onerror = undefined;\n });\n });\ndefine(\"ember-metal/tests/run_loop/run_bind_test\",\n [\"ember-metal/run_loop\"],\n function(__dependency1__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n\n module('system/run_loop/run_bind_test');\n\n test('Ember.run.bind builds a run-loop wrapped callback handler', function() {\n expect(3);\n\n var obj = {\n value: 0,\n increment: function(increment) {\n ok(run.currentRunLoop, 'expected a run-loop');\n return this.value += increment;\n }\n };\n\n var proxiedFunction = run.bind(obj, obj.increment, 1);\n equal(proxiedFunction(), 1);\n equal(obj.value, 1);\n });\n\n test('Ember.run.bind keeps the async callback arguments', function() {\n\n var asyncCallback = function(increment, increment2, increment3) {\n ok(run.currentRunLoop, 'expected a run-loop');\n equal(increment, 1);\n equal(increment2, 2);\n equal(increment3, 3);\n };\n\n var asyncFunction = function(fn) {\n fn(2, 3);\n };\n\n asyncFunction(run.bind(asyncCallback, asyncCallback, 1));\n });\n });\ndefine(\"ember-metal/tests/run_loop/run_test\",\n [\"ember-metal/run_loop\"],\n function(__dependency1__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n\n module('system/run_loop/run_test');\n\n test('Ember.run invokes passed function, returning value', function() {\n var obj = {\n foo: function() { return [this.bar, 'FOO']; },\n bar: 'BAR',\n checkArgs: function(arg1, arg2) { return [ arg1, this.bar, arg2 ]; }\n };\n\n equal(run(function() { return 'FOO'; }), 'FOO', 'pass function only');\n deepEqual(run(obj, obj.foo), ['BAR', 'FOO'], 'pass obj and obj.method');\n deepEqual(run(obj, 'foo'), ['BAR', 'FOO'], 'pass obj and \"method\"');\n deepEqual(run(obj, obj.checkArgs, 'hello', 'world'), ['hello', 'BAR', 'world'], 'pass obj, obj.method, and extra arguments');\n });\n });\ndefine(\"ember-metal/tests/run_loop/schedule_test\",\n [\"ember-metal/run_loop\"],\n function(__dependency1__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n\n module('system/run_loop/schedule_test');\n\n test('scheduling item in queue should defer until finished', function() {\n var cnt = 0;\n\n run(function() {\n run.schedule('actions', function() { cnt++; });\n run.schedule('actions', function() { cnt++; });\n equal(cnt, 0, 'should not run action yet') ;\n });\n\n equal(cnt, 2, 'should flush actions now');\n\n });\n\n test('nested runs should queue each phase independently', function() {\n var cnt = 0;\n\n run(function() {\n run.schedule('actions', function() { cnt++; });\n equal(cnt, 0, 'should not run action yet') ;\n\n run(function() {\n run.schedule('actions', function() { cnt++; });\n });\n equal(cnt, 1, 'should not run action yet') ;\n\n });\n\n equal(cnt, 2, 'should flush actions now');\n\n });\n\n test('prior queues should be flushed before moving on to next queue', function() {\n var order = [];\n\n run(function() {\n var runLoop = run.currentRunLoop;\n ok(runLoop, 'run loop present');\n\n run.schedule('sync', function() {\n order.push('sync');\n equal(runLoop, run.currentRunLoop, 'same run loop used');\n });\n run.schedule('actions', function() {\n order.push('actions');\n equal(runLoop, run.currentRunLoop, 'same run loop used');\n\n run.schedule('actions', function() {\n order.push('actions');\n equal(runLoop, run.currentRunLoop, 'same run loop used');\n });\n\n run.schedule('sync', function() {\n order.push('sync');\n equal(runLoop, run.currentRunLoop, 'same run loop used');\n });\n });\n run.schedule('destroy', function() {\n order.push('destroy');\n equal(runLoop, run.currentRunLoop, 'same run loop used');\n });\n });\n\n deepEqual(order, ['sync', 'actions', 'sync', 'actions', 'destroy']);\n });\n\n test('makes sure it does not trigger an autorun during testing', function() {\n expectAssertion(function() {\n run.schedule('actions', function() {});\n }, /wrap any code with asynchronous side-effects in an run/);\n\n // make sure not just the first violation is asserted.\n expectAssertion(function() {\n run.schedule('actions', function() {});\n }, /wrap any code with asynchronous side-effects in an run/);\n });\n });\ndefine(\"ember-metal/tests/run_loop/sync_test\",\n [\"ember-metal/run_loop\"],\n function(__dependency1__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n\n module('system/run_loop/sync_test');\n\n test('sync() will immediately flush the sync queue only', function() {\n var cnt = 0;\n\n run(function() {\n\n function cntup() { cnt++; }\n\n function syncfunc() {\n if (++cnt<5) run.schedule('sync', syncfunc);\n run.schedule('actions', cntup);\n }\n\n syncfunc();\n\n equal(cnt, 1, 'should not run action yet') ;\n run.sync();\n\n equal(cnt, 5, 'should have run sync queue continuously');\n });\n\n equal(cnt, 10, 'should flush actions now too');\n\n });\n\n test('calling sync() outside a run loop does not cause an error', function() {\n expect(0);\n\n run.sync();\n });\n });\ndefine(\"ember-metal/tests/run_loop/unwind_test\",\n [\"ember-metal/run_loop\",\"ember-metal/error\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var EmberError = __dependency2__[\"default\"];\n\n module('system/run_loop/unwind_test');\n\n test('RunLoop unwinds despite unhandled exception', function() {\n var initialRunLoop = run.currentRunLoop;\n\n raises(function() {\n run(function() {\n run.schedule('actions', function() { throw new EmberError(\"boom!\"); });\n });\n }, Error, \"boom!\");\n\n // The real danger at this point is that calls to autorun will stick\n // tasks into the already-dead runloop, which will never get\n // flushed. I can't easily demonstrate this in a unit test because\n // autorun explicitly doesn't work in test mode. - ef4\n equal(run.currentRunLoop, initialRunLoop, \"Previous run loop should be cleaned up despite exception\");\n\n // Prevent a failure in this test from breaking subsequent tests.\n run.currentRunLoop = initialRunLoop;\n\n });\n\n test('run unwinds despite unhandled exception', function() {\n var initialRunLoop = run.currentRunLoop;\n\n raises(function() {\n run(function() {\n throw new EmberError(\"boom!\");\n });\n }, EmberError, \"boom!\");\n\n equal(run.currentRunLoop, initialRunLoop, \"Previous run loop should be cleaned up despite exception\");\n\n // Prevent a failure in this test from breaking subsequent tests.\n run.currentRunLoop = initialRunLoop;\n\n });\n });\ndefine(\"ember-metal/tests/utils/can_invoke_test\",\n [\"ember-metal/utils\"],\n function(__dependency1__) {\n \"use strict\";\n var canInvoke = __dependency1__.canInvoke;\n\n var obj;\n\n module(\"Ember.canInvoke\", {\n setup: function() {\n obj = {\n foobar: \"foobar\",\n aMethodThatExists: function() {}\n };\n },\n\n teardown: function() {\n obj = undefined;\n }\n });\n\n test(\"should return false if the object doesn't exist\", function() {\n equal(canInvoke(undefined, 'aMethodThatDoesNotExist'), false);\n });\n\n test(\"should return true if the method exists on the object\", function() {\n equal(canInvoke(obj, 'aMethodThatExists'), true);\n });\n\n test(\"should return false if the method doesn't exist on the object\", function() {\n equal(canInvoke(obj, 'aMethodThatDoesNotExist'), false);\n });\n\n test(\"should return false if the property exists on the object but is a non-function\", function() {\n equal(canInvoke(obj, 'foobar'), false);\n });\n });\ndefine(\"ember-metal/tests/utils/generate_guid_test\",\n [\"ember-metal/utils\"],\n function(__dependency1__) {\n \"use strict\";\n var generateGuid = __dependency1__.generateGuid;\n\n module(\"Ember.generateGuid\");\n\n test(\"Prefix\", function() {\n var a = {};\n\n ok( generateGuid(a, 'tyrell').indexOf('tyrell') > -1, \"guid can be prefixed\" );\n });\n });\ndefine(\"ember-metal/tests/utils/guidFor_test\",\n [\"ember-metal/utils\",\"ember-metal/watching\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var guidFor = __dependency1__.guidFor;\n var generateGuid = __dependency1__.generateGuid;\n var rewatch = __dependency2__.rewatch;\n\n module(\"guidFor\");\n\n var sameGuid = function(a, b, message) {\n equal( guidFor(a), guidFor(b), message );\n };\n\n var diffGuid = function(a, b, message) {\n ok( guidFor(a) !== guidFor(b), message);\n };\n\n var nanGuid = function(obj) {\n var type = typeof obj;\n ok( isNaN(parseInt(guidFor(obj), 0)), \"guids for \" + type + \"don't parse to numbers\");\n };\n\n test(\"Object\", function() {\n var a = {}, b = {};\n\n sameGuid( a, a, \"same object always yields same guid\" );\n diffGuid( a, b, \"different objects yield different guids\" );\n nanGuid( a );\n });\n\n test(\"Object with prototype\", function() {\n var Class = function() { };\n\n guidFor(Class.prototype);\n\n var a = new Class();\n var b = new Class();\n\n sameGuid( a, b , \"without calling rewatch, objects copy the guid from their prototype\");\n\n rewatch(a);\n rewatch(b);\n\n diffGuid( a, b, \"after calling rewatch, objects don't share guids\" );\n });\n\n test(\"strings\", function() {\n var a = \"string A\", aprime = \"string A\", b = \"String B\";\n\n sameGuid( a, a, \"same string always yields same guid\" );\n sameGuid( a, aprime, \"identical strings always yield the same guid\" );\n diffGuid( a, b, \"different strings yield different guids\" );\n nanGuid( a );\n });\n\n test(\"numbers\", function() {\n var a = 23, aprime = 23, b = 34;\n\n sameGuid( a, a, \"same numbers always yields same guid\" );\n sameGuid( a, aprime, \"identical numbers always yield the same guid\" );\n diffGuid( a, b, \"different numbers yield different guids\" );\n nanGuid( a );\n });\n\n test(\"numbers\", function() {\n var a = true, aprime = true, b = false;\n\n sameGuid( a, a, \"same booleans always yields same guid\" );\n sameGuid( a, aprime, \"identical booleans always yield the same guid\" );\n diffGuid( a, b, \"different boolean yield different guids\" );\n nanGuid( a );\n nanGuid( b );\n });\n\n test(\"null and undefined\", function() {\n var a = null, aprime = null, b;\n\n sameGuid( a, a, \"null always returns the same guid\" );\n sameGuid( b, b, \"undefined always returns the same guid\" );\n sameGuid( a, aprime, \"different nulls return the same guid\" );\n diffGuid( a, b, \"null and undefined return different guids\" );\n nanGuid( a );\n nanGuid( b );\n });\n\n test(\"arrays\", function() {\n var a = [\"a\", \"b\", \"c\"], aprime = [\"a\", \"b\", \"c\"], b = [\"1\", \"2\", \"3\"];\n\n sameGuid( a, a, \"same instance always yields same guid\" );\n diffGuid( a, aprime, \"identical arrays always yield the same guid\" );\n diffGuid( a, b, \"different arrays yield different guids\" );\n nanGuid( a );\n });\n });\ndefine(\"ember-metal/tests/utils/is_array_test\",\n [\"ember-metal/utils\"],\n function(__dependency1__) {\n \"use strict\";\n var isArray = __dependency1__.isArray;\n module(\"Ember Type Checking\");\n\n var global = this;\n\n test(\"Ember.isArray\" ,function() {\n var numarray = [1,2,3],\n number = 23,\n strarray = [\"Hello\", \"Hi\"],\n string = \"Hello\",\n object = {},\n length = {length: 12},\n fn = function() {};\n\n equal( isArray(numarray), true, \"[1,2,3]\" );\n equal( isArray(number), false, \"23\" );\n equal( isArray(strarray), true, '[\"Hello\", \"Hi\"]' );\n equal( isArray(string), false, '\"Hello\"' );\n equal( isArray(object), false, \"{}\" );\n equal( isArray(length), true, \"{length: 12}\" );\n equal( isArray(global), false, \"global\" );\n equal( isArray(fn), false, \"function() {}\" );\n });\n });\ndefine(\"ember-metal/tests/utils/meta_test\",\n [\"ember-metal/core\",\"ember-metal/platform\",\"ember-metal/utils\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n /*global jQuery*/\n var Ember = __dependency1__[\"default\"];\n var create = __dependency2__.create;\n var platform = __dependency2__.platform;\n var getMeta = __dependency3__.getMeta;\n var setMeta = __dependency3__.setMeta;\n var meta = __dependency3__.meta;\n var metaPath = __dependency3__.metaPath;\n\n module(\"Ember.meta\");\n\n test(\"should return the same hash for an object\", function() {\n var obj = {};\n\n meta(obj).foo = \"bar\";\n\n equal(meta(obj).foo, \"bar\", \"returns same hash with multiple calls to Ember.meta()\");\n });\n\n module(\"Ember.metaPath\");\n\n test(\"should not create nested objects if writable is false\", function() {\n var obj = {};\n\n ok(!meta(obj).foo, \"precond - foo property on meta does not yet exist\");\n expectDeprecation(function(){\n equal(metaPath(obj, ['foo', 'bar', 'baz'], false), undefined, \"should return undefined when writable is false and doesn't already exist\");\n });\n equal(meta(obj).foo, undefined, \"foo property is not created\");\n });\n\n test(\"should create nested objects if writable is true\", function() {\n var obj = {};\n\n ok(!meta(obj).foo, \"precond - foo property on meta does not yet exist\");\n\n expectDeprecation(function(){\n equal(typeof metaPath(obj, ['foo', 'bar', 'baz'], true), \"object\", \"should return hash when writable is true and doesn't already exist\");\n });\n ok(meta(obj).foo.bar.baz['bat'] = true, \"can set a property on the newly created hash\");\n });\n\n test(\"getMeta and setMeta\", function() {\n var obj = {};\n\n ok(!getMeta(obj, 'foo'), \"precond - foo property on meta does not yet exist\");\n setMeta(obj, 'foo', \"bar\");\n equal(getMeta(obj, 'foo'), \"bar\", \"foo property on meta now exists\");\n });\n\n module(\"Ember.meta enumerable\");\n // Tests fix for https://github.com/emberjs/ember.js/issues/344\n // This is primarily for older browsers such as IE8\n if (platform.defineProperty.isSimulated) {\n if (Ember.imports.jQuery) {\n test(\"meta is not jQuery.isPlainObject\", function () {\n var proto, obj;\n proto = {foo: 'bar'};\n equal(jQuery.isPlainObject(meta(proto)), false, 'meta should not be isPlainObject when meta property cannot be marked as enumerable: false');\n obj = create(proto);\n equal(jQuery.isPlainObject(meta(obj)), false, 'meta should not be isPlainObject when meta property cannot be marked as enumerable: false');\n });\n }\n } else {\n test(\"meta is not enumerable\", function () {\n var proto, obj, props, prop;\n proto = {foo: 'bar'};\n meta(proto);\n obj = create(proto);\n meta(obj);\n obj.bar = 'baz';\n props = [];\n for (prop in obj) {\n props.push(prop);\n }\n deepEqual(props.sort(), ['bar', 'foo']);\n if (typeof JSON !== 'undefined' && 'stringify' in JSON) {\n try {\n JSON.stringify(obj);\n } catch (e) {\n ok(false, 'meta should not fail JSON.stringify');\n }\n }\n });\n }\n });\ndefine(\"ember-metal/tests/utils/try_catch_finally_test\",\n [\"ember-metal/utils\"],\n function(__dependency1__) {\n \"use strict\";\n var tryCatchFinally = __dependency1__.tryCatchFinally;\n\n var tryCount, catchCount, finalizeCount, tryable, catchable, finalizer, error,\n tryableResult, catchableResult, finalizerResult;\n\n module(\"Ember.tryFinally\", {\n setup: function() {\n error = new Error('Test Error');\n tryCount = 0;\n finalizeCount = 0;\n catchCount = 0;\n tryableResult = 'tryable return value';\n catchableResult = 'catchable return value';\n finalizerResult = undefined;\n\n tryable = function() { tryCount++; return tryableResult; };\n catchable = function() { catchCount++; return catchableResult; };\n finalizer = function() { finalizeCount++; return finalizerResult; };\n },\n\n teardown: function() {\n tryCount = catchCount = finalizeCount = tryable = catchable = finalizer =\n finalizeCount = tryableResult = null;\n }\n });\n\n function callTryCatchFinallyWithError() {\n var errorWasThrown;\n try {\n tryCatchFinally(tryable, catchable, finalizer);\n } catch(e) {\n errorWasThrown = true;\n equal(e, error, 'correct error was thrown');\n }\n\n equal(errorWasThrown, true, 'error was thrown');\n }\n\n test(\"no failure\", function() {\n equal(tryCatchFinally(tryable, catchable, finalizer), tryableResult, 'correct return value');\n\n equal(tryCount, 1, 'tryable was called once');\n equal(catchCount, 0, 'catchable was never called');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"no failure, return from finally\", function() {\n finalizerResult = 'finalizer return value';\n\n equal(tryCatchFinally(tryable, catchable, finalizer), finalizerResult, 'correct return value');\n\n equal(tryCount, 1, 'tryable was called once');\n equal(catchCount, 0, 'catchable was never called');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"try failed\", function() {\n tryable = function() { tryCount++; throw error; };\n\n var result = tryCatchFinally(tryable, catchable, finalizer);\n\n equal(result, catchableResult, 'correct return value');\n\n equal(tryCount, 1, 'tryable was called once');\n equal(catchCount, 1, 'catchable was called once');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"catch failed\", function() {\n catchable = function() { catchCount++; throw error; };\n\n tryCatchFinally(tryable, catchable, finalizer);\n\n equal(tryCount, 1, 'tryable was called once');\n equal(catchCount, 0, 'catchable was called once');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"try and catch failed\", function() {\n tryable = function() { tryCount++; throw error; };\n catchable = function() { catchCount++; throw error; };\n\n callTryCatchFinallyWithError();\n\n equal(tryCount, 1, 'tryable was called once');\n equal(catchCount, 1, 'catchable was called once');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"finally failed\", function() {\n finalizer = function() { finalizeCount++; throw error; };\n\n callTryCatchFinallyWithError();\n\n equal(tryCount, 1, 'tryable was called once');\n equal(catchCount, 0, 'catchable was never called');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"finally and try failed\", function() {\n tryable = function() { tryCount++; throw error; };\n finalizer = function() { finalizeCount++; throw error; };\n\n callTryCatchFinallyWithError();\n\n equal(tryCount, 1, 'tryable was called once');\n equal(catchCount, 1, 'catchable was called once');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"finally, catch and try failed\", function() {\n tryable = function() { tryCount++; throw error; };\n catchable = function() { catchCount++; throw error; };\n finalizer = function() { finalizeCount++; throw error; };\n\n callTryCatchFinallyWithError();\n\n equal(tryCount, 1, 'tryable was called once');\n equal(catchCount, 1, 'catchable was called once');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n });\ndefine(\"ember-metal/tests/utils/try_finally_test\",\n [\"ember-metal/utils\"],\n function(__dependency1__) {\n \"use strict\";\n var tryFinally = __dependency1__.tryFinally;\n\n var tryCount, finalizeCount, tryable, finalizer, error, tryableResult, finalizerResult;\n\n module(\"Ember.tryFinally\", {\n setup: function() {\n error = new Error('Test Error');\n tryCount = 0;\n finalizeCount = 0;\n tryableResult = 'tryable return value';\n finalizerResult = undefined;\n\n tryable = function() { tryCount++; return tryableResult; };\n finalizer = function() { finalizeCount++; return finalizerResult; };\n },\n\n teardown: function() {\n tryCount = finalizeCount = tryable = finalizer = finalizeCount = tryableResult = null;\n }\n });\n\n function callTryFinallyWithError() {\n var errorWasThrown;\n try {\n tryFinally(tryable, finalizer);\n } catch(e) {\n errorWasThrown = true;\n equal(e, error, 'correct error was thrown');\n }\n\n equal(errorWasThrown, true, 'error was thrown');\n }\n\n test(\"no failure\", function() {\n equal(tryFinally(tryable, finalizer), tryableResult, 'correct return value');\n\n equal(tryCount, 1, 'tryable was called once');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"no failure, return from finally\", function() {\n finalizerResult = 'finalizer return value';\n\n equal(tryFinally(tryable, finalizer), finalizerResult, 'crrect return value');\n\n equal(tryCount, 1, 'tryable was called once');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"try failed\", function() {\n tryable = function() { tryCount++; throw error; };\n\n callTryFinallyWithError();\n\n equal(tryCount, 1, 'tryable was called once');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"finally failed\", function() {\n finalizer = function() { finalizeCount++; throw error; };\n\n callTryFinallyWithError();\n\n equal(tryCount, 1, 'tryable was called once');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n\n test(\"finally and try failed\", function() {\n tryable = function() { tryCount++; throw error; };\n finalizer = function() { finalizeCount++; throw error; };\n\n callTryFinallyWithError();\n\n equal(tryCount, 1, 'tryable was called once');\n equal(finalizeCount, 1, 'finalize was called once');\n });\n });\ndefine(\"ember-metal/tests/utils/try_invoke_test\",\n [\"ember-metal/utils\"],\n function(__dependency1__) {\n \"use strict\";\n var tryInvoke = __dependency1__.tryInvoke;\n\n var obj;\n\n module(\"Ember.tryInvoke\", {\n setup: function() {\n obj = {\n aMethodThatExists: function() { return true; },\n aMethodThatTakesArguments: function(arg1, arg2) { return arg1 === arg2; }\n };\n },\n\n teardown: function() {\n obj = undefined;\n }\n });\n\n test(\"should return undefined when the object doesn't exist\", function() {\n equal(tryInvoke(undefined, 'aMethodThatDoesNotExist'), undefined);\n });\n\n test(\"should return undefined when asked to perform a method that doesn't exist on the object\", function() {\n equal(tryInvoke(obj, 'aMethodThatDoesNotExist'), undefined);\n });\n\n test(\"should return what the method returns when asked to perform a method that exists on the object\", function() {\n equal(tryInvoke(obj, 'aMethodThatExists'), true);\n });\n\n test(\"should return what the method returns when asked to perform a method that takes arguments and exists on the object\", function() {\n equal(tryInvoke(obj, 'aMethodThatTakesArguments', [true, true]), true);\n });\n });\ndefine(\"ember-metal/tests/utils/type_of_test\",\n [\"ember-metal/utils\"],\n function(__dependency1__) {\n \"use strict\";\n var typeOf = __dependency1__.typeOf;\n\n module(\"Ember Type Checking\");\n\n test(\"Ember.typeOf\", function() {\n var MockedDate = function() { };\n MockedDate.prototype = new Date();\n\n var mockedDate = new MockedDate(),\n date = new Date(),\n error = new Error('boum'),\n object = {a: 'b'};\n\n equal( typeOf(), 'undefined', \"undefined\");\n equal( typeOf(null), 'null', \"null\");\n equal( typeOf('Cyril'), 'string', \"Cyril\");\n equal( typeOf(101), 'number', \"101\");\n equal( typeOf(true), 'boolean', \"true\");\n equal( typeOf([1,2,90]), 'array', \"[1,2,90]\");\n equal( typeOf(/abc/), 'regexp', \"/abc/\");\n equal( typeOf(date), 'date', \"new Date()\");\n equal( typeOf(mockedDate), 'date', \"mocked date\");\n equal( typeOf(error), 'error', \"error\");\n equal( typeOf(object), 'object', \"object\");\n\n if(Ember.Object) {\n var klass = Ember.Object.extend(),\n instance = Ember.Object.create();\n\n equal( Ember.typeOf(klass), 'class', \"class\");\n equal( Ember.typeOf(instance), 'instance', \"instance\");\n }\n });\n });\ndefine(\"ember-metal/tests/watching/isWatching_test\",\n [\"ember-metal/property_get\",\"ember-metal/properties\",\"ember-metal/mixin\",\"ember-metal/observer\",\"ember-metal/watching\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var get = __dependency1__.get;\n var defineProperty = __dependency2__.defineProperty;\n var Mixin = __dependency3__.Mixin;\n var observer = __dependency3__.observer;\n var addObserver = __dependency4__.addObserver;\n var removeObserver = __dependency4__.removeObserver;\n var isWatching = __dependency5__.isWatching;\n\n module('isWatching');\n\n var testObserver = function(setup, teardown, key) {\n var obj = {}, fn = function() {};\n key = key || 'foo';\n\n equal(isWatching(obj, key), false, \"precond - isWatching is false by default\");\n setup(obj, key, fn);\n equal(isWatching(obj, key), true, \"isWatching is true when observers are added\");\n teardown(obj, key, fn);\n equal(isWatching(obj, key), false, \"isWatching is false after observers are removed\");\n };\n\n test(\"isWatching is true for regular local observers\", function() {\n testObserver(function(obj, key, fn) {\n Mixin.create({\n didChange: observer(key, fn)\n }).apply(obj);\n }, function(obj, key, fn) {\n removeObserver(obj, key, obj, fn);\n });\n });\n\n test(\"isWatching is true for nonlocal observers\", function() {\n testObserver(function(obj, key, fn) {\n addObserver(obj, key, obj, fn);\n }, function(obj, key, fn) {\n removeObserver(obj, key, obj, fn);\n });\n });\n\n test(\"isWatching is true for chained observers\", function() {\n testObserver(function(obj, key, fn) {\n addObserver(obj, key + '.bar', obj, fn);\n }, function(obj, key, fn) {\n removeObserver(obj, key + '.bar', obj, fn);\n });\n });\n\n test(\"isWatching is true for computed properties\", function() {\n testObserver(function(obj, key, fn) {\n defineProperty(obj, 'computed', Ember.computed(fn).property(key));\n get(obj, 'computed');\n }, function(obj, key, fn) {\n defineProperty(obj, 'computed', null);\n });\n });\n\n test(\"isWatching is true for chained computed properties\", function() {\n testObserver(function(obj, key, fn) {\n defineProperty(obj, 'computed', Ember.computed(fn).property(key + '.bar'));\n get(obj, 'computed');\n }, function(obj, key, fn) {\n defineProperty(obj, 'computed', null);\n });\n });\n\n // can't watch length on Array - it is special...\n // But you should be able to watch a length property of an object\n test(\"isWatching is true for 'length' property on object\", function() {\n testObserver(function(obj, key, fn) {\n defineProperty(obj, 'length', null, '26.2 miles');\n addObserver(obj, 'length', obj, fn);\n }, function(obj, key, fn) {\n removeObserver(obj, 'length', obj, fn);\n }, 'length');\n });\n });\ndefine(\"ember-metal/tests/watching/unwatch_test\",\n [\"ember-metal/tests/props_helper\",\"ember-metal/watching\",\"ember-metal/property_events\",\"ember-metal/properties\",\"ember-metal/events\",\"ember-metal/computed\",\"ember-metal/property_get\",\"ember-metal/property_set\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var testBoth = __dependency1__[\"default\"];\n var watch = __dependency2__.watch;\n var unwatch = __dependency2__.unwatch;\n var propertyWillChange = __dependency3__.propertyWillChange;\n var propertyDidChange = __dependency3__.propertyDidChange;\n var defineProperty = __dependency4__.defineProperty;\n var addListener = __dependency5__.addListener;\n var computed = __dependency6__.computed;\n var get = __dependency7__.get;\n var set = __dependency8__.set;\n\n var willCount, didCount;\n\n module('unwatch', {\n setup: function() {\n willCount = didCount = 0;\n }\n });\n\n function addListeners(obj, keyPath) {\n addListener(obj, keyPath + ':before', function() {\n willCount++;\n });\n addListener(obj, keyPath + ':change', function() {\n didCount++;\n });\n }\n\n testBoth('unwatching a computed property - regular get/set', function(get, set) {\n\n var obj = {};\n defineProperty(obj, 'foo', computed(function(keyName, value) {\n if (value !== undefined) this.__foo = value;\n return this.__foo;\n }));\n addListeners(obj, 'foo');\n\n watch(obj, 'foo');\n set(obj, 'foo', 'bar');\n equal(willCount, 1, 'should have invoked willCount');\n equal(didCount, 1, 'should have invoked didCount');\n\n unwatch(obj, 'foo');\n willCount = didCount = 0;\n set(obj, 'foo', 'BAZ');\n equal(willCount, 0, 'should NOT have invoked willCount');\n equal(didCount, 0, 'should NOT have invoked didCount');\n });\n\n\n testBoth('unwatching a regular property - regular get/set', function(get, set) {\n\n var obj = { foo: 'BIFF' };\n addListeners(obj, 'foo');\n\n watch(obj, 'foo');\n set(obj, 'foo', 'bar');\n equal(willCount, 1, 'should have invoked willCount');\n equal(didCount, 1, 'should have invoked didCount');\n\n unwatch(obj, 'foo');\n willCount = didCount = 0;\n set(obj, 'foo', 'BAZ');\n equal(willCount, 0, 'should NOT have invoked willCount');\n equal(didCount, 0, 'should NOT have invoked didCount');\n });\n\n test('unwatching should be nested', function() {\n\n var obj = { foo: 'BIFF' };\n addListeners(obj, 'foo');\n\n watch(obj, 'foo');\n watch(obj, 'foo');\n set(obj, 'foo', 'bar');\n equal(willCount, 1, 'should have invoked willCount');\n equal(didCount, 1, 'should have invoked didCount');\n\n unwatch(obj, 'foo');\n willCount = didCount = 0;\n set(obj, 'foo', 'BAZ');\n equal(willCount, 1, 'should NOT have invoked willCount');\n equal(didCount, 1, 'should NOT have invoked didCount');\n\n unwatch(obj, 'foo');\n willCount = didCount = 0;\n set(obj, 'foo', 'BAZ');\n equal(willCount, 0, 'should NOT have invoked willCount');\n equal(didCount, 0, 'should NOT have invoked didCount');\n });\n\n testBoth('unwatching \"length\" property on an object', function(get, set) {\n\n var obj = { foo: 'RUN' };\n addListeners(obj, 'length');\n\n // Can watch length when it is undefined\n watch(obj, 'length');\n set(obj, 'length', '10k');\n equal(willCount, 1, 'should have invoked willCount');\n equal(didCount, 1, 'should have invoked didCount');\n\n // Should stop watching despite length now being defined (making object 'array-like')\n unwatch(obj, 'length');\n willCount = didCount = 0;\n set(obj, 'length', '5k');\n equal(willCount, 0, 'should NOT have invoked willCount');\n equal(didCount, 0, 'should NOT have invoked didCount');\n\n });\n });\ndefine(\"ember-metal/tests/watching/watch_test\",\n [\"ember-metal/core\",\"ember-metal/tests/props_helper\",\"ember-metal/enumerable_utils\",\"ember-metal/events\",\"ember-metal/watching\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var testBoth = __dependency2__[\"default\"];\n var EnumerableUtils = __dependency3__[\"default\"];\n var addListener = __dependency4__.addListener;\n var watch = __dependency5__.watch;\n var unwatch = __dependency5__.unwatch;\n var destroy = __dependency5__.destroy;\n\n\n var willCount, didCount,\n willKeys, didKeys,\n indexOf = EnumerableUtils.indexOf,\n originalLookup, lookup, Global;\n\n module('watch', {\n setup: function() {\n willCount = didCount = 0;\n willKeys = [];\n didKeys = [];\n\n originalLookup = Ember.lookup;\n Ember.lookup = lookup = {};\n },\n\n teardown: function(){\n Ember.lookup = originalLookup;\n }\n });\n\n function addListeners(obj, keyPath) {\n addListener(obj, keyPath + ':before', function() {\n willCount++;\n willKeys.push(keyPath);\n });\n addListener(obj, keyPath + ':change', function() {\n didCount++;\n didKeys.push(keyPath);\n });\n }\n\n testBoth('watching a computed property', function(get, set) {\n\n var obj = {};\n Ember.defineProperty(obj, 'foo', Ember.computed(function(keyName, value) {\n if (value !== undefined) this.__foo = value;\n return this.__foo;\n }));\n addListeners(obj, 'foo');\n\n watch(obj, 'foo');\n set(obj, 'foo', 'bar');\n equal(willCount, 1, 'should have invoked willCount');\n equal(didCount, 1, 'should have invoked didCount');\n });\n\n testBoth('watching a regular defined property', function(get, set) {\n\n var obj = { foo: 'baz' };\n addListeners(obj, 'foo');\n\n watch(obj, 'foo');\n equal(get(obj, 'foo'), 'baz', 'should have original prop');\n\n set(obj, 'foo', 'bar');\n equal(willCount, 1, 'should have invoked willCount');\n equal(didCount, 1, 'should have invoked didCount');\n\n equal(get(obj, 'foo'), 'bar', 'should get new value');\n equal(obj.foo, 'bar', 'property should be accessible on obj');\n });\n\n testBoth('watching a regular undefined property', function(get, set) {\n\n var obj = { };\n addListeners(obj, 'foo');\n\n watch(obj, 'foo');\n\n equal('foo' in obj, false, 'precond undefined');\n\n set(obj, 'foo', 'bar');\n\n equal(willCount, 1, 'should have invoked willCount');\n equal(didCount, 1, 'should have invoked didCount');\n\n equal(get(obj, 'foo'), 'bar', 'should get new value');\n equal(obj.foo, 'bar', 'property should be accessible on obj');\n });\n\n testBoth('watches should inherit', function(get, set) {\n\n var obj = { foo: 'baz' };\n var objB = Ember.create(obj);\n\n addListeners(obj, 'foo');\n watch(obj, 'foo');\n equal(get(obj, 'foo'), 'baz', 'should have original prop');\n\n set(obj, 'foo', 'bar');\n set(objB, 'foo', 'baz');\n equal(willCount, 2, 'should have invoked willCount once only');\n equal(didCount, 2, 'should have invoked didCount once only');\n });\n\n test(\"watching an object THEN defining it should work also\", function() {\n\n var obj = {};\n addListeners(obj, 'foo');\n\n watch(obj, 'foo');\n\n Ember.defineProperty(obj, 'foo');\n Ember.set(obj, 'foo', 'bar');\n\n equal(Ember.get(obj, 'foo'), 'bar', 'should have set');\n equal(willCount, 1, 'should have invoked willChange once');\n equal(didCount, 1, 'should have invoked didChange once');\n\n });\n\n test(\"watching a chain then defining the property\", function () {\n var obj = {};\n var foo = {bar: 'bar'};\n addListeners(obj, 'foo.bar');\n addListeners(foo, 'bar');\n\n watch(obj, 'foo.bar');\n\n Ember.defineProperty(obj, 'foo', undefined, foo);\n Ember.set(foo, 'bar', 'baz');\n\n deepEqual(willKeys, ['foo.bar', 'bar'], 'should have invoked willChange with bar, foo.bar');\n deepEqual(didKeys, ['foo.bar', 'bar'], 'should have invoked didChange with bar, foo.bar');\n equal(willCount, 2, 'should have invoked willChange twice');\n equal(didCount, 2, 'should have invoked didChange twice');\n });\n\n test(\"watching a chain then defining the nested property\", function () {\n var bar = {};\n var obj = {foo: bar};\n var baz = {baz: 'baz'};\n addListeners(obj, 'foo.bar.baz');\n addListeners(baz, 'baz');\n\n watch(obj, 'foo.bar.baz');\n\n Ember.defineProperty(bar, 'bar', undefined, baz);\n Ember.set(baz, 'baz', 'BOO');\n\n deepEqual(willKeys, ['foo.bar.baz', 'baz'], 'should have invoked willChange with bar, foo.bar');\n deepEqual(didKeys, ['foo.bar.baz', 'baz'], 'should have invoked didChange with bar, foo.bar');\n equal(willCount, 2, 'should have invoked willChange twice');\n equal(didCount, 2, 'should have invoked didChange twice');\n });\n\n testBoth('watching an object value then unwatching should restore old value', function(get, set) {\n\n var obj = { foo: { bar: { baz: { biff: 'BIFF' } } } };\n addListeners(obj, 'foo.bar.baz.biff');\n\n watch(obj, 'foo.bar.baz.biff');\n\n var foo = Ember.get(obj, 'foo');\n equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist');\n\n unwatch(obj, 'foo.bar.baz.biff');\n equal(get(get(get(foo, 'bar'), 'baz'), 'biff'), 'BIFF', 'biff should exist');\n });\n\n testBoth('watching a global object that does not yet exist should queue', function(get, set) {\n lookup['Global'] = Global = null;\n\n var obj = {};\n addListeners(obj, 'Global.foo');\n\n watch(obj, 'Global.foo'); // only works on global chained props\n\n equal(willCount, 0, 'should not have fired yet');\n equal(didCount, 0, 'should not have fired yet');\n\n lookup['Global'] = Global = { foo: 'bar' };\n addListeners(Global, 'foo');\n\n watch.flushPending(); // this will also be invoked automatically on ready\n\n equal(willCount, 0, 'should not have fired yet');\n equal(didCount, 0, 'should not have fired yet');\n\n set(Global, 'foo', 'baz');\n\n // should fire twice because this is a chained property (once on key, once\n // on path)\n equal(willCount, 2, 'should be watching');\n equal(didCount, 2, 'should be watching');\n\n lookup['Global'] = Global = null; // reset\n });\n\n test('when watching a global object, destroy should remove chain watchers from the global object', function() {\n\n lookup['Global'] = Global = { foo: 'bar' };\n var obj = {};\n addListeners(obj, 'Global.foo');\n\n watch(obj, 'Global.foo');\n\n var meta_Global = Ember.meta(Global);\n var chainNode = Ember.meta(obj).chains._chains.Global._chains.foo;\n var index = indexOf(meta_Global.chainWatchers.foo, chainNode);\n\n equal(meta_Global.watching.foo, 1, 'should be watching foo');\n strictEqual(meta_Global.chainWatchers.foo[index], chainNode, 'should have chain watcher');\n\n destroy(obj);\n\n index = indexOf(meta_Global.chainWatchers.foo, chainNode);\n equal(meta_Global.watching.foo, 0, 'should not be watching foo');\n equal(index, -1, 'should not have chain watcher');\n\n lookup['Global'] = Global = null; // reset\n });\n\n test('when watching another object, destroy should remove chain watchers from the other object', function() {\n\n var objA = {};\n var objB = {foo: 'bar'};\n objA.b = objB;\n addListeners(objA, 'b.foo');\n\n watch(objA, 'b.foo');\n\n var meta_objB = Ember.meta(objB);\n var chainNode = Ember.meta(objA).chains._chains.b._chains.foo;\n var index = indexOf(meta_objB.chainWatchers.foo, chainNode);\n\n equal(meta_objB.watching.foo, 1, 'should be watching foo');\n strictEqual(meta_objB.chainWatchers.foo[index], chainNode, 'should have chain watcher');\n\n destroy(objA);\n\n index = indexOf(meta_objB.chainWatchers.foo, chainNode);\n equal(meta_objB.watching.foo, 0, 'should not be watching foo');\n equal(index, -1, 'should not have chain watcher');\n });\n\n // TESTS for length property\n\n testBoth('watching \"length\" property on an object', function(get, set) {\n\n var obj = { length: '26.2 miles' };\n addListeners(obj, 'length');\n\n watch(obj, 'length');\n equal(get(obj, 'length'), '26.2 miles', 'should have original prop');\n\n set(obj, 'length', '10k');\n equal(willCount, 1, 'should have invoked willCount');\n equal(didCount, 1, 'should have invoked didCount');\n\n equal(get(obj, 'length'), '10k', 'should get new value');\n equal(obj.length, '10k', 'property should be accessible on obj');\n });\n\n testBoth('watching \"length\" property on an array', function(get, set) {\n\n var arr = [];\n addListeners(arr, 'length');\n\n watch(arr, 'length');\n equal(get(arr, 'length'), 0, 'should have original prop');\n\n set(arr, 'length', '10');\n equal(willCount, 0, 'should NOT have invoked willCount');\n equal(didCount, 0, 'should NOT have invoked didCount');\n\n equal(get(arr, 'length'), 10, 'should get new value');\n equal(arr.length, 10, 'property should be accessible on arr');\n });\n });\n})();\n//@ sourceURL=ember-metal/~tests/ember-metal");minispade.register('ember-metal/~tests/ember-metal_test', "(function() {minispade.require(\"ember-metal/~tests/ember-metal\");\nrequireModule(\"ember-metal/tests/accessors/getPath_test\");\nrequireModule(\"ember-metal/tests/accessors/getProperties_test\");\nrequireModule(\"ember-metal/tests/accessors/get_test\");\nrequireModule(\"ember-metal/tests/accessors/isGlobalPath_test\");\nrequireModule(\"ember-metal/tests/accessors/normalizeTuple_test\");\nrequireModule(\"ember-metal/tests/accessors/setPath_test\");\nrequireModule(\"ember-metal/tests/accessors/set_test\");\nrequireModule(\"ember-metal/tests/binding/connect_test\");\nrequireModule(\"ember-metal/tests/binding/oneWay_test\");\nrequireModule(\"ember-metal/tests/binding/sync_test\");\nrequireModule(\"ember-metal/tests/chains_test\");\nrequireModule(\"ember-metal/tests/computed_test\");\nrequireModule(\"ember-metal/tests/core/inspect_test\");\nrequireModule(\"ember-metal/tests/enumerable_utils_test\");\nrequireModule(\"ember-metal/tests/error_test\");\nrequireModule(\"ember-metal/tests/events_test\");\nrequireModule(\"ember-metal/tests/features_test\");\nrequireModule(\"ember-metal/tests/instrumentation_test\");\nrequireModule(\"ember-metal/tests/is_blank_test\");\nrequireModule(\"ember-metal/tests/is_empty_test\");\nrequireModule(\"ember-metal/tests/is_none_test\");\nrequireModule(\"ember-metal/tests/libraries_test\");\nrequireModule(\"ember-metal/tests/map_test\");\nrequireModule(\"ember-metal/tests/mixin/alias_method_test\");\nrequireModule(\"ember-metal/tests/mixin/apply_test\");\nrequireModule(\"ember-metal/tests/mixin/computed_test\");\nrequireModule(\"ember-metal/tests/mixin/concatenatedProperties_test\");\nrequireModule(\"ember-metal/tests/mixin/detect_test\");\nrequireModule(\"ember-metal/tests/mixin/introspection_test\");\nrequireModule(\"ember-metal/tests/mixin/mergedProperties_test\");\nrequireModule(\"ember-metal/tests/mixin/method_test\");\nrequireModule(\"ember-metal/tests/mixin/observer_test\");\nrequireModule(\"ember-metal/tests/mixin/reopen_test\");\nrequireModule(\"ember-metal/tests/mixin/required_test\");\nrequireModule(\"ember-metal/tests/mixin/without_test\");\nrequireModule(\"ember-metal/tests/observer_test\");\nrequireModule(\"ember-metal/tests/performance_test\");\nrequireModule(\"ember-metal/tests/platform/create_test\");\nrequireModule(\"ember-metal/tests/platform/defineProperty_test\");\nrequireModule(\"ember-metal/tests/properties_test\");\nrequireModule(\"ember-metal/tests/run_loop/add_queue_test\");\nrequireModule(\"ember-metal/tests/run_loop/debounce_test\");\nrequireModule(\"ember-metal/tests/run_loop/join_test\");\nrequireModule(\"ember-metal/tests/run_loop/later_test\");\nrequireModule(\"ember-metal/tests/run_loop/next_test\");\nrequireModule(\"ember-metal/tests/run_loop/once_test\");\nrequireModule(\"ember-metal/tests/run_loop/onerror_test\");\nrequireModule(\"ember-metal/tests/run_loop/run_bind_test\");\nrequireModule(\"ember-metal/tests/run_loop/run_test\");\nrequireModule(\"ember-metal/tests/run_loop/schedule_test\");\nrequireModule(\"ember-metal/tests/run_loop/sync_test\");\nrequireModule(\"ember-metal/tests/run_loop/unwind_test\");\nrequireModule(\"ember-metal/tests/utils/can_invoke_test\");\nrequireModule(\"ember-metal/tests/utils/generate_guid_test\");\nrequireModule(\"ember-metal/tests/utils/guidFor_test\");\nrequireModule(\"ember-metal/tests/utils/is_array_test\");\nrequireModule(\"ember-metal/tests/utils/meta_test\");\nrequireModule(\"ember-metal/tests/utils/try_catch_finally_test\");\nrequireModule(\"ember-metal/tests/utils/try_finally_test\");\nrequireModule(\"ember-metal/tests/utils/try_invoke_test\");\nrequireModule(\"ember-metal/tests/utils/type_of_test\");\nrequireModule(\"ember-metal/tests/watching/isWatching_test\");\nrequireModule(\"ember-metal/tests/watching/unwatch_test\");\nrequireModule(\"ember-metal/tests/watching/watch_test\");\n})();\n//@ sourceURL=ember-metal/~tests/ember-metal_test");minispade.register('ember-routing/~tests/ember-routing', "(function() {define(\"ember-routing/tests/helpers/action_test\",\n [\"ember-metal/core\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-views/system/event_dispatcher\",\"ember-runtime/system/object\",\"ember-runtime/controllers/controller\",\"ember-runtime/controllers/object_controller\",\"ember-runtime/controllers/array_controller\",\"ember-handlebars\",\"ember-views/views/view\",\"ember-views/views/component\",\"ember-views/system/jquery\",\"ember-routing/helpers/shared\",\"ember-routing/helpers/action\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // A, FEATURES, assert, TESTING_DEPRECATION\n var set = __dependency2__.set;\n var run = __dependency3__[\"default\"];\n var EventDispatcher = __dependency4__[\"default\"];\n\n var EmberObject = __dependency5__[\"default\"];\n var EmberController = __dependency6__.Controller;\n var EmberObjectController = __dependency7__[\"default\"];\n var EmberArrayController = __dependency8__[\"default\"];\n\n var EmberHandlebars = __dependency9__[\"default\"];\n var EmberView = __dependency10__.View;\n var EmberComponent = __dependency11__[\"default\"];\n var jQuery = __dependency12__[\"default\"];\n\n var ActionHelper = __dependency14__.ActionHelper;\n var actionHelper = __dependency14__.actionHelper;\n\n var dispatcher, view, originalActionHelper,\n originalRegisterAction = ActionHelper.registerAction;\n\n var appendView = function() {\n run(function() { view.appendTo('#qunit-fixture'); });\n };\n\n module(\"Ember.Handlebars - action helper\", {\n setup: function() {\n originalActionHelper = EmberHandlebars.helpers['action'];\n EmberHandlebars.registerHelper('action', actionHelper);\n\n dispatcher = EventDispatcher.create();\n dispatcher.setup();\n },\n\n teardown: function() {\n run(function() {\n dispatcher.destroy();\n if (view) { view.destroy(); }\n });\n\n delete EmberHandlebars.helpers['action'];\n EmberHandlebars.helpers['action'] = originalActionHelper;\n\n Ember.TESTING_DEPRECATION = false;\n }\n });\n\n test(\"should output a data attribute with a guid\", function() {\n view = EmberView.create({\n template: EmberHandlebars.compile('edit')\n });\n\n appendView();\n\n ok(view.$('a').attr('data-ember-action').match(/\\d+/), \"A data-ember-action attribute with a guid was added\");\n });\n\n test(\"should by default register a click event\", function() {\n var registeredEventName;\n\n ActionHelper.registerAction = function(actionName, options) {\n registeredEventName = options.eventName;\n };\n\n view = EmberView.create({\n template: EmberHandlebars.compile('edit')\n });\n\n appendView();\n\n equal(registeredEventName, 'click', \"The click event was properly registered\");\n\n ActionHelper.registerAction = originalRegisterAction;\n });\n\n test(\"should allow alternative events to be handled\", function() {\n var registeredEventName;\n\n ActionHelper.registerAction = function(actionName, options) {\n registeredEventName = options.eventName;\n };\n\n view = EmberView.create({\n template: EmberHandlebars.compile('edit')\n });\n\n appendView();\n\n equal(registeredEventName, 'mouseUp', \"The alternative mouseUp event was properly registered\");\n\n ActionHelper.registerAction = originalRegisterAction;\n });\n\n test(\"should by default target the view's controller\", function() {\n var registeredTarget, controller = {};\n\n ActionHelper.registerAction = function(actionName, options) {\n registeredTarget = options.target;\n };\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('edit')\n });\n\n appendView();\n\n equal(registeredTarget.root, controller, \"The controller was registered as the target\");\n\n ActionHelper.registerAction = originalRegisterAction;\n });\n\n test(\"Inside a yield, the target points at the original target\", function() {\n var controller = {}, watted = false;\n\n var component = EmberComponent.extend({\n boundText: \"inner\",\n truthy: true,\n obj: {},\n layout: EmberHandlebars.compile(\"

    {{boundText}}

    {{#if truthy}}{{#with obj}}{{yield}}{{/with}}{{/if}}

    \")\n });\n\n view = EmberView.create({\n controller: {\n boundText: \"outer\",\n truthy: true,\n wat: function() {\n watted = true;\n },\n obj: {\n component: component,\n truthy: true,\n boundText: 'insideWith'\n }\n },\n template: EmberHandlebars.compile('{{#with obj}}{{#if truthy}}{{#view component}}{{#if truthy}}

    {{boundText}}

    {{/if}}{{/view}}{{/if}}{{/with}}')\n });\n\n appendView();\n\n run(function() {\n view.$(\".wat\").click();\n });\n\n equal(watted, true, \"The action was called on the right context\");\n });\n\n test(\"should target the current controller inside an {{each}} loop\", function() {\n var registeredTarget;\n\n ActionHelper.registerAction = function(actionName, options) {\n registeredTarget = options.target;\n };\n\n var itemController = EmberObjectController.create();\n\n var ArrayController = EmberArrayController.extend({\n itemController: 'stub',\n controllerAt: function(idx, object) {\n return itemController;\n }\n });\n\n var controller = ArrayController.create({\n model: Ember.A([1])\n });\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('{{#each controller}}{{action \"editTodo\"}}{{/each}}')\n });\n\n appendView();\n\n equal(registeredTarget.root, itemController, \"the item controller is the target of action\");\n\n ActionHelper.registerAction = originalRegisterAction;\n });\n\n test(\"should allow a target to be specified\", function() {\n var registeredTarget;\n\n ActionHelper.registerAction = function(actionName, options) {\n registeredTarget = options.target;\n };\n\n var anotherTarget = EmberView.create();\n\n view = EmberView.create({\n controller: {},\n template: EmberHandlebars.compile('edit'),\n anotherTarget: anotherTarget\n });\n\n appendView();\n\n equal(registeredTarget.options.data.keywords.view, view, \"The specified target was registered\");\n equal(registeredTarget.target, 'view.anotherTarget', \"The specified target was registered\");\n\n ActionHelper.registerAction = originalRegisterAction;\n\n run(function() {\n anotherTarget.destroy();\n });\n });\n\n test(\"should lazily evaluate the target\", function() {\n var firstEdit = 0, secondEdit = 0;\n\n var controller = {};\n var first = {\n edit: function() {\n firstEdit++;\n }\n };\n\n var second = {\n edit: function() {\n secondEdit++;\n }\n };\n\n controller.theTarget = first;\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('edit')\n });\n\n appendView();\n\n run(function() {\n jQuery('a').trigger('click');\n });\n\n equal(firstEdit, 1);\n\n set(controller, 'theTarget', second);\n\n run(function() {\n jQuery('a').trigger('click');\n });\n\n equal(firstEdit, 1);\n equal(secondEdit, 1);\n });\n\n test(\"should register an event handler\", function() {\n var eventHandlerWasCalled = false;\n\n var controller = EmberController.extend({\n actions: { edit: function() { eventHandlerWasCalled = true; } }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('click me')\n });\n\n appendView();\n\n var actionId = view.$('a[data-ember-action]').attr('data-ember-action');\n\n ok(ActionHelper.registeredActions[actionId], \"The action was registered\");\n\n view.$('a').trigger('click');\n\n ok(eventHandlerWasCalled, \"The event handler was called\");\n });\n\n test(\"handles whitelisted modifier keys\", function() {\n var eventHandlerWasCalled = false, shortcutHandlerWasCalled = false;\n\n var controller = EmberController.extend({\n actions: {\n edit: function() { eventHandlerWasCalled = true; },\n shortcut: function() { shortcutHandlerWasCalled = true; }\n }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('click me
    click me too
    ')\n });\n\n appendView();\n\n var actionId = view.$('a[data-ember-action]').attr('data-ember-action');\n\n ok(ActionHelper.registeredActions[actionId], \"The action was registered\");\n\n var e = jQuery.Event('click');\n e.altKey = true;\n view.$('a').trigger(e);\n\n ok(eventHandlerWasCalled, \"The event handler was called\");\n\n e = jQuery.Event('click');\n e.ctrlKey = true;\n view.$('div').trigger(e);\n\n ok(shortcutHandlerWasCalled, \"The \\\"any\\\" shortcut's event handler was called\");\n });\n\n test(\"should be able to use action more than once for the same event within a view\", function() {\n var editWasCalled = false,\n deleteWasCalled = false,\n originalEventHandlerWasCalled = false;\n\n var controller = EmberController.extend({\n actions: {\n edit: function() { editWasCalled = true; },\n \"delete\": function() { deleteWasCalled = true; }\n }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile(\n 'editdelete'\n ),\n click: function() { originalEventHandlerWasCalled = true; }\n });\n\n appendView();\n\n view.$('#edit').trigger('click');\n\n equal(editWasCalled, true, \"The edit action was called\");\n equal(deleteWasCalled, false, \"The delete action was not called\");\n\n editWasCalled = deleteWasCalled = originalEventHandlerWasCalled = false;\n\n view.$('#delete').trigger('click');\n\n equal(editWasCalled, false, \"The edit action was not called\");\n equal(deleteWasCalled, true, \"The delete action was called\");\n\n editWasCalled = deleteWasCalled = originalEventHandlerWasCalled = false;\n\n view.$().trigger('click');\n\n equal(editWasCalled, false, \"The edit action was not called\");\n equal(deleteWasCalled, false, \"The delete action was not called\");\n });\n\n test(\"the event should not bubble if `bubbles=false` is passed\", function() {\n var editWasCalled = false,\n deleteWasCalled = false,\n originalEventHandlerWasCalled = false;\n\n var controller = EmberController.extend({\n actions: {\n edit: function() { editWasCalled = true; },\n \"delete\": function() { deleteWasCalled = true; }\n }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile(\n 'editdelete'\n ),\n click: function() { originalEventHandlerWasCalled = true; }\n });\n\n appendView();\n\n view.$('#edit').trigger('click');\n\n equal(editWasCalled, true, \"The edit action was called\");\n equal(deleteWasCalled, false, \"The delete action was not called\");\n equal(originalEventHandlerWasCalled, false, \"The original event handler was not called\");\n\n editWasCalled = deleteWasCalled = originalEventHandlerWasCalled = false;\n\n view.$('#delete').trigger('click');\n\n equal(editWasCalled, false, \"The edit action was not called\");\n equal(deleteWasCalled, true, \"The delete action was called\");\n equal(originalEventHandlerWasCalled, false, \"The original event handler was not called\");\n\n editWasCalled = deleteWasCalled = originalEventHandlerWasCalled = false;\n\n view.$().trigger('click');\n\n equal(editWasCalled, false, \"The edit action was not called\");\n equal(deleteWasCalled, false, \"The delete action was not called\");\n equal(originalEventHandlerWasCalled, true, \"The original event handler was called\");\n });\n\n test(\"should work properly in an #each block\", function() {\n var eventHandlerWasCalled = false;\n\n var controller = EmberController.extend({\n actions: { edit: function() { eventHandlerWasCalled = true; } }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n items: Ember.A([1, 2, 3, 4]),\n template: EmberHandlebars.compile('{{#each view.items}}click me{{/each}}')\n });\n\n appendView();\n\n view.$('a').trigger('click');\n\n ok(eventHandlerWasCalled, \"The event handler was called\");\n });\n\n test(\"should work properly in a #with block\", function() {\n var eventHandlerWasCalled = false;\n\n var controller = EmberController.extend({\n actions: { edit: function() { eventHandlerWasCalled = true; } }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n something: {ohai: 'there'},\n template: EmberHandlebars.compile('{{#with view.something}}click me{{/with}}')\n });\n\n appendView();\n\n view.$('a').trigger('click');\n\n ok(eventHandlerWasCalled, \"The event handler was called\");\n });\n\n test(\"should unregister event handlers on rerender\", function() {\n var eventHandlerWasCalled = false;\n\n view = EmberView.extend({\n template: EmberHandlebars.compile('click me'),\n actions: { edit: function() { eventHandlerWasCalled = true; } }\n }).create();\n\n appendView();\n\n var previousActionId = view.$('a[data-ember-action]').attr('data-ember-action');\n\n run(function() {\n view.rerender();\n });\n\n ok(!ActionHelper.registeredActions[previousActionId], \"On rerender, the event handler was removed\");\n\n var newActionId = view.$('a[data-ember-action]').attr('data-ember-action');\n\n ok(ActionHelper.registeredActions[newActionId], \"After rerender completes, a new event handler was added\");\n });\n\n test(\"should unregister event handlers on inside virtual views\", function() {\n var things = Ember.A([\n {\n name: 'Thingy'\n }\n ]);\n view = EmberView.create({\n template: EmberHandlebars.compile('{{#each view.things}}click me{{/each}}'),\n things: things\n });\n\n appendView();\n\n var actionId = view.$('a[data-ember-action]').attr('data-ember-action');\n\n run(function() {\n things.removeAt(0);\n });\n\n ok(!ActionHelper.registeredActions[actionId], \"After the virtual view was destroyed, the action was unregistered\");\n });\n\n test(\"should properly capture events on child elements of a container with an action\", function() {\n var eventHandlerWasCalled = false;\n\n var controller = EmberController.extend({\n actions: { edit: function() { eventHandlerWasCalled = true; } }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('
    ')\n });\n\n appendView();\n\n view.$('button').trigger('click');\n\n ok(eventHandlerWasCalled, \"Event on a child element triggered the action of it's parent\");\n });\n\n test(\"should allow bubbling of events from action helper to original parent event\", function() {\n var eventHandlerWasCalled = false,\n originalEventHandlerWasCalled = false;\n\n var controller = EmberController.extend({\n actions: { edit: function() { eventHandlerWasCalled = true; } }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('click me'),\n click: function() { originalEventHandlerWasCalled = true; }\n });\n\n appendView();\n\n view.$('a').trigger('click');\n\n ok(eventHandlerWasCalled && originalEventHandlerWasCalled, \"Both event handlers were called\");\n });\n\n test(\"should not bubble an event from action helper to original parent event if `bubbles=false` is passed\", function() {\n var eventHandlerWasCalled = false,\n originalEventHandlerWasCalled = false;\n\n var controller = EmberController.extend({\n actions: { edit: function() { eventHandlerWasCalled = true; } }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('click me'),\n click: function() { originalEventHandlerWasCalled = true; }\n });\n\n appendView();\n\n view.$('a').trigger('click');\n\n ok(eventHandlerWasCalled, \"The child handler was called\");\n ok(!originalEventHandlerWasCalled, \"The parent handler was not called\");\n });\n\n test(\"should allow 'send' as action name (#594)\", function() {\n var eventHandlerWasCalled = false;\n var eventObjectSent;\n\n var controller = EmberController.extend({\n send: function() { eventHandlerWasCalled = true; }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('send')\n });\n\n appendView();\n\n view.$('a').trigger('click');\n\n ok(eventHandlerWasCalled, \"The view's send method was called\");\n });\n\n\n test(\"should send the view, event and current Handlebars context to the action\", function() {\n var passedTarget;\n var passedContext;\n\n var aTarget = EmberController.extend({\n actions: {\n edit: function(context) {\n passedTarget = this;\n passedContext = context;\n }\n }\n }).create();\n\n var aContext = { aTarget: aTarget };\n\n view = EmberView.create({\n aContext: aContext,\n template: EmberHandlebars.compile('{{#with view.aContext}}edit{{/with}}')\n });\n\n appendView();\n\n view.$('#edit').trigger('click');\n\n strictEqual(passedTarget, aTarget, \"the action is called with the target as this\");\n strictEqual(passedContext, aContext, \"the parameter is passed along\");\n });\n\n test(\"should only trigger actions for the event they were registered on\", function() {\n var editWasCalled = false;\n\n view = EmberView.extend({\n template: EmberHandlebars.compile('edit'),\n actions: { edit: function() { editWasCalled = true; } }\n }).create();\n\n appendView();\n\n view.$('a').trigger('mouseover');\n\n ok(!editWasCalled, \"The action wasn't called\");\n });\n\n test(\"should unwrap controllers passed as a context\", function() {\n var passedContext,\n model = EmberObject.create(),\n controller = EmberObjectController.extend({\n model: model,\n actions: {\n edit: function(context) {\n passedContext = context;\n }\n }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('')\n });\n\n appendView();\n\n view.$('button').trigger('click');\n\n equal(passedContext, model, \"the action was passed the unwrapped model\");\n });\n\n test(\"should allow multiple contexts to be specified\", function() {\n var passedContexts,\n models = [EmberObject.create(), EmberObject.create()];\n\n var controller = EmberController.extend({\n actions: {\n edit: function() {\n passedContexts = [].slice.call(arguments);\n }\n }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n modelA: models[0],\n modelB: models[1],\n template: EmberHandlebars.compile('')\n });\n\n appendView();\n\n view.$('button').trigger('click');\n\n deepEqual(passedContexts, models, \"the action was called with the passed contexts\");\n });\n\n test(\"should allow multiple contexts to be specified mixed with string args\", function() {\n var passedParams,\n model = EmberObject.create();\n\n var controller = EmberController.extend({\n actions: {\n edit: function() {\n passedParams = [].slice.call(arguments);\n }\n }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n modelA: model,\n template: EmberHandlebars.compile('')\n });\n\n appendView();\n\n view.$('button').trigger('click');\n\n deepEqual(passedParams, [\"herp\", model], \"the action was called with the passed contexts\");\n });\n\n var namespace = {\n \"Component\": {\n toString: function() { return \"Component\"; },\n find: function() { return { id: 1 }; }\n }\n };\n\n var compile = function(string) {\n return EmberHandlebars.compile(string);\n };\n\n test(\"it does not trigger action with special clicks\", function() {\n var showCalled = false;\n\n view = EmberView.create({\n template: compile(\"Hi\")\n });\n\n var controller = EmberController.extend({\n actions: {\n show: function() {\n showCalled = true;\n }\n }\n }).create();\n\n run(function() {\n view.set('controller', controller);\n view.appendTo('#qunit-fixture');\n });\n\n function checkClick(prop, value, expected) {\n var event = jQuery.Event(\"click\");\n event[prop] = value;\n view.$('a').trigger(event);\n if (expected) {\n ok(showCalled, \"should call action with \"+prop+\":\"+value);\n ok(event.isDefaultPrevented(), \"should prevent default\");\n } else {\n ok(!showCalled, \"should not call action with \"+prop+\":\"+value);\n ok(!event.isDefaultPrevented(), \"should not prevent default\");\n }\n }\n\n checkClick('ctrlKey', true, false);\n checkClick('altKey', true, false);\n checkClick('metaKey', true, false);\n checkClick('shiftKey', true, false);\n checkClick('which', 2, false);\n\n checkClick('which', 1, true);\n checkClick('which', undefined, true); // IE <9\n });\n\n test(\"it can trigger actions for keyboard events\", function() {\n var showCalled = false;\n\n view = EmberView.create({\n template: compile(\"\")\n });\n\n var controller = EmberController.extend({\n actions: {\n show: function() {\n showCalled = true;\n }\n }\n }).create();\n\n run(function() {\n view.set('controller', controller);\n view.appendTo('#qunit-fixture');\n });\n\n var event = jQuery.Event(\"keyup\");\n event.char = 'a';\n event.which = 65;\n view.$('input').trigger(event);\n ok(showCalled, \"should call action with keyup\");\n });\n\n test(\"a quoteless parameter should allow dynamic lookup of the actionName\", function(){\n expect(4);\n var lastAction, actionOrder = [];\n\n view = EmberView.create({\n template: compile(\"Hi\")\n });\n\n var controller = EmberController.extend({\n hookMeUp: 'biggityBoom',\n actions: {\n biggityBoom: function() {\n lastAction = 'biggityBoom';\n actionOrder.push(lastAction);\n },\n whompWhomp: function() {\n lastAction = 'whompWhomp';\n actionOrder.push(lastAction);\n },\n sloopyDookie: function(){\n lastAction = 'sloopyDookie';\n actionOrder.push(lastAction);\n }\n }\n }).create();\n\n run(function() {\n view.set('controller', controller);\n view.appendTo('#qunit-fixture');\n });\n\n var testBoundAction = function(propertyValue){\n controller.set('hookMeUp', propertyValue);\n\n run(function(){\n view.$(\"#woot-bound-param\").click();\n });\n\n equal(lastAction, propertyValue, 'lastAction set to ' + propertyValue);\n };\n\n testBoundAction('whompWhomp');\n testBoundAction('sloopyDookie');\n testBoundAction('biggityBoom');\n\n deepEqual(actionOrder, ['whompWhomp', 'sloopyDookie', 'biggityBoom'], 'action name was looked up properly');\n });\n\n test(\"a quoteless parameter should lookup actionName in context\", function(){\n expect(4);\n var lastAction, actionOrder = [];\n\n view = EmberView.create({\n template: compile(\"{{#each allactions}}{{title}}{{/each}}\")\n });\n\n var controller = EmberController.extend({\n allactions: Ember.A([{title: 'Biggity Boom',name: 'biggityBoom'},\n {title: 'Whomp Whomp',name: 'whompWhomp'},\n {title: 'Sloopy Dookie',name: 'sloopyDookie'}]),\n actions: {\n biggityBoom: function() {\n lastAction = 'biggityBoom';\n actionOrder.push(lastAction);\n },\n whompWhomp: function() {\n lastAction = 'whompWhomp';\n actionOrder.push(lastAction);\n },\n sloopyDookie: function(){\n lastAction = 'sloopyDookie';\n actionOrder.push(lastAction);\n }\n }\n }).create();\n\n run(function() {\n view.set('controller', controller);\n view.appendTo('#qunit-fixture');\n });\n\n var testBoundAction = function(propertyValue){\n run(function(){\n view.$(\"#\"+propertyValue).click();\n });\n\n equal(lastAction, propertyValue, 'lastAction set to ' + propertyValue);\n };\n\n testBoundAction('whompWhomp');\n testBoundAction('sloopyDookie');\n testBoundAction('biggityBoom');\n\n deepEqual(actionOrder, ['whompWhomp', 'sloopyDookie', 'biggityBoom'], 'action name was looked up properly');\n });\n\n test(\"a quoteless parameter should resolve actionName, including path\", function(){\n expect(4);\n var lastAction, actionOrder = [];\n\n view = EmberView.create({\n template: compile(\"{{#each item in allactions}}{{item.title}}{{/each}}\")\n });\n\n var controller = EmberController.extend({\n allactions: Ember.A([{title: 'Biggity Boom',name: 'biggityBoom'},\n {title: 'Whomp Whomp',name: 'whompWhomp'},\n {title: 'Sloopy Dookie',name: 'sloopyDookie'}]),\n actions: {\n biggityBoom: function() {\n lastAction = 'biggityBoom';\n actionOrder.push(lastAction);\n },\n whompWhomp: function() {\n lastAction = 'whompWhomp';\n actionOrder.push(lastAction);\n },\n sloopyDookie: function(){\n lastAction = 'sloopyDookie';\n actionOrder.push(lastAction);\n }\n }\n }).create();\n\n run(function() {\n view.set('controller', controller);\n view.appendTo('#qunit-fixture');\n });\n\n var testBoundAction = function(propertyValue){\n run(function(){\n view.$(\"#\"+propertyValue).click();\n });\n\n equal(lastAction, propertyValue, 'lastAction set to ' + propertyValue);\n };\n\n testBoundAction('whompWhomp');\n testBoundAction('sloopyDookie');\n testBoundAction('biggityBoom');\n\n deepEqual(actionOrder, ['whompWhomp', 'sloopyDookie', 'biggityBoom'], 'action name was looked up properly');\n });\n\n test(\"a quoteless parameter that also exists as an action name functions properly\", function(){\n Ember.TESTING_DEPRECATION = true;\n var triggeredAction;\n\n view = EmberView.create({\n template: compile(\"Hi\")\n });\n\n var controller = EmberController.extend({\n actions: {\n ohNoeNotValid: function() {\n triggeredAction = true;\n }\n }\n }).create();\n\n run(function() {\n view.set('controller', controller);\n view.appendTo('#qunit-fixture');\n });\n\n run(function(){\n view.$(\"#oops-bound-param\").click();\n });\n\n ok(triggeredAction, 'the action was triggered');\n });\n\n test(\"a quoteless parameter that also exists as an action name results in an assertion\", function(){\n var triggeredAction;\n\n view = EmberView.create({\n template: compile(\"Hi\")\n });\n\n var controller = EmberController.extend({\n actions: {\n ohNoeNotValid: function() {\n triggeredAction = true;\n }\n }\n }).create();\n\n run(function() {\n view.set('controller', controller);\n view.appendTo('#qunit-fixture');\n });\n\n var oldAssert = Ember.assert;\n Ember.assert = function(message, test){\n ok(test, message + \" -- was properly asserted\");\n };\n\n run(function(){\n view.$(\"#oops-bound-param\").click();\n });\n\n ok(triggeredAction, 'the action was triggered');\n\n Ember.assert = oldAssert;\n });\n\n test(\"a quoteless parameter that also exists as an action name in deprecated action in controller style results in an assertion\", function(){\n var dropDeprecatedActionStyleOrig = Ember.FEATURES['ember-routing-drop-deprecated-action-style'];\n Ember.FEATURES['ember-routing-drop-deprecated-action-style'] = false;\n\n var triggeredAction;\n\n view = EmberView.create({\n template: compile(\"Hi\")\n });\n\n var controller = EmberController.extend({\n ohNoeNotValid: function() {\n triggeredAction = true;\n }\n }).create();\n\n run(function() {\n view.set('controller', controller);\n view.appendTo('#qunit-fixture');\n });\n\n var oldAssert = Ember.assert;\n Ember.assert = function(message, test){\n ok(test, message + \" -- was properly asserted\");\n };\n\n run(function(){\n view.$(\"#oops-bound-param\").click();\n });\n\n ok(triggeredAction, 'the action was triggered');\n\n Ember.assert = oldAssert;\n Ember.FEATURES['ember-routing-drop-deprecated-action-style'] = dropDeprecatedActionStyleOrig;\n });\n\n module(\"Ember.Handlebars - action helper - deprecated invoking directly on target\", {\n setup: function() {\n originalActionHelper = EmberHandlebars.helpers['action'];\n EmberHandlebars.registerHelper('action', actionHelper);\n\n dispatcher = EventDispatcher.create();\n dispatcher.setup();\n },\n\n teardown: function() {\n delete EmberHandlebars.helpers['action'];\n EmberHandlebars.helpers['action'] = originalActionHelper;\n\n run(function() {\n dispatcher.destroy();\n if (view) { view.destroy(); }\n });\n }\n });\n\n if (!Ember.FEATURES.isEnabled('ember-routing-drop-deprecated-action-style')) {\n test(\"should invoke a handler defined directly on the target (DEPRECATED)\", function() {\n var eventHandlerWasCalled,\n model = EmberObject.create();\n\n var controller = EmberController.extend({\n edit: function() {\n eventHandlerWasCalled = true;\n }\n }).create();\n\n view = EmberView.create({\n controller: controller,\n template: EmberHandlebars.compile('')\n });\n\n appendView();\n\n expectDeprecation(/Action handlers implemented directly on controllers are deprecated/);\n\n view.$('button').trigger('click');\n\n ok(eventHandlerWasCalled, \"the action was called\");\n });\n }\n\n test(\"should respect preventDefault=false option if provided\", function(){\n view = EmberView.create({\n template: compile(\"Hi\")\n });\n\n var controller = EmberController.extend({\n actions: {\n show: function() { }\n }\n }).create();\n\n run(function() {\n view.set('controller', controller);\n view.appendTo('#qunit-fixture');\n });\n\n var event = jQuery.Event(\"click\");\n view.$('a').trigger(event);\n\n equal(event.isDefaultPrevented(), false, \"should not preventDefault\");\n });\n });\ndefine(\"ember-routing/tests/helpers/outlet_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"container/container\",\"ember-runtime/system/namespace\",\"ember-runtime/system/string\",\"ember-runtime/controllers/controller\",\"ember-runtime/controllers/object_controller\",\"ember-runtime/controllers/array_controller\",\"ember-routing/system/router\",\"ember-routing/location/hash_location\",\"ember-handlebars\",\"ember-handlebars/views/metamorph_view\",\"ember-routing/ext/view\",\"ember-views/views/container_view\",\"ember-views/system/jquery\",\"ember-routing/helpers/outlet\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // TEMPLATES\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var run = __dependency4__[\"default\"];\n\n var Container = __dependency5__[\"default\"];\n var Namespace = __dependency6__[\"default\"];\n var decamelize = __dependency7__.decamelize;\n var classify = __dependency7__.classify;\n var Controller = __dependency8__.Controller;\n var ObjectController = __dependency9__[\"default\"];\n var ArrayController = __dependency10__[\"default\"];\n\n var EmberRouter = __dependency11__[\"default\"];\n var HashLocation = __dependency12__[\"default\"];\n\n var EmberHandlebars = __dependency13__[\"default\"];\n var _MetamorphView = __dependency14__._MetamorphView;\n var EmberView = __dependency15__[\"default\"];\n var EmberContainerView = __dependency16__[\"default\"];\n var jQuery = __dependency17__[\"default\"];\n\n var outletHelper = __dependency18__.outletHelper;\n\n var buildContainer = function(namespace) {\n var container = new Container();\n\n container.set = set;\n container.resolver = resolverFor(namespace);\n container.optionsForType('view', { singleton: false });\n container.optionsForType('template', { instantiate: false });\n container.register('application:main', namespace, { instantiate: false });\n container.injection('router:main', 'namespace', 'application:main');\n\n container.register('location:hash', HashLocation);\n\n container.register('controller:basic', Controller, { instantiate: false });\n container.register('controller:object', ObjectController, { instantiate: false });\n container.register('controller:array', ArrayController, { instantiate: false });\n\n container.typeInjection('route', 'router', 'router:main');\n\n return container;\n };\n\n function resolverFor(namespace) {\n return function(fullName) {\n var nameParts = fullName.split(\":\"),\n type = nameParts[0], name = nameParts[1];\n\n if (type === 'template') {\n var templateName = decamelize(name);\n if (Ember.TEMPLATES[templateName]) {\n return Ember.TEMPLATES[templateName];\n }\n }\n\n var className = classify(name) + classify(type);\n var factory = get(namespace, className);\n\n if (factory) { return factory; }\n };\n }\n\n var appendView = function(view) {\n run(function() { view.appendTo('#qunit-fixture'); });\n };\n\n var compile = EmberHandlebars.compile;\n var trim = jQuery.trim;\n\n var view, container, originalOutletHelper;\n\n module(\"Handlebars {{outlet}} helpers\", {\n\n setup: function() {\n originalOutletHelper = EmberHandlebars.helpers['outlet'];\n EmberHandlebars.registerHelper('outlet', outletHelper);\n\n var namespace = Namespace.create();\n container = buildContainer(namespace);\n container.register('view:default', EmberView.extend());\n container.register('router:main', EmberRouter.extend());\n },\n teardown: function() {\n delete EmberHandlebars.helpers['outlet'];\n EmberHandlebars.helpers['outlet'] = originalOutletHelper;\n\n run(function () {\n if (container) {\n container.destroy();\n }\n if (view) {\n view.destroy();\n }\n });\n }\n });\n\n test(\"view should support connectOutlet for the main outlet\", function() {\n var template = \"

    HI

    {{outlet}}\";\n view = EmberView.create({\n template: EmberHandlebars.compile(template)\n });\n\n appendView(view);\n\n equal(view.$().text(), 'HI');\n\n run(function() {\n view.connectOutlet('main', EmberView.create({\n template: compile(\"

    BYE

    \")\n }));\n });\n\n // Replace whitespace for older IE\n equal(trim(view.$().text()), 'HIBYE');\n });\n\n test(\"outlet should support connectOutlet in slots in prerender state\", function() {\n var template = \"

    HI

    {{outlet}}\";\n view = EmberView.create({\n template: EmberHandlebars.compile(template)\n });\n\n view.connectOutlet('main', EmberView.create({\n template: compile(\"

    BYE

    \")\n }));\n\n appendView(view);\n\n equal(view.$().text(), 'HIBYE');\n });\n\n test(\"outlet should support an optional name\", function() {\n var template = \"

    HI

    {{outlet mainView}}\";\n view = EmberView.create({\n template: EmberHandlebars.compile(template)\n });\n\n appendView(view);\n\n equal(view.$().text(), 'HI');\n\n run(function() {\n view.connectOutlet('mainView', EmberView.create({\n template: compile(\"

    BYE

    \")\n }));\n });\n\n // Replace whitespace for older IE\n equal(trim(view.$().text()), 'HIBYE');\n });\n\n\n test(\"outlet should correctly lookup a view\", function() {\n\n var template,\n ContainerView,\n childView;\n\n ContainerView = EmberContainerView.extend();\n\n container.register(\"view:containerView\", ContainerView);\n\n template = \"

    HI

    {{outlet view='containerView'}}\";\n\n view = EmberView.create({\n template: EmberHandlebars.compile(template),\n container : container\n });\n\n childView = EmberView.create({\n template: compile(\"

    BYE

    \")\n });\n\n appendView(view);\n\n equal(view.$().text(), 'HI');\n\n run(function() {\n view.connectOutlet('main', childView);\n });\n\n ok(ContainerView.detectInstance(childView.get('_parentView')), \"The custom view class should be used for the outlet\");\n\n // Replace whitespace for older IE\n equal(trim(view.$().text()), 'HIBYE');\n\n });\n\n test(\"outlet should assert view is specified as a string\", function() {\n\n var template = \"

    HI

    {{outlet view=containerView}}\";\n\n expectAssertion(function () {\n\n view = EmberView.create({\n template: EmberHandlebars.compile(template),\n container : container\n });\n\n appendView(view);\n\n });\n\n });\n\n test(\"outlet should assert view path is successfully resolved\", function() {\n\n var template = \"

    HI

    {{outlet view='someViewNameHere'}}\";\n\n expectAssertion(function () {\n\n view = EmberView.create({\n template: EmberHandlebars.compile(template),\n container : container\n });\n\n appendView(view);\n\n });\n\n });\n\n test(\"outlet should support an optional view class\", function() {\n var template = \"

    HI

    {{outlet viewClass=view.outletView}}\";\n view = EmberView.create({\n template: EmberHandlebars.compile(template),\n outletView: EmberContainerView.extend()\n });\n\n appendView(view);\n\n equal(view.$().text(), 'HI');\n\n var childView = EmberView.create({\n template: compile(\"

    BYE

    \")\n });\n\n run(function() {\n view.connectOutlet('main', childView);\n });\n\n ok(view.outletView.detectInstance(childView.get('_parentView')), \"The custom view class should be used for the outlet\");\n\n // Replace whitespace for older IE\n equal(trim(view.$().text()), 'HIBYE');\n });\n\n\n test(\"Outlets bind to the current view, not the current concrete view\", function() {\n var parentTemplate = \"

    HI

    {{outlet}}\";\n var middleTemplate = \"

    MIDDLE

    {{outlet}}\";\n var bottomTemplate = \"

    BOTTOM

    \";\n\n view = EmberView.create({\n template: compile(parentTemplate)\n });\n\n var middleView = _MetamorphView.create({\n template: compile(middleTemplate)\n });\n\n var bottomView = _MetamorphView.create({\n template: compile(bottomTemplate)\n });\n\n appendView(view);\n\n run(function() {\n view.connectOutlet('main', middleView);\n });\n\n run(function() {\n middleView.connectOutlet('main', bottomView);\n });\n\n var output = jQuery('#qunit-fixture h1 ~ h2 ~ h3').text();\n equal(output, \"BOTTOM\", \"all templates were rendered\");\n });\n\n test(\"view should support disconnectOutlet for the main outlet\", function() {\n var template = \"

    HI

    {{outlet}}\";\n view = EmberView.create({\n template: EmberHandlebars.compile(template)\n });\n\n appendView(view);\n\n equal(view.$().text(), 'HI');\n\n run(function() {\n view.connectOutlet('main', EmberView.create({\n template: compile(\"

    BYE

    \")\n }));\n });\n\n // Replace whitespace for older IE\n equal(trim(view.$().text()), 'HIBYE');\n\n run(function() {\n view.disconnectOutlet('main');\n });\n\n // Replace whitespace for older IE\n equal(trim(view.$().text()), 'HI');\n });\n\n test(\"Outlets bind to the current template's view, not inner contexts\", function() {\n var parentTemplate = \"

    HI

    {{#if view.alwaysTrue}}{{#with this}}{{outlet}}{{/with}}{{/if}}\";\n var bottomTemplate = \"

    BOTTOM

    \";\n\n view = EmberView.create({\n alwaysTrue: true,\n template: compile(parentTemplate)\n });\n\n var bottomView = _MetamorphView.create({\n template: compile(bottomTemplate)\n });\n\n appendView(view);\n\n run(function() {\n view.connectOutlet('main', bottomView);\n });\n\n var output = jQuery('#qunit-fixture h1 ~ h3').text();\n equal(output, \"BOTTOM\", \"all templates were rendered\");\n });\n\n test(\"should support layouts\", function() {\n var template = \"{{outlet}}\",\n layout = \"

    HI

    {{yield}}\";\n view = EmberView.create({\n template: EmberHandlebars.compile(template),\n layout: EmberHandlebars.compile(layout)\n });\n\n appendView(view);\n\n equal(view.$().text(), 'HI');\n\n run(function() {\n view.connectOutlet('main', EmberView.create({\n template: compile(\"

    BYE

    \")\n }));\n });\n // Replace whitespace for older IE\n equal(trim(view.$().text()), 'HIBYE');\n });\n });\ndefine(\"ember-routing/tests/helpers/render_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-metal/platform\",\"ember-metal/mixin\",\"container/container\",\"ember-runtime/system/namespace\",\"ember-runtime/system/string\",\"ember-runtime/controllers/controller\",\"ember-runtime/controllers/object_controller\",\"ember-runtime/controllers/array_controller\",\"ember-routing/system/router\",\"ember-routing/location/hash_location\",\"ember-handlebars\",\"ember-routing/ext/view\",\"ember-views/system/jquery\",\"ember-routing/helpers/render\",\"ember-routing/helpers/action\",\"ember-routing/helpers/outlet\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__, __dependency16__, __dependency17__, __dependency18__, __dependency19__, __dependency20__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // TEMPLATES\n var get = __dependency2__.get;\n var emberSet = __dependency3__.set;\n var run = __dependency4__[\"default\"];\n var create = __dependency5__.create;\n var observer = __dependency6__.observer;\n\n var Container = __dependency7__[\"default\"];\n var Namespace = __dependency8__[\"default\"];\n var classify = __dependency9__.classify;\n var decamelize = __dependency9__.decamelize;\n\n var EmberController = __dependency10__.Controller;\n var EmberObjectController = __dependency11__[\"default\"];\n var EmberArrayController = __dependency12__[\"default\"];\n\n var EmberRouter = __dependency13__[\"default\"];\n var HashLocation = __dependency14__[\"default\"];\n\n var EmberHandlebars = __dependency15__[\"default\"];\n var EmberView = __dependency16__[\"default\"];\n var jQuery = __dependency17__[\"default\"];\n\n var renderHelper = __dependency18__[\"default\"];\n var ActionHelper = __dependency19__.ActionHelper;\n var actionHelper = __dependency19__.actionHelper;\n var outletHelper = __dependency20__.outletHelper;\n\n var appendView = function(view) {\n run(function() { view.appendTo('#qunit-fixture'); });\n };\n\n var set = function(object, key, value) {\n run(function() { emberSet(object, key, value); });\n };\n\n var compile = function(template) {\n return EmberHandlebars.compile(template);\n };\n\n var buildContainer = function(namespace) {\n var container = new Container();\n\n container.set = emberSet;\n container.resolver = resolverFor(namespace);\n container.optionsForType('view', { singleton: false });\n container.optionsForType('template', { instantiate: false });\n container.register('application:main', namespace, { instantiate: false });\n container.injection('router:main', 'namespace', 'application:main');\n\n container.register('location:hash', HashLocation);\n\n container.register('controller:basic', EmberController, { instantiate: false });\n container.register('controller:object', EmberObjectController, { instantiate: false });\n container.register('controller:array', EmberArrayController, { instantiate: false });\n\n container.typeInjection('route', 'router', 'router:main');\n\n return container;\n };\n\n function resolverFor(namespace) {\n return function(fullName) {\n var nameParts = fullName.split(\":\"),\n type = nameParts[0], name = nameParts[1];\n\n if (type === 'template') {\n var templateName = decamelize(name);\n if (Ember.TEMPLATES[templateName]) {\n return Ember.TEMPLATES[templateName];\n }\n }\n\n var className = classify(name) + classify(type);\n var factory = get(namespace, className);\n\n if (factory) { return factory; }\n };\n }\n\n var view, container, originalRenderHelper, originalActionHelper, originalOutletHelper;\n\n module(\"Handlebars {{render}} helper\", {\n setup: function() {\n originalOutletHelper = EmberHandlebars.helpers['outlet'];\n EmberHandlebars.registerHelper('outlet', outletHelper);\n\n originalRenderHelper = EmberHandlebars.helpers['render'];\n EmberHandlebars.registerHelper('render', renderHelper);\n\n originalActionHelper = EmberHandlebars.helpers['action'];\n EmberHandlebars.registerHelper('action', actionHelper);\n\n\n var namespace = Namespace.create();\n container = buildContainer(namespace);\n container.register('view:default', EmberView.extend());\n container.register('router:main', EmberRouter.extend());\n },\n teardown: function() {\n delete EmberHandlebars.helpers['render'];\n EmberHandlebars.helpers['render'] = originalRenderHelper;\n\n delete EmberHandlebars.helpers['action'];\n EmberHandlebars.helpers['action'] = originalActionHelper;\n\n delete EmberHandlebars.helpers['outlet'];\n EmberHandlebars.helpers['outlet'] = originalOutletHelper;\n\n run(function () {\n if (container) {\n container.destroy();\n }\n if (view) {\n view.destroy();\n }\n });\n\n Ember.TEMPLATES = {};\n }\n });\n\n test(\"{{render}} helper should render given template\", function() {\n var template = \"

    HI

    {{render 'home'}}\";\n var controller = EmberController.extend({container: container});\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n Ember.TEMPLATES['home'] = compile(\"

    BYE

    \");\n\n appendView(view);\n\n equal(view.$().text(), 'HIBYE');\n ok(container.lookup('router:main')._lookupActiveView('home'), 'should register home as active view');\n });\n\n test(\"{{render}} helper should have assertion if neither template nor view exists\", function() {\n var template = \"

    HI

    {{render 'oops'}}\";\n var controller = EmberController.extend({container: container});\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n expectAssertion(function() {\n appendView(view);\n }, 'You used `{{render \\'oops\\'}}`, but \\'oops\\' can not be found as either a template or a view.');\n });\n\n test(\"{{render}} helper should not have assertion if template is supplied in block-form\", function() {\n var template = \"

    HI

    {{#render 'good'}} {{name}}{{/render}}\";\n var controller = EmberController.extend({container: container});\n container.register('controller:good', EmberController.extend({ name: 'Rob'}));\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n appendView(view);\n\n equal(view.$().text(), 'HI Rob');\n });\n\n test(\"{{render}} helper should not have assertion if view exists without a template\", function() {\n var template = \"

    HI

    {{render 'oops'}}\";\n var controller = EmberController.extend({container: container});\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n container.register('view:oops', EmberView.extend());\n\n appendView(view);\n\n equal(view.$().text(), 'HI');\n });\n\n test(\"{{render}} helper should render given template with a supplied model\", function() {\n var template = \"

    HI

    {{render 'post' post}}\";\n var post = {\n title: \"Rails is omakase\"\n };\n\n var Controller = EmberController.extend({\n container: container,\n post: post\n });\n\n var controller = Controller.create({\n });\n\n view = EmberView.create({\n controller: controller,\n template: compile(template)\n });\n\n var PostController = EmberObjectController.extend();\n container.register('controller:post', PostController);\n\n Ember.TEMPLATES['post'] = compile(\"

    {{title}}

    \");\n\n appendView(view);\n\n var postController = view.get('_childViews')[0].get('controller');\n\n equal(view.$().text(), 'HIRails is omakase');\n equal(postController.get('model'), post);\n\n set(controller, 'post', { title: \"Rails is unagi\" });\n\n equal(view.$().text(), 'HIRails is unagi');\n if (create.isSimulated) {\n equal(postController.get('model').title, \"Rails is unagi\");\n } else {\n deepEqual(postController.get('model'), { title: \"Rails is unagi\" });\n }\n });\n\n test(\"{{render}} helper with a supplied model should not fire observers on the controller\", function () {\n var template = \"

    HI

    {{render 'post' post}}\";\n var post = {\n title: \"Rails is omakase\"\n };\n\n view = EmberView.create({\n controller: EmberController.create({\n container: container,\n post: post\n }),\n template: compile(template)\n });\n\n var PostController = EmberObjectController.extend({\n contentDidChange: observer('content', function(){\n contentDidChange++;\n })\n });\n\n container.register('controller:post', PostController);\n\n Ember.TEMPLATES['post'] = compile(\"

    {{title}}

    \");\n\n var contentDidChange = 0;\n appendView(view);\n equal(contentDidChange, 0, \"content observer did not fire\");\n\n });\n\n test(\"{{render}} helper should raise an error when a given controller name does not resolve to a controller\", function() {\n var template = '

    HI

    {{render \"home\" controller=\"postss\"}}';\n var controller = EmberController.extend({container: container});\n container.register('controller:posts', EmberArrayController.extend());\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n Ember.TEMPLATES['home'] = compile(\"

    BYE

    \");\n\n expectAssertion(function() {\n appendView(view);\n }, 'The controller name you supplied \\'postss\\' did not resolve to a controller.');\n });\n\n test(\"{{render}} helper should render with given controller\", function() {\n var template = '

    HI

    {{render \"home\" controller=\"posts\"}}';\n var controller = EmberController.extend({container: container});\n container.register('controller:posts', EmberArrayController.extend());\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n Ember.TEMPLATES['home'] = compile(\"

    BYE

    \");\n\n appendView(view);\n\n var renderedView = container.lookup('router:main')._lookupActiveView('home');\n equal(container.lookup('controller:posts'), renderedView.get('controller'), 'rendered with correct controller');\n });\n\n test(\"{{render}} helper should render a template without a model only once\", function() {\n var template = \"

    HI

    {{render 'home'}}
    {{render home}}\";\n var controller = EmberController.extend({container: container});\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n Ember.TEMPLATES['home'] = compile(\"

    BYE

    \");\n\n expectAssertion(function() {\n appendView(view);\n }, /\\{\\{render\\}\\} helper once/i);\n });\n\n test(\"{{render}} helper should render templates with models multiple times\", function() {\n var template = \"

    HI

    {{render 'post' post1}} {{render 'post' post2}}\";\n var post1 = {\n title: \"Me first\"\n };\n var post2 = {\n title: \"Then me\"\n };\n\n var Controller = EmberController.extend({\n container: container,\n post1: post1,\n post2: post2\n });\n\n var controller = Controller.create();\n\n view = EmberView.create({\n controller: controller,\n template: compile(template)\n });\n\n var PostController = EmberObjectController.extend();\n container.register('controller:post', PostController, {singleton: false});\n\n Ember.TEMPLATES['post'] = compile(\"

    {{title}}

    \");\n\n appendView(view);\n\n var postController1 = view.get('_childViews')[0].get('controller');\n var postController2 = view.get('_childViews')[1].get('controller');\n\n ok(view.$().text().match(/^HI ?Me first ?Then me$/));\n equal(postController1.get('model'), post1);\n equal(postController2.get('model'), post2);\n\n set(controller, 'post1', { title: \"I am new\" });\n\n ok(view.$().text().match(/^HI ?I am new ?Then me$/));\n if (create.isSimulated) {\n equal(postController1.get('model').title, \"I am new\");\n } else {\n deepEqual(postController1.get('model'), { title: \"I am new\" });\n }\n });\n\n test(\"{{render}} helper should not leak controllers\", function() {\n var template = \"

    HI

    {{render 'post' post1}}\";\n var post1 = {\n title: \"Me first\"\n };\n\n var Controller = EmberController.extend({\n container: container,\n post1: post1\n });\n\n var controller = Controller.create();\n\n view = EmberView.create({\n controller: controller,\n template: compile(template)\n });\n\n var PostController = EmberObjectController.extend();\n container.register('controller:post', PostController);\n\n Ember.TEMPLATES['post'] = compile(\"

    {{title}}

    \");\n\n appendView(view);\n\n var postController1 = view.get('_childViews')[0].get('controller');\n\n run(view, 'destroy');\n\n ok(postController1.isDestroyed, 'expected postController to be destroyed');\n });\n\n test(\"{{render}} helper should not treat invocations with falsy contexts as context-less\", function() {\n var template = \"

    HI

    {{render 'post' zero}} {{render 'post' nonexistent}}\";\n\n view = EmberView.create({\n controller: EmberController.createWithMixins({\n container: container,\n zero: false\n }),\n template: compile(template)\n });\n\n var PostController = EmberObjectController.extend();\n container.register('controller:post', PostController, {singleton: false});\n\n Ember.TEMPLATES['post'] = compile(\"

    {{#unless content}}NOTHING{{/unless}}

    \");\n\n appendView(view);\n\n var postController1 = view.get('_childViews')[0].get('controller');\n var postController2 = view.get('_childViews')[1].get('controller');\n\n ok(view.$().text().match(/^HI ?NOTHING ?NOTHING$/));\n equal(postController1.get('model'), 0);\n equal(postController2.get('model'), undefined);\n });\n\n test(\"{{render}} helper should render templates both with and without models\", function() {\n var template = \"

    HI

    {{render 'post'}} {{render 'post' post}}\";\n var post = {\n title: \"Rails is omakase\"\n };\n\n var Controller = EmberController.extend({\n container: container,\n post: post\n });\n\n var controller = Controller.create();\n\n view = EmberView.create({\n controller: controller,\n template: compile(template)\n });\n\n var PostController = EmberObjectController.extend();\n container.register('controller:post', PostController, {singleton: false});\n\n Ember.TEMPLATES['post'] = compile(\"

    Title:{{title}}

    \");\n\n appendView(view);\n\n var postController1 = view.get('_childViews')[0].get('controller');\n var postController2 = view.get('_childViews')[1].get('controller');\n\n ok(view.$().text().match(/^HI ?Title: ?Title:Rails is omakase$/));\n equal(postController1.get('model'), null);\n equal(postController2.get('model'), post);\n\n set(controller, 'post', { title: \"Rails is unagi\" });\n\n ok(view.$().text().match(/^HI ?Title: ?Title:Rails is unagi$/));\n if (create.isSimulated) {\n equal(postController2.get('model').title, \"Rails is unagi\");\n } else {\n deepEqual(postController2.get('model'), { title: \"Rails is unagi\" });\n }\n });\n\n test(\"{{render}} helper should link child controllers to the parent controller\", function() {\n var parentTriggered = 0;\n\n var template = '

    HI

    {{render \"posts\"}}';\n var controller = EmberController.extend({\n container: container,\n actions: {\n parentPlease: function() {\n parentTriggered++;\n }\n },\n role: \"Mom\"\n });\n\n container.register('controller:posts', EmberArrayController.extend());\n\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n Ember.TEMPLATES['posts'] = compile('');\n\n appendView(view);\n\n var button = jQuery(\"#parent-action\"),\n actionId = button.data('ember-action'),\n action = ActionHelper.registeredActions[actionId],\n handler = action.handler;\n\n equal(button.text(), \"Go to Mom\", \"The parentController property is set on the child controller\");\n\n run(null, handler, new jQuery.Event(\"click\"));\n\n equal(parentTriggered, 1, \"The event bubbled to the parent\");\n });\n\n test(\"{{render}} helper should be able to render a template again when it was removed\", function() {\n var template = \"

    HI

    {{outlet}}\";\n var controller = EmberController.extend({container: container});\n view = EmberView.create({\n template: compile(template)\n });\n\n Ember.TEMPLATES['home'] = compile(\"

    BYE

    \");\n\n appendView(view);\n\n run(function() {\n view.connectOutlet('main', EmberView.create({\n controller: controller.create(),\n template: compile(\"

    1{{render 'home'}}

    \")\n }));\n });\n\n equal(view.$().text(), 'HI1BYE');\n\n run(function() {\n view.connectOutlet('main', EmberView.create({\n controller: controller.create(),\n template: compile(\"

    2{{render 'home'}}

    \")\n }));\n });\n\n equal(view.$().text(), 'HI2BYE');\n });\n\n test(\"{{render}} works with dot notation\", function() {\n var template = '

    BLOG

    {{render \"blog.post\"}}';\n\n var controller = EmberController.extend({container: container});\n container.register('controller:blog.post', EmberObjectController.extend());\n\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n Ember.TEMPLATES['blog.post'] = compile(\"

    POST

    \");\n\n appendView(view);\n\n var renderedView = container.lookup('router:main')._lookupActiveView('blog.post');\n equal(renderedView.get('viewName'), 'blogPost', 'camelizes the view name');\n equal(container.lookup('controller:blog.post'), renderedView.get('controller'), 'rendered with correct controller');\n });\n\n test(\"{{render}} works with slash notation\", function() {\n var template = '

    BLOG

    {{render \"blog/post\"}}';\n\n var controller = EmberController.extend({container: container});\n container.register('controller:blog.post', EmberObjectController.extend());\n\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n Ember.TEMPLATES['blog.post'] = compile(\"

    POST

    \");\n\n appendView(view);\n\n var renderedView = container.lookup('router:main')._lookupActiveView('blog.post');\n equal(renderedView.get('viewName'), 'blogPost', 'camelizes the view name');\n equal(container.lookup('controller:blog.post'), renderedView.get('controller'), 'rendered with correct controller');\n });\n\n test(\"Using quoteless templateName works properly (DEPRECATED)\", function(){\n var template = '

    HI

    {{render home}}';\n var controller = EmberController.extend({container: container});\n view = EmberView.create({\n controller: controller.create(),\n template: compile(template)\n });\n\n Ember.TEMPLATES['home'] = compile(\"

    BYE

    \");\n\n expectDeprecation(\"Using a quoteless parameter with {{render}} is deprecated. Please update to quoted usage '{{render \\\"home\\\"}}.\");\n appendView(view);\n\n equal(view.$('p:contains(BYE)').length, 1, \"template was rendered\");\n });\n });\ndefine(\"ember-routing/tests/location/auto_location_test\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-runtime/copy\",\"ember-runtime/system/object\",\"ember-routing/location/auto_location\",\"ember-routing/location/api\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__) {\n \"use strict\";\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n var run = __dependency3__[\"default\"];\n var copy = __dependency4__[\"default\"];\n var EmberObject = __dependency5__[\"default\"];\n var AutoLocation = __dependency6__[\"default\"];\n var EmberLocation = __dependency7__[\"default\"];\n\n var AutoTestLocation, location, supportsHistory, supportsHashChange,\n getSupportsHistory = AutoLocation._getSupportsHistory,\n getSupportsHashChange = AutoLocation._getSupportsHashChange;\n\n var FakeHistoryLocation = EmberObject.extend({\n implementation: 'history'\n });\n\n var FakeHashLocation = EmberObject.extend({\n implementation: 'hash'\n });\n\n var FakeNoneLocation = EmberObject.extend({\n implementation: 'none'\n });\n\n function createLocation(options) {\n if (!options) { options = {}; }\n location = AutoTestLocation.create(options);\n }\n\n module(\"Ember.AutoLocation\", {\n setup: function() {\n supportsHistory = supportsHashChange = null;\n\n AutoTestLocation = copy(AutoLocation);\n\n AutoTestLocation._HistoryLocation = FakeHistoryLocation;\n AutoTestLocation._HashLocation = FakeHashLocation;\n AutoTestLocation._NoneLocation = FakeNoneLocation;\n\n AutoTestLocation._getSupportsHistory = function () {\n if (supportsHistory !== null) {\n return supportsHistory;\n } else {\n return getSupportsHistory.call(this);\n }\n };\n\n AutoTestLocation._getSupportsHashChange = function () {\n if (supportsHashChange !== null) {\n return supportsHashChange;\n } else {\n return getSupportsHashChange.call(this);\n }\n };\n\n AutoTestLocation._window = {\n document: {},\n navigator: {\n userAgent: ''\n }\n };\n\n AutoTestLocation._location = {\n href: 'http://test.com/',\n pathname: '/',\n hash: '',\n search: '',\n replace: function () {\n ok(false, 'location.replace should not be called');\n }\n };\n\n AutoTestLocation._history = {\n pushState: function () {\n ok(false, 'history.pushState should not be called');\n },\n replaceState: function () {\n ok(false, 'history.replaceState should not be called');\n }\n };\n },\n\n teardown: function() {\n run(function() {\n if (location && location.destroy) { location.destroy(); }\n location = AutoTestLocation = null;\n });\n }\n });\n\n test(\"_replacePath cannot be used to redirect to a different origin (website)\", function() {\n expect(1);\n\n var expectedURL;\n\n AutoTestLocation._location = {\n protocol: 'http:',\n hostname: 'emberjs.com',\n port: '1337',\n\n replace: function (url) {\n equal(url, expectedURL);\n }\n };\n\n expectedURL = 'http://emberjs.com:1337//google.com';\n AutoTestLocation._replacePath('//google.com');\n });\n\n test(\"AutoLocation.create() should return a HistoryLocation instance when pushStates are supported\", function() {\n expect(2);\n\n supportsHistory = true;\n\n createLocation();\n\n equal(get(location, 'implementation'), 'history');\n equal(location instanceof FakeHistoryLocation, true);\n });\n\n test(\"AutoLocation.create() should return a HashLocation instance when pushStates are not supported, but hashchange events are and the URL is already in the HashLocation format\", function() {\n expect(2);\n\n supportsHistory = false;\n supportsHashChange = true;\n\n AutoTestLocation._location.hash = '#/testd';\n\n createLocation();\n\n equal(get(location, 'implementation'), 'hash');\n equal(location instanceof FakeHashLocation, true);\n });\n\n test(\"AutoLocation.create() should return a NoneLocation instance when neither history nor hashchange is supported.\", function() {\n expect(2);\n\n supportsHistory = false;\n supportsHashChange = false;\n\n AutoTestLocation._location.hash = '#/testd';\n\n createLocation();\n\n equal(get(location, 'implementation'), 'none');\n equal(location instanceof FakeNoneLocation, true);\n });\n\n test(\"AutoLocation.create() should consider an index path (i.e. '/\\') without any location.hash as OK for HashLocation\", function() {\n expect(2);\n\n supportsHistory = false;\n supportsHashChange = true;\n\n AutoTestLocation._location = {\n href: 'http://test.com/',\n pathname: '/',\n hash: '',\n search: '',\n replace: function (path) {\n ok(false, 'location.replace should not be called');\n }\n };\n\n createLocation();\n\n equal(get(location, 'implementation'), 'hash');\n equal(location instanceof FakeHashLocation, true);\n });\n\n test(\"AutoLocation._getSupportsHistory() should use `history.pushState` existance as proof of support\", function() {\n expect(3);\n\n AutoTestLocation._history.pushState = function () {};\n equal(AutoTestLocation._getSupportsHistory(), true, 'Returns true if `history.pushState` exists');\n\n delete AutoTestLocation._history.pushState;\n equal(AutoTestLocation._getSupportsHistory(), false, 'Returns false if `history.pushState` does not exist');\n\n AutoTestLocation._history = undefined;\n equal(AutoTestLocation._getSupportsHistory(), false, 'Returns false if `history` does not exist');\n });\n\n test(\"AutoLocation.create() should transform the URL for hashchange-only browsers viewing a HistoryLocation-formatted path\", function() {\n expect(4);\n\n supportsHistory = false;\n supportsHashChange = true;\n\n AutoTestLocation._location = {\n hash: '',\n hostname: 'test.com',\n href: 'http://test.com/test',\n pathname: '/test',\n protocol: 'http:',\n port: '',\n search: '',\n\n replace: function (path) {\n equal(path, 'http://test.com/#/test', 'location.replace should be called with normalized HashLocation path');\n }\n };\n\n createLocation();\n\n equal(get(location, 'implementation'), 'none', 'NoneLocation should be returned while we attempt to location.replace()');\n equal(location instanceof FakeNoneLocation, true, 'NoneLocation should be returned while we attempt to location.replace()');\n equal(get(location, 'cancelRouterSetup'), true, 'cancelRouterSetup should be set so the router knows.');\n });\n\n test(\"AutoLocation.create() should transform the URL for pushState-supported browsers viewing a HashLocation-formatted url\", function() {\n expect(4);\n\n supportsHistory = true;\n supportsHashChange = true;\n\n AutoTestLocation._location = {\n hash: '#/test',\n hostname: 'test.com',\n href: 'http://test.com/#/test',\n pathname: '/',\n protocol: 'http:',\n port: '',\n search: '',\n\n replace: function (path) {\n equal(path, 'http://test.com/test', 'location.replace should be called with normalized HistoryLocation url');\n }\n };\n\n createLocation();\n\n equal(get(location, 'implementation'), 'none', 'NoneLocation should be returned while we attempt to location.replace()');\n equal(location instanceof FakeNoneLocation, true, 'NoneLocation should be returned while we attempt to location.replace()');\n equal(get(location, 'cancelRouterSetup'), true, 'cancelRouterSetup should be set so the router knows.');\n });\n\n test(\"AutoLocation._getSupportsHistory() should handle false positive for Android 2.2/2.3, returning false\", function() {\n expect(1);\n\n var fakeNavigator = {\n userAgent: 'Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'\n };\n\n AutoTestLocation._window.navigator = fakeNavigator;\n\n equal(AutoTestLocation._getSupportsHistory(), false);\n });\n\n test(\"AutoLocation._getSupportsHashChange() should use `onhashchange` event existance as proof of support\", function() {\n expect(2);\n\n AutoTestLocation._window.onhashchange = null;\n equal(AutoTestLocation._getSupportsHashChange(), true, 'Returns true if `onhashchange` exists');\n\n AutoTestLocation._window = {\n navigator: window.navigator,\n document: {}\n };\n\n equal(AutoTestLocation._getSupportsHashChange(), false, 'Returns false if `onhashchange` does not exist');\n });\n\n test(\"AutoLocation._getSupportsHashChange() should handle false positive for IE8 running in IE7 compatibility mode, returning false\", function() {\n expect(1);\n\n AutoTestLocation._window = {\n onhashchange: null,\n document: {\n documentMode: 7\n }\n };\n\n equal(AutoTestLocation._getSupportsHashChange(), false);\n });\n\n test(\"AutoLocation._getPath() should normalize location.pathname, making sure it always returns a leading slash\", function() {\n expect(2);\n\n AutoTestLocation._location = { pathname: 'test' };\n equal(AutoTestLocation._getPath(), '/test', 'When there is no leading slash, one is added.');\n\n AutoTestLocation._location = { pathname: '/test' };\n equal(AutoTestLocation._getPath(), '/test', 'When a leading slash is already there, it isn\\'t added again');\n });\n\n test(\"AutoLocation._getHash() should be an alias to Ember.Location._getHash, otherwise it needs its own test!\", function() {\n expect(1);\n\n equal(AutoTestLocation._getHash, EmberLocation._getHash);\n });\n\n test(\"AutoLocation._getQuery() should return location.search as-is\", function() {\n expect(1);\n\n AutoTestLocation._location = { search: '?foo=bar' };\n equal(AutoTestLocation._getQuery(), '?foo=bar');\n });\n\n test(\"AutoLocation._getFullPath() should return full pathname including query and hash\", function() {\n expect(1);\n\n AutoTestLocation._location = {\n href: 'http://test.com/about?foo=bar#foo',\n pathname: '/about',\n search: '?foo=bar',\n hash: '#foo'\n };\n\n equal(AutoTestLocation._getFullPath(), '/about?foo=bar#foo');\n });\n\n test(\"AutoLocation._getHistoryPath() should return a normalized, HistoryLocation-supported path\", function() {\n expect(3);\n\n AutoTestLocation.rootURL = '/app/';\n\n AutoTestLocation._location = {\n href: 'http://test.com/app/about?foo=bar#foo',\n pathname: '/app/about',\n search: '?foo=bar',\n hash: '#foo'\n };\n equal(AutoTestLocation._getHistoryPath(), '/app/about?foo=bar#foo', 'URLs already in HistoryLocation form should come out the same');\n\n AutoTestLocation._location = {\n href: 'http://test.com/app/#/about?foo=bar#foo',\n pathname: '/app/',\n search: '',\n hash: '#/about?foo=bar#foo'\n };\n equal(AutoTestLocation._getHistoryPath(), '/app/about?foo=bar#foo', 'HashLocation formed URLs should be normalized');\n\n AutoTestLocation._location = {\n href: 'http://test.com/app/#about?foo=bar#foo',\n pathname: '/app/',\n search: '',\n hash: '#about?foo=bar#foo'\n };\n equal(AutoTestLocation._getHistoryPath(), '/app/#about?foo=bar#foo', 'URLs with a hash not following #/ convention shouldn\\'t be normalized as a route');\n });\n\n test(\"AutoLocation._getHashPath() should return a normalized, HashLocation-supported path\", function() {\n expect(3);\n\n AutoTestLocation.rootURL = '/app/';\n\n AutoTestLocation._location = {\n href: 'http://test.com/app/#/about?foo=bar#foo',\n pathname: '/app/',\n search: '',\n hash: '#/about?foo=bar#foo'\n };\n equal(AutoTestLocation._getHashPath(), '/app/#/about?foo=bar#foo', 'URLs already in HistoryLocation form should come out the same');\n\n AutoTestLocation._location = {\n href: 'http://test.com/app/about?foo=bar#foo',\n pathname: '/app/about',\n search: '?foo=bar',\n hash: '#foo'\n };\n equal(AutoTestLocation._getHashPath(), '/app/#/about?foo=bar#foo', 'HistoryLocation formed URLs should be normalized');\n\n AutoTestLocation._location = {\n href: 'http://test.com/app/#about?foo=bar#foo',\n pathname: '/app/',\n search: '',\n hash: '#about?foo=bar#foo'\n };\n\n equal(AutoTestLocation._getHashPath(), '/app/#/#about?foo=bar#foo', 'URLs with a hash not following #/ convention shouldn\\'t be normalized as a route');\n });\n\n test(\"AutoLocation.create requires any rootURL given to end in a trailing forward slash\", function() {\n expect(3);\n\n var expectedMsg = /rootURL must end with a trailing forward slash e.g. \"\\/app\\/\"/;\n\n expectAssertion(function() {\n createLocation({ rootURL: 'app' });\n }, expectedMsg);\n\n expectAssertion(function() {\n createLocation({ rootURL: '/app' });\n }, expectedMsg);\n\n expectAssertion(function() {\n // Note the trailing whitespace\n createLocation({ rootURL: '/app/ ' });\n }, expectedMsg);\n });\n });\ndefine(\"ember-routing/tests/location/history_location_test\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-routing/location/history_location\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n var run = __dependency3__[\"default\"];\n var HistoryLocation = __dependency4__[\"default\"];\n\n var FakeHistory, HistoryTestLocation, location,\n rootURL = window.location.pathname;\n\n function createLocation(options){\n if(!options) { options = {}; }\n location = HistoryTestLocation.create(options);\n }\n\n module(\"Ember.HistoryLocation\", {\n setup: function() {\n FakeHistory = {\n state: null,\n _states: [],\n replaceState: function(state, title, url){\n this.state = state;\n this._states[0] = state;\n },\n pushState: function(state, title, url){\n this.state = state;\n this._states.unshift(state);\n }\n };\n\n HistoryTestLocation = HistoryLocation.extend({\n history: FakeHistory\n });\n },\n\n teardown: function() {\n run(function() {\n if (location) { location.destroy(); }\n });\n }\n });\n\n test(\"HistoryLocation initState does not get fired on init\", function() {\n expect(1);\n\n HistoryTestLocation.reopen({\n init: function(){\n ok(true, 'init was called');\n this._super();\n },\n initState: function() {\n ok(false, 'initState() should not be called automatically');\n }\n });\n\n createLocation();\n });\n\n test(\"webkit doesn't fire popstate on page load\", function() {\n expect(1);\n\n HistoryTestLocation.reopen({\n initState: function() {\n this._super();\n // these two should be equal to be able\n // to successfully detect webkit initial popstate\n equal(this._previousURL, this.getURL());\n }\n });\n\n createLocation();\n location.initState();\n });\n\n test(\"base URL is removed when retrieving the current pathname\", function() {\n expect(1);\n\n HistoryTestLocation.reopen({\n init: function() {\n this._super();\n\n set(this, 'location', { pathname: '/base/foo/bar' });\n set(this, 'baseURL', '/base/');\n },\n\n initState: function() {\n this._super();\n\n equal(this.getURL(), '/foo/bar');\n }\n });\n\n createLocation();\n location.initState();\n });\n\n test(\"base URL is preserved when moving around\", function() {\n expect(1);\n\n HistoryTestLocation.reopen({\n init: function() {\n this._super();\n\n set(this, 'location', { pathname: '/base/foo/bar' });\n set(this, 'baseURL', '/base/');\n }\n });\n\n createLocation();\n location.initState();\n location.setURL('/one/two');\n\n equal(FakeHistory.state.path, '/base/one/two');\n });\n\n test(\"setURL continues to set even with a null state (iframes may set this)\", function() {\n expect(1);\n\n createLocation();\n location.initState();\n\n FakeHistory.pushState(null);\n location.setURL('/three/four');\n\n equal(FakeHistory.state && FakeHistory.state.path, '/three/four');\n });\n\n test(\"replaceURL continues to set even with a null state (iframes may set this)\", function() {\n expect(1);\n\n createLocation();\n location.initState();\n\n FakeHistory.pushState(null);\n location.replaceURL('/three/four');\n\n equal(FakeHistory.state && FakeHistory.state.path, '/three/four');\n });\n\n test(\"HistoryLocation.getURL() returns the current url, excluding both rootURL and baseURL\", function() {\n expect(1);\n\n HistoryTestLocation.reopen({\n init: function() {\n this._super();\n\n set(this, 'location', { pathname: '/base/foo/bar' });\n set(this, 'rootURL', '/app/');\n set(this, 'baseURL', '/base/');\n }\n });\n\n createLocation();\n\n equal(location.getURL(), '/foo/bar');\n });\n });\ndefine(\"ember-routing/tests/system/controller_for_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"container/container\",\"ember-runtime/system/namespace\",\"ember-runtime/system/string\",\"ember-runtime/controllers/controller\",\"ember-runtime/controllers/object_controller\",\"ember-runtime/controllers/array_controller\",\"ember-routing/system/controller_for\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // A\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var run = __dependency4__[\"default\"];\n\n var Container = __dependency5__[\"default\"];\n var Namespace = __dependency6__[\"default\"];\n var classify = __dependency7__.classify;\n var Controller = __dependency8__.Controller;\n var ObjectController = __dependency9__[\"default\"];\n var ArrayController = __dependency10__[\"default\"];\n var controllerFor = __dependency11__.controllerFor;\n var generateController = __dependency11__.generateController;\n\n var buildContainer = function(namespace) {\n var container = new Container();\n\n container.set = set;\n container.resolver = resolverFor(namespace);\n container.optionsForType('view', { singleton: false });\n\n container.register('application:main', namespace, { instantiate: false });\n\n container.register('controller:basic', Controller, { instantiate: false });\n container.register('controller:object', ObjectController, { instantiate: false });\n container.register('controller:array', ArrayController, { instantiate: false });\n\n return container;\n };\n\n function resolverFor(namespace) {\n return function(fullName) {\n var nameParts = fullName.split(\":\"),\n type = nameParts[0], name = nameParts[1];\n\n if (name === 'basic') {\n name = '';\n }\n var className = classify(name) + classify(type);\n var factory = get(namespace, className);\n\n\n\n if (factory) { return factory; }\n };\n }\n\n var container, appController, namespace;\n\n module(\"Ember.controllerFor\", {\n setup: function() {\n namespace = Namespace.create();\n container = buildContainer(namespace);\n container.register('controller:app', Controller.extend());\n appController = container.lookup('controller:app');\n },\n teardown: function() {\n run(function () {\n container.destroy();\n namespace.destroy();\n });\n }\n });\n\n test(\"controllerFor should lookup for registered controllers\", function() {\n var controller = controllerFor(container, 'app');\n\n equal(appController, controller, 'should find app controller');\n });\n\n module(\"Ember.generateController\", {\n setup: function() {\n namespace = Namespace.create();\n container = buildContainer(namespace);\n },\n teardown: function() {\n run(function () {\n container.destroy();\n namespace.destroy();\n });\n }\n });\n\n test(\"generateController should create Ember.Controller\", function() {\n var controller = generateController(container, 'home');\n\n ok(controller instanceof Controller, 'should create controller');\n });\n\n test(\"generateController should create Ember.ObjectController\", function() {\n var context = {};\n var controller = generateController(container, 'home', context);\n\n ok(controller instanceof ObjectController, 'should create controller');\n });\n\n test(\"generateController should create Ember.ArrayController\", function() {\n var context = Ember.A();\n var controller = generateController(container, 'home', context);\n\n ok(controller instanceof ArrayController, 'should create controller');\n });\n\n test(\"generateController should create App.Controller if provided\", function() {\n var controller;\n namespace.Controller = Controller.extend();\n\n controller = generateController(container, 'home');\n\n ok(controller instanceof namespace.Controller, 'should create controller');\n });\n\n test(\"generateController should create App.ObjectController if provided\", function() {\n var context = {}, controller;\n namespace.ObjectController = ObjectController.extend();\n\n controller = generateController(container, 'home', context);\n\n ok(controller instanceof namespace.ObjectController, 'should create controller');\n\n });\n\n test(\"generateController should create App.ArrayController if provided\", function() {\n var context = Ember.A(), controller;\n namespace.ArrayController = ArrayController.extend();\n\n controller = generateController(container, 'home', context);\n\n ok(controller instanceof namespace.ArrayController, 'should create controller');\n\n });\n });\ndefine(\"ember-routing/tests/system/dsl_test\",\n [\"ember-routing/system/router\"],\n function(__dependency1__) {\n \"use strict\";\n var EmberRouter = __dependency1__[\"default\"];\n\n var Router;\n\n module(\"Ember Router DSL\", {\n setup: function() {\n Router = EmberRouter.extend();\n },\n teardown: function() {\n Router = null;\n }\n });\n\n test(\"should fail when using a reserved route name\", function() {\n expect(2);\n\n expectAssertion(function() {\n Router.map(function() {\n this.route('basic');\n });\n }, \"'basic' cannot be used as a route name.\");\n\n expectAssertion(function() {\n Router.map(function() {\n this.resource('basic');\n });\n }, \"'basic' cannot be used as a resource name.\");\n });\n });\ndefine(\"ember-routing/tests/system/route_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"container/container\",\"ember-runtime/system/object\",\"ember-routing/system/route\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // assert\n var run = __dependency2__[\"default\"];\n var Container = __dependency3__[\"default\"];\n var EmberObject = __dependency4__[\"default\"];\n var EmberRoute = __dependency5__[\"default\"];\n\n var route, routeOne, routeTwo, router, container, lookupHash;\n\n function createRoute(){\n route = EmberRoute.create();\n }\n\n function cleanupRoute(){\n run(route, 'destroy');\n }\n\n module(\"Ember.Route\", {\n setup: createRoute,\n teardown: cleanupRoute\n });\n\n test(\"default store utilizes the container to acquire the model factory\", function() {\n var Post, post;\n\n expect(4);\n\n post = {};\n\n Post = EmberObject.extend();\n Post.reopenClass({\n find: function(id) {\n return post;\n }\n });\n\n container = {\n has: function() { return true; },\n lookupFactory: lookupFactory\n };\n\n route.container = container;\n\n equal(route.model({ post_id: 1}), post);\n equal(route.findModel('post', 1), post, '#findModel returns the correct post');\n\n function lookupFactory(fullName) {\n equal(fullName, \"model:post\", \"correct factory was looked up\");\n\n return Post;\n }\n\n });\n\n test(\"'store' can be injected by data persistence frameworks\", function() {\n expect(8);\n run(route, 'destroy');\n\n var container = new Container();\n var post = {\n id: 1\n };\n\n var Store = EmberObject.extend({\n find: function(type, value){\n ok(true, 'injected model was called');\n equal(type, 'post', 'correct type was called');\n equal(value, 1, 'correct value was called');\n return post;\n }\n });\n\n container.register('route:index', EmberRoute);\n container.register('store:main', Store);\n\n container.injection('route', 'store', 'store:main');\n\n route = container.lookup('route:index');\n\n equal(route.model({ post_id: 1}), post, '#model returns the correct post');\n equal(route.findModel('post', 1), post, '#findModel returns the correct post');\n });\n\n test(\"assert if 'store.find' method is not found\", function() {\n expect(1);\n run(route, 'destroy');\n\n var container = new Container();\n var Post = EmberObject.extend();\n\n container.register('route:index', EmberRoute);\n container.register('model:post', Post);\n\n route = container.lookup('route:index');\n\n expectAssertion(function() {\n route.findModel('post', 1);\n }, 'Post has no method `find`.');\n });\n\n test(\"asserts if model class is not found\", function() {\n expect(1);\n run(route, 'destroy');\n\n var container = new Container();\n container.register('route:index', EmberRoute);\n\n route = container.lookup('route:index');\n\n expectAssertion(function() {\n route.model({ post_id: 1});\n }, \"You used the dynamic segment post_id in your route undefined, but undefined.Post did not exist and you did not override your route's `model` hook.\");\n });\n\n test(\"'store' does not need to be injected\", function() {\n expect(1);\n\n run(route, 'destroy');\n var originalAssert = Ember.assert;\n\n var container = new Container();\n container.register('route:index', EmberRoute);\n\n route = container.lookup('route:index');\n\n ignoreAssertion(function(){\n route.model({ post_id: 1});\n });\n\n ok(true, 'no error was raised');\n });\n\n module(\"Ember.Route serialize\", {\n setup: createRoute,\n teardown: cleanupRoute\n });\n\n test(\"returns the models properties if params does not include *_id\", function(){\n var model = {id: 2, firstName: 'Ned', lastName: 'Ryerson'};\n\n deepEqual(route.serialize(model, ['firstName', 'lastName']), {firstName: 'Ned', lastName: 'Ryerson'}, \"serialized correctly\");\n });\n\n test(\"returns model.id if params include *_id\", function(){\n var model = {id: 2};\n\n deepEqual(route.serialize(model, ['post_id']), {post_id: 2}, \"serialized correctly\");\n });\n\n test(\"returns undefined if model is not set\", function(){\n equal(route.serialize(undefined, ['post_id']), undefined, \"serialized correctly\");\n });\n\n module(\"Ember.Route interaction\", {\n setup: function() {\n container = {\n lookup: function(fullName) {\n return lookupHash[fullName];\n }\n };\n\n routeOne = EmberRoute.create({ container: container, routeName: 'one' });\n routeTwo = EmberRoute.create({ container: container, routeName: 'two' });\n\n lookupHash = {\n 'route:one': routeOne,\n 'route:two': routeTwo\n };\n },\n\n teardown: function() {\n run(function() {\n routeOne.destroy();\n routeTwo.destroy();\n });\n }\n });\n\n test(\"controllerFor uses route's controllerName if specified\", function() {\n var testController = {};\n lookupHash['controller:test'] = testController;\n\n routeOne.controllerName = 'test';\n\n equal(routeTwo.controllerFor('one'), testController);\n });\n });\ndefine(\"ember-routing/tests/system/router_test\",\n [\"ember-metal/run_loop\",\"ember-runtime/copy\",\"ember-metal/merge\",\"ember-metal/enumerable_utils\",\"container/container\",\"ember-routing/location/hash_location\",\"ember-routing/location/auto_location\",\"ember-routing/system/router\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var copy = __dependency2__[\"default\"];\n var merge = __dependency3__[\"default\"];\n var EnumerableUtils = __dependency4__[\"default\"];\n var Container = __dependency5__[\"default\"];\n var HashLocation = __dependency6__[\"default\"];\n var AutoLocation = __dependency7__[\"default\"];\n var EmberRouter = __dependency8__[\"default\"];\n\n var map = EnumerableUtils.map,\n container, Router, router;\n\n function createRouter(overrides) {\n var opts = merge({ container: container }, overrides);\n router = Router.create(opts);\n }\n\n module(\"Ember Router\", {\n setup: function() {\n container = new Container();\n\n //register the HashLocation (the default)\n container.register('location:hash', HashLocation);\n\n // ensure rootURL is injected into any locations\n container.injection('location', 'rootURL', '-location-setting:root-url');\n\n Router = EmberRouter.extend();\n },\n teardown: function() {\n container = Router = router = null;\n }\n });\n\n test(\"should create a router if one does not exist on the constructor\", function() {\n createRouter();\n\n ok(router.router);\n });\n\n test(\"should destroy its location upon destroying the routers container.\", function() {\n createRouter();\n\n var location = router.get('location');\n\n run(container, 'destroy');\n\n ok(location.isDestroyed, \"location should be destroyed\");\n });\n\n test(\"should instantiate its location with its `rootURL`\", function() {\n createRouter({\n rootURL: '/rootdir/'\n });\n\n var location = router.get('location');\n\n equal(location.get('rootURL'), '/rootdir/');\n });\n\n test(\"Ember.AutoLocation._replacePath should be called with the right path\", function() {\n expect(1);\n\n var AutoTestLocation = copy(AutoLocation);\n\n AutoTestLocation._location = {\n href: 'http://test.com/rootdir/welcome',\n origin: 'http://test.com',\n pathname: '/rootdir/welcome',\n hash: '',\n search: '',\n replace: function(url) {\n equal(url, 'http://test.com/rootdir/#/welcome');\n }\n };\n AutoTestLocation._getSupportsHistory = function() { return false; };\n\n container.register('location:auto', AutoTestLocation);\n\n createRouter({\n location: 'auto',\n rootURL: '/rootdir/'\n });\n });\n\n test(\"Ember.Router._routePath should consume identical prefixes\", function() {\n createRouter();\n\n expect(8);\n\n function routePath(s1, s2, s3) {\n var handlerInfos = map(arguments, function(s) {\n return { name: s };\n });\n handlerInfos.unshift({ name: 'ignored' });\n\n return EmberRouter._routePath(handlerInfos);\n }\n\n equal(routePath('foo'), 'foo');\n equal(routePath('foo', 'bar', 'baz'), 'foo.bar.baz');\n equal(routePath('foo', 'foo.bar'), 'foo.bar');\n equal(routePath('foo', 'foo.bar', 'foo.bar.baz'), 'foo.bar.baz');\n equal(routePath('foo', 'foo.bar', 'foo.bar.baz.wow'), 'foo.bar.baz.wow');\n equal(routePath('foo', 'foo.bar.baz.wow'), 'foo.bar.baz.wow');\n equal(routePath('foo.bar', 'bar.baz.wow'), 'foo.bar.baz.wow');\n\n // This makes no sense, not trying to handle it, just\n // making sure it doesn't go boom.\n equal(routePath('foo.bar.baz', 'foo'), 'foo.bar.baz.foo');\n });\n\n test(\"Router should cancel routing setup when the Location class says so via cancelRouterSetup\", function() {\n expect(0);\n\n var FakeLocation = {\n cancelRouterSetup: true,\n create: function () { return this; }\n };\n\n container.register('location:fake', FakeLocation);\n\n router = Router.create({\n container: container,\n location: 'fake',\n\n _setupRouter: function () {\n ok(false, '_setupRouter should not be called');\n }\n });\n\n router.startRouting();\n });\n\n test(\"AutoLocation should replace the url when it's not in the preferred format\", function() {\n expect(1);\n\n var AutoTestLocation = copy(AutoLocation);\n\n AutoTestLocation._location = {\n href: 'http://test.com/rootdir/welcome',\n origin: 'http://test.com',\n pathname: '/rootdir/welcome',\n hash: '',\n search: '',\n replace: function(url) {\n equal(url, 'http://test.com/rootdir/#/welcome');\n }\n };\n\n AutoTestLocation._getSupportsHistory = function() { return false; };\n\n container.register('location:auto', AutoTestLocation);\n\n createRouter({\n location: 'auto',\n rootURL: '/rootdir/'\n });\n });\n });\n})();\n//@ sourceURL=ember-routing/~tests/ember-routing");minispade.register('ember-routing/~tests/ember-routing_test', "(function() {minispade.require(\"ember-routing/~tests/ember-routing\");\nrequireModule(\"ember-routing/tests/helpers/action_test\");\nrequireModule(\"ember-routing/tests/helpers/outlet_test\");\nrequireModule(\"ember-routing/tests/helpers/render_test\");\nrequireModule(\"ember-routing/tests/location/auto_location_test\");\nrequireModule(\"ember-routing/tests/location/history_location_test\");\nrequireModule(\"ember-routing/tests/system/controller_for_test\");\nrequireModule(\"ember-routing/tests/system/dsl_test\");\nrequireModule(\"ember-routing/tests/system/route_test\");\nrequireModule(\"ember-routing/tests/system/router_test\");\n})();\n//@ sourceURL=ember-routing/~tests/ember-routing_test");minispade.register('ember-runtime/~tests/ember-runtime', "(function() {define(\"ember-runtime/tests/computed/compose_computed_test\",\n [\"ember-metal/core\",\"ember-metal/utils\",\"ember-metal/observer\",\"ember-metal/computed\",\"ember-runtime/computed/reduce_computed_macros\",\"ember-metal/run_loop\",\"ember-metal/properties\",\"ember-runtime/compare\",\"ember-metal/tests/props_helper\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var metaFor = __dependency2__.metaFor;\n var addObserver = __dependency3__.addObserver;\n var computed = __dependency4__.computed;\n var mapBy = __dependency5__.mapBy;\n var union = __dependency5__.union;\n var sort = __dependency5__.sort;\n var run = __dependency6__[\"default\"];\n var defineProperty = __dependency7__.defineProperty;\n var compare = __dependency8__[\"default\"];\n var testBoth = __dependency9__[\"default\"];\n var EmberObject = __dependency10__[\"default\"];\n\n if (Ember.FEATURES.isEnabled('composable-computed-properties')) {\n var obj;\n\n module('computed - composable', {\n teardown: function () {\n if (obj && obj.destroy) {\n run(function() {\n obj.destroy();\n });\n }\n }\n });\n\n testBoth('should be able to take a computed property as a parameter for ember objects', function(get, set) {\n var not = computed.not,\n equals = computed.equal;\n\n obj = EmberObject.extend({\n firstName: null,\n lastName: null,\n state: null,\n napTime: not(equals('state', 'sleepy'))\n }).create({\n firstName: 'Alex',\n lastName: 'Navasardyan',\n state: 'sleepy'\n });\n\n equal(get(obj, 'firstName'), 'Alex');\n equal(get(obj, 'lastName'), 'Navasardyan');\n\n equal(get(obj, 'state'), 'sleepy');\n equal(get(obj, 'napTime'), false);\n\n set(obj, 'state', 'not sleepy');\n equal(get(obj, 'state'), 'not sleepy');\n equal(get(obj, 'napTime'), true);\n });\n\n testBoth('should work with plain JavaScript objects', function(get, set) {\n var not = computed.not,\n equals = computed.equal;\n\n obj = {\n firstName: 'Alex',\n lastName: 'Navasardyan',\n state: 'sleepy'\n };\n\n defineProperty(obj, 'napTime', not(equals('state', 'sleepy')));\n\n equal(get(obj, 'firstName'), 'Alex');\n equal(get(obj, 'lastName'), 'Navasardyan');\n\n equal(get(obj, 'state'), 'sleepy');\n equal(get(obj, 'napTime'), false);\n\n set(obj, 'state', 'not sleepy');\n equal(get(obj, 'state'), 'not sleepy');\n equal(get(obj, 'napTime'), true);\n });\n\n testBoth('should be able to take many computed properties as parameters', function(get, set) {\n var and = computed.and,\n equals = computed.equal,\n not = computed.not,\n obj = EmberObject.extend({\n firstName: null,\n lastName: null,\n state: null,\n hungry: null,\n thirsty: null,\n napTime: and(equals('state', 'sleepy'), not('hungry'), not('thirsty'))\n }).create({\n firstName: 'Alex',\n lastName: 'Navasardyan',\n state: 'sleepy',\n hungry: true,\n thirsty: false\n });\n\n equal(get(obj, 'firstName'), 'Alex');\n equal(get(obj, 'lastName'), 'Navasardyan');\n\n equal(get(obj, 'state'), 'sleepy');\n equal(get(obj, 'napTime'), false);\n\n set(obj, 'state', 'not sleepy');\n equal(get(obj, 'state'), 'not sleepy');\n equal(get(obj, 'napTime'), false);\n\n set(obj, 'state', 'sleepy');\n set(obj, 'thristy', false);\n set(obj, 'hungry', false);\n equal(get(obj, 'napTime'), true);\n });\n\n testBoth('composable computed properties can be shared between types', function (get, set) {\n var not = computed.not,\n equals = computed.equal,\n notSleepy = not(equals('state', 'sleepy')),\n Type0 = EmberObject.extend({\n state: null,\n napTime: notSleepy\n }),\n Type1 = EmberObject.extend({\n state: null,\n napTime: notSleepy\n }),\n obj0 = Type0.create({ state: 'sleepy'}),\n obj1 = Type1.create({ state: 'sleepy' });\n\n equal(get(obj0, 'state'), 'sleepy');\n equal(get(obj0, 'napTime'), false);\n\n set(obj0, 'state', 'not sleepy');\n equal(get(obj0, 'state'), 'not sleepy');\n equal(get(obj0, 'napTime'), true);\n\n equal(get(obj1, 'state'), 'sleepy');\n equal(get(obj1, 'napTime'), false);\n\n set(obj1, 'state', 'not sleepy');\n equal(get(obj1, 'state'), 'not sleepy');\n equal(get(obj1, 'napTime'), true);\n });\n\n testBoth('composable computed properties work with existing CP macros', function(get, set) {\n var not = computed.not,\n equals = computed.equal,\n observerCalls = 0;\n\n obj = EmberObject.extend({\n firstName: null,\n lastName: null,\n state: null,\n napTime: not(equals('state', 'sleepy'))\n }).create({\n firstName: 'Alex',\n lastName: 'Navasardyan',\n state: 'sleepy'\n });\n\n addObserver(obj, 'napTime', function () {\n ++observerCalls;\n });\n\n equal(get(obj, 'napTime'), false);\n equal(observerCalls, 0);\n\n set(obj, 'state', 'not sleepy');\n equal(observerCalls, 1);\n equal(get(obj, 'napTime'), true);\n });\n\n testBoth('composable computed properties work with arrayComputed properties', function (get, set) {\n obj = EmberObject.extend({\n names: sort(\n union(mapBy('people', 'firstName'), mapBy('people', 'lastName'), 'cats'),\n compare\n )\n }).create({\n people: Ember.A([{\n firstName: 'Alex', lastName: 'Navasardyan'\n }, {\n firstName: 'David', lastName: 'Hamilton'\n }]),\n cats: Ember.A(['Grey Kitty', 'Little Boots'])\n });\n\n deepEqual(get(obj, 'names'), ['Alex', 'David', 'Grey Kitty', 'Hamilton', 'Little Boots', 'Navasardyan']);\n });\n\n testBoth('composable computed properties work with CPs that have no dependencies', function (get, set) {\n var not = computed.not,\n constant = function (c) {\n return computed(function () {\n return c;\n });\n };\n\n obj = EmberObject.extend({\n p: not(constant(true))\n }).create();\n\n equal(get(obj, 'p'), false, \"ccp works with dependencies that themselves have no dependencies\");\n });\n\n testBoth('composable computed properties work with depKey paths', function (get, set) {\n var not = computed.not,\n alias = computed.alias;\n\n obj = EmberObject.extend({\n q: not(alias('indirection.p'))\n }).create({\n indirection: { p: true }\n });\n\n equal(get(obj, 'q'), false, \"ccp is initially correct\");\n\n set(obj, 'indirection.p', false);\n\n equal(get(obj, 'q'), true, \"ccp is true after dependent chain updated\");\n });\n\n testBoth('composable computed properties work with macros that have non-cp args', function (get, set) {\n var equals = computed.equal,\n not = computed.not,\n or = computed.or;\n\n obj = EmberObject.extend({\n isJaime: equals('name', 'Jaime'),\n isCersei: equals('name', 'Cersei'),\n\n isEither: or( equals('name', 'Jaime'),\n equals('name', 'Cersei'))\n }).create({\n name: 'Robb'\n });\n\n equal(false, get(obj, 'isEither'), \"Robb is neither Jaime nor Cersei\");\n\n set(obj, 'name', 'Jaime');\n\n equal(true, get(obj, 'isEither'), \"Jaime is either Jaime nor Cersei\");\n\n set(obj, 'name', 'Cersei');\n\n equal(true, get(obj, 'isEither'), \"Cersei is either Jaime nor Cersei\");\n\n set(obj, 'name', 'Tyrion');\n\n equal(false, get(obj, 'isEither'), \"Tyrion is neither Jaime nor Cersei\");\n });\n }\n });\ndefine(\"ember-runtime/tests/computed/computed_macros_test\",\n [\"ember-metal/computed\",\"ember-runtime/system/object\",\"ember-runtime/tests/props_helper\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var computed = __dependency1__.computed;\n var EmberObject = __dependency2__[\"default\"];\n var testBoth = __dependency3__.testBoth;\n\n module('CP macros');\n\n if (Ember.FEATURES.isEnabled('ember-metal-computed-empty-array')) {\n testBoth('Ember.computed.empty', function (get, set) {\n var obj = EmberObject.extend({\n bestLannister: null,\n lannisters: null,\n\n bestLannisterUnspecified: computed.empty('bestLannister'),\n noLannistersKnown: computed.empty('lannisters')\n }).create({\n lannisters: Ember.A([])\n });\n\n equal(get(obj, 'bestLannisterUnspecified'), true, \"bestLannister initially empty\");\n equal(get(obj, 'noLannistersKnown'), true, \"lannisters initially empty\");\n\n get(obj, 'lannisters').pushObject('Tyrion');\n set(obj, 'bestLannister', 'Tyrion');\n\n equal(get(obj, 'bestLannisterUnspecified'), false, \"empty respects strings\");\n equal(get(obj, 'noLannistersKnown'), false, \"empty respects array mutations\");\n });\n\n if (Ember.FEATURES.isEnabled('composable-computed-properties')) {\n testBoth('Ember.computed.empty with composable computed properties', function (get, set) {\n var obj = EmberObject.extend({\n lannisters: null,\n\n noPeopleKnown: computed.empty(computed.alias('lannisters'))\n }).create({\n lannisters: Ember.A([])\n });\n\n equal(get(obj, 'noPeopleKnown'), true, \"lannisters initially empty\");\n\n get(obj, 'lannisters').pushObject('Tyrion');\n\n equal(get(obj, 'noPeopleKnown'), false, \"empty respects array mutations\");\n });\n }\n }\n });\ndefine(\"ember-runtime/tests/computed/reduce_computed_macros_test\",\n [\"ember-metal/core\",\"ember-metal/enumerable_utils\",\"ember-runtime/system/object\",\"ember-metal/set_properties\",\"ember-runtime/system/object_proxy\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-metal/computed\",\"ember-metal/observer\",\"ember-metal/property_events\",\"ember-metal/array\",\"ember-metal/mixin\",\"ember-runtime/computed/reduce_computed_macros\",\"ember-runtime/system/native_array\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var EnumerableUtils = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var setProperties = __dependency4__[\"default\"];\n var ObjectProxy = __dependency5__[\"default\"];\n var get = __dependency6__.get;\n var set = __dependency7__.set;\n var run = __dependency8__[\"default\"];\n var computed = __dependency9__.computed;\n var addObserver = __dependency10__.addObserver;\n var beginPropertyChanges = __dependency11__.beginPropertyChanges;\n var endPropertyChanges = __dependency11__.endPropertyChanges;\n var forEach = __dependency12__.forEach;\n var observer = __dependency13__.observer;\n var computedSum = __dependency14__.sum;\n var computedMin = __dependency14__.min;\n var computedMax = __dependency14__.max;\n var computedMap = __dependency14__.map;\n var computedSort = __dependency14__.sort;\n var computedSetDiff = __dependency14__.setDiff;\n var computedMapBy = __dependency14__.mapBy;\n var mapProperty = __dependency14__.mapProperty;\n var computedFilter = __dependency14__.filter;\n var computedFilterBy = __dependency14__.filterBy;\n var computedUniq = __dependency14__.uniq;\n var computedUnion = __dependency14__.union;\n var computedIntersect = __dependency14__.intersect;\n\n var NativeArray = __dependency15__[\"default\"];\n\n var obj, sorted, sortProps, items, userFnCalls, todos, filtered;\n\n module('computedMap', {\n setup: function() {\n run(function() {\n userFnCalls = 0;\n obj = EmberObject.createWithMixins({\n array: Ember.A([{ v: 1 }, { v: 3}, { v: 2 }, { v: 1 }]),\n\n mapped: computedMap('array.@each.v', function(item) {\n ++userFnCalls;\n return item.v;\n }),\n\n arrayObjects: Ember.A([\n EmberObject.create({ v: { name: 'Robert' }}),\n EmberObject.create({ v: { name: 'Leanna' }})]),\n mappedObjects: computedMap('arrayObjects.@each.v', function (item) {\n return {\n name: item.v.name\n };\n })\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"it maps simple properties\", function() {\n deepEqual(get(obj, 'mapped'), [1, 3, 2, 1]);\n\n run(function() {\n obj.get('array').pushObject({ v: 5 });\n });\n\n deepEqual(get(obj, 'mapped'), [1, 3, 2, 1, 5]);\n\n run(function() {\n obj.get('array').removeAt(3);\n });\n\n deepEqual(get(obj, 'mapped'), [1, 3, 2, 5]);\n });\n\n test(\"it caches properly\", function() {\n var array = get(obj, 'array'),\n mapped = get(obj, 'mapped');\n\n equal(userFnCalls, 4, \"precond - mapper called expected number of times\");\n\n run(function() {\n array.addObject({v: 7});\n });\n\n equal(userFnCalls, 5, \"precond - mapper called expected number of times\");\n\n get(obj, 'mapped');\n\n equal(userFnCalls, 5, \"computedMap caches properly\");\n });\n\n test(\"it maps simple unshifted properties\", function() {\n var array = Ember.A([]);\n\n run(function() {\n obj = EmberObject.createWithMixins({\n array: array,\n mapped: computedMap('array', function (item) { return item.toUpperCase(); })\n });\n get(obj, 'mapped');\n });\n\n run(function() {\n array.unshiftObject('c');\n array.unshiftObject('b');\n array.unshiftObject('a');\n\n array.popObject();\n });\n\n deepEqual(get(obj, 'mapped'), ['A', 'B'], \"properties unshifted in sequence are mapped correctly\");\n });\n\n test(\"it maps objects\", function() {\n deepEqual(get(obj, 'mappedObjects'), [{ name: 'Robert'}, { name: 'Leanna' }]);\n\n run(function() {\n obj.get('arrayObjects').pushObject({ v: { name: 'Eddard' }});\n });\n\n deepEqual(get(obj, 'mappedObjects'), [{ name: 'Robert' }, { name: 'Leanna' }, { name: 'Eddard' }]);\n\n run(function() {\n obj.get('arrayObjects').removeAt(1);\n });\n\n deepEqual(get(obj, 'mappedObjects'), [{ name: 'Robert' }, { name: 'Eddard' }]);\n\n run(function() {\n obj.get('arrayObjects').objectAt(0).set('v', { name: 'Stannis' });\n });\n\n deepEqual(get(obj, 'mappedObjects'), [{ name: 'Stannis' }, { name: 'Eddard' }]);\n });\n\n test(\"it maps unshifted objects with property observers\", function() {\n var array = Ember.A([]),\n cObj = { v: 'c' };\n\n run(function() {\n obj = EmberObject.createWithMixins({\n array: array,\n mapped: computedMap('array.@each.v', function (item) {\n return get(item, 'v').toUpperCase();\n })\n });\n get(obj, 'mapped');\n });\n\n run(function() {\n array.unshiftObject(cObj);\n array.unshiftObject({ v: 'b' });\n array.unshiftObject({ v: 'a' });\n\n set(cObj, 'v', 'd');\n });\n\n deepEqual(array.mapBy('v'), ['a', 'b', 'd'], \"precond - unmapped array is correct\");\n deepEqual(get(obj, 'mapped'), ['A', 'B', 'D'], \"properties unshifted in sequence are mapped correctly\");\n });\n\n module('computedMapBy', {\n setup: function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n array: Ember.A([{ v: 1 }, { v: 3}, { v: 2 }, { v: 1 }]),\n mapped: computedMapBy('array', 'v')\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"it maps properties\", function() {\n var mapped = get(obj, 'mapped');\n\n deepEqual(get(obj, 'mapped'), [1, 3, 2, 1]);\n\n run(function() {\n obj.get('array').pushObject({ v: 5 });\n });\n\n deepEqual(get(obj, 'mapped'), [1, 3, 2, 1, 5]);\n\n run(function() {\n obj.get('array').removeAt(3);\n });\n\n deepEqual(get(obj, 'mapped'), [1, 3, 2, 5]);\n });\n\n test(\"it is observerable\", function() {\n var mapped = get(obj, 'mapped'),\n calls = 0;\n\n deepEqual(get(obj, 'mapped'), [1, 3, 2, 1]);\n\n addObserver(obj, 'mapped.@each', function() {\n calls++;\n });\n\n run(function() {\n obj.get('array').pushObject({ v: 5 });\n });\n\n equal(calls, 1, 'computedMapBy is observerable');\n });\n\n\n module('computedFilter', {\n setup: function() {\n run(function() {\n userFnCalls = 0;\n obj = EmberObject.createWithMixins({\n array: Ember.A([1, 2, 3, 4, 5, 6, 7, 8]),\n filtered: computedFilter('array', function(item) {\n ++userFnCalls;\n return item % 2 === 0;\n })\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"it filters according to the specified filter function\", function() {\n var filtered = get(obj, 'filtered');\n\n deepEqual(filtered, [2,4,6,8], \"computedFilter filters by the specified function\");\n });\n\n test(\"it caches properly\", function() {\n var array = get(obj, 'array'),\n filtered = get(obj, 'filtered');\n\n equal(userFnCalls, 8, \"precond - filter called expected number of times\");\n\n run(function() {\n array.addObject(11);\n });\n\n equal(userFnCalls, 9, \"precond - filter called expected number of times\");\n\n get(obj, 'filtered');\n\n equal(userFnCalls, 9, \"computedFilter caches properly\");\n });\n\n test(\"it updates as the array is modified\", function() {\n var array = get(obj, 'array'),\n filtered = get(obj, 'filtered');\n\n deepEqual(filtered, [2,4,6,8], \"precond - filtered array is initially correct\");\n\n run(function() {\n array.addObject(11);\n });\n deepEqual(filtered, [2,4,6,8], \"objects not passing the filter are not added\");\n\n run(function() {\n array.addObject(12);\n });\n deepEqual(filtered, [2,4,6,8,12], \"objects passing the filter are added\");\n\n run(function() {\n array.removeObject(3);\n array.removeObject(4);\n });\n deepEqual(filtered, [2,6,8,12], \"objects removed from the dependent array are removed from the computed array\");\n });\n\n test(\"the dependent array can be cleared one at a time\", function() {\n var array = get(obj, 'array'),\n filtered = get(obj, 'filtered');\n\n deepEqual(filtered, [2,4,6,8], \"precond - filtered array is initially correct\");\n\n run(function() {\n // clear 1-8 but in a random order\n array.removeObject(3);\n array.removeObject(1);\n array.removeObject(2);\n array.removeObject(4);\n array.removeObject(8);\n array.removeObject(6);\n array.removeObject(5);\n array.removeObject(7);\n });\n\n deepEqual(filtered, [], \"filtered array cleared correctly\");\n });\n\n test(\"the dependent array can be `clear`ed directly (#3272)\", function() {\n var array = get(obj, 'array'),\n filtered = get(obj, 'filtered');\n\n deepEqual(filtered, [2,4,6,8], \"precond - filtered array is initially correct\");\n\n run(function() {\n array.clear();\n });\n\n deepEqual(filtered, [], \"filtered array cleared correctly\");\n });\n\n test(\"it updates as the array is replaced\", function() {\n var array = get(obj, 'array'),\n filtered = get(obj, 'filtered');\n\n deepEqual(filtered, [2,4,6,8], \"precond - filtered array is initially correct\");\n\n run(function() {\n set(obj, 'array', Ember.A([20,21,22,23,24]));\n });\n deepEqual(filtered, [20,22,24], \"computed array is updated when array is changed\");\n });\n\n module('computedFilterBy', {\n setup: function() {\n obj = EmberObject.createWithMixins({\n array: Ember.A([\n {name: \"one\", a:1, b:false},\n {name: \"two\", a:2, b:false},\n {name: \"three\", a:1, b:true},\n {name: \"four\", b:true}\n ]),\n a1s: computedFilterBy('array', 'a', 1),\n as: computedFilterBy('array', 'a'),\n bs: computedFilterBy('array', 'b')\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"properties can be filtered by truthiness\", function() {\n var array = get(obj, 'array'),\n as = get(obj, 'as'),\n bs = get(obj, 'bs');\n\n deepEqual(as.mapBy('name'), ['one', 'two', 'three'], \"properties can be filtered by existence\");\n deepEqual(bs.mapBy('name'), ['three', 'four'], \"booleans can be filtered\");\n\n run(function() {\n set(array.objectAt(0), 'a', undefined);\n set(array.objectAt(3), 'a', true);\n\n set(array.objectAt(0), 'b', true);\n set(array.objectAt(3), 'b', false);\n });\n deepEqual(as.mapBy('name'), ['two', 'three', 'four'], \"arrays computed by filter property respond to property changes\");\n deepEqual(bs.mapBy('name'), ['one', 'three'], \"arrays computed by filtered property respond to property changes\");\n\n run(function() {\n array.pushObject({name:\"five\", a:6, b:true});\n });\n deepEqual(as.mapBy('name'), ['two', 'three', 'four', 'five'], \"arrays computed by filter property respond to added objects\");\n deepEqual(bs.mapBy('name'), ['one', 'three', 'five'], \"arrays computed by filtered property respond to added objects\");\n\n run(function() {\n array.popObject();\n });\n deepEqual(as.mapBy('name'), ['two', 'three', 'four'], \"arrays computed by filter property respond to removed objects\");\n deepEqual(bs.mapBy('name'), ['one', 'three'], \"arrays computed by filtered property respond to removed objects\");\n\n run(function() {\n set(obj, 'array', Ember.A([{name: \"six\", a:12, b:true}]));\n });\n deepEqual(as.mapBy('name'), ['six'], \"arrays computed by filter property respond to array changes\");\n deepEqual(bs.mapBy('name'), ['six'], \"arrays computed by filtered property respond to array changes\");\n });\n\n test(\"properties can be filtered by values\", function() {\n var array = get(obj, 'array'),\n a1s = get(obj, 'a1s');\n\n deepEqual(a1s.mapBy('name'), ['one', 'three'], \"properties can be filtered by matching value\");\n\n run(function() {\n array.pushObject({ name: \"five\", a:1 });\n });\n deepEqual(a1s.mapBy('name'), ['one', 'three', 'five'], \"arrays computed by matching value respond to added objects\");\n\n run(function() {\n array.popObject();\n });\n deepEqual(a1s.mapBy('name'), ['one', 'three'], \"arrays computed by matching value respond to removed objects\");\n\n run(function() {\n set(array.objectAt(1), 'a', 1);\n set(array.objectAt(2), 'a', 2);\n });\n deepEqual(a1s.mapBy('name'), ['one', 'two'], \"arrays computed by matching value respond to modified properties\");\n });\n\n test(\"properties values can be replaced\", function() {\n obj = EmberObject.createWithMixins({\n array: Ember.A([]),\n a1s: computedFilterBy('array', 'a', 1),\n a1bs: computedFilterBy('a1s', 'b')\n });\n\n var a1bs = get(obj, 'a1bs');\n deepEqual(a1bs.mapBy('name'), [], \"properties can be filtered by matching value\");\n\n run(function() {\n set(obj, 'array', Ember.A([{name: 'item1', a:1, b:true}]));\n });\n\n a1bs = get(obj, 'a1bs');\n deepEqual(a1bs.mapBy('name'), ['item1'], \"properties can be filtered by matching value\");\n });\n\n forEach.call([['uniq', computedUniq], ['union', computedUnion]], function (tuple) {\n var alias = tuple[0],\n testedFunc = tuple[1];\n\n module('computed.' + alias, {\n setup: function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n array: Ember.A([1,2,3,4,5,6]),\n array2: Ember.A([4,5,6,7,8,9,4,5,6,7,8,9]),\n array3: Ember.A([1,8,10]),\n union: testedFunc('array', 'array2', 'array3')\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"does not include duplicates\", function() {\n var array = get(obj, 'array'),\n array2 = get(obj, 'array2'),\n array3 = get(obj, 'array3'),\n union = get(obj, 'union');\n\n deepEqual(union, [1,2,3,4,5,6,7,8,9,10], alias + \" does not include duplicates\");\n\n run(function() {\n array.pushObject(8);\n });\n\n deepEqual(union, [1,2,3,4,5,6,7,8,9,10], alias + \" does not add existing items\");\n\n run(function() {\n array.pushObject(11);\n });\n\n deepEqual(union, [1,2,3,4,5,6,7,8,9,10,11], alias + \" adds new items\");\n\n run(function() {\n array2.removeAt(6); // remove 7\n });\n\n deepEqual(union, [1,2,3,4,5,6,7,8,9,10,11], alias + \" does not remove items that are still in the dependent array\");\n\n run(function() {\n array2.removeObject(7);\n });\n\n deepEqual(union, [1,2,3,4,5,6,8,9,10,11], alias + \" removes items when their last instance is gone\");\n });\n\n test(\"has set-union semantics\", function() {\n var array = get(obj, 'array'),\n array2 = get(obj, 'array2'),\n array3 = get(obj, 'array3'),\n union = get(obj, 'union');\n\n deepEqual(union, [1,2,3,4,5,6,7,8,9,10], alias + \" is initially correct\");\n\n run(function() {\n array.removeObject(6);\n });\n\n deepEqual(union, [1,2,3,4,5,6,7,8,9,10], \"objects are not removed if they exist in other dependent arrays\");\n\n run(function() {\n array.clear();\n });\n\n deepEqual(union, [1,4,5,6,7,8,9,10], \"objects are removed when they are no longer in any dependent array\");\n });\n });\n\n module('computed.intersect', {\n setup: function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n array: Ember.A([1,2,3,4,5,6]),\n array2: Ember.A([3,3,3,4,5]),\n array3: Ember.A([3,5,6,7,8]),\n intersection: computedIntersect('array', 'array2', 'array3')\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"it has set-intersection semantics\", function() {\n var array = get(obj, 'array'),\n array2 = get(obj, 'array2'),\n array3 = get(obj, 'array3'),\n intersection = get(obj, 'intersection');\n\n deepEqual(intersection, [3,5], \"intersection is initially correct\");\n\n run(function() {\n array2.shiftObject();\n });\n deepEqual(intersection, [3,5], \"objects are not removed when they are still in all dependent arrays\");\n\n run(function() {\n array2.shiftObject();\n });\n deepEqual(intersection, [3,5], \"objects are not removed when they are still in all dependent arrays\");\n\n run(function() {\n array2.shiftObject();\n });\n deepEqual(intersection, [5], \"objects are removed once they are gone from all dependent arrays\");\n\n run(function() {\n array2.pushObject(1);\n });\n deepEqual(intersection, [5], \"objects are not added as long as they are missing from any dependent array\");\n\n run(function() {\n array3.pushObject(1);\n });\n deepEqual(intersection, [5,1], \"objects added once they belong to all dependent arrays\");\n });\n\n\n module('computedSetDiff', {\n setup: function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n array: Ember.A([1,2,3,4,5,6,7]),\n array2: Ember.A([3,4,5,10]),\n diff: computedSetDiff('array', 'array2')\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"it throws an error if given fewer or more than two dependent properties\", function() {\n throws(function () {\n EmberObject.createWithMixins({\n array: Ember.A([1,2,3,4,5,6,7]),\n array2: Ember.A([3,4,5]),\n diff: computedSetDiff('array')\n });\n }, /requires exactly two dependent arrays/, \"setDiff requires two dependent arrays\");\n\n throws(function () {\n EmberObject.createWithMixins({\n array: Ember.A([1,2,3,4,5,6,7]),\n array2: Ember.A([3,4,5]),\n array3: Ember.A([7]),\n diff: computedSetDiff('array', 'array2', 'array3')\n });\n }, /requires exactly two dependent arrays/, \"setDiff requires two dependent arrays\");\n });\n\n\n test(\"it has set-diff semantics\", function() {\n var array1 = get(obj, 'array'),\n array2 = get(obj, 'array2'),\n diff = get(obj, 'diff');\n\n deepEqual(diff, [1, 2, 6, 7], \"set-diff is initially correct\");\n\n run(function() {\n array2.popObject();\n });\n deepEqual(diff, [1,2,6,7], \"removing objects from the remove set has no effect if the object is not in the keep set\");\n\n run(function() {\n array2.shiftObject();\n });\n deepEqual(diff, [1, 2, 6, 7, 3], \"removing objects from the remove set adds them if they're in the keep set\");\n\n run(function() {\n array1.removeObject(3);\n });\n deepEqual(diff, [1, 2, 6, 7], \"removing objects from the keep array removes them from the computed array\");\n\n run(function() {\n array1.pushObject(5);\n });\n deepEqual(diff, [1, 2, 6, 7], \"objects added to the keep array that are in the remove array are not added to the computed array\");\n\n run(function() {\n array1.pushObject(22);\n });\n deepEqual(diff, [1, 2, 6, 7, 22], \"objects added to the keep array not in the remove array are added to the computed array\");\n });\n\n\n function commonSortTests() {\n test(\"arrays are initially sorted\", function() {\n run(function() {\n sorted = get(obj, 'sortedItems');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"array is initially sorted\");\n });\n\n test(\"changing the dependent array updates the sorted array\", function() {\n run(function() {\n sorted = get(obj, 'sortedItems');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n set(obj, 'items', Ember.A([{\n fname: 'Roose', lname: 'Bolton'\n }, {\n fname: 'Theon', lname: 'Greyjoy'\n }, {\n fname: 'Ramsey', lname: 'Bolton'\n }, {\n fname: 'Stannis', lname: 'Baratheon'\n }]));\n });\n\n deepEqual(sorted.mapBy('fname'), ['Stannis', 'Ramsey', 'Roose', 'Theon'], \"changing dependent array updates sorted array\");\n });\n\n test(\"adding to the dependent array updates the sorted array\", function() {\n run(function() {\n sorted = get(obj, 'sortedItems');\n items = get(obj, 'items');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n items.pushObject({ fname: 'Tyrion', lname: 'Lannister' });\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Tyrion', 'Bran', 'Robb'], \"Adding to the dependent array updates the sorted array\");\n });\n\n test(\"removing from the dependent array updates the sorted array\", function() {\n run(function() {\n sorted = get(obj, 'sortedItems');\n items = get(obj, 'items');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n items.popObject();\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Robb'], \"Removing from the dependent array updates the sorted array\");\n });\n\n test(\"distinct items may be sort-equal, although their relative order will not be guaranteed\", function() {\n var jaime, jaimeInDisguise;\n\n run(function() {\n // We recreate jaime and \"Cersei\" here only for test stability: we want\n // their guid-ordering to be deterministic\n jaimeInDisguise = EmberObject.create({\n fname: 'Cersei', lname: 'Lannister', age: 34\n });\n jaime = EmberObject.create({\n fname: 'Jaime', lname: 'Lannister', age: 34\n });\n items = get(obj, 'items');\n\n items.replace(0, 1, jaime);\n items.replace(1, 1, jaimeInDisguise);\n sorted = get(obj, 'sortedItems');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n // comparator will now return 0.\n // Apparently it wasn't a very good disguise.\n jaimeInDisguise.set('fname', 'Jaime');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Jaime', 'Jaime', 'Bran', 'Robb'], \"sorted array is updated\");\n\n run(function() {\n // comparator will again return non-zero\n jaimeInDisguise.set('fname', 'Cersei');\n });\n\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"sorted array is updated\");\n });\n\n test(\"guid sort-order fallback with a serach proxy is not confused by non-search ObjectProxys\", function() {\n var tyrion = { fname: \"Tyrion\", lname: \"Lannister\" },\n tyrionInDisguise = ObjectProxy.create({\n fname: \"Yollo\",\n lname: \"\",\n content: tyrion\n });\n\n items = get(obj, 'items');\n sorted = get(obj, 'sortedItems');\n\n run(function() {\n items.pushObject(tyrion);\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Tyrion', 'Bran', 'Robb']);\n\n run(function() {\n items.pushObject(tyrionInDisguise);\n });\n\n deepEqual(sorted.mapBy('fname'), ['Yollo', 'Cersei', 'Jaime', 'Tyrion', 'Bran', 'Robb']);\n });\n }\n\n module('computedSort - sortProperties', {\n setup: function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n itemSorting: Ember.A(['lname', 'fname']),\n items: Ember.A([{\n fname: \"Jaime\", lname: \"Lannister\", age: 34\n }, {\n fname: \"Cersei\", lname: \"Lannister\", age: 34\n }, {\n fname: \"Robb\", lname: \"Stark\", age: 16\n }, {\n fname: \"Bran\", lname: \"Stark\", age: 8\n }]),\n\n sortedItems: computedSort('items', 'itemSorting')\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n commonSortTests();\n\n test(\"updating sort properties updates the sorted array\", function() {\n run(function() {\n sorted = get(obj, 'sortedItems');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n set(obj, 'itemSorting', Ember.A(['fname:desc']));\n });\n\n deepEqual(sorted.mapBy('fname'), ['Robb', 'Jaime', 'Cersei', 'Bran'], \"after updating sort properties array is updated\");\n });\n\n test(\"updating sort properties in place updates the sorted array\", function() {\n run(function() {\n sorted = get(obj, 'sortedItems');\n sortProps = get(obj, 'itemSorting');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n sortProps.clear();\n sortProps.pushObject('fname');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Bran', 'Cersei', 'Jaime', 'Robb'], \"after updating sort properties array is updated\");\n });\n\n test(\"updating new sort properties in place updates the sorted array\", function() {\n run(function() {\n sorted = get(obj, 'sortedItems');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n set(obj, 'itemSorting', Ember.A(['age:desc', 'fname:asc']));\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Robb', 'Bran'], \"precond - array is correct after item sorting is changed\");\n\n run(function() {\n items = get(obj, 'items');\n\n var cersei = items.objectAt(1);\n set(cersei, 'age', 29); // how vain\n });\n\n deepEqual(sorted.mapBy('fname'), ['Jaime', 'Cersei', 'Robb', 'Bran'], \"after updating sort properties array is updated\");\n });\n\n test(\"sort direction defaults to ascending\", function() {\n run(function() {\n sorted = get(obj, 'sortedItems');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n set(obj, 'itemSorting', Ember.A(['fname']));\n });\n\n deepEqual(sorted.mapBy('fname'), ['Bran', 'Cersei', 'Jaime', 'Robb'], \"sort direction defaults to ascending\");\n });\n\n test(\"updating an item's sort properties updates the sorted array\", function() {\n var tyrionInDisguise;\n\n run(function() {\n sorted = get(obj, 'sortedItems');\n items = get(obj, 'items');\n });\n\n tyrionInDisguise = items.objectAt(1);\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n set(tyrionInDisguise, 'fname', 'Tyrion');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Jaime', 'Tyrion', 'Bran', 'Robb'], \"updating an item's sort properties updates the sorted array\");\n });\n\n test(\"updating several of an item's sort properties updated the sorted array\", function() {\n var sansaInDisguise;\n\n run(function() {\n sorted = get(obj, 'sortedItems');\n items = get(obj, 'items');\n });\n\n sansaInDisguise = items.objectAt(1);\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n setProperties(sansaInDisguise, {\n fname: 'Sansa',\n lname: 'Stark'\n });\n });\n\n deepEqual(sorted.mapBy('fname'), ['Jaime', 'Bran', 'Robb', 'Sansa'], \"updating an item's sort properties updates the sorted array\");\n });\n\n test(\"updating an item's sort properties does not error when binary search does a self compare (#3273)\", function() {\n var jaime, cersei;\n\n run(function() {\n jaime = EmberObject.create({\n name: 'Jaime',\n status: 1\n });\n cersei = EmberObject.create({\n name: 'Cersei',\n status: 2\n });\n\n obj = EmberObject.createWithMixins({\n people: Ember.A([jaime, cersei]),\n sortProps: Ember.A(['status']),\n sortedPeople: computedSort('people', 'sortProps')\n });\n });\n\n deepEqual(get(obj, 'sortedPeople'), [jaime, cersei], \"precond - array is initially sorted\");\n\n run(function() {\n cersei.set('status', 3);\n });\n\n deepEqual(get(obj, 'sortedPeople'), [jaime, cersei], \"array is sorted correctly\");\n\n run(function() {\n cersei.set('status', 2);\n });\n\n deepEqual(get(obj, 'sortedPeople'), [jaime, cersei], \"array is sorted correctly\");\n });\n\n test(\"property paths in sort properties update the sorted array\", function () {\n var jaime, cersei, sansa;\n\n run(function () {\n jaime = EmberObject.create({\n relatedObj: EmberObject.create({ status: 1, firstName: 'Jaime', lastName: 'Lannister' })\n });\n cersei = EmberObject.create({\n relatedObj: EmberObject.create({ status: 2, firstName: 'Cersei', lastName: 'Lannister' })\n });\n sansa = EmberObject.create({\n relatedObj: EmberObject.create({ status: 3, firstName: 'Sansa', lastName: 'Stark' })\n });\n\n obj = EmberObject.createWithMixins({\n people: Ember.A([jaime, cersei, sansa]),\n sortProps: Ember.A(['relatedObj.status']),\n sortedPeople: computedSort('people', 'sortProps')\n });\n });\n\n deepEqual(get(obj, 'sortedPeople'), [jaime, cersei, sansa], \"precond - array is initially sorted\");\n\n run(function () {\n cersei.set('status', 3);\n });\n\n deepEqual(get(obj, 'sortedPeople'), [jaime, cersei, sansa], \"array is sorted correctly\");\n\n run(function () {\n cersei.set('status', 1);\n });\n\n deepEqual(get(obj, 'sortedPeople'), [jaime, cersei, sansa], \"array is sorted correctly\");\n\n run(function () {\n sansa.set('status', 1);\n });\n\n deepEqual(get(obj, 'sortedPeople'), [jaime, cersei, sansa], \"array is sorted correctly\");\n\n run(function () {\n obj.set('sortProps', Ember.A(['relatedObj.firstName']));\n });\n\n deepEqual(get(obj, 'sortedPeople'), [cersei, jaime, sansa], \"array is sorted correctly\");\n });\n\n function sortByLnameFname(a, b) {\n var lna = get(a, 'lname'),\n lnb = get(b, 'lname');\n\n if (lna !== lnb) {\n return lna > lnb ? 1 : -1;\n }\n\n return sortByFnameAsc(a,b);\n }\n\n function sortByFnameAsc(a, b) {\n var fna = get(a, 'fname'),\n fnb = get(b, 'fname');\n\n if (fna === fnb) {\n return 0;\n }\n return fna > fnb ? 1 : -1;\n }\n\n function sortByFnameDesc(a, b) {\n return -sortByFnameAsc(a,b);\n }\n\n module('computedSort - sort function', {\n setup: function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n items: Ember.A([{\n fname: \"Jaime\", lname: \"Lannister\", age: 34\n }, {\n fname: \"Cersei\", lname: \"Lannister\", age: 34\n }, {\n fname: \"Robb\", lname: \"Stark\", age: 16\n }, {\n fname: \"Bran\", lname: \"Stark\", age: 8\n }]),\n\n sortedItems: computedSort('items.@each.fname', sortByLnameFname)\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n commonSortTests();\n\n test(\"changing item properties specified via @each triggers a resort of the modified item\", function() {\n var tyrionInDisguise;\n\n run(function() {\n sorted = get(obj, 'sortedItems');\n items = get(obj, 'items');\n });\n\n tyrionInDisguise = items.objectAt(1);\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n set(tyrionInDisguise, 'fname', 'Tyrion');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Jaime', 'Tyrion', 'Bran', 'Robb'], \"updating a specified property on an item resorts it\");\n });\n\n test(\"changing item properties not specified via @each does not trigger a resort\", function() {\n var cersei;\n\n run(function() {\n sorted = get(obj, 'sortedItems');\n items = get(obj, 'items');\n });\n\n cersei = items.objectAt(1);\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"precond - array is initially sorted\");\n\n run(function() {\n set(cersei, 'lname', 'Stark'); // plot twist! (possibly not canon)\n });\n\n // The array has become unsorted. If your sort function is sensitive to\n // properties, they *must* be specified as dependent item property keys or\n // we'll be doing binary searches on unsorted arrays.\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime', 'Bran', 'Robb'], \"updating an unspecified property on an item does not resort it\");\n });\n\n module('computedMax', {\n setup: function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n items: Ember.A([1,2,3]),\n max: computedMax('items')\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"max tracks the max number as objects are added\", function() {\n equal(get(obj, 'max'), 3, \"precond - max is initially correct\");\n\n run(function() {\n items = get(obj, 'items');\n });\n\n run(function() {\n items.pushObject(5);\n });\n\n equal(get(obj, 'max'), 5, \"max updates when a larger number is added\");\n\n run(function() {\n items.pushObject(2);\n });\n\n equal(get(obj, 'max'), 5, \"max does not update when a smaller number is added\");\n });\n\n test(\"max recomputes when the current max is removed\", function() {\n equal(get(obj, 'max'), 3, \"precond - max is initially correct\");\n\n run(function() {\n items = get(obj, 'items');\n items.removeObject(2);\n });\n\n equal(get(obj, 'max'), 3, \"max is unchanged when a non-max item is removed\");\n\n run(function() {\n items.removeObject(3);\n });\n\n equal(get(obj, 'max'), 1, \"max is recomputed when the current max is removed\");\n });\n\n module('computedMin', {\n setup: function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n items: Ember.A([1,2,3]),\n min: computedMin('items')\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"min tracks the min number as objects are added\", function() {\n equal(get(obj, 'min'), 1, \"precond - min is initially correct\");\n\n run(function() {\n items = get(obj, 'items');\n });\n\n run(function() {\n items.pushObject(-2);\n });\n\n equal(get(obj, 'min'), -2, \"min updates when a smaller number is added\");\n\n run(function() {\n items.pushObject(2);\n });\n\n equal(get(obj, 'min'), -2, \"min does not update when a larger number is added\");\n });\n\n test(\"min recomputes when the current min is removed\", function() {\n equal(get(obj, 'min'), 1, \"precond - min is initially correct\");\n\n run(function() {\n items = get(obj, 'items');\n items.removeObject(2);\n });\n\n equal(get(obj, 'min'), 1, \"min is unchanged when a non-min item is removed\");\n\n run(function() {\n items.removeObject(1);\n });\n\n equal(get(obj, 'min'), 3, \"min is recomputed when the current min is removed\");\n });\n\n module('Ember.arrayComputed - mixed sugar', {\n setup: function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n items: Ember.A([{\n fname: \"Jaime\", lname: \"Lannister\", age: 34\n }, {\n fname: \"Cersei\", lname: \"Lannister\", age: 34\n }, {\n fname: \"Robb\", lname: \"Stark\", age: 16\n }, {\n fname: \"Bran\", lname: \"Stark\", age: 8\n }]),\n\n lannisters: computedFilterBy('items', 'lname', 'Lannister'),\n lannisterSorting: Ember.A(['fname']),\n sortedLannisters: computedSort('lannisters', 'lannisterSorting'),\n\n\n starks: computedFilterBy('items', 'lname', 'Stark'),\n starkAges: computedMapBy('starks', 'age'),\n oldestStarkAge: computedMax('starkAges')\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"filtering and sorting can be combined\", function() {\n run(function() {\n items = get(obj, 'items');\n sorted = get(obj, 'sortedLannisters');\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Jaime'], \"precond - array is initially filtered and sorted\");\n\n run(function() {\n items.pushObject({fname: 'Tywin', lname: 'Lannister'});\n items.pushObject({fname: 'Lyanna', lname: 'Stark'});\n items.pushObject({fname: 'Gerion', lname: 'Lannister'});\n });\n\n deepEqual(sorted.mapBy('fname'), ['Cersei', 'Gerion', 'Jaime', 'Tywin'], \"updates propagate to array\");\n });\n\n test(\"filtering, sorting and reduce (max) can be combined\", function() {\n run(function() {\n items = get(obj, 'items');\n });\n\n equal(16, get(obj, 'oldestStarkAge'), \"precond - end of chain is initially correct\");\n\n run(function() {\n items.pushObject({fname: 'Rickon', lname: 'Stark', age: 5});\n });\n\n equal(16, get(obj, 'oldestStarkAge'), \"chain is updated correctly\");\n\n run(function() {\n items.pushObject({fname: 'Eddard', lname: 'Stark', age: 35});\n });\n\n equal(35, get(obj, 'oldestStarkAge'), \"chain is updated correctly\");\n });\n\n function todo(name, priority) {\n return EmberObject.create({name: name, priority: priority});\n }\n\n function priorityComparator(todoA, todoB) {\n var pa = parseInt(get(todoA, 'priority'), 10),\n pb = parseInt(get(todoB, 'priority'), 10);\n\n return pa - pb;\n }\n\n function evenPriorities(todo) {\n var p = parseInt(get(todo, 'priority'), 10);\n\n return p % 2 === 0;\n }\n\n module('Ember.arrayComputed - chains', {\n setup: function() {\n obj = EmberObject.createWithMixins({\n todos: Ember.A([todo('E', 4), todo('D', 3), todo('C', 2), todo('B', 1), todo('A', 0)]),\n sorted: computedSort('todos.@each.priority', priorityComparator),\n filtered: computedFilter('sorted.@each.priority', evenPriorities)\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"it can filter and sort when both depend on the same item property\", function() {\n filtered = get(obj, 'filtered');\n sorted = get(obj, 'sorted');\n todos = get(obj, 'todos');\n\n deepEqual(todos.mapProperty('name'), ['E', 'D', 'C', 'B', 'A'], \"precond - todos initially correct\");\n deepEqual(sorted.mapProperty('name'), ['A', 'B', 'C', 'D', 'E'], \"precond - sorted initially correct\");\n deepEqual(filtered.mapProperty('name'), ['A', 'C', 'E'], \"precond - filtered initially correct\");\n\n run(function() {\n beginPropertyChanges();\n // here we trigger several changes\n // A. D.priority 3 -> 6\n // 1. updated sorted from item property change\n // a. remove D; reinsert D\n // b. update filtered from sorted change\n // 2. update filtered from item property change\n //\n // If 1.b happens before 2 it should invalidate 2\n todos.objectAt(1).set('priority', 6);\n endPropertyChanges();\n });\n\n deepEqual(todos.mapProperty('name'), ['E', 'D', 'C', 'B', 'A'], \"precond - todos remain correct\");\n deepEqual(sorted.mapProperty('name'), ['A', 'B', 'C', 'E', 'D'], \"precond - sorted updated correctly\");\n deepEqual(filtered.mapProperty('name'), ['A', 'C', 'E', 'D'], \"filtered updated correctly\");\n });\n\n module('Chaining array and reduced CPs', {\n setup: function() {\n run(function() {\n userFnCalls = 0;\n obj = EmberObject.createWithMixins({\n array: Ember.A([{ v: 1 }, { v: 3}, { v: 2 }, { v: 1 }]),\n mapped: computedMapBy('array', 'v'),\n max: computedMax('mapped'),\n maxDidChange: observer('max', function(){\n userFnCalls++;\n })\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"it computes interdependent array computed properties\", function() {\n var mapped = get(obj, 'mapped');\n\n equal(get(obj, 'max'), 3, 'sanity - it properly computes the maximum value');\n equal(userFnCalls, 0, 'observer is not called on initialisation');\n\n var calls = 0;\n addObserver(obj, 'max', function(){ calls++; });\n\n run(function() {\n obj.get('array').pushObject({ v: 5 });\n });\n\n equal(get(obj, 'max'), 5, 'maximum value is updated correctly');\n equal(userFnCalls, 1, 'object defined observers fire');\n equal(calls, 1, 'runtime created observers fire');\n });\n\n module('computedSum', {\n setup: function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n array: Ember.A([ 1, 2, 3 ]),\n total: computedSum('array')\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test('sums the values in the dependentKey', function(){\n var sum = get(obj, 'total');\n equal(sum, 6, 'sums the values');\n });\n\n test('updates when array is modified', function(){\n var sum = function(){\n return get(obj, 'total');\n };\n\n run(function(){\n get(obj, 'array').pushObject(1);\n });\n\n equal(sum(), 7, 'recomputed when elements are added');\n\n run(function(){\n get(obj, 'array').popObject();\n });\n\n equal(sum(), 6, 'recomputes when elements are removed');\n });\n });\ndefine(\"ember-runtime/tests/computed/reduce_computed_test\",\n [\"ember-metal/core\",\"ember-metal/enumerable_utils\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/utils\",\"ember-metal/run_loop\",\"ember-metal/mixin\",\"ember-runtime/keys\",\"ember-runtime/system/object\",\"ember-metal/computed\",\"ember-runtime/computed/array_computed\",\"ember-runtime/computed/reduce_computed\",\"ember-runtime/system/array_proxy\",\"ember-runtime/system/subarray\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var EnumerableUtils = __dependency2__[\"default\"];\n var get = __dependency3__.get;\n var getWithDefault = __dependency3__.getWithDefault;\n var set = __dependency4__.set;\n var meta = __dependency5__.meta;\n var run = __dependency6__[\"default\"];\n var observer = __dependency7__.observer;\n var keys = __dependency8__[\"default\"];\n var EmberObject = __dependency9__[\"default\"];\n var ComputedProperty = __dependency10__.ComputedProperty;\n var computed = __dependency10__.computed;\n var arrayComputed = __dependency11__.arrayComputed;\n var reduceComputed = __dependency12__.reduceComputed;\n var ArrayProxy = __dependency13__[\"default\"];\n var SubArray = __dependency14__[\"default\"];\n\n var map = EnumerableUtils.map,\n metaFor = meta,\n obj, addCalls, removeCalls, callbackItems;\n\n module('arrayComputed', {\n setup: function () {\n addCalls = removeCalls = 0;\n\n obj = EmberObject.createWithMixins({\n numbers: Ember.A([ 1, 2, 3, 4, 5, 6 ]),\n otherNumbers: Ember.A([ 7, 8, 9 ]),\n\n // Users would obviously just use `Ember.computed.map`\n // This implemantion is fine for these tests, but doesn't properly work as\n // it's not index based.\n evenNumbers: arrayComputed('numbers', {\n addedItem: function (array, item) {\n addCalls++;\n if (item % 2 === 0) {\n array.pushObject(item);\n }\n return array;\n },\n removedItem: function (array, item) {\n removeCalls++;\n array.removeObject(item);\n return array;\n }\n }),\n\n evenNumbersMultiDep: arrayComputed('numbers', 'otherNumbers', {\n addedItem: function (array, item) {\n if (item % 2 === 0) {\n array.pushObject(item);\n }\n return array;\n }\n }),\n\n nestedNumbers: Ember.A(map([1,2,3,4,5,6], function (n) {\n return EmberObject.create({ p: 'otherProperty', v: n });\n })),\n\n evenNestedNumbers: arrayComputed({\n addedItem: function (array, item, keyName) {\n var value = item.get('v');\n if (value % 2 === 0) {\n array.pushObject(value);\n }\n return array;\n },\n removedItem: function (array, item, keyName) {\n array.removeObject(item.get('v'));\n return array;\n }\n }).property('nestedNumbers.@each.v')\n });\n },\n\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n\n test(\"array computed properties are instances of ComputedProperty\", function() {\n ok(arrayComputed({}) instanceof ComputedProperty);\n });\n\n test(\"when the dependent array is null or undefined, `addedItem` is not called and only the initial value is returned\", function() {\n obj = EmberObject.createWithMixins({\n numbers: null,\n doubledNumbers: arrayComputed('numbers', {\n addedItem: function (array, n) {\n addCalls++;\n array.pushObject(n * 2);\n return array;\n }\n })\n });\n\n deepEqual(get(obj, 'doubledNumbers'), [], \"When the dependent array is null, the initial value is returned\");\n equal(addCalls, 0, \"`addedItem` is not called when the dependent array is null\");\n\n run(function() {\n set(obj, 'numbers', Ember.A([1,2]));\n });\n\n deepEqual(get(obj, 'doubledNumbers'), [2,4], \"An initially null dependent array can still be set later\");\n equal(addCalls, 2, \"`addedItem` is called when the dependent array is initially set\");\n });\n\n test(\"on first retrieval, array computed properties are computed\", function() {\n deepEqual(get(obj, 'evenNumbers'), [2,4,6], \"array computed properties are correct on first invocation\");\n });\n\n test(\"on first retrieval, array computed properties with multiple dependent keys are computed\", function() {\n deepEqual(get(obj, 'evenNumbersMultiDep'), [2, 4, 6, 8], \"array computed properties are correct on first invocation\");\n });\n\n test(\"on first retrieval, array computed properties dependent on nested objects are computed\", function() {\n deepEqual(get(obj, 'evenNestedNumbers'), [2,4,6], \"array computed properties are correct on first invocation\");\n });\n\n test(\"after the first retrieval, array computed properties observe additions to dependent arrays\", function() {\n var numbers = get(obj, 'numbers'),\n // set up observers\n evenNumbers = get(obj, 'evenNumbers');\n\n run(function() {\n numbers.pushObjects([7, 8]);\n });\n\n deepEqual(evenNumbers, [2, 4, 6, 8], \"array computed properties watch dependent arrays\");\n });\n\n test(\"after the first retrieval, array computed properties observe removals from dependent arrays\", function() {\n var numbers = get(obj, 'numbers'),\n // set up observers\n evenNumbers = get(obj, 'evenNumbers');\n\n run(function() {\n numbers.removeObjects([3, 4]);\n });\n\n deepEqual(evenNumbers, [2, 6], \"array computed properties watch dependent arrays\");\n });\n\n test(\"after first retrieval, array computed properties can observe properties on array items\", function() {\n var nestedNumbers = get(obj, 'nestedNumbers'),\n evenNestedNumbers = get(obj, 'evenNestedNumbers');\n\n deepEqual(evenNestedNumbers, [2, 4, 6], 'precond -- starts off with correct values');\n\n run(function() {\n nestedNumbers.objectAt(0).set('v', 22);\n });\n\n deepEqual(nestedNumbers.mapBy('v'), [22, 2, 3, 4, 5, 6], 'nested numbers is updated');\n deepEqual(evenNestedNumbers, [2, 4, 6, 22], 'adds new number');\n });\n\n test(\"changes to array computed properties happen synchronously\", function() {\n var nestedNumbers = get(obj, 'nestedNumbers'),\n evenNestedNumbers = get(obj, 'evenNestedNumbers');\n\n deepEqual(evenNestedNumbers, [2, 4, 6], 'precond -- starts off with correct values');\n\n run(function() {\n nestedNumbers.objectAt(0).set('v', 22);\n deepEqual(nestedNumbers.mapBy('v'), [22, 2, 3, 4, 5, 6], 'nested numbers is updated');\n deepEqual(evenNestedNumbers, [2, 4, 6, 22], 'adds new number');\n });\n });\n\n test(\"multiple dependent keys can be specified via brace expansion\", function() {\n var obj = EmberObject.createWithMixins({\n bar: Ember.A(),\n baz: Ember.A(),\n foo: reduceComputed({\n initialValue: Ember.A(),\n addedItem: function(array, item) { array.pushObject('a:' + item); return array; },\n removedItem: function(array, item) { array.pushObject('r:' + item); return array; }\n }).property('{bar,baz}')\n });\n\n deepEqual(get(obj, 'foo'), [], \"initially empty\");\n\n get(obj, 'bar').pushObject(1);\n\n deepEqual(get(obj, 'foo'), ['a:1'], \"added item from brace-expanded dependency\");\n\n get(obj, 'baz').pushObject(2);\n\n deepEqual(get(obj, 'foo'), ['a:1', 'a:2'], \"added item from brace-expanded dependency\");\n\n get(obj, 'bar').popObject();\n\n deepEqual(get(obj, 'foo'), ['a:1', 'a:2', 'r:1'], \"removed item from brace-expanded dependency\");\n\n get(obj, 'baz').popObject();\n\n deepEqual(get(obj, 'foo'), ['a:1', 'a:2', 'r:1', 'r:2'], \"removed item from brace-expanded dependency\");\n });\n\n test(\"multiple item property keys can be specified via brace expansion\", function() {\n var addedCalls = 0,\n removedCalls = 0,\n expected = Ember.A(),\n item = { propA: 'A', propB: 'B', propC: 'C' },\n obj = EmberObject.createWithMixins({\n bar: Ember.A([item]),\n foo: reduceComputed({\n initialValue: Ember.A(),\n addedItem: function(array, item, changeMeta) {\n array.pushObject('a:' + get(item, 'propA') + ':' + get(item, 'propB') + ':' + get(item, 'propC'));\n return array;\n },\n removedItem: function(array, item, changeMeta) {\n array.pushObject('r:' + get(item, 'propA') + ':' + get(item, 'propB') + ':' + get(item, 'propC'));\n return array;\n }\n }).property('bar.@each.{propA,propB}')\n });\n\n expected.pushObjects(['a:A:B:C']);\n deepEqual(get(obj, 'foo'), expected, \"initially added dependent item\");\n\n set(item, 'propA', 'AA');\n\n expected.pushObjects(['r:AA:B:C', 'a:AA:B:C']);\n deepEqual(get(obj, 'foo'), expected, \"observing item property key specified via brace expansion\");\n\n set(item, 'propB', 'BB');\n\n expected.pushObjects(['r:AA:BB:C', 'a:AA:BB:C']);\n deepEqual(get(obj, 'foo'), expected, \"observing item property key specified via brace expansion\");\n\n set(item, 'propC', 'CC');\n\n deepEqual(get(obj, 'foo'), expected, \"not observing unspecified item properties\");\n });\n\n test(\"doubly nested item property keys (@each.foo.@each) are not supported\", function() {\n run(function() {\n obj = EmberObject.createWithMixins({\n peopleByOrdinalPosition: Ember.A([{ first: Ember.A([EmberObject.create({ name: \"Jaime Lannister\" })])}]),\n people: arrayComputed({\n addedItem: function (array, item) {\n array.pushObject(get(item, 'first.firstObject'));\n return array;\n }\n }).property('peopleByOrdinalPosition.@each.first'),\n names: arrayComputed({\n addedItem: function (array, item) {\n equal(get(item, 'name'), 'Jaime Lannister');\n array.pushObject(item.get('name'));\n return array;\n }\n }).property('people.@each.name')\n });\n });\n\n equal(obj.get('names.firstObject'), 'Jaime Lannister', \"Doubly nested item properties can be retrieved manually\");\n\n throws(function() {\n obj = EmberObject.createWithMixins({\n people: [{ first: Ember.A([EmberObject.create({ name: \"Jaime Lannister\" })])}],\n names: arrayComputed({\n addedItem: function (array, item) {\n array.pushObject(item);\n return array;\n }\n }).property('people.@each.first.@each.name')\n });\n }, /Nested @each/, \"doubly nested item property keys are not supported\");\n });\n\n test(\"after the first retrieval, array computed properties observe dependent arrays\", function() {\n var numbers = get(obj, 'numbers'),\n evenNumbers = get(obj, 'evenNumbers');\n\n deepEqual(evenNumbers, [2, 4, 6], 'precond -- starts off with correct values');\n\n run(function() {\n set(obj, 'numbers', Ember.A([20, 23, 28]));\n });\n\n deepEqual(evenNumbers, [20, 28], \"array computed properties watch dependent arrays\");\n });\n\n test(\"array observers are torn down when dependent arrays change\", function() {\n var numbers = get(obj, 'numbers'),\n evenNumbers = get(obj, 'evenNumbers');\n\n equal(addCalls, 6, 'precond - add has been called for each item in the array');\n equal(removeCalls, 0, 'precond - removed has not been called');\n\n run(function() {\n set(obj, 'numbers', Ember.A([20, 23, 28]));\n });\n\n equal(addCalls, 9, 'add is called for each item in the new array');\n equal(removeCalls, 0, 'remove is not called when the array is reset');\n\n numbers.replace(0, numbers.get('length'), Ember.A([7,8,9,10]));\n\n equal(addCalls, 9, 'add is not called');\n equal(removeCalls, 0, 'remove is not called');\n });\n\n test(\"modifying properties on dependent array items triggers observers exactly once\", function() {\n var numbers = get(obj, 'numbers'),\n evenNumbers = get(obj, 'evenNumbers');\n\n equal(addCalls, 6, 'precond - add has not been called for each item in the array');\n equal(removeCalls, 0, 'precond - removed has not been called');\n\n run(function() {\n numbers.replace(0,2,[7,8,9,10]);\n });\n\n equal(addCalls, 10, 'add is called for each item added');\n equal(removeCalls, 2, 'removed is called for each item removed');\n deepEqual(evenNumbers, [4,6,8,10], 'sanity check - dependent arrays are updated');\n });\n\n test(\"multiple array computed properties on the same object can observe dependent arrays\", function() {\n var numbers = get(obj, 'numbers'),\n otherNumbers = get(obj, 'otherNumbers');\n\n deepEqual(get(obj, 'evenNumbers'), [2,4,6], \"precond - evenNumbers is initially correct\");\n deepEqual(get(obj, 'evenNumbersMultiDep'), [2, 4, 6, 8], \"precond - evenNumbersMultiDep is initially correct\");\n\n run(function() {\n numbers.pushObject(12);\n otherNumbers.pushObject(14);\n });\n\n deepEqual(get(obj, 'evenNumbers'), [2,4,6,12], \"evenNumbers is updated\");\n deepEqual(get(obj, 'evenNumbersMultiDep'), [2, 4, 6, 8, 12, 14], \"evenNumbersMultiDep is updated\");\n });\n\n test(\"an error is thrown when a reduceComputed is defined without an initialValue property\", function() {\n var defineExploder = function() {\n EmberObject.createWithMixins({\n collection: Ember.A(),\n exploder: reduceComputed('collection', {\n initialize: function(initialValue, changeMeta, instanceMeta) {},\n\n addedItem: function(accumulatedValue,item,changeMeta,instanceMeta) {\n return item;\n },\n\n removedItem: function(accumulatedValue,item,changeMeta,instanceMeta) {\n return item;\n }\n })\n });\n };\n\n throws(defineExploder, /declared\\ without\\ an\\ initial\\ value/, \"an error is thrown when the reduceComputed is defined without an initialValue\");\n });\n\n test(\"dependent arrays with multiple item properties are not double-counted\", function() {\n var obj = EmberObject.extend({\n items: Ember.A([{ foo: true }, { bar: false }, { bar: true }]),\n countFooOrBar: reduceComputed({\n initialValue: 0,\n addedItem: function (acc) {\n ++addCalls;\n return acc;\n },\n\n removedItem: function (acc) {\n ++removeCalls;\n return acc;\n }\n }).property('items.@each.foo', 'items.@each.bar', 'items')\n }).create();\n\n equal(0, addCalls, \"precond - no adds yet\");\n equal(0, removeCalls, \"precond - no removes yet\");\n\n get(obj, 'countFooOrBar');\n\n equal(3, addCalls, \"all items added once\");\n equal(0, removeCalls, \"no removes yet\");\n });\n\n test(\"dependent arrays can use `replace` with an out of bounds index to add items\", function() {\n var dependentArray = Ember.A(),\n array;\n\n obj = EmberObject.extend({\n dependentArray: dependentArray,\n computed: arrayComputed('dependentArray', {\n addedItem: function (acc, item, changeMeta) {\n acc.insertAt(changeMeta.index, item);\n return acc;\n },\n removedItem: function (acc) { return acc; }\n })\n }).create();\n\n array = get(obj, 'computed');\n\n deepEqual(array, [], \"precond - computed array is initially empty\");\n\n dependentArray.replace(100, 0, [1, 2]);\n\n deepEqual(array, [1, 2], \"index >= length treated as a push\");\n\n dependentArray.replace(-100, 0, [3, 4]);\n\n deepEqual(array, [3, 4, 1, 2], \"index < 0 treated as an unshift\");\n });\n\n test(\"dependent arrays can use `replace` with a negative index to remove items indexed from the right\", function() {\n var dependentArray = Ember.A([1,2,3,4,5]),\n array;\n\n obj = EmberObject.extend({\n dependentArray: dependentArray,\n computed: arrayComputed('dependentArray', {\n addedItem: function (acc, item) { return acc; },\n removedItem: function (acc, item) { acc.pushObject(item); return acc; }\n })\n }).create();\n\n array = get(obj, 'computed');\n\n deepEqual(array, [], \"precond - no items have been removed initially\");\n\n dependentArray.replace(-3, 2);\n\n deepEqual(array, [4,3], \"index < 0 used as a right index for removal\");\n });\n\n test(\"dependent arrays that call `replace` with an out of bounds index to remove items is a no-op\", function() {\n var dependentArray = Ember.A([1, 2]),\n array;\n\n obj = EmberObject.extend({\n dependentArray: dependentArray,\n computed: arrayComputed('dependentArray', {\n addedItem: function (acc, item, changeMeta) { return acc; },\n removedItem: function (acc) {\n ok(false, \"no items have been removed\");\n }\n })\n }).create();\n\n array = get(obj, 'computed');\n\n deepEqual(array, [], \"precond - computed array is initially empty\");\n\n dependentArray.replace(100, 2);\n });\n\n test(\"dependent arrays that call `replace` with a too-large removedCount a) works and b) still right-truncates\", function() {\n var dependentArray = Ember.A([1, 2]),\n array;\n\n obj = EmberObject.extend({\n dependentArray: dependentArray,\n computed: arrayComputed('dependentArray', {\n addedItem: function (acc, item) { return acc; },\n removedItem: function (acc, item) { acc.pushObject(item); return acc; }\n })\n }).create();\n\n array = get(obj, 'computed');\n\n deepEqual(array, [], \"precond - computed array is initially empty\");\n\n dependentArray.replace(1, 200);\n\n deepEqual(array, [2], \"array was correctly right-truncated\");\n });\n\n test(\"removedItem is not erroneously called for dependent arrays during a recomputation\", function() {\n function addedItem(array, item, changeMeta) {\n array.insertAt(changeMeta.index, item);\n return array;\n }\n\n function removedItem(array, item, changeMeta) {\n ok(get(array, 'length') > changeMeta.index, \"removedItem not called with invalid index\");\n array.removeAt(changeMeta.index, 1);\n return array;\n }\n\n var dependentArray = Ember.A(),\n options = {\n addedItem: addedItem,\n removedItem: removedItem\n };\n\n obj = EmberObject.extend({\n dependentArray: Ember.A([1, 2]),\n identity0: arrayComputed('dependentArray', options),\n identity1: arrayComputed('identity0', options)\n }).create();\n\n get(obj, 'identity1');\n run(function() {\n obj.notifyPropertyChange('dependentArray');\n });\n\n ok(true, \"removedItem not invoked with invalid index\");\n });\n\n module('arrayComputed - recomputation DKs', {\n setup: function() {\n obj = EmberObject.extend({\n people: Ember.A([{\n name: 'Jaime Lannister',\n title: 'Kingsguard'\n }, {\n name: 'Cersei Lannister',\n title: 'Queen'\n }]),\n\n titles: arrayComputed('people', {\n addedItem: function (acc, person) {\n acc.pushObject(get(person, 'title'));\n return acc;\n }\n })\n }).create();\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"recomputations from `arrayComputed` observers add back dependent keys\", function() {\n var meta = metaFor(obj),\n people = get(obj, 'people'),\n titles;\n\n equal(meta.deps, undefined, \"precond - nobody depends on people'\");\n equal(meta.watching.people, undefined, \"precond - nobody is watching people\");\n\n titles = get(obj, 'titles');\n\n deepEqual(titles, [\"Kingsguard\", \"Queen\"], \"precond - value is correct\");\n\n ok(meta.deps.people !== undefined, \"people has dependencies\");\n deepEqual(keys(meta.deps.people), [\"titles\"], \"only titles depends on people\");\n equal(meta.deps.people.titles, 1, \"titles depends on people exactly once\");\n equal(meta.watching.people, 2, \"people has two watchers: the array listener and titles\");\n\n run(function() {\n set(obj, 'people', Ember.A());\n });\n\n // Regular CPs are invalidated when their dependent keys change, but array\n // computeds keep refs up to date\n deepEqual(titles, [], \"value is correct\");\n equal(meta.cache.titles, titles, \"value remains cached\");\n ok(meta.deps.people !== undefined, \"people has dependencies\");\n deepEqual(keys(meta.deps.people), [\"titles\"], \"meta.deps.people is unchanged\");\n equal(meta.deps.people.titles, 1, \"deps.people.titles is unchanged\");\n equal(meta.watching.people, 2, \"watching.people is unchanged\");\n });\n\n module('Ember.arryComputed - self chains', {\n setup: function() {\n var a = EmberObject.create({ name: 'a' }),\n b = EmberObject.create({ name: 'b' });\n\n obj = ArrayProxy.createWithMixins({\n content: Ember.A([a, b]),\n names: arrayComputed('@this.@each.name', {\n addedItem: function (array, item, changeMeta, instanceMeta) {\n var mapped = get(item, 'name');\n array.insertAt(changeMeta.index, mapped);\n return array;\n },\n removedItem: function(array, item, changeMeta, instanceMeta) {\n array.removeAt(changeMeta.index, 1);\n return array;\n }\n })\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"@this can be used to treat the object as the array itself\", function() {\n var names = get(obj, 'names');\n\n deepEqual(names, ['a', 'b'], \"precond - names is initially correct\");\n\n run(function() {\n obj.objectAt(1).set('name', 'c');\n });\n\n deepEqual(names, ['a', 'c'], \"@this can be used with item property observers\");\n\n run(function() {\n obj.pushObject({ name: 'd' });\n });\n\n deepEqual(names, ['a', 'c', 'd'], \"@this observes new items\");\n });\n\n module('arrayComputed - changeMeta property observers', {\n setup: function() {\n callbackItems = [];\n run(function() {\n obj = EmberObject.createWithMixins({\n items: Ember.A([EmberObject.create({ n: 'zero' }), EmberObject.create({ n: 'one' })]),\n itemsN: arrayComputed('items.@each.n', {\n addedItem: function (array, item, changeMeta, instanceMeta) {\n callbackItems.push('add:' + changeMeta.index + \":\" + get(changeMeta.item, 'n'));\n },\n removedItem: function (array, item, changeMeta, instanceMeta) {\n callbackItems.push('remove:' + changeMeta.index + \":\" + get(changeMeta.item, 'n'));\n }\n })\n });\n });\n },\n teardown: function() {\n run(function() {\n obj.destroy();\n });\n }\n });\n\n test(\"changeMeta includes item and index\", function() {\n var expected, items, item;\n\n items = get(obj, 'items');\n\n // initial computation add0 add1\n run(function() {\n obj.get('itemsN');\n });\n\n // add2\n run(function() {\n items.pushObject(EmberObject.create({ n: 'two' }));\n });\n\n // remove2\n run(function() {\n items.popObject();\n });\n\n // remove0 add0\n run(function() {\n set(get(items, 'firstObject'), 'n', \"zero'\");\n });\n\n expected = [\"add:0:zero\", \"add:1:one\", \"add:2:two\", \"remove:2:two\", \"remove:0:zero'\", \"add:0:zero'\"];\n deepEqual(callbackItems, expected, \"changeMeta includes items\");\n\n // [zero', one] -> [zero', one, five, six]\n // add2 add3\n run(function() {\n items.pushObject(EmberObject.create({ n: 'five' }));\n items.pushObject(EmberObject.create({ n: 'six' }));\n });\n\n // remove0 add0\n run(function() {\n items.objectAt(0).set('n', \"zero''\");\n });\n\n expected = expected.concat(['add:2:five', 'add:3:six', \"remove:0:zero''\", \"add:0:zero''\"]);\n deepEqual(callbackItems, expected, \"changeMeta includes items\");\n\n // [zero'', one, five, six] -> [zero'', five, six]\n // remove1\n run(function() {\n item = items.objectAt(1);\n items.removeAt(1, 1);\n });\n\n run(function() {\n // observer should have been removed from the deleted item\n item.set('n', 'ten thousand');\n });\n\n // [zero'', five, six] -> [zero'', five, seven]\n // remove2 add2\n run(function() {\n items.objectAt(2).set('n', \"seven\");\n });\n\n // observer should have been added to the new item\n expected = expected.concat(['remove:1:one', 'remove:2:seven', 'add:2:seven']);\n deepEqual(callbackItems, expected, \"changeMeta includes items\");\n\n // reset (does not call remove)\n run(function() {\n item = items.objectAt(1);\n set(obj, 'items', Ember.A([]));\n });\n\n run(function() {\n // observers should have been removed from the items in the old array\n set(item, 'n', 'eleven thousand');\n });\n\n deepEqual(callbackItems, expected, \"items removed from the array had observers removed\");\n });\n\n test(\"`updateIndexes` is not over-eager about skipping retain:n (#4620)\", function() {\n var tracked = Ember.A();\n obj = EmberObject.extend({\n content: Ember.A([{ n: \"one\" }, { n: \"two\" }]),\n items: arrayComputed('content.@each.n', {\n addedItem: function (array, item, changeMeta) {\n tracked.push('+' + get(item, 'n') + '@' + changeMeta.index);\n array.insertAt(changeMeta.index, item);\n return array;\n },\n removedItem: function (array, item, changeMeta) {\n tracked.push('-' + (changeMeta.previousValues ? changeMeta.previousValues.n : get(item, 'n')) + '@' + changeMeta.index);\n array.removeAt(changeMeta.index);\n return array;\n }\n })\n }).create();\n\n run(function () {\n obj.get('items');\n });\n\n deepEqual(tracked, [\"+one@0\", \"+two@1\"], \"precond - array is set up correctly\");\n\n run(function () {\n obj.get('content').shiftObject();\n });\n\n deepEqual(tracked, [\"+one@0\", \"+two@1\", \"-one@0\"], \"array handles unshift correctly\");\n\n run(function () {\n set(obj, 'content.lastObject.n', 'three');\n });\n\n deepEqual(tracked, [\"+one@0\", \"+two@1\", \"-one@0\", \"-two@0\", \"+three@0\"], \"array handles a change when operations are delete:m retain:n-m\");\n });\n\n test(\"when initialValue is undefined, everything works as advertised\", function() {\n var chars = EmberObject.createWithMixins({\n letters: Ember.A(),\n firstUpper: reduceComputed('letters', {\n initialValue: undefined,\n\n initialize: function(initialValue, changeMeta, instanceMeta) {\n instanceMeta.matchingItems = Ember.A();\n instanceMeta.subArray = new SubArray();\n instanceMeta.firstMatch = function() {\n return getWithDefault(instanceMeta.matchingItems, 'firstObject', initialValue);\n };\n },\n\n addedItem: function(accumulatedValue,item,changeMeta,instanceMeta) {\n var filterIndex;\n filterIndex = instanceMeta.subArray.addItem(changeMeta.index, item.toUpperCase() === item);\n if (filterIndex > -1) {\n instanceMeta.matchingItems.insertAt(filterIndex, item);\n }\n return instanceMeta.firstMatch();\n },\n\n removedItem: function(accumulatedValue,item,changeMeta,instanceMeta) {\n var filterIndex = instanceMeta.subArray.removeItem(changeMeta.index);\n if (filterIndex > -1) {\n instanceMeta.matchingItems.removeAt(filterIndex);\n }\n return instanceMeta.firstMatch();\n }\n })\n });\n equal(get(chars, 'firstUpper'), undefined, \"initialValue is undefined\");\n\n get(chars, 'letters').pushObjects(['a', 'b', 'c']);\n\n equal(get(chars, 'firstUpper'), undefined, \"result is undefined when no matches are present\");\n\n get(chars, 'letters').pushObjects(['A', 'B', 'C']);\n\n equal(get(chars, 'firstUpper'), 'A', \"result is the first match when matching objects are present\");\n\n get(chars, 'letters').removeAt(3);\n\n equal(get(chars, 'firstUpper'), 'B', \"result is the next match when the first matching object is removed\");\n });\n\n module('arrayComputed - completely invalidating dependencies', {\n setup: function () {\n addCalls = removeCalls = 0;\n }\n });\n\n test(\"non-array dependencies completely invalidate a reduceComputed CP\", function() {\n var dependentArray = Ember.A();\n\n obj = EmberObject.extend({\n nonArray: 'v0',\n dependentArray: dependentArray,\n\n computed: arrayComputed('dependentArray', 'nonArray', {\n addedItem: function (array) {\n ++addCalls;\n return array;\n },\n\n removedItem: function (array) {\n --removeCalls;\n return array;\n }\n })\n }).create();\n\n get(obj, 'computed');\n\n equal(addCalls, 0, \"precond - add has not initially been called\");\n equal(removeCalls, 0, \"precond - remove has not initially been called\");\n\n dependentArray.pushObjects([1, 2]);\n\n equal(addCalls, 2, \"add called one-at-a-time for dependent array changes\");\n equal(removeCalls, 0, \"remove not called\");\n\n run(function() {\n set(obj, 'nonArray', 'v1');\n });\n\n equal(addCalls, 4, \"array completely recomputed when non-array dependency changed\");\n equal(removeCalls, 0, \"remove not called\");\n });\n\n test(\"array dependencies specified with `.[]` completely invalidate a reduceComputed CP\", function() {\n var dependentArray = Ember.A(),\n totallyInvalidatingDependentArray = Ember.A();\n\n obj = EmberObject.extend({\n totallyInvalidatingDependentArray: totallyInvalidatingDependentArray,\n dependentArray: dependentArray,\n\n computed: arrayComputed('dependentArray', 'totallyInvalidatingDependentArray.[]', {\n addedItem: function (array, item) {\n ok(item !== 3, \"totally invalidating items are never passed to the one-at-a-time callbacks\");\n ++addCalls;\n return array;\n },\n\n removedItem: function (array, item) {\n ok(item !== 3, \"totally invalidating items are never passed to the one-at-a-time callbacks\");\n --removeCalls;\n return array;\n }\n })\n }).create();\n\n get(obj, 'computed');\n\n equal(addCalls, 0, \"precond - add has not initially been called\");\n equal(removeCalls, 0, \"precond - remove has not initially been called\");\n\n dependentArray.pushObjects([1, 2]);\n\n equal(addCalls, 2, \"add called one-at-a-time for dependent array changes\");\n equal(removeCalls, 0, \"remove not called\");\n\n run(function() {\n totallyInvalidatingDependentArray.pushObject(3);\n });\n\n equal(addCalls, 4, \"array completely recomputed when totally invalidating dependent array modified\");\n equal(removeCalls, 0, \"remove not called\");\n });\n\n test(\"returning undefined in addedItem/removedItem completely invalidates a reduceComputed CP\", function() {\n var dependentArray = Ember.A([3,2,1]),\n counter = 0;\n\n obj = EmberObject.extend({\n dependentArray: dependentArray,\n\n computed: reduceComputed('dependentArray', {\n initialValue: Infinity,\n\n addedItem: function (accumulatedValue, item, changeMeta, instanceMeta) {\n return Math.min(accumulatedValue, item);\n },\n\n removedItem: function (accumulatedValue, item, changeMeta, instanceMeta) {\n if (item > accumulatedValue) {\n return accumulatedValue;\n }\n }\n }),\n\n computedDidChange: observer('computed', function() {\n counter++;\n })\n }).create();\n\n get(obj, 'computed');\n equal(get(obj, 'computed'), 1);\n equal(counter, 0);\n\n dependentArray.pushObject(10);\n equal(get(obj, 'computed'), 1);\n equal(counter, 0);\n\n dependentArray.removeObject(10);\n equal(get(obj, 'computed'), 1);\n equal(counter, 0);\n\n dependentArray.removeObject(1);\n equal(get(obj, 'computed'), 2);\n equal(counter, 1);\n });\n\n if (!Ember.EXTEND_PROTOTYPES && !Ember.EXTEND_PROTOTYPES.Array) {\n test(\"reduceComputed complains about array dependencies that are not `Ember.Array`s\", function() {\n var Type = EmberObject.extend({\n rc: reduceComputed('array', {\n initialValue: 0,\n addedItem: function(v){ return v; },\n removedItem: function(v){ return v; }\n })\n });\n\n expectAssertion(function() {\n obj = Type.create({ array: [] });\n get(obj, 'rc');\n }, /must be an `Ember.Array`/, \"Ember.reduceComputed complains about dependent non-extended native arrays\");\n });\n }\n });\ndefine(\"ember-runtime/tests/controllers/array_controller_test\",\n [\"ember-metal/core\",\"ember-runtime/tests/suites/mutable_array\",\"ember-runtime/controllers/array_controller\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var MutableArrayTests = __dependency2__[\"default\"];\n var ArrayController = __dependency3__[\"default\"];\n\n module(\"ember-runtime/controllers/array_controller_test\");\n\n MutableArrayTests.extend({\n name: 'Ember.ArrayController',\n\n newObject: function(ary) {\n var ret = ary ? ary.slice() : this.newFixture(3);\n return ArrayController.create({\n content: Ember.A(ret)\n });\n },\n\n mutate: function(obj) {\n obj.pushObject(Ember.get(obj, 'length')+1);\n },\n\n toArray: function(obj) {\n return obj.toArray ? obj.toArray() : obj.slice();\n }\n }).run();\n\n test(\"defaults it's `content` to an empty array\", function () {\n var Controller = ArrayController.extend();\n deepEqual(Controller.create().get(\"content\"), [], \"`ArrayController` defaults it's content to an empty array\");\n equal(Controller.create().get('firstObject'), undefined, 'can fetch firstObject');\n equal(Controller.create().get('lastObject'), undefined, 'can fetch lastObject');\n });\n\n\n test(\"Ember.ArrayController length property works even if content was not set initially\", function() {\n var controller = ArrayController.create();\n controller.pushObject('item');\n equal(controller.get('length'), 1);\n });\n });\ndefine(\"ember-runtime/tests/controllers/controller_test\",\n [\"ember-metal/core\",\"ember-runtime/controllers/controller\",\"ember-runtime/controllers/object_controller\",\"ember-metal/mixin\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var Controller = __dependency2__.Controller;\n var ControllerMixin = __dependency2__.ControllerMixin;\n var ObjectController = __dependency3__[\"default\"];\n var Mixin = __dependency4__.Mixin;\n\n module('Controller event handling');\n\n test(\"Action can be handled by a function on actions object\", function() {\n expect(1);\n var TestController = Controller.extend({\n actions: {\n poke: function() {\n ok(true, 'poked');\n }\n }\n });\n var controller = TestController.create({});\n controller.send(\"poke\");\n });\n\n // TODO: Can we support this?\n // test(\"Actions handlers can be configured to use another name\", function() {\n // expect(1);\n // var TestController = Controller.extend({\n // actionsProperty: 'actionHandlers',\n // actionHandlers: {\n // poke: function() {\n // ok(true, 'poked');\n // }\n // }\n // });\n // var controller = TestController.create({});\n // controller.send(\"poke\");\n // });\n\n test(\"When `_actions` is provided, `actions` is left alone\", function() {\n expect(2);\n var TestController = Controller.extend({\n actions: ['foo', 'bar'],\n _actions: {\n poke: function() {\n ok(true, 'poked');\n }\n }\n });\n var controller = TestController.create({});\n controller.send(\"poke\");\n equal('foo', controller.get(\"actions\")[0], 'actions property is not untouched');\n });\n\n test(\"Actions object doesn't shadow a proxied object's 'actions' property\", function() {\n var TestController = ObjectController.extend({\n content: {\n actions: 'foo'\n },\n actions: {\n poke: function() {\n console.log('ouch');\n }\n }\n });\n var controller = TestController.create({});\n equal(controller.get(\"actions\"), 'foo', \"doesn't shadow the content's actions property\");\n });\n\n test(\"A handled action can be bubbled to the target for continued processing\", function() {\n expect(2);\n var TestController = Controller.extend({\n actions: {\n poke: function() {\n ok(true, 'poked 1');\n return true;\n }\n }\n });\n\n var controller = TestController.create({\n target: Controller.extend({\n actions: {\n poke: function() {\n ok(true, 'poked 2');\n }\n }\n }).create()\n });\n controller.send(\"poke\");\n });\n\n test(\"Action can be handled by a superclass' actions object\", function() {\n expect(4);\n\n var SuperController = Controller.extend({\n actions: {\n foo: function() {\n ok(true, 'foo');\n },\n bar: function(msg) {\n equal(msg, \"HELLO\");\n }\n }\n });\n\n var BarControllerMixin = Mixin.create({\n actions: {\n bar: function(msg) {\n equal(msg, \"HELLO\");\n this._super(msg);\n }\n }\n });\n\n var IndexController = SuperController.extend(BarControllerMixin, {\n actions: {\n baz: function() {\n ok(true, 'baz');\n }\n }\n });\n\n var controller = IndexController.create({});\n controller.send(\"foo\");\n controller.send(\"bar\", \"HELLO\");\n controller.send(\"baz\");\n });\n\n module('Controller deprecations');\n\n if (!Ember.FEATURES.isEnabled('ember-routing-drop-deprecated-action-style')) {\n test(\"Action can be handled by method directly on controller (DEPRECATED)\", function() {\n expectDeprecation(/Action handlers implemented directly on controllers are deprecated/);\n var TestController = Controller.extend({\n poke: function() {\n ok(true, 'poked');\n }\n });\n var controller = TestController.create({});\n controller.send(\"poke\");\n });\n }\n });\ndefine(\"ember-runtime/tests/controllers/item_controller_class_test\",\n [\"ember-metal/core\",\"ember-metal/utils\",\"ember-metal/run_loop\",\"ember-metal/property_get\",\"ember-metal/computed\",\"ember-runtime/compare\",\"ember-runtime/system/object\",\"ember-runtime/controllers/array_controller\",\"ember-runtime/controllers/object_controller\",\"ember-runtime/computed/reduce_computed_macros\",\"container\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var guidFor = __dependency2__.guidFor;\n var run = __dependency3__[\"default\"];\n var get = __dependency4__.get;\n var computed = __dependency5__.computed;\n var compare = __dependency6__[\"default\"];\n var EmberObject = __dependency7__[\"default\"];\n var ArrayController = __dependency8__[\"default\"];\n var ObjectController = __dependency9__[\"default\"];\n var sort = __dependency10__.sort;\n var Container = __dependency11__[\"default\"];\n\n var lannisters, arrayController, controllerClass, otherControllerClass, container, itemControllerCount,\n tywin, jaime, cersei, tyrion;\n\n module(\"Ember.ArrayController - itemController\", {\n setup: function() {\n container = new Container();\n\n tywin = EmberObject.create({ name: 'Tywin' });\n jaime = EmberObject.create({ name: 'Jaime' });\n cersei = EmberObject.create({ name: 'Cersei' });\n tyrion = EmberObject.create({ name: 'Tyrion' });\n lannisters = Ember.A([ tywin, jaime, cersei ]);\n\n itemControllerCount = 0;\n controllerClass = ObjectController.extend({\n init: function() {\n ++itemControllerCount;\n this._super();\n },\n\n toString: function() {\n return \"itemController for \" + this.get('name');\n }\n });\n\n otherControllerClass = ObjectController.extend({\n toString: function() {\n return \"otherItemController for \" + this.get('name');\n }\n });\n\n container.register(\"controller:Item\", controllerClass);\n container.register(\"controller:OtherItem\", otherControllerClass);\n },\n teardown: function() {\n run(function() {\n container.destroy();\n });\n }\n });\n\n function createUnwrappedArrayController() {\n arrayController = ArrayController.create({\n container: container,\n content: lannisters\n });\n }\n\n function createArrayController() {\n arrayController = ArrayController.create({\n container: container,\n itemController: 'Item',\n content: lannisters\n });\n }\n\n function createDynamicArrayController() {\n arrayController = ArrayController.create({\n container: container,\n lookupItemController: function(object) {\n if (\"Tywin\" === object.get(\"name\")) {\n return \"Item\";\n } else {\n return \"OtherItem\";\n }\n },\n content: lannisters\n });\n }\n\n test(\"when no `itemController` is set, `objectAtContent` returns objects directly\", function() {\n createUnwrappedArrayController();\n\n strictEqual(arrayController.objectAtContent(1), jaime, \"No controller is returned when itemController is not set\");\n });\n\n test(\"when `itemController` is set, `objectAtContent` returns an instance of the controller\", function() {\n createArrayController();\n\n var jaimeController = arrayController.objectAtContent(1);\n\n ok(controllerClass.detectInstance(jaimeController), \"A controller is returned when itemController is set\");\n });\n\n\n test(\"when `idx` is out of range, `objectAtContent` does not create a controller\", function() {\n controllerClass.reopen({\n init: function() {\n ok(false, \"Controllers should not be created when `idx` is out of range\");\n }\n });\n\n createArrayController();\n strictEqual(arrayController.objectAtContent(50), undefined, \"no controllers are created for out of range indexes\");\n });\n\n test(\"when the underlying object is null, a controller is still returned\", function() {\n createArrayController();\n arrayController.unshiftObject(null);\n var firstController = arrayController.objectAtContent(0);\n ok(controllerClass.detectInstance(firstController), \"A controller is still created for null objects\");\n });\n\n test(\"the target of item controllers is the parent controller\", function() {\n createArrayController();\n\n var jaimeController = arrayController.objectAtContent(1);\n\n equal(jaimeController.get('target'), arrayController, \"Item controllers' targets are their parent controller\");\n });\n\n test(\"the parentController property of item controllers is set to the parent controller\", function() {\n createArrayController();\n\n var jaimeController = arrayController.objectAtContent(1);\n\n equal(jaimeController.get('parentController'), arrayController, \"Item controllers' targets are their parent controller\");\n });\n\n test(\"when the underlying object has not changed, `objectAtContent` always returns the same instance\", function() {\n createArrayController();\n\n strictEqual(arrayController.objectAtContent(1), arrayController.objectAtContent(1), \"Controller instances are reused\");\n });\n\n test(\"when the index changes, `objectAtContent` still returns the same instance\", function() {\n createArrayController();\n var jaimeController = arrayController.objectAtContent(1);\n arrayController.unshiftObject(tyrion);\n\n strictEqual(arrayController.objectAtContent(2), jaimeController, \"Controller instances are reused\");\n });\n\n test(\"when the underlying array changes, old subcontainers are destroyed\", function() {\n createArrayController();\n // cause some controllers to be instantiated\n arrayController.objectAtContent(1);\n arrayController.objectAtContent(2);\n\n // Not a public API; just checking for cleanup\n var subControllers = get(arrayController, '_subControllers'),\n jaimeController = subControllers[1],\n cerseiController = subControllers[2];\n\n equal(!!jaimeController.isDestroying, false, \"precond - nobody is destroyed yet\");\n equal(!!cerseiController.isDestroying, false, \"precond - nobody is destroyed yet\");\n\n run(function() {\n arrayController.set('content', Ember.A());\n });\n\n equal(!!jaimeController.isDestroying, true, \"old subcontainers are destroyed\");\n equal(!!cerseiController.isDestroying, true, \"old subcontainers are destroyed\");\n });\n\n\n test(\"item controllers are created lazily\", function() {\n createArrayController();\n\n equal(itemControllerCount, 0, \"precond - no item controllers yet\");\n\n arrayController.objectAtContent(1);\n\n equal(itemControllerCount, 1, \"item controllers are created lazily\");\n });\n\n test(\"when items are removed from the arrayController, their respective subcontainers are destroyed\", function() {\n createArrayController();\n var jaimeController = arrayController.objectAtContent(1),\n cerseiController = arrayController.objectAtContent(2),\n subControllers = get(arrayController, '_subControllers');\n\n equal(!!jaimeController.isDestroyed, false, \"precond - nobody is destroyed yet\");\n equal(!!cerseiController.isDestroyed, false, \"precond - nobody is destroyed yet\");\n\n run(function() {\n arrayController.removeObject(cerseiController);\n });\n\n equal(!!cerseiController.isDestroying, true, \"Removed objects' containers are cleaned up\");\n equal(!!jaimeController.isDestroying, false, \"Retained objects' containers are not cleaned up\");\n });\n\n test(\"one cannot remove wrapped content directly when specifying `itemController`\", function() {\n createArrayController();\n var jaimeController = arrayController.objectAtContent(1),\n cerseiController = arrayController.objectAtContent(2);\n\n equal(arrayController.get('length'), 3, \"precondition - array is in initial state\");\n arrayController.removeObject(cersei);\n\n equal(arrayController.get('length'), 3, \"cannot remove wrapped objects directly\");\n\n run(function() {\n arrayController.removeObject(cerseiController);\n });\n equal(arrayController.get('length'), 2, \"can remove wrapper objects\");\n });\n\n test(\"when items are removed from the underlying array, their respective subcontainers are destroyed\", function() {\n createArrayController();\n var jaimeController = arrayController.objectAtContent(1),\n cerseiController = arrayController.objectAtContent(2),\n subContainers = get(arrayController, 'subContainers');\n\n equal(!!jaimeController.isDestroying, false, \"precond - nobody is destroyed yet\");\n equal(!!cerseiController.isDestroying, false, \"precond - nobody is destroyed yet\");\n\n run(function() {\n lannisters.removeObject(cersei); // if only it were that easy\n });\n\n equal(!!jaimeController.isDestroyed, false, \"Retained objects' containers are not cleaned up\");\n equal(!!cerseiController.isDestroyed, true, \"Removed objects' containers are cleaned up\");\n });\n\n test(\"`itemController` can be dynamic by overwriting `lookupItemController`\", function() {\n createDynamicArrayController();\n\n var tywinController = arrayController.objectAtContent(0),\n jaimeController = arrayController.objectAtContent(1);\n\n ok(controllerClass.detectInstance(tywinController), \"lookupItemController can return different classes for different objects\");\n ok(otherControllerClass.detectInstance(jaimeController), \"lookupItemController can return different classes for different objects\");\n });\n\n test(\"when `idx` is out of range, `lookupItemController` is not called\", function() {\n arrayController = ArrayController.create({\n container: container,\n lookupItemController: function(object) {\n ok(false, \"`lookupItemController` should not be called when `idx` is out of range\");\n },\n content: lannisters\n });\n\n strictEqual(arrayController.objectAtContent(50), undefined, \"no controllers are created for indexes that are superior to the length\");\n strictEqual(arrayController.objectAtContent(-1), undefined, \"no controllers are created for indexes less than zero\");\n });\n\n test(\"if `lookupItemController` returns a string, it must be resolvable by the container\", function() {\n arrayController = ArrayController.create({\n container: container,\n lookupItemController: function(object) {\n return \"NonExistant\";\n },\n content: lannisters\n });\n\n throws(function() {\n arrayController.objectAtContent(1);\n },\n /NonExistant/,\n \"`lookupItemController` must return either null or a valid controller name\");\n });\n\n test(\"array observers can invoke `objectAt` without overwriting existing item controllers\", function() {\n createArrayController();\n\n var tywinController = arrayController.objectAtContent(0),\n arrayObserverCalled = false;\n\n arrayController.reopen({\n lannistersWillChange: Ember.K,\n lannistersDidChange: function(_, idx, removedAmt, addedAmt) {\n arrayObserverCalled = true;\n equal(this.objectAt(idx).get('name'), \"Tyrion\", \"Array observers get the right object via `objectAt`\");\n }\n });\n arrayController.addArrayObserver(arrayController, {\n willChange: 'lannistersWillChange',\n didChange: 'lannistersDidChange'\n });\n\n run(function() {\n lannisters.unshiftObject(tyrion);\n });\n\n equal(arrayObserverCalled, true, \"Array observers are called normally\");\n equal(tywinController.get('name'), \"Tywin\", \"Array observers calling `objectAt` does not overwrite existing controllers' content\");\n });\n\n module('Ember.ArrayController - itemController with arrayComputed', {\n setup: function() {\n container = new Container();\n\n cersei = EmberObject.create({ name: 'Cersei' });\n jaime = EmberObject.create({ name: 'Jaime' });\n lannisters = Ember.A([ jaime, cersei ]);\n\n controllerClass = ObjectController.extend({\n title: computed(function () {\n switch (get(this, 'name')) {\n case 'Jaime': return 'Kingsguard';\n case 'Cersei': return 'Queen';\n }\n }).property('name'),\n\n toString: function() {\n return \"itemController for \" + this.get('name');\n }\n });\n\n container.register(\"controller:Item\", controllerClass);\n },\n teardown: function() {\n run(function() {\n container.destroy();\n });\n }\n });\n\n test(\"item controllers can be used to provide properties for array computed macros\", function() {\n createArrayController();\n\n ok(compare(guidFor(cersei), guidFor(jaime)) < 0, \"precond - guid tiebreaker would fail test\");\n\n arrayController.reopen({\n sortProperties: Ember.A(['title']),\n sorted: sort('@this', 'sortProperties')\n });\n\n deepEqual(arrayController.get('sorted').mapProperty('name'), ['Jaime', 'Cersei'], \"ArrayController items can be sorted on itemController properties\");\n });\n });\ndefine(\"ember-runtime/tests/controllers/object_controller_tests\",\n [\"ember-runtime/controllers/object_controller\"],\n function(__dependency1__) {\n \"use strict\";\n var ObjectController = __dependency1__[\"default\"];\n\n module(\"Ember.ObjectController\");\n\n\n test(\"should be able to set the target property of an ObjectController\", function() {\n var controller = ObjectController.create();\n var target = {};\n\n controller.set('target', target);\n equal(controller.get('target'), target, \"able to set the target property\");\n });\n });\ndefine(\"ember-runtime/tests/core/compare_test\",\n [\"ember-metal/utils\",\"ember-runtime/system/object\",\"ember-runtime/compare\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var typeOf = __dependency1__.typeOf;\n var EmberObject = __dependency2__[\"default\"];\n var compare = __dependency3__[\"default\"];\n\n // test parsing of query string\n var v = [];\n module(\"Ember.compare()\", {\n setup: function() {\n // setup dummy data\n v[0] = null;\n v[1] = false;\n v[2] = true;\n v[3] = -12;\n v[4] = 3.5;\n v[5] = 'a string';\n v[6] = 'another string';\n v[7] = 'last string';\n v[8] = [1,2];\n v[9] = [1,2,3];\n v[10] = [1,3];\n v[11] = {a: 'hash'};\n v[12] = EmberObject.create();\n v[13] = function (a) {return a;};\n v[14] = new Date('2012/01/01');\n v[15] = new Date('2012/06/06');\n }\n });\n\n\n // ..........................................................\n // TESTS\n //\n\n test(\"ordering should work\", function() {\n for (var j=0; j < v.length; j++) {\n equal(compare(v[j],v[j]), 0, j +' should equal itself');\n for (var i=j+1; i < v.length; i++) {\n equal(compare(v[j],v[i]), -1, 'v[' + j + '] (' + typeOf(v[j]) + ') should be smaller than v[' + i + '] (' + typeOf(v[i]) + ')' );\n }\n\n }\n });\n });\ndefine(\"ember-runtime/tests/core/copy_test\",\n [\"ember-runtime/copy\"],\n function(__dependency1__) {\n \"use strict\";\n var copy = __dependency1__[\"default\"];\n\n module(\"Ember Copy Method\");\n\n test(\"Ember.copy null\", function() {\n var obj = {field: null};\n equal(copy(obj, true).field, null, \"null should still be null\");\n });\n\n test(\"Ember.copy date\", function() {\n var date = new Date(2014, 7, 22),\n dateCopy = copy(date);\n equal(date.getTime(), dateCopy.getTime(), \"dates should be equivalent\");\n });\n });\ndefine(\"ember-runtime/tests/core/isEqual_test\",\n [\"ember-runtime/core\"],\n function(__dependency1__) {\n \"use strict\";\n var isEqual = __dependency1__.isEqual;\n\n module(\"isEqual\");\n\n test(\"undefined and null\", function() {\n ok( isEqual(undefined, undefined), \"undefined is equal to undefined\" );\n ok( !isEqual(undefined, null), \"undefined is not equal to null\" );\n ok( isEqual(null, null), \"null is equal to null\" );\n ok( !isEqual(null, undefined), \"null is not equal to undefined\" );\n });\n\n test(\"strings should be equal\",function() {\n ok( !isEqual(\"Hello\", \"Hi\"), \"different Strings are unequal\" );\n ok( isEqual(\"Hello\", \"Hello\"), \"same Strings are equal\" );\n });\n\n test(\"numericals should be equal\",function() {\n ok( isEqual(24, 24), \"same numbers are equal\" );\n ok( !isEqual(24, 21), \"different numbers are inequal\" );\n });\n\n test(\"dates should be equal\",function() {\n ok ( isEqual(new Date(1985, 7, 22), new Date(1985, 7, 22)), \"same dates are equal\" );\n ok ( !isEqual(new Date(2014, 7, 22), new Date(1985, 7, 22)), \"different dates are not equal\" );\n });\n\n test(\"array should be equal\",function() {\n // NOTE: We don't test for array contents -- that would be too expensive.\n ok( !isEqual( [1,2], [1,2] ), 'two array instances with the same values should not be equal' );\n ok( !isEqual( [1,2], [1] ), 'two array instances with different values should not be equal' );\n });\n\n test(\"first object implements isEqual should use it\", function() {\n ok(isEqual({ isEqual: function() { return true; } }, null), 'should return true always');\n\n var obj = { isEqual: function() { return false; } };\n equal(isEqual(obj, obj), false, 'should return false because isEqual returns false');\n });\n });\ndefine(\"ember-runtime/tests/core/is_array_test\",\n [\"ember-metal/core\",\"ember-metal/utils\",\"ember-runtime/system/array_proxy\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var isArray = __dependency2__.isArray;\n var ArrayProxy = __dependency3__[\"default\"];\n\n module(\"Ember Type Checking\");\n\n test(\"Ember.isArray\" ,function() {\n var arrayProxy = ArrayProxy.create({ content: Ember.A() });\n\n equal(isArray(arrayProxy), true, \"[]\");\n });\n });\ndefine(\"ember-runtime/tests/core/is_empty_test\",\n [\"ember-metal/core\",\"ember-metal/is_empty\",\"ember-runtime/system/array_proxy\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var isEmpty = __dependency2__.isEmpty;\n var ArrayProxy = __dependency3__[\"default\"];\n\n module(\"Ember.isEmpty\");\n\n test(\"Ember.isEmpty\", function() {\n var arrayProxy = ArrayProxy.create({ content: Ember.A() });\n\n equal(true, isEmpty(arrayProxy), \"for an ArrayProxy that has empty content\");\n });\n });\ndefine(\"ember-runtime/tests/core/keys_test\",\n [\"ember-metal/property_set\",\"ember-runtime/keys\",\"ember-metal/observer\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var set = __dependency1__.set;\n var keys = __dependency2__[\"default\"];\n var addObserver = __dependency3__.addObserver;\n var removeObserver = __dependency3__.removeObserver;\n var EmberObject = __dependency4__[\"default\"];\n\n module(\"Fetch Keys \");\n\n test(\"should get a key array for a specified object\", function() {\n var object1 = {};\n\n object1.names = \"Rahul\";\n object1.age = \"23\";\n object1.place = \"Mangalore\";\n\n var object2 = keys(object1);\n\n deepEqual(object2, ['names','age','place']);\n });\n\n test(\"should get a key array for a specified Ember.Object\", function() {\n var object1 = EmberObject.create({\n names: \"Rahul\",\n age: \"23\",\n place: \"Mangalore\"\n });\n\n var object2 = keys(object1);\n\n deepEqual(object2, ['names','age','place']);\n });\n\n // This test is for IE8.\n test(\"should get a key array for property that is named the same as prototype property\", function() {\n var object1 = {\n toString: function() {}\n };\n\n var object2 = keys(object1);\n\n deepEqual(object2, ['toString']);\n });\n\n test('should not contain properties declared in the prototype', function () {\n var beer = EmberObject.extend({\n type: 'ipa'\n }).create();\n\n deepEqual(keys(beer), []);\n });\n\n test('should return properties that were set after object creation', function () {\n var beer = EmberObject.extend({\n type: 'ipa'\n }).create();\n\n set(beer, 'brand', 'big daddy');\n\n deepEqual(keys(beer), ['brand']);\n });\n\n module('Keys behavior with observers');\n\n test('should not leak properties on the prototype', function () {\n var beer = EmberObject.extend({\n type: 'ipa'\n }).create();\n\n addObserver(beer, 'type', Ember.K);\n deepEqual(keys(beer), []);\n removeObserver(beer, 'type', Ember.K);\n });\n\n test('observing a non existent property', function () {\n var beer = EmberObject.extend({\n type: 'ipa'\n }).create();\n\n addObserver(beer, 'brand', Ember.K);\n\n deepEqual(keys(beer), []);\n\n set(beer, 'brand', 'Corona');\n deepEqual(keys(beer), ['brand']);\n\n removeObserver(beer, 'brand', Ember.K);\n });\n\n test('with observers switched on and off', function () {\n var beer = EmberObject.extend({\n type: 'ipa'\n }).create();\n\n addObserver(beer, 'type', Ember.K);\n removeObserver(beer, 'type', Ember.K);\n\n deepEqual(keys(beer), []);\n });\n\n test('observers switched on and off with setter in between', function () {\n var beer = EmberObject.extend({\n type: 'ipa'\n }).create();\n\n addObserver(beer, 'type', Ember.K);\n set(beer, 'type', 'ale');\n removeObserver(beer, 'type', Ember.K);\n\n deepEqual(keys(beer), ['type']);\n });\n\n test('observer switched on and off and then setter', function () {\n var beer = EmberObject.extend({\n type: 'ipa'\n }).create();\n\n addObserver(beer, 'type', Ember.K);\n removeObserver(beer, 'type', Ember.K);\n set(beer, 'type', 'ale');\n\n deepEqual(keys(beer), ['type']);\n });\n });\ndefine(\"ember-runtime/tests/core/type_test\",\n [\"ember-metal/utils\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var typeOf = __dependency1__.typeOf;\n var EmberObject = __dependency2__[\"default\"];\n\n module(\"Ember Type Checking\");\n\n test(\"Ember.typeOf\", function() {\n var a = null,\n arr = [1,2,3],\n obj = {},\n object = EmberObject.create({ method: function() {} });\n\n equal(typeOf(undefined), 'undefined', \"item of type undefined\");\n equal(typeOf(a), 'null', \"item of type null\");\n equal(typeOf(arr), 'array', \"item of type array\");\n equal(typeOf(obj), 'object', \"item of type object\");\n equal(typeOf(object), 'instance', \"item of type instance\");\n equal(typeOf(object.method), 'function', \"item of type function\") ;\n equal(typeOf(EmberObject), 'class', \"item of type class\");\n equal(typeOf(new Error()), 'error', \"item of type error\");\n });\n });\ndefine(\"ember-runtime/tests/ext/function_test\",\n [\"ember-runtime/tests/props_helper\"],\n function(__dependency1__) {\n \"use strict\";\n var testWithDefault = __dependency1__.testWithDefault;\n var testBoth = __dependency1__.testBoth;\n\n module('Function.prototype.observes() helper');\n\n testBoth('global observer helper takes multiple params', function(get, set) {\n\n if (Ember.EXTEND_PROTOTYPES === false) {\n ok(\"undefined\" === typeof Function.prototype.observes, 'Function.prototype helper disabled');\n return ;\n }\n\n var MyMixin = Ember.Mixin.create({\n\n count: 0,\n\n foo: function() {\n set(this, 'count', get(this, 'count')+1);\n }.observes('bar', 'baz')\n\n });\n\n var obj = Ember.mixin({}, MyMixin);\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj, 'bar', \"BAZ\");\n set(obj, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 2, 'should invoke observer after change');\n });\n\n module('Function.prototype.on() helper');\n\n testBoth('sets up an event listener, and can trigger the function on multiple events', function(get, set) {\n\n if (Ember.EXTEND_PROTOTYPES === false) {\n ok(\"undefined\" === typeof Function.prototype.on, 'Function.prototype helper disabled');\n return ;\n }\n\n var MyMixin = Ember.Mixin.create({\n\n count: 0,\n\n foo: function() {\n set(this, 'count', get(this, 'count')+1);\n }.on('bar', 'baz')\n\n });\n\n var obj = Ember.mixin({}, Ember.Evented, MyMixin);\n equal(get(obj, 'count'), 0, 'should not invoke listener immediately');\n\n obj.trigger('bar');\n obj.trigger('baz');\n equal(get(obj, 'count'), 2, 'should invoke listeners when events trigger');\n });\n\n testBoth('can be chained with observes', function(get, set) {\n\n if (Ember.EXTEND_PROTOTYPES === false) {\n ok('Function.prototype helper disabled');\n return ;\n }\n\n var MyMixin = Ember.Mixin.create({\n\n count: 0,\n bay: 'bay',\n foo: function() {\n set(this, 'count', get(this, 'count')+1);\n }.observes('bay').on('bar')\n });\n\n var obj = Ember.mixin({}, Ember.Evented, MyMixin);\n equal(get(obj, 'count'), 0, 'should not invoke listener immediately');\n\n set(obj, 'bay', 'BAY');\n obj.trigger('bar');\n equal(get(obj, 'count'), 2, 'should invoke observer and listener');\n });\n\n module('Function.prototype.property() helper');\n\n testBoth('sets up a ComputedProperty', function(get, set) {\n\n if (Ember.EXTEND_PROTOTYPES === false) {\n ok(\"undefined\" === typeof Function.prototype.property, 'Function.prototype helper disabled');\n return ;\n }\n\n var MyClass = Ember.Object.extend({\n firstName: null,\n lastName: null,\n fullName: function() {\n return get(this, 'firstName') + ' ' + get(this, 'lastName');\n }.property('firstName', 'lastName')\n });\n\n var obj = MyClass.create({firstName: 'Fred', lastName: 'Flinstone'});\n equal(get(obj, 'fullName'), 'Fred Flinstone', 'should return the computed value');\n\n set(obj, 'firstName', \"Wilma\");\n equal(get(obj, 'fullName'), 'Wilma Flinstone', 'should return the new computed value');\n\n set(obj, 'lastName', \"\");\n equal(get(obj, 'fullName'), 'Wilma ', 'should return the new computed value');\n });\n });\ndefine(\"ember-runtime/tests/ext/mixin_test\",\n [\"ember-metal/property_set\",\"ember-metal/property_get\",\"ember-metal/mixin\",\"ember-metal/platform\",\"ember-metal/binding\",\"ember-metal/run_loop\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var set = __dependency1__.set;\n var get = __dependency2__.get;\n var Mixin = __dependency3__.Mixin;\n var create = __dependency4__.create;\n var platform = __dependency4__.platform;\n var Binding = __dependency5__.Binding;\n var isGlobalPath = __dependency5__.isGlobalPath;\n var bind = __dependency5__.bind;\n var oneWay = __dependency5__.oneWay;\n var run = __dependency6__[\"default\"];\n\n module('system/mixin/binding_test');\n\n test('Defining a property ending in Binding should setup binding when applied', function() {\n\n var MyMixin = Mixin.create({\n fooBinding: 'bar.baz'\n });\n\n var obj = { bar: { baz: 'BIFF' } };\n\n run(function() {\n MyMixin.apply(obj);\n });\n\n ok(get(obj, 'fooBinding') instanceof Binding, 'should be a binding object');\n equal(get(obj, 'foo'), 'BIFF', 'binding should be created and synced');\n\n });\n\n test('Defining a property ending in Binding should apply to prototype children', function() {\n var MyMixin, obj, obj2;\n\n run(function() {\n MyMixin = Mixin.create({\n fooBinding: 'bar.baz'\n });\n });\n\n obj = { bar: { baz: 'BIFF' } };\n\n run(function() {\n MyMixin.apply(obj);\n });\n\n\n obj2 = create(obj);\n run(function() {\n set(get(obj2, 'bar'), 'baz', 'BARG');\n });\n\n\n ok(get(obj2, 'fooBinding') instanceof Binding, 'should be a binding object');\n equal(get(obj2, 'foo'), 'BARG', 'binding should be created and synced');\n\n });\n });\ndefine(\"ember-runtime/tests/ext/rsvp_test\",\n [\"ember-metal/run_loop\",\"ember-runtime/ext/rsvp\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var RSVP = __dependency2__[\"default\"];\n\n module('Ember.RSVP');\n\n test('Ensure that errors thrown from within a promise are sent to the console', function(){\n var error = new Error('Error thrown in a promise for testing purposes.');\n\n try {\n run(function(){\n new RSVP.Promise(function(resolve, reject){\n throw error;\n });\n });\n ok(false, 'expected assertion to be thrown');\n } catch (e) {\n equal(e, error, \"error was re-thrown\");\n }\n });\n });\ndefine(\"ember-runtime/tests/legacy_1x/mixins/observable/chained_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-metal/observer\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var run = __dependency4__[\"default\"];\n var EmberObject = __dependency5__[\"default\"];\n var addObserver = __dependency6__.addObserver;\n\n /*\n NOTE: This test is adapted from the 1.x series of unit tests. The tests\n are the same except for places where we intend to break the API we instead\n validate that we warn the developer appropriately.\n\n CHANGES FROM 1.6:\n\n * changed obj.set() and obj.get() to Ember.set() and Ember.get()\n * changed obj.addObserver() to addObserver()\n */\n\n module(\"Ember.Observable - Observing with @each\");\n\n test(\"chained observers on enumerable properties are triggered when the observed property of any item changes\", function() {\n var family = EmberObject.create({ momma: null });\n var momma = EmberObject.create({ children: [] });\n\n var child1 = EmberObject.create({ name: \"Bartholomew\" });\n var child2 = EmberObject.create({ name: \"Agnes\" });\n var child3 = EmberObject.create({ name: \"Dan\" });\n var child4 = EmberObject.create({ name: \"Nancy\" });\n\n set(family, 'momma', momma);\n set(momma, 'children', Ember.A([child1, child2, child3]));\n\n var observerFiredCount = 0;\n addObserver(family, 'momma.children.@each.name', this, function() {\n observerFiredCount++;\n });\n\n observerFiredCount = 0;\n run(function() { get(momma, 'children').setEach('name', 'Juan'); });\n equal(observerFiredCount, 3, \"observer fired after changing child names\");\n\n observerFiredCount = 0;\n run(function() { get(momma, 'children').pushObject(child4); });\n equal(observerFiredCount, 1, \"observer fired after adding a new item\");\n\n observerFiredCount = 0;\n run(function() { set(child4, 'name', \"Herbert\"); });\n equal(observerFiredCount, 1, \"observer fired after changing property on new object\");\n\n set(momma, 'children', []);\n\n observerFiredCount = 0;\n run(function() { set(child1, 'name', \"Hanna\"); });\n equal(observerFiredCount, 0, \"observer did not fire after removing changing property on a removed object\");\n });\n });\ndefine(\"ember-runtime/tests/legacy_1x/mixins/observable/observable_test\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/enumerable_utils\",\"ember-metal/computed\",\"ember-metal/run_loop\",\"ember-metal/utils\",\"ember-metal/mixin\",\"ember-runtime/system/string\",\"ember-runtime/system/object\",\"ember-runtime/mixins/observable\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__) {\n \"use strict\";\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n var EnumerableUtils = __dependency3__[\"default\"];\n var computed = __dependency4__.computed;\n var run = __dependency5__[\"default\"];\n var typeOf = __dependency6__.typeOf;\n var observer = __dependency7__.observer;\n var fmt = __dependency8__.fmt;\n var w = __dependency8__.w;\n var EmberObject = __dependency9__[\"default\"];\n var Observable = __dependency10__[\"default\"];\n\n var forEach = EnumerableUtils.forEach;\n\n /*\n NOTE: This test is adapted from the 1.x series of unit tests. The tests\n are the same except for places where we intend to break the API we instead\n validate that we warn the developer appropriately.\n\n CHANGES FROM 1.6:\n\n * Added ObservableObject which applies the Ember.Observable mixin.\n * Changed reference to Ember.T_FUNCTION to 'function'\n * Changed all references to sc_super to this._super()\n * Changed Ember.objectForPropertyPath() to Ember.getPath()\n * Removed allPropertiesDidChange test - no longer supported\n * Changed test that uses 'ObjectE' as path to 'objectE' to reflect new\n rule on using capital letters for property paths.\n * Removed test passing context to addObserver. context param is no longer\n supported.\n * Changed calls to Ember.Binding.flushPendingChanges() -> run.sync()\n * removed test in observer around line 862 that expected key/value to be\n the last item in the chained path. Should be root and chained path\n\n */\n\n // ========================================================================\n // Ember.Observable Tests\n // ========================================================================\n\n var object, ObjectC, ObjectD, objectA, objectB;\n\n var ObservableObject = EmberObject.extend(Observable);\n var originalLookup = Ember.lookup, lookup;\n\n // ..........................................................\n // GET()\n //\n\n module(\"object.get()\", {\n\n setup: function() {\n object = ObservableObject.createWithMixins(Observable, {\n\n normal: 'value',\n numberVal: 24,\n toggleVal: true,\n\n computed: computed(function() { return 'value'; }).volatile(),\n\n method: function() { return \"value\"; },\n\n nullProperty: null,\n\n unknownProperty: function(key, value) {\n this.lastUnknownProperty = key ;\n return \"unknown\" ;\n }\n\n });\n }\n\n });\n\n test(\"should get normal properties\", function() {\n equal(object.get('normal'), 'value') ;\n });\n\n test(\"should call computed properties and return their result\", function() {\n equal(object.get(\"computed\"), \"value\") ;\n });\n\n test(\"should return the function for a non-computed property\", function() {\n var value = object.get(\"method\") ;\n equal(typeOf(value), 'function') ;\n });\n\n test(\"should return null when property value is null\", function() {\n equal(object.get(\"nullProperty\"), null) ;\n });\n\n test(\"should call unknownProperty when value is undefined\", function() {\n equal(object.get(\"unknown\"), \"unknown\") ;\n equal(object.lastUnknownProperty, \"unknown\") ;\n });\n\n // ..........................................................\n // Ember.GET()\n //\n module(\"Ember.get()\", {\n setup: function() {\n objectA = ObservableObject.createWithMixins({\n\n normal: 'value',\n numberVal: 24,\n toggleVal: true,\n\n computed: computed(function() { return 'value'; }).volatile(),\n\n method: function() { return \"value\"; },\n\n nullProperty: null,\n\n unknownProperty: function(key, value) {\n this.lastUnknownProperty = key ;\n return \"unknown\" ;\n }\n\n });\n\n objectB = {\n normal: 'value',\n\n nullProperty: null\n };\n }\n });\n\n test(\"should get normal properties on Ember.Observable\", function() {\n equal(get(objectA, 'normal'), 'value') ;\n });\n\n test(\"should call computed properties on Ember.Observable and return their result\", function() {\n equal(get(objectA, \"computed\"), \"value\") ;\n });\n\n test(\"should return the function for a non-computed property on Ember.Observable\", function() {\n var value = get(objectA, \"method\") ;\n equal(typeOf(value), 'function') ;\n });\n\n test(\"should return null when property value is null on Ember.Observable\", function() {\n equal(get(objectA, \"nullProperty\"), null) ;\n });\n\n test(\"should call unknownProperty when value is undefined on Ember.Observable\", function() {\n equal(get(object, \"unknown\"), \"unknown\") ;\n equal(object.lastUnknownProperty, \"unknown\") ;\n });\n\n test(\"should get normal properties on standard objects\", function() {\n equal(get(objectB, 'normal'), 'value');\n });\n\n test(\"should return null when property is null on standard objects\", function() {\n equal(get(objectB, 'nullProperty'), null);\n });\n\n /*\n test(\"raise if the provided object is null\", function() {\n raises(function() {\n get(null, 'key');\n });\n });\n */\n\n test(\"raise if the provided object is undefined\", function() {\n expectAssertion(function() {\n get(undefined, 'key');\n }, /Cannot call get with 'key' on an undefined object/i);\n });\n\n test(\"should work when object is Ember (used in Ember.get)\", function() {\n equal(get('Ember.RunLoop'), Ember.RunLoop, 'Ember.get');\n equal(get(Ember, 'RunLoop'), Ember.RunLoop, 'Ember.get(Ember, RunLoop)');\n });\n\n module(\"Ember.get() with paths\", {\n setup: function() {\n lookup = Ember.lookup = {};\n },\n\n teardown: function() {\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"should return a property at a given path relative to the lookup\", function() {\n lookup.Foo = ObservableObject.create({\n Bar: ObservableObject.createWithMixins({\n Baz: computed(function() { return \"blargh\"; }).volatile()\n })\n });\n\n equal(get('Foo.Bar.Baz'), \"blargh\");\n });\n\n test(\"should return a property at a given path relative to the passed object\", function() {\n var foo = ObservableObject.create({\n bar: ObservableObject.createWithMixins({\n baz: computed(function() { return \"blargh\"; }).volatile()\n })\n });\n\n equal(get(foo, 'bar.baz'), \"blargh\");\n });\n\n test(\"should return a property at a given path relative to the lookup - JavaScript hash\", function() {\n lookup.Foo = {\n Bar: {\n Baz: \"blargh\"\n }\n };\n\n equal(get('Foo.Bar.Baz'), \"blargh\");\n });\n\n test(\"should return a property at a given path relative to the passed object - JavaScript hash\", function() {\n var foo = {\n bar: {\n baz: \"blargh\"\n }\n };\n\n equal(get(foo, 'bar.baz'), \"blargh\");\n });\n\n // ..........................................................\n // SET()\n //\n\n module(\"object.set()\", {\n\n setup: function() {\n object = ObservableObject.createWithMixins({\n\n // normal property\n normal: 'value',\n\n // computed property\n _computed: \"computed\",\n computed: computed(function(key, value) {\n if (value !== undefined) {\n this._computed = value ;\n }\n return this._computed ;\n }).volatile(),\n\n // method, but not a property\n _method: \"method\",\n method: function(key, value) {\n if (value !== undefined) {\n this._method = value ;\n }\n return this._method ;\n },\n\n // null property\n nullProperty: null,\n\n // unknown property\n _unknown: 'unknown',\n unknownProperty: function(key) {\n return this._unknown ;\n },\n\n setUnknownProperty: function(key, value) {\n this._unknown = value ;\n return this._unknown ;\n }\n });\n }\n\n });\n\n test(\"should change normal properties and return this\", function() {\n var ret = object.set(\"normal\", \"changed\") ;\n equal(object.normal, \"changed\") ;\n equal(ret, object) ;\n });\n\n test(\"should call computed properties passing value and return this\", function() {\n var ret = object.set(\"computed\", \"changed\") ;\n equal(object._computed, \"changed\") ;\n equal(ret, object) ;\n });\n\n test(\"should change normal properties when passing undefined\", function() {\n var ret = object.set('normal', undefined);\n equal(object.normal, undefined);\n equal(ret, object);\n });\n\n test(\"should replace the function for a non-computed property and return this\", function() {\n var ret = object.set(\"method\", \"changed\") ;\n equal(object._method, \"method\") ; // make sure this was NOT run\n ok(typeOf(object.method) !== 'function') ;\n equal(ret, object) ;\n });\n\n test(\"should replace prover when property value is null\", function() {\n var ret = object.set(\"nullProperty\", \"changed\") ;\n equal(object.nullProperty, \"changed\") ;\n equal(ret, object) ;\n });\n\n test(\"should call unknownProperty with value when property is undefined\", function() {\n var ret = object.set(\"unknown\", \"changed\") ;\n equal(object._unknown, \"changed\") ;\n equal(ret, object) ;\n });\n\n // ..........................................................\n // COMPUTED PROPERTIES\n //\n\n module(\"Computed properties\", {\n setup: function() {\n lookup = Ember.lookup = {};\n\n object = ObservableObject.createWithMixins({\n\n // REGULAR\n\n computedCalls: [],\n computed: computed(function(key, value) {\n this.computedCalls.push(value);\n return 'computed';\n }).volatile(),\n\n computedCachedCalls: [],\n computedCached: computed(function(key, value) {\n this.computedCachedCalls.push(value);\n return 'computedCached';\n }),\n\n\n // DEPENDENT KEYS\n\n changer: 'foo',\n\n dependentCalls: [],\n dependent: computed(function(key, value) {\n this.dependentCalls.push(value);\n return 'dependent';\n }).property('changer').volatile(),\n\n dependentFrontCalls: [],\n dependentFront: computed('changer', function(key, value) {\n this.dependentFrontCalls.push(value);\n return 'dependentFront';\n }).volatile(),\n\n dependentCachedCalls: [],\n dependentCached: computed(function(key, value) {\n this.dependentCachedCalls.push(value);\n return 'dependentCached';\n }).property('changer'),\n\n // everytime it is recomputed, increments call\n incCallCount: 0,\n inc: computed(function() {\n return this.incCallCount++;\n }).property('changer'),\n\n // depends on cached property which depends on another property...\n nestedIncCallCount: 0,\n nestedInc: computed(function(key, value) {\n get(this, 'inc');\n return this.nestedIncCallCount++;\n }).property('inc'),\n\n // two computed properties that depend on a third property\n state: 'on',\n isOn: computed(function(key, value) {\n if (value !== undefined) this.set('state', 'on');\n return this.get('state') === 'on';\n }).property('state').volatile(),\n\n isOff: computed(function(key, value) {\n if (value !== undefined) this.set('state', 'off');\n return this.get('state') === 'off';\n }).property('state').volatile()\n\n }) ;\n },\n teardown: function() {\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"getting values should call function return value\", function() {\n\n // get each property twice. Verify return.\n var keys = w('computed computedCached dependent dependentFront dependentCached');\n\n forEach(keys, function(key) {\n equal(object.get(key), key, fmt('Try #1: object.get(%@) should run function', [key]));\n equal(object.get(key), key, fmt('Try #2: object.get(%@) should run function', [key]));\n });\n\n // verify each call count. cached should only be called once\n forEach(w('computedCalls dependentFrontCalls dependentCalls'), function(key) {\n equal(object[key].length, 2, fmt('non-cached property %@ should be called 2x', [key]));\n });\n\n forEach(w('computedCachedCalls dependentCachedCalls'), function(key) {\n equal(object[key].length, 1, fmt('non-cached property %@ should be called 1x', [key]));\n });\n\n });\n\n test(\"setting values should call function return value\", function() {\n\n // get each property twice. Verify return.\n var keys = w('computed dependent dependentFront computedCached dependentCached');\n var values = w('value1 value2');\n\n forEach(keys, function(key) {\n\n equal(object.set(key, values[0]), object, fmt('Try #1: object.set(%@, %@) should run function', [key, values[0]]));\n\n equal(object.set(key, values[1]), object, fmt('Try #2: object.set(%@, %@) should run function', [key, values[1]]));\n\n equal(object.set(key, values[1]), object, fmt('Try #3: object.set(%@, %@) should not run function since it is setting same value as before', [key, values[1]]));\n\n });\n\n\n // verify each call count. cached should only be called once\n forEach(keys, function(key) {\n var calls = object[key + 'Calls'], idx;\n var expectedLength;\n\n // Cached properties first check their cached value before setting the\n // property. Other properties blindly call set.\n expectedLength = 3;\n equal(calls.length, expectedLength, fmt('set(%@) should be called the right amount of times', [key]));\n for(idx=0;idx<2;idx++) {\n equal(calls[idx], values[idx], fmt('call #%@ to set(%@) should have passed value %@', [idx+1, key, values[idx]]));\n }\n });\n\n });\n\n test(\"notify change should clear cache\", function() {\n\n // call get several times to collect call count\n object.get('computedCached'); // should run func\n object.get('computedCached'); // should not run func\n\n object.propertyWillChange('computedCached')\n .propertyDidChange('computedCached');\n\n object.get('computedCached'); // should run again\n equal(object.computedCachedCalls.length, 2, 'should have invoked method 2x');\n });\n\n test(\"change dependent should clear cache\", function() {\n\n // call get several times to collect call count\n var ret1 = object.get('inc'); // should run func\n equal(object.get('inc'), ret1, 'multiple calls should not run cached prop');\n\n object.set('changer', 'bar');\n\n equal(object.get('inc'), ret1+1, 'should increment after dependent key changes'); // should run again\n });\n\n test(\"just notifying change of dependent should clear cache\", function() {\n\n // call get several times to collect call count\n var ret1 = object.get('inc'); // should run func\n equal(object.get('inc'), ret1, 'multiple calls should not run cached prop');\n\n object.notifyPropertyChange('changer');\n\n equal(object.get('inc'), ret1+1, 'should increment after dependent key changes'); // should run again\n });\n\n test(\"changing dependent should clear nested cache\", function() {\n\n // call get several times to collect call count\n var ret1 = object.get('nestedInc'); // should run func\n equal(object.get('nestedInc'), ret1, 'multiple calls should not run cached prop');\n\n object.set('changer', 'bar');\n\n equal(object.get('nestedInc'), ret1+1, 'should increment after dependent key changes'); // should run again\n\n });\n\n test(\"just notifying change of dependent should clear nested cache\", function() {\n\n // call get several times to collect call count\n var ret1 = object.get('nestedInc'); // should run func\n equal(object.get('nestedInc'), ret1, 'multiple calls should not run cached prop');\n\n object.notifyPropertyChange('changer');\n\n equal(object.get('nestedInc'), ret1+1, 'should increment after dependent key changes'); // should run again\n\n });\n\n\n // This verifies a specific bug encountered where observers for computed\n // properties would fire before their prop caches were cleared.\n test(\"change dependent should clear cache when observers of dependent are called\", function() {\n\n // call get several times to collect call count\n var ret1 = object.get('inc'); // should run func\n equal(object.get('inc'), ret1, 'multiple calls should not run cached prop');\n\n // add observer to verify change...\n object.addObserver('inc', this, function() {\n equal(object.get('inc'), ret1+1, 'should increment after dependent key changes'); // should run again\n });\n\n // now run\n object.set('changer', 'bar');\n\n });\n\n test('setting one of two computed properties that depend on a third property should clear the kvo cache', function() {\n // we have to call set twice to fill up the cache\n object.set('isOff', true);\n object.set('isOn', true);\n\n // setting isOff to true should clear the kvo cache\n object.set('isOff', true);\n equal(object.get('isOff'), true, 'object.isOff should be true');\n equal(object.get('isOn'), false, 'object.isOn should be false');\n });\n\n test(\"dependent keys should be able to be specified as property paths\", function() {\n var depObj = ObservableObject.createWithMixins({\n menu: ObservableObject.create({\n price: 5\n }),\n\n menuPrice: computed(function() {\n return this.get('menu.price');\n }).property('menu.price')\n });\n\n equal(depObj.get('menuPrice'), 5, \"precond - initial value returns 5\");\n\n depObj.set('menu.price', 6);\n\n equal(depObj.get('menuPrice'), 6, \"cache is properly invalidated after nested property changes\");\n });\n\n test(\"nested dependent keys should propagate after they update\", function() {\n var bindObj;\n run(function () {\n lookup.DepObj = ObservableObject.createWithMixins({\n restaurant: ObservableObject.create({\n menu: ObservableObject.create({\n price: 5\n })\n }),\n\n price: computed(function() {\n return this.get('restaurant.menu.price');\n }).property('restaurant.menu.price')\n });\n\n bindObj = ObservableObject.createWithMixins({\n priceBinding: \"DepObj.price\"\n });\n });\n\n equal(bindObj.get('price'), 5, \"precond - binding propagates\");\n\n run(function () {\n lookup.DepObj.set('restaurant.menu.price', 10);\n });\n\n equal(bindObj.get('price'), 10, \"binding propagates after a nested dependent keys updates\");\n\n run(function () {\n lookup.DepObj.set('restaurant.menu', ObservableObject.create({\n price: 15\n }));\n });\n\n equal(bindObj.get('price'), 15, \"binding propagates after a middle dependent keys updates\");\n });\n\n test(\"cacheable nested dependent keys should clear after their dependencies update\", function() {\n ok(true);\n\n var DepObj;\n\n run(function() {\n lookup.DepObj = DepObj = ObservableObject.createWithMixins({\n restaurant: ObservableObject.create({\n menu: ObservableObject.create({\n price: 5\n })\n }),\n\n price: computed(function() {\n return this.get('restaurant.menu.price');\n }).property('restaurant.menu.price')\n });\n });\n\n equal(DepObj.get('price'), 5, \"precond - computed property is correct\");\n\n run(function() {\n DepObj.set('restaurant.menu.price', 10);\n });\n equal(DepObj.get('price'), 10, \"cacheable computed properties are invalidated even if no run loop occurred\");\n\n run(function() {\n DepObj.set('restaurant.menu.price', 20);\n });\n equal(DepObj.get('price'), 20, \"cacheable computed properties are invalidated after a second get before a run loop\");\n equal(DepObj.get('price'), 20, \"precond - computed properties remain correct after a run loop\");\n\n run(function() {\n DepObj.set('restaurant.menu', ObservableObject.create({\n price: 15\n }));\n });\n\n\n equal(DepObj.get('price'), 15, \"cacheable computed properties are invalidated after a middle property changes\");\n\n run(function() {\n DepObj.set('restaurant.menu', ObservableObject.create({\n price: 25\n }));\n });\n\n equal(DepObj.get('price'), 25, \"cacheable computed properties are invalidated after a middle property changes again, before a run loop\");\n });\n\n\n\n // ..........................................................\n // OBSERVABLE OBJECTS\n //\n\n module(\"Observable objects & object properties \", {\n\n setup: function() {\n object = ObservableObject.createWithMixins({\n\n normal: 'value',\n abnormal: 'zeroValue',\n numberVal: 24,\n toggleVal: true,\n observedProperty: 'beingWatched',\n testRemove: 'observerToBeRemoved',\n normalArray: Ember.A([1,2,3,4,5]),\n\n getEach: function() {\n var keys = ['normal','abnormal'];\n var ret = [];\n for(var idx=0; idx run.sync();\n * changes obj.set() and obj.get() to Ember.set() and Ember.get()\n * Fixed an actual bug in unit tests around line 133\n * fixed 'bindings should disconnect on destroy' test to use destroy.\n */\n\n // ========================================================================\n // EmberObject bindings Tests\n // ========================================================================\n\n var testObject, fromObject, extraObject, TestObject;\n var TestNamespace, originalLookup, lookup;\n\n var bindModuleOpts = {\n\n setup: function() {\n originalLookup = Ember.lookup;\n Ember.lookup = lookup = {};\n\n testObject = EmberObject.create({\n foo: \"bar\",\n bar: \"foo\",\n extraObject: null\n });\n\n fromObject = EmberObject.create({\n bar: \"foo\",\n extraObject: null\n }) ;\n\n extraObject = EmberObject.create({\n foo: \"extraObjectValue\"\n }) ;\n\n lookup['TestNamespace'] = TestNamespace = {\n fromObject: fromObject,\n testObject: testObject\n } ;\n },\n\n teardown: function() {\n testObject = fromObject = extraObject = null ;\n Ember.lookup = originalLookup;\n }\n\n };\n\n module(\"bind() method\", bindModuleOpts);\n\n test(\"bind(TestNamespace.fromObject.bar) should follow absolute path\", function() {\n run(function() {\n // create binding\n testObject.bind(\"foo\", \"TestNamespace.fromObject.bar\");\n\n // now make a change to see if the binding triggers.\n set(fromObject, \"bar\", \"changedValue\");\n });\n\n equal(\"changedValue\", get(testObject, \"foo\"), \"testObject.foo\");\n });\n\n test(\"bind(.bar) should bind to relative path\", function() {\n run(function() {\n // create binding\n testObject.bind(\"foo\", \"bar\") ;\n\n // now make a change to see if the binding triggers.\n set(testObject, \"bar\", \"changedValue\") ;\n });\n\n equal(\"changedValue\", get(testObject, \"foo\"), \"testObject.foo\");\n });\n\n var fooBindingModuleOpts = {\n\n setup: function() {\n originalLookup = Ember.lookup;\n Ember.lookup = lookup = {};\n\n TestObject = EmberObject.extend({\n foo: \"bar\",\n bar: \"foo\",\n extraObject: null\n });\n\n fromObject = EmberObject.create({\n bar: \"foo\",\n extraObject: null\n }) ;\n\n extraObject = EmberObject.create({\n foo: \"extraObjectValue\"\n }) ;\n\n lookup['TestNamespace'] = TestNamespace = {\n fromObject: fromObject,\n testObject: TestObject\n } ;\n },\n\n teardown: function() {\n Ember.lookup = originalLookup;\n TestObject = fromObject = extraObject = null ;\n // delete TestNamespace ;\n }\n\n };\n\n module(\"fooBinding method\", fooBindingModuleOpts);\n\n\n test(\"fooBinding: TestNamespace.fromObject.bar should follow absolute path\", function() {\n // create binding\n run(function() {\n testObject = TestObject.createWithMixins({\n fooBinding: \"TestNamespace.fromObject.bar\"\n }) ;\n\n // now make a change to see if the binding triggers.\n set(fromObject, \"bar\", \"changedValue\") ;\n });\n\n equal(\"changedValue\", get(testObject, \"foo\"), \"testObject.foo\");\n });\n\n test(\"fooBinding: .bar should bind to relative path\", function() {\n run(function() {\n testObject = TestObject.createWithMixins({\n fooBinding: \"bar\"\n });\n // now make a change to see if the binding triggers.\n set(testObject, \"bar\", \"changedValue\");\n });\n\n equal(\"changedValue\", get(testObject, \"foo\"), \"testObject.foo\");\n });\n\n test('fooBinding: should disconnect bindings when destroyed', function () {\n run(function() {\n testObject = TestObject.createWithMixins({\n fooBinding: \"TestNamespace.fromObject.bar\"\n });\n\n set(TestNamespace.fromObject, 'bar', 'BAZ');\n });\n\n equal(get(testObject, 'foo'), 'BAZ', 'binding should have synced');\n\n destroy(testObject);\n\n run(function() {\n set(TestNamespace.fromObject, 'bar', 'BIFF');\n });\n\n ok(get(testObject, 'foo') !== 'bar', 'binding should not have synced');\n });\n });\ndefine(\"ember-runtime/tests/legacy_1x/system/object/concatenated_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-runtime/system/string\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var EmberStringUtils = __dependency4__[\"default\"];\n var EmberObject = __dependency5__[\"default\"];\n\n /*\n NOTE: This test is adapted from the 1.x series of unit tests. The tests\n are the same except for places where we intend to break the API we instead\n validate that we warn the developer appropriately.\n\n CHANGES FROM 1.6:\n\n * changed get(obj, ) and set(obj, ) to Ember.get() and Ember.set()\n * converted uses of obj.isEqual() to use deepEqual() test since isEqual is not\n always defined\n */\n\n\n\n var klass;\n\n module(\"EmberObject Concatenated Properties\", {\n setup: function() {\n klass = EmberObject.extend({\n concatenatedProperties: ['values', 'functions'],\n values: ['a', 'b', 'c'],\n functions: [Ember.K]\n });\n }\n });\n\n test(\"concatenates instances\", function() {\n var obj = klass.create({\n values: ['d', 'e', 'f']\n });\n\n var values = get(obj, 'values'),\n expected = ['a', 'b', 'c', 'd', 'e', 'f'];\n deepEqual(values, expected, EmberStringUtils.fmt(\"should concatenate values property (expected: %@, got: %@)\", [expected, values]));\n });\n\n test(\"concatenates subclasses\", function() {\n var subKlass = klass.extend({\n values: ['d', 'e', 'f']\n });\n var obj = subKlass.create();\n\n var values = get(obj, 'values'),\n expected = ['a', 'b', 'c', 'd', 'e', 'f'];\n deepEqual(values, expected, EmberStringUtils.fmt(\"should concatenate values property (expected: %@, got: %@)\", [expected, values]));\n });\n\n test(\"concatenates reopen\", function() {\n klass.reopen({\n values: ['d', 'e', 'f']\n });\n var obj = klass.create();\n\n var values = get(obj, 'values'),\n expected = ['a', 'b', 'c', 'd', 'e', 'f'];\n deepEqual(values, expected, EmberStringUtils.fmt(\"should concatenate values property (expected: %@, got: %@)\", [expected, values]));\n });\n\n test(\"concatenates mixin\", function() {\n var mixin = {\n values: ['d', 'e']\n };\n var subKlass = klass.extend(mixin, {\n values: ['f']\n });\n var obj = subKlass.create();\n\n var values = get(obj, 'values'),\n expected = ['a', 'b', 'c', 'd', 'e', 'f'];\n deepEqual(values, expected, EmberStringUtils.fmt(\"should concatenate values property (expected: %@, got: %@)\", [expected, values]));\n });\n\n test(\"concatenates reopen, subclass, and instance\", function() {\n klass.reopen({ values: ['d'] });\n var subKlass = klass.extend({ values: ['e'] });\n var obj = subKlass.create({ values: ['f'] });\n\n var values = get(obj, 'values'),\n expected = ['a', 'b', 'c', 'd', 'e', 'f'];\n deepEqual(values, expected, EmberStringUtils.fmt(\"should concatenate values property (expected: %@, got: %@)\", [expected, values]));\n });\n\n test(\"concatenates subclasses when the values are functions\", function() {\n var subKlass = klass.extend({\n functions: Ember.K\n });\n var obj = subKlass.create();\n\n var values = get(obj, 'functions'),\n expected = [Ember.K, Ember.K];\n deepEqual(values, expected, EmberStringUtils.fmt(\"should concatenate functions property (expected: %@, got: %@)\", [expected, values]));\n });\n });\ndefine(\"ember-runtime/tests/legacy_1x/system/run_loop_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/mixin\",\"ember-metal/run_loop\",\"ember-metal/binding\",\"ember-runtime/mixins/observable\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var emberObserver = __dependency4__.observer;\n var run = __dependency5__[\"default\"];\n var Binding = __dependency6__.Binding;\n var Observable = __dependency7__[\"default\"];\n var EmberObject = __dependency8__[\"default\"];\n\n /*\n NOTE: This test is adapted from the 1.x series of unit tests. The tests\n are the same except for places where we intend to break the API we instead\n validate that we warn the developer appropriately.\n\n CHANGES FROM 1.6:\n\n * Updated the API usage for setting up and syncing Binding since these\n are not the APIs this file is testing.\n\n * Disabled a call to invokeOnce() around line 127 because it appeared to be\n broken anyway. I don't think it ever even worked.\n */\n\n var MyApp, binding1, binding2, previousPreventRunloop;\n\n module(\"System:run_loop() - chained binding\", {\n setup: function() {\n MyApp = {};\n MyApp.first = EmberObject.createWithMixins(Observable, {\n output: 'MyApp.first'\n }) ;\n\n MyApp.second = EmberObject.createWithMixins(Observable, {\n input: 'MyApp.second',\n output: 'MyApp.second',\n\n inputDidChange: emberObserver(\"input\", function() {\n this.set(\"output\", this.get(\"input\")) ;\n })\n\n }) ;\n\n MyApp.third = EmberObject.createWithMixins(Observable, {\n input: \"MyApp.third\"\n }) ;\n }\n });\n\n test(\"Should propagate bindings after the RunLoop completes (using Ember.RunLoop)\", function() {\n run(function () {\n\n //Binding of output of MyApp.first object to input of MyApp.second object\n binding1 = Binding.from(\"first.output\")\n .to(\"second.input\").connect(MyApp) ;\n\n //Binding of output of MyApp.second object to input of MyApp.third object\n binding2 = Binding.from(\"second.output\")\n .to(\"third.input\").connect(MyApp) ;\n\n });\n run(function () {\n // Based on the above binding if you change the output of MyApp.first\n // object it should change the all the variable of\n // MyApp.first,MyApp.second and MyApp.third object\n MyApp.first.set(\"output\", \"change\") ;\n\n //Changes the output of the MyApp.first object\n equal(MyApp.first.get(\"output\"), \"change\") ;\n\n //since binding has not taken into effect the value still remains as change.\n equal(MyApp.second.get(\"output\"), \"MyApp.first\") ;\n\n }); // allows bindings to trigger...\n\n //Value of the output variable changed to 'change'\n equal(MyApp.first.get(\"output\"), \"change\") ;\n\n //Since binding triggered after the end loop the value changed to 'change'.\n equal(MyApp.second.get(\"output\"), \"change\") ;\n });\n\n test(\"Should propagate bindings after the RunLoop completes\", function() {\n run(function () {\n //Binding of output of MyApp.first object to input of MyApp.second object\n binding1 = Binding.from(\"first.output\")\n .to(\"second.input\").connect(MyApp) ;\n\n //Binding of output of MyApp.second object to input of MyApp.third object\n binding2 = Binding.from(\"second.output\")\n .to(\"third.input\").connect(MyApp) ;\n });\n\n run(function () {\n //Based on the above binding if you change the output of MyApp.first object it should\n //change the all the variable of MyApp.first,MyApp.second and MyApp.third object\n MyApp.first.set(\"output\", \"change\") ;\n\n //Changes the output of the MyApp.first object\n equal(MyApp.first.get(\"output\"), \"change\") ;\n\n //since binding has not taken into effect the value still remains as change.\n equal(MyApp.second.get(\"output\"), \"MyApp.first\") ;\n });\n\n //Value of the output variable changed to 'change'\n equal(MyApp.first.get(\"output\"), \"change\") ;\n\n //Since binding triggered after the end loop the value changed to 'change'.\n equal(MyApp.second.get(\"output\"), \"change\") ;\n });\n });\ndefine(\"ember-runtime/tests/legacy_1x/system/set_test\",\n [\"ember-metal/core\",\"ember-metal/is_none\",\"ember-runtime/system/set\",\"ember-runtime/system/object\",\"ember-runtime/mixins/array\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var isNone = __dependency2__.isNone;\n var none = __dependency2__.none;\n var Set = __dependency3__[\"default\"];\n var EmberObject = __dependency4__[\"default\"];\n var EmberArray = __dependency5__[\"default\"];\n\n // NOTE: This test is adapted from the 1.x series of unit tests. The tests\n // are the same except for places where we intend to break the API we instead\n // validate that we warn the developer appropriately.\n //\n // * Changed Set.clone() call to Set.copy()\n\n // ========================================================================\n // Set Tests\n // ========================================================================\n\n var a, b, c ; // global variables\n\n module(\"creating Set instances\", {\n\n setup: function() {\n // create objects...\n a = { name: \"a\" } ;\n b = { name: \"b\" } ;\n c = { name: \"c\" } ;\n },\n\n teardown: function() {\n a = undefined ;\n b = undefined ;\n c = undefined ;\n }\n\n });\n\n test(\"new Set() should create empty set\", function() {\n var set = new Set() ;\n equal(set.length, 0) ;\n });\n\n test(\"new Set([1,2,3]) should create set with three items in them\", function() {\n var set = new Set(Ember.A([a,b,c])) ;\n equal(set.length, 3) ;\n equal(set.contains(a), true) ;\n equal(set.contains(b), true) ;\n equal(set.contains(c), true) ;\n });\n\n test(\"new Set() should accept anything that implements EmberArray\", function() {\n var arrayLikeObject = EmberObject.createWithMixins(EmberArray, {\n _content: [a,b,c],\n length: 3,\n objectAt: function(idx) { return this._content[idx]; }\n }) ;\n\n var set = new Set(arrayLikeObject) ;\n equal(set.length, 3) ;\n equal(set.contains(a), true) ;\n equal(set.contains(b), true) ;\n equal(set.contains(c), true) ;\n });\n\n var set ; // global variables\n\n // The tests below also end up testing the contains() method pretty\n // exhaustively.\n module(\"Set.add + Set.contains\", {\n\n setup: function() {\n set = new Set() ;\n },\n\n teardown: function() {\n set = undefined ;\n }\n\n });\n\n test(\"should add an EmberObject\", function() {\n var obj = EmberObject.create() ;\n\n var oldLength = set.length ;\n set.add(obj) ;\n equal(set.contains(obj), true, \"contains()\") ;\n equal(set.length, oldLength+1, \"new set length\") ;\n });\n\n test(\"should add a regular hash\", function() {\n var obj = {} ;\n\n var oldLength = set.length ;\n set.add(obj) ;\n equal(set.contains(obj), true, \"contains()\") ;\n equal(set.length, oldLength+1, \"new set length\") ;\n });\n\n test(\"should add a string\", function() {\n var obj = \"String!\" ;\n\n var oldLength = set.length ;\n set.add(obj) ;\n equal(set.contains(obj), true, \"contains()\") ;\n equal(set.length, oldLength+1, \"new set length\") ;\n });\n\n test(\"should add a number\", function() {\n var obj = 23 ;\n\n var oldLength = set.length ;\n set.add(obj) ;\n equal(set.contains(obj), true, \"contains()\") ;\n equal(set.length, oldLength+1, \"new set length\") ;\n });\n\n test(\"should add bools\", function() {\n var oldLength = set.length ;\n\n set.add(true) ;\n equal(set.contains(true), true, \"contains(true)\");\n equal(set.length, oldLength+1, \"new set length\");\n\n set.add(false);\n equal(set.contains(false), true, \"contains(false)\");\n equal(set.length, oldLength+2, \"new set length\");\n });\n\n test(\"should add 0\", function() {\n var oldLength = set.length ;\n\n set.add(0) ;\n equal(set.contains(0), true, \"contains(0)\");\n equal(set.length, oldLength+1, \"new set length\");\n });\n\n test(\"should add a function\", function() {\n var obj = function() { return \"Test function\"; } ;\n\n var oldLength = set.length ;\n set.add(obj) ;\n equal(set.contains(obj), true, \"contains()\") ;\n equal(set.length, oldLength+1, \"new set length\") ;\n });\n\n test(\"should NOT add a null\", function() {\n set.add(null) ;\n equal(set.length, 0) ;\n equal(set.contains(null), false) ;\n });\n\n test(\"should NOT add an undefined\", function() {\n set.add(undefined) ;\n equal(set.length, 0) ;\n equal(set.contains(undefined), false) ;\n });\n\n test(\"adding an item, removing it, adding another item\", function() {\n var item1 = \"item1\" ;\n var item2 = \"item2\" ;\n\n set.add(item1) ; // add to set\n set.remove(item1) ; //remove from set\n set.add(item2) ;\n\n equal(set.contains(item1), false, \"set.contains(item1)\") ;\n\n set.add(item1) ; // re-add to set\n equal(set.length, 2, \"set.length\") ;\n });\n\n module(\"Set.remove + Set.contains\", {\n\n // generate a set with every type of object, but none of the specific\n // ones we add in the tests below...\n setup: function() {\n set = new Set(Ember.A([\n EmberObject.create({ dummy: true }),\n { isHash: true },\n \"Not the String\",\n 16, true, false, 0])) ;\n },\n\n teardown: function() {\n set = undefined ;\n }\n\n });\n\n test(\"should remove an EmberObject and reduce length\", function() {\n var obj = EmberObject.create() ;\n set.add(obj) ;\n equal(set.contains(obj), true) ;\n var oldLength = set.length ;\n\n set.remove(obj) ;\n equal(set.contains(obj), false, \"should be removed\") ;\n equal(set.length, oldLength-1, \"should be 1 shorter\") ;\n });\n\n test(\"should remove a regular hash and reduce length\", function() {\n var obj = {} ;\n set.add(obj) ;\n equal(set.contains(obj), true) ;\n var oldLength = set.length ;\n\n set.remove(obj) ;\n equal(set.contains(obj), false, \"should be removed\") ;\n equal(set.length, oldLength-1, \"should be 1 shorter\") ;\n });\n\n test(\"should remove a string and reduce length\", function() {\n var obj = \"String!\" ;\n set.add(obj) ;\n equal(set.contains(obj), true) ;\n var oldLength = set.length ;\n\n set.remove(obj) ;\n equal(set.contains(obj), false, \"should be removed\") ;\n equal(set.length, oldLength-1, \"should be 1 shorter\") ;\n });\n\n test(\"should remove a number and reduce length\", function() {\n var obj = 23 ;\n set.add(obj) ;\n equal(set.contains(obj), true) ;\n var oldLength = set.length ;\n\n set.remove(obj) ;\n equal(set.contains(obj), false, \"should be removed\") ;\n equal(set.length, oldLength-1, \"should be 1 shorter\") ;\n });\n\n test(\"should remove a bools and reduce length\", function() {\n var oldLength = set.length ;\n set.remove(true) ;\n equal(set.contains(true), false, \"should be removed\") ;\n equal(set.length, oldLength-1, \"should be 1 shorter\") ;\n\n set.remove(false);\n equal(set.contains(false), false, \"should be removed\") ;\n equal(set.length, oldLength-2, \"should be 2 shorter\") ;\n });\n\n test(\"should remove 0 and reduce length\", function() {\n var oldLength = set.length;\n set.remove(0) ;\n equal(set.contains(0), false, \"should be removed\") ;\n equal(set.length, oldLength-1, \"should be 1 shorter\") ;\n });\n\n test(\"should remove a function and reduce length\", function() {\n var obj = function() { return \"Test function\"; } ;\n set.add(obj) ;\n equal(set.contains(obj), true) ;\n var oldLength = set.length ;\n\n set.remove(obj) ;\n equal(set.contains(obj), false, \"should be removed\") ;\n equal(set.length, oldLength-1, \"should be 1 shorter\") ;\n });\n\n test(\"should NOT remove a null\", function() {\n var oldLength = set.length ;\n set.remove(null) ;\n equal(set.length, oldLength) ;\n });\n\n test(\"should NOT remove an undefined\", function() {\n var oldLength = set.length ;\n set.remove(undefined) ;\n equal(set.length, oldLength) ;\n });\n\n test(\"should ignore removing an object not in the set\", function() {\n var obj = EmberObject.create() ;\n var oldLength = set.length ;\n set.remove(obj) ;\n equal(set.length, oldLength) ;\n });\n\n module(\"Set.pop + Set.copy\", {\n // generate a set with every type of object, but none of the specific\n // ones we add in the tests below...\n setup: function() {\n set = new Set(Ember.A([\n EmberObject.create({ dummy: true }),\n { isHash: true },\n \"Not the String\",\n 16, false])) ;\n },\n\n teardown: function() {\n set = undefined ;\n }\n });\n\n test(\"the pop() should remove an arbitrary object from the set\", function() {\n var oldLength = set.length ;\n var obj = set.pop();\n ok(!isNone(obj), 'pops up an item');\n equal(set.length, oldLength-1, 'length shorter by 1');\n });\n\n test(\"should pop false and 0\", function() {\n set = new Set(Ember.A([false]));\n ok(set.pop() === false, \"should pop false\");\n\n set = new Set(Ember.A([0]));\n ok(set.pop() === 0, \"should pop 0\");\n });\n\n test(\"the copy() should return an indentical set\", function() {\n var oldLength = set.length ;\n var obj = set.copy();\n equal(oldLength,obj.length,'length of the clone should be same');\n equal(obj.contains(set[0]), true);\n equal(obj.contains(set[1]), true);\n equal(obj.contains(set[2]), true);\n equal(obj.contains(set[3]), true);\n equal(obj.contains(set[4]), true);\n });\n });\ndefine(\"ember-runtime/tests/mixins/action_handler_test\",\n [\"ember-metal/run_loop\",\"ember-runtime/controllers/controller\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var Controller = __dependency2__.Controller;\n var ControllerMixin = __dependency2__.ControllerMixin;\n\n test(\"passing a function for the actions hash triggers an assertion\", function() {\n expect(1);\n\n var controller = Controller.extend({\n actions: function(){}\n });\n\n expectAssertion(function(){\n run(function(){\n controller.create();\n });\n });\n });\n });\ndefine(\"ember-runtime/tests/mixins/array_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/observer\",\"ember-metal/mixin\",\"ember-metal/computed\",\"ember-runtime/tests/props_helper\",\"ember-runtime/tests/suites/array\",\"ember-runtime/system/object\",\"ember-runtime/mixins/array\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // Ember.A\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var addObserver = __dependency4__.addObserver;\n var emberObserver = __dependency5__.observer;\n var computed = __dependency6__.computed;\n var testWithDefault = __dependency7__.testWithDefault;\n var testBoth = __dependency7__.testBoth;\n var ArrayTests = __dependency8__.ArrayTests;\n var EmberObject = __dependency9__[\"default\"];\n var EmberArray = __dependency10__[\"default\"];\n\n /*\n Implement a basic fake mutable array. This validates that any non-native\n enumerable can impl this API.\n */\n var TestArray = EmberObject.extend(EmberArray, {\n\n _content: null,\n\n init: function(ary) {\n this._content = ary || [];\n },\n\n // some methods to modify the array so we can test changes. Note that\n // arrays can be modified even if they don't implement MutableArray. The\n // MutableArray is just a standard API for mutation but not required.\n addObject: function(obj) {\n var idx = this._content.length;\n this.arrayContentWillChange(idx, 0, 1);\n this._content.push(obj);\n this.arrayContentDidChange(idx, 0, 1);\n },\n\n removeFirst: function(idx) {\n this.arrayContentWillChange(0, 1, 0);\n this._content.shift();\n this.arrayContentDidChange(0, 1, 0);\n },\n\n objectAt: function(idx) {\n return this._content[idx];\n },\n\n length: computed(function() {\n return this._content.length;\n })\n });\n\n\n ArrayTests.extend({\n\n name: 'Basic Mutable Array',\n\n newObject: function(ary) {\n ary = ary ? ary.slice() : this.newFixture(3);\n return new TestArray(ary);\n },\n\n // allows for testing of the basic enumerable after an internal mutation\n mutate: function(obj) {\n obj.addObject(this.getFixture(1)[0]);\n },\n\n toArray: function(obj) {\n return obj.slice();\n }\n\n }).run();\n\n test(\"the return value of slice has Ember.Array applied\", function() {\n var x = EmberObject.createWithMixins(EmberArray, {\n length: 0\n });\n var y = x.slice(1);\n equal(EmberArray.detect(y), true, \"mixin should be applied\");\n });\n\n test(\"slice supports negative index arguments\", function() {\n var testArray = new TestArray([1,2,3,4]);\n\n deepEqual(testArray.slice(-2), [3, 4], 'slice(-2)');\n deepEqual(testArray.slice(-2, -1), [3], 'slice(-2, -1');\n deepEqual(testArray.slice(-2, -2), [], 'slice(-2, -2)');\n deepEqual(testArray.slice(-1, -2), [], 'slice(-1, -2)');\n\n deepEqual(testArray.slice(-4, 1), [1], 'slice(-4, 1)');\n deepEqual(testArray.slice(-4, 5), [1,2,3,4], 'slice(-4, 5)');\n deepEqual(testArray.slice(-4), [1,2,3,4], 'slice(-4)');\n\n deepEqual(testArray.slice(0, -1), [1,2,3], 'slice(0, -1)');\n deepEqual(testArray.slice(0, -4), [], 'slice(0, -4)');\n deepEqual(testArray.slice(0, -3), [1], 'slice(0, -3)');\n\n });\n\n // ..........................................................\n // CONTENT DID CHANGE\n //\n\n var DummyArray = EmberObject.extend(EmberArray, {\n nextObject: function() {},\n length: 0,\n objectAt: function(idx) { return 'ITEM-'+idx; }\n });\n\n var obj, observer;\n\n\n // ..........................................................\n // NOTIFY ARRAY OBSERVERS\n //\n\n module('mixins/array/arrayContent[Will|Did]Change');\n\n test('should notify observers of []', function() {\n\n obj = DummyArray.createWithMixins({\n _count: 0,\n enumerablePropertyDidChange: emberObserver('[]', function() {\n this._count++;\n })\n });\n\n equal(obj._count, 0, 'should not have invoked yet');\n\n obj.arrayContentWillChange(0, 1, 1);\n obj.arrayContentDidChange(0, 1, 1);\n\n equal(obj._count, 1, 'should have invoked');\n\n });\n\n // ..........................................................\n // NOTIFY CHANGES TO LENGTH\n //\n\n module('notify observers of length', {\n setup: function() {\n obj = DummyArray.createWithMixins({\n _after: 0,\n lengthDidChange: emberObserver('length', function() {\n this._after++;\n })\n\n });\n\n equal(obj._after, 0, 'should not have fired yet');\n },\n\n teardown: function() {\n obj = null;\n }\n });\n\n test('should notify observers when call with no params', function() {\n obj.arrayContentWillChange();\n equal(obj._after, 0);\n\n obj.arrayContentDidChange();\n equal(obj._after, 1);\n });\n\n // API variation that included items only\n test('should not notify when passed lengths are same', function() {\n obj.arrayContentWillChange(0, 1, 1);\n equal(obj._after, 0);\n\n obj.arrayContentDidChange(0, 1, 1);\n equal(obj._after, 0);\n });\n\n test('should notify when passed lengths are different', function() {\n obj.arrayContentWillChange(0, 1, 2);\n equal(obj._after, 0);\n\n obj.arrayContentDidChange(0, 1, 2);\n equal(obj._after, 1);\n });\n\n\n // ..........................................................\n // NOTIFY ARRAY OBSERVER\n //\n\n module('notify array observers', {\n setup: function() {\n obj = DummyArray.create();\n\n observer = EmberObject.createWithMixins({\n _before: null,\n _after: null,\n\n arrayWillChange: function() {\n equal(this._before, null); // should only call once\n this._before = Array.prototype.slice.call(arguments);\n },\n\n arrayDidChange: function() {\n equal(this._after, null); // should only call once\n this._after = Array.prototype.slice.call(arguments);\n }\n });\n\n obj.addArrayObserver(observer);\n },\n\n teardown: function() {\n obj = observer = null;\n }\n });\n\n test('should notify enumerable observers when called with no params', function() {\n obj.arrayContentWillChange();\n deepEqual(observer._before, [obj, 0, -1, -1]);\n\n obj.arrayContentDidChange();\n deepEqual(observer._after, [obj, 0, -1, -1]);\n });\n\n // API variation that included items only\n test('should notify when called with same length items', function() {\n obj.arrayContentWillChange(0, 1, 1);\n deepEqual(observer._before, [obj, 0, 1, 1]);\n\n obj.arrayContentDidChange(0, 1, 1);\n deepEqual(observer._after, [obj, 0, 1, 1]);\n });\n\n test('should notify when called with diff length items', function() {\n obj.arrayContentWillChange(0, 2, 1);\n deepEqual(observer._before, [obj, 0, 2, 1]);\n\n obj.arrayContentDidChange(0, 2, 1);\n deepEqual(observer._after, [obj, 0, 2, 1]);\n });\n\n test('removing enumerable observer should disable', function() {\n obj.removeArrayObserver(observer);\n obj.arrayContentWillChange();\n deepEqual(observer._before, null);\n\n obj.arrayContentDidChange();\n deepEqual(observer._after, null);\n });\n\n // ..........................................................\n // NOTIFY ENUMERABLE OBSERVER\n //\n\n module('notify enumerable observers as well', {\n setup: function() {\n obj = DummyArray.create();\n\n observer = EmberObject.createWithMixins({\n _before: null,\n _after: null,\n\n enumerableWillChange: function() {\n equal(this._before, null); // should only call once\n this._before = Array.prototype.slice.call(arguments);\n },\n\n enumerableDidChange: function() {\n equal(this._after, null); // should only call once\n this._after = Array.prototype.slice.call(arguments);\n }\n });\n\n obj.addEnumerableObserver(observer);\n },\n\n teardown: function() {\n obj = observer = null;\n }\n });\n\n test('should notify enumerable observers when called with no params', function() {\n obj.arrayContentWillChange();\n deepEqual(observer._before, [obj, null, null], 'before');\n\n obj.arrayContentDidChange();\n deepEqual(observer._after, [obj, null, null], 'after');\n });\n\n // API variation that included items only\n test('should notify when called with same length items', function() {\n obj.arrayContentWillChange(0, 1, 1);\n deepEqual(observer._before, [obj, ['ITEM-0'], 1], 'before');\n\n obj.arrayContentDidChange(0, 1, 1);\n deepEqual(observer._after, [obj, 1, ['ITEM-0']], 'after');\n });\n\n test('should notify when called with diff length items', function() {\n obj.arrayContentWillChange(0, 2, 1);\n deepEqual(observer._before, [obj, ['ITEM-0', 'ITEM-1'], 1], 'before');\n\n obj.arrayContentDidChange(0, 2, 1);\n deepEqual(observer._after, [obj, 2, ['ITEM-0']], 'after');\n });\n\n test('removing enumerable observer should disable', function() {\n obj.removeEnumerableObserver(observer);\n obj.arrayContentWillChange();\n deepEqual(observer._before, null, 'before');\n\n obj.arrayContentDidChange();\n deepEqual(observer._after, null, 'after');\n });\n\n // ..........................................................\n // @each\n //\n\n var ary;\n\n module('EmberArray.@each support', {\n setup: function() {\n ary = new TestArray([\n { isDone: true, desc: 'Todo 1' },\n { isDone: false, desc: 'Todo 2' },\n { isDone: true, desc: 'Todo 3' },\n { isDone: false, desc: 'Todo 4' }\n ]);\n },\n\n teardown: function() {\n ary = null;\n }\n });\n\n test('adding an object should notify (@each)', function() {\n\n var called = 0;\n\n var observerObject = EmberObject.create({\n wasCalled: function() {\n called++;\n }\n });\n\n // get(ary, '@each');\n addObserver(ary, '@each', observerObject, 'wasCalled');\n\n ary.addObject(EmberObject.create({\n desc: \"foo\",\n isDone: false\n }));\n\n equal(called, 1, \"calls observer when object is pushed\");\n\n });\n\n test('adding an object should notify (@each.isDone)', function() {\n\n var called = 0;\n\n var observerObject = EmberObject.create({\n wasCalled: function() {\n called++;\n }\n });\n\n addObserver(ary, '@each.isDone', observerObject, 'wasCalled');\n\n ary.addObject(EmberObject.create({\n desc: \"foo\",\n isDone: false\n }));\n\n equal(called, 1, \"calls observer when object is pushed\");\n\n });\n\n test('using @each to observe arrays that does not return objects raise error', function() {\n\n var called = 0;\n\n var observerObject = EmberObject.create({\n wasCalled: function() {\n called++;\n }\n });\n\n ary = TestArray.create({\n objectAt: function(idx) {\n return get(this._content[idx], 'desc');\n }\n });\n\n addObserver(ary, '@each.isDone', observerObject, 'wasCalled');\n\n expectAssertion(function() {\n ary.addObject(EmberObject.create({\n desc: \"foo\",\n isDone: false\n }));\n }, /When using @each to observe the array/);\n\n equal(called, 0, 'not calls observer when object is pushed');\n });\n\n test('modifying the array should also indicate the isDone prop itself has changed', function() {\n // NOTE: we never actually get the '@each.isDone' property here. This is\n // important because it tests the case where we don't have an isDone\n // EachArray materialized but just want to know when the property has\n // changed.\n\n var each = get(ary, '@each');\n var count = 0;\n\n addObserver(each, 'isDone', function() { count++; });\n\n count = 0;\n var item = ary.objectAt(2);\n set(item, 'isDone', !get(item, 'isDone'));\n equal(count, 1, '@each.isDone should have notified');\n });\n\n\n testBoth(\"should be clear caches for computed properties that have dependent keys on arrays that are changed after object initialization\", function(get, set) {\n var obj = EmberObject.createWithMixins({\n init: function() {\n set(this, 'resources', Ember.A());\n },\n\n common: computed(function() {\n return get(get(this, 'resources').objectAt(0), 'common');\n }).property('resources.@each.common')\n });\n\n get(obj, 'resources').pushObject(EmberObject.create({ common: \"HI!\" }));\n equal(\"HI!\", get(obj, 'common'));\n\n set(get(obj, 'resources').objectAt(0), 'common', \"BYE!\");\n equal(\"BYE!\", get(obj, 'common'));\n });\n\n testBoth(\"observers that contain @each in the path should fire only once the first time they are accessed\", function(get, set) {\n var count = 0;\n\n var obj = EmberObject.createWithMixins({\n init: function() {\n // Observer does not fire on init\n set(this, 'resources', Ember.A());\n },\n\n commonDidChange: emberObserver('resources.@each.common', function() {\n count++;\n })\n });\n\n // Observer fires second time when new object is added\n get(obj, 'resources').pushObject(EmberObject.create({ common: \"HI!\" }));\n // Observer fires third time when property on an object is changed\n set(get(obj, 'resources').objectAt(0), 'common', \"BYE!\");\n\n equal(count, 2, \"observers should only be called once\");\n });\n });\ndefine(\"ember-runtime/tests/mixins/comparable_test\",\n [\"ember-metal/property_get\",\"ember-runtime/system/object\",\"ember-runtime/compare\",\"ember-runtime/mixins/comparable\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var get = __dependency1__.get;\n var EmberObject = __dependency2__[\"default\"];\n var compare = __dependency3__[\"default\"];\n var Comparable = __dependency4__[\"default\"];\n\n var Rectangle = EmberObject.extend(Comparable, {\n length: 0,\n width: 0,\n\n area: function() {\n return get(this,'length') * get(this, 'width');\n },\n\n compare: function(a, b) {\n return compare(a.area(), b.area());\n }\n\n });\n\n var r1, r2;\n\n module(\"Comparable\", {\n\n setup: function() {\n r1 = Rectangle.create({length: 6, width: 12});\n r2 = Rectangle.create({length: 6, width: 13});\n },\n\n teardown: function() {\n }\n\n });\n\n test(\"should be comparable and return the correct result\", function() {\n equal(Comparable.detect(r1), true);\n equal(compare(r1, r1), 0);\n equal(compare(r1, r2), -1);\n equal(compare(r2, r1), 1);\n });\n });\ndefine(\"ember-runtime/tests/mixins/copyable_test\",\n [\"ember-runtime/tests/suites/copyable\",\"ember-runtime/mixins/copyable\",\"ember-runtime/system/object\",\"ember-metal/utils\",\"ember-metal/property_set\",\"ember-metal/property_get\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var CopyableTests = __dependency1__[\"default\"];\n var Copyable = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var generateGuid = __dependency4__.generateGuid;\n var set = __dependency5__.set;\n var get = __dependency6__.get;\n\n var CopyableObject = EmberObject.extend(Copyable, {\n\n id: null,\n\n init: function() {\n this._super();\n set(this, 'id', generateGuid());\n },\n\n copy: function() {\n var ret = new CopyableObject();\n set(ret, 'id', get(this, 'id'));\n return ret;\n }\n });\n\n CopyableTests.extend({\n\n name: 'Copyable Basic Test',\n\n newObject: function() {\n return new CopyableObject();\n },\n\n isEqual: function(a, b) {\n if (!(a instanceof CopyableObject) || !(b instanceof CopyableObject)) return false;\n return get(a, 'id') === get(b,'id');\n }\n }).run();\n });\ndefine(\"ember-runtime/tests/mixins/deferred_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-runtime/mixins/deferred\",\"ember-runtime/ext/rsvp\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var Deferred = __dependency4__[\"default\"];\n var RSVP = __dependency5__[\"default\"];\n\n module(\"Deferred\");\n\n test(\"can resolve deferred\", function() {\n var deferred, count = 0;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(function(a) {\n count++;\n });\n\n run(deferred, 'resolve', deferred);\n\n equal(count, 1, \"was fulfilled\");\n });\n\n test(\"can reject deferred\", function() {\n\n var deferred, count = 0;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(null, function() {\n count++;\n });\n\n run(deferred, 'reject');\n\n equal(count, 1, \"fail callback was called\");\n });\n\n test(\"can resolve with then\", function() {\n\n var deferred, count1 = 0 ,count2 = 0;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(function() {\n count1++;\n }, function() {\n count2++;\n });\n\n run(deferred, 'resolve', deferred);\n\n equal(count1, 1, \"then were resolved\");\n equal(count2, 0, \"then was not rejected\");\n });\n\n test(\"can reject with then\", function() {\n\n var deferred, count1 = 0 ,count2 = 0;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(function() {\n count1++;\n }, function() {\n count2++;\n });\n\n run(deferred, 'reject');\n\n equal(count1, 0, \"then was not resolved\");\n equal(count2, 1, \"then were rejected\");\n });\n\n test(\"can call resolve multiple times\", function() {\n\n var deferred, count = 0;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(function() {\n count++;\n });\n\n run(function() {\n deferred.resolve(deferred);\n deferred.resolve(deferred);\n deferred.resolve(deferred);\n });\n\n equal(count, 1, \"calling resolve multiple times has no effect\");\n });\n\n test(\"resolve prevent reject\", function() {\n var deferred, resolved = false, rejected = false, progress = 0;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(function() {\n resolved = true;\n }, function() {\n rejected = true;\n });\n\n run(deferred, 'resolve', deferred);\n run(deferred, 'reject');\n\n equal(resolved, true, \"is resolved\");\n equal(rejected, false, \"is not rejected\");\n });\n\n test(\"reject prevent resolve\", function() {\n var deferred, resolved = false, rejected = false, progress = 0;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(function() {\n resolved = true;\n }, function() {\n rejected = true;\n });\n\n run(deferred, 'reject');\n run(deferred, 'reject', deferred);\n\n equal(resolved, false, \"is not resolved\");\n equal(rejected, true, \"is rejected\");\n });\n\n test(\"will call callbacks if they are added after resolution\", function() {\n\n var deferred, count1 = 0;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n run(deferred, 'resolve', 'toto');\n\n run(function() {\n deferred.then(function(context) {\n if (context === 'toto') {\n count1++;\n }\n });\n\n deferred.then(function(context) {\n if (context === 'toto') {\n count1++;\n }\n });\n });\n\n equal(count1, 2, \"callbacks called after resolution\");\n });\n\n test(\"then is chainable\", function() {\n var deferred, count = 0;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(function() {\n eval('error'); // Use eval to pass JSHint\n }).then(null, function() {\n count++;\n });\n\n run(deferred, 'resolve', deferred);\n\n equal(count, 1, \"chained callback was called\");\n });\n\n\n\n test(\"can self fulfill\", function() {\n expect(1);\n var deferred;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(function(value) {\n equal(value, deferred, \"successfully resolved to itself\");\n });\n\n run(deferred, 'resolve', deferred);\n });\n\n\n test(\"can self reject\", function() {\n expect(1);\n var deferred;\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(function() {\n ok(false, 'should not fulfill');\n },function(value) {\n equal(value, deferred, \"successfully rejected to itself\");\n });\n\n run(deferred, 'reject', deferred);\n });\n\n test(\"can fulfill to a custom value\", function() {\n expect(1);\n var deferred, obj = {};\n\n run(function() {\n deferred = EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then(function(value) {\n equal(value, obj, \"successfully resolved to given value\");\n });\n\n run(deferred, 'resolve', obj);\n });\n\n\n test(\"can chain self fulfilling objects\", function() {\n expect(2);\n var firstDeferred, secondDeferred;\n\n run(function() {\n firstDeferred = EmberObject.createWithMixins(Deferred);\n secondDeferred = EmberObject.createWithMixins(Deferred);\n });\n\n firstDeferred.then(function(value) {\n equal(value, firstDeferred, \"successfully resolved to the first deferred\");\n return secondDeferred;\n }).then(function(value) {\n equal(value, secondDeferred, \"successfully resolved to the second deferred\");\n });\n\n run(function() {\n firstDeferred.resolve(firstDeferred);\n secondDeferred.resolve(secondDeferred);\n });\n });\n\n test(\"can do multi level assimilation\", function() {\n expect(1);\n var firstDeferred, secondDeferred, firstDeferredResolved = false;\n\n run(function() {\n firstDeferred = EmberObject.createWithMixins(Deferred);\n secondDeferred = EmberObject.createWithMixins(Deferred);\n });\n\n firstDeferred.then(function() {\n firstDeferredResolved = true;\n });\n\n secondDeferred.then(function() {\n ok(firstDeferredResolved, \"first deferred already resolved\");\n });\n\n run(secondDeferred, 'resolve', firstDeferred);\n run(firstDeferred, 'resolve', firstDeferred);\n });\n\n\n test(\"can handle rejection without rejection handler\", function() {\n expect(2);\n\n var reason = 'some reason';\n\n var deferred = run(function() {\n return EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then().then(function() {\n ok(false, 'expected rejection, got fulfillment');\n }, function(actualReason) {\n ok(true, 'expected fulfillment');\n equal(actualReason, reason);\n });\n\n run(deferred, 'reject', reason);\n });\n\n test(\"can handle fulfillment without fulfillment handler\", function() {\n expect(2);\n\n var fulfillment = 'some fulfillment';\n\n var deferred = run(function() {\n return EmberObject.createWithMixins(Deferred);\n });\n\n deferred.then().then(function(actualFulfillment) {\n ok(true, 'expected fulfillment');\n equal(fulfillment, actualFulfillment);\n }, function(reason) {\n ok(false, 'expected fulfillment, got reason' + reason);\n });\n\n run(deferred, 'resolve', fulfillment);\n });\n\n if (Ember.FEATURES['ember-runtime-test-friendly-promises']) {\n var asyncStarted = 0;\n var asyncEnded = 0;\n var Promise = RSVP.Promise;\n\n var EmberTest;\n var EmberTesting;\n\n module(\"Deferred RSVP's async + Testing\", {\n setup: function() {\n EmberTest = Ember.Test;\n EmberTesting = Ember.testing;\n\n Ember.Test = {\n adapter: {\n asyncStart: function() {\n asyncStarted++;\n QUnit.stop();\n },\n asyncEnd: function() {\n asyncEnded++;\n QUnit.start();\n }\n }\n };\n },\n teardown: function() {\n asyncStarted = 0;\n asyncEnded = 0;\n\n Ember.testing = EmberTesting;\n Ember.Test = EmberTest;\n }\n });\n\n test(\"given `Ember.testing = true`, correctly informs the test suite about async steps\", function() {\n expect(19);\n\n ok(!run.currentRunLoop, 'expect no run-loop');\n\n Ember.testing = true;\n\n equal(asyncStarted, 0);\n equal(asyncEnded, 0);\n\n var user = Promise.resolve({\n name: 'tomster'\n });\n\n equal(asyncStarted, 1);\n equal(asyncEnded, 0);\n\n user.then(function(user){\n equal(asyncStarted, 1);\n equal(asyncEnded, 1);\n\n equal(user.name, 'tomster');\n\n return Promise.resolve(1).then(function(){\n equal(asyncStarted, 1);\n equal(asyncEnded, 1);\n });\n\n }).then(function(){\n equal(asyncStarted, 1);\n equal(asyncEnded, 1);\n\n return new Promise(function(resolve){\n QUnit.stop(); // raw async, we must inform the test framework manually\n setTimeout(function(){\n QUnit.start(); // raw async, we must inform the test framework manually\n\n equal(asyncStarted, 1);\n equal(asyncEnded, 1);\n\n resolve({\n name: 'async tomster'\n });\n\n equal(asyncStarted, 2);\n equal(asyncEnded, 1);\n }, 0);\n });\n }).then(function(user){\n equal(user.name, 'async tomster');\n equal(asyncStarted, 2);\n equal(asyncEnded, 2);\n });\n });\n }\n });\ndefine(\"ember-runtime/tests/mixins/enumerable_test\",\n [\"ember-metal/core\",\"ember-runtime/tests/suites/enumerable\",\"ember-metal/enumerable_utils\",\"ember-runtime/system/object\",\"ember-runtime/mixins/enumerable\",\"ember-runtime/mixins/array\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/computed\",\"ember-metal/mixin\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // for Ember.K and Ember.A\n var EnumerableTests = __dependency2__[\"default\"];\n var EnumerableUtils = __dependency3__[\"default\"];\n var EmberObject = __dependency4__[\"default\"];\n var Enumerable = __dependency5__[\"default\"];\n var EmberArray = __dependency6__[\"default\"];\n var get = __dependency7__.get;\n var set = __dependency8__.set;\n var computed = __dependency9__.computed;\n var emberObserver = __dependency10__.observer;\n\n var indexOf = EnumerableUtils.indexOf;\n\n /*\n Implement a basic fake enumerable. This validates that any non-native\n enumerable can impl this API.\n */\n var TestEnumerable = EmberObject.extend(Enumerable, {\n\n _content: null,\n\n init: function(ary) {\n this._content = ary || [];\n },\n\n addObject: function(obj) {\n if (indexOf(this._content, obj)>=0) return this;\n this._content.push(obj);\n this.enumerableContentDidChange();\n },\n\n nextObject: function(idx) {\n return idx >= get(this, 'length') ? undefined : this._content[idx];\n },\n\n length: computed(function() {\n return this._content.length;\n }),\n\n slice: function() {\n return this._content.slice();\n }\n\n });\n\n\n EnumerableTests.extend({\n\n name: 'Basic Enumerable',\n\n newObject: function(ary) {\n ary = ary ? ary.slice() : this.newFixture(3);\n return new TestEnumerable(ary);\n },\n\n // allows for testing of the basic enumerable after an internal mutation\n mutate: function(obj) {\n obj.addObject(obj._content.length+1);\n },\n\n toArray: function(obj) {\n return obj.slice();\n }\n\n }).run();\n\n module('Ember.Enumerable');\n\n test(\"should apply Ember.Array to return value of map\", function() {\n var x = EmberObject.createWithMixins(Enumerable);\n var y = x.map(Ember.K);\n equal(EmberArray.detect(y), true, \"should have mixin applied\");\n });\n\n test(\"should apply Ember.Array to return value of filter\", function() {\n var x = EmberObject.createWithMixins(Enumerable);\n var y = x.filter(Ember.K);\n equal(EmberArray.detect(y), true, \"should have mixin applied\");\n });\n\n test(\"should apply Ember.Array to return value of invoke\", function() {\n var x = EmberObject.createWithMixins(Enumerable);\n var y = x.invoke(Ember.K);\n equal(EmberArray.detect(y), true, \"should have mixin applied\");\n });\n\n test(\"should apply Ember.Array to return value of toArray\", function() {\n var x = EmberObject.createWithMixins(Enumerable);\n var y = x.toArray(Ember.K);\n equal(EmberArray.detect(y), true, \"should have mixin applied\");\n });\n\n test(\"should apply Ember.Array to return value of without\", function() {\n var x = EmberObject.createWithMixins(Enumerable, {\n contains: function() {\n return true;\n }\n });\n var y = x.without(Ember.K);\n equal(EmberArray.detect(y), true, \"should have mixin applied\");\n });\n\n test(\"should apply Ember.Array to return value of uniq\", function() {\n var x = EmberObject.createWithMixins(Enumerable);\n var y = x.uniq(Ember.K);\n equal(EmberArray.detect(y), true, \"should have mixin applied\");\n });\n\n test('any', function() {\n var kittens = Ember.A([{\n color: 'white'\n }, {\n color: 'black'\n }, {\n color: 'white'\n }]),\n foundWhite = kittens.any(function(kitten) { return kitten.color === 'white'; }),\n foundWhite2 = kittens.isAny('color', 'white');\n\n equal(foundWhite, true);\n equal(foundWhite2, true);\n });\n\n test('any with NaN', function() {\n var numbers = Ember.A([1,2,NaN,4]);\n\n var hasNaN = numbers.any(function(n){ return isNaN(n); });\n\n equal(hasNaN, true, \"works when matching NaN\");\n });\n\n test('every', function() {\n var allColorsKittens = Ember.A([{\n color: 'white'\n }, {\n color: 'black'\n }, {\n color: 'white'\n }]),\n allWhiteKittens = Ember.A([{\n color: 'white'\n }, {\n color: 'white'\n }, {\n color: 'white'\n }]),\n allWhite = false,\n whiteKittenPredicate = function(kitten) { return kitten.color === 'white'; };\n\n allWhite = allColorsKittens.every(whiteKittenPredicate);\n equal(allWhite, false);\n\n allWhite = allWhiteKittens.every(whiteKittenPredicate);\n equal(allWhite, true);\n\n allWhite = allColorsKittens.isEvery('color', 'white');\n equal(allWhite, false);\n\n allWhite = allWhiteKittens.isEvery('color', 'white');\n equal(allWhite, true);\n });\n\n // ..........................................................\n // CONTENT DID CHANGE\n //\n\n var DummyEnum = EmberObject.extend(Enumerable, {\n nextObject: function() {},\n length: 0\n });\n\n var obj, observer;\n\n // ..........................................................\n // NOTIFY ENUMERABLE PROPERTY\n //\n\n module('mixins/enumerable/enumerableContentDidChange');\n\n test('should notify observers of []', function() {\n\n var obj = EmberObject.createWithMixins(Enumerable, {\n nextObject: function() {}, // avoid exceptions\n\n _count: 0,\n enumerablePropertyDidChange: emberObserver('[]', function() {\n this._count++;\n })\n });\n\n equal(obj._count, 0, 'should not have invoked yet');\n obj.enumerableContentWillChange();\n obj.enumerableContentDidChange();\n equal(obj._count, 1, 'should have invoked');\n\n });\n\n // ..........................................................\n // NOTIFY CHANGES TO LENGTH\n //\n\n module('notify observers of length', {\n setup: function() {\n obj = DummyEnum.createWithMixins({\n _after: 0,\n lengthDidChange: emberObserver('length', function() {\n this._after++;\n })\n\n });\n\n equal(obj._after, 0, 'should not have fired yet');\n },\n\n teardown: function() {\n obj = null;\n }\n });\n\n test('should notify observers when call with no params', function() {\n obj.enumerableContentWillChange();\n equal(obj._after, 0);\n\n obj.enumerableContentDidChange();\n equal(obj._after, 1);\n });\n\n // API variation that included items only\n test('should not notify when passed arrays of same length', function() {\n var added = ['foo'], removed = ['bar'];\n obj.enumerableContentWillChange(removed, added);\n equal(obj._after, 0);\n\n obj.enumerableContentDidChange(removed, added);\n equal(obj._after, 0);\n });\n\n test('should notify when passed arrays of different length', function() {\n var added = ['foo'], removed = ['bar', 'baz'];\n obj.enumerableContentWillChange(removed, added);\n equal(obj._after, 0);\n\n obj.enumerableContentDidChange(removed, added);\n equal(obj._after, 1);\n });\n\n // API variation passes indexes only\n test('should not notify when passed with indexes', function() {\n obj.enumerableContentWillChange(1, 1);\n equal(obj._after, 0);\n\n obj.enumerableContentDidChange(1, 1);\n equal(obj._after, 0);\n });\n\n test('should notify when passed old index API with delta', function() {\n obj.enumerableContentWillChange(1, 2);\n equal(obj._after, 0);\n\n obj.enumerableContentDidChange(1, 2);\n equal(obj._after, 1);\n });\n\n\n // ..........................................................\n // NOTIFY ENUMERABLE OBSERVER\n //\n\n module('notify enumerable observers', {\n setup: function() {\n obj = DummyEnum.create();\n\n observer = EmberObject.createWithMixins({\n _before: null,\n _after: null,\n\n enumerableWillChange: function() {\n equal(this._before, null); // should only call once\n this._before = Array.prototype.slice.call(arguments);\n },\n\n enumerableDidChange: function() {\n equal(this._after, null); // should only call once\n this._after = Array.prototype.slice.call(arguments);\n }\n });\n\n obj.addEnumerableObserver(observer);\n },\n\n teardown: function() {\n obj = observer = null;\n }\n });\n\n test('should notify enumerable observers when called with no params', function() {\n obj.enumerableContentWillChange();\n deepEqual(observer._before, [obj, null, null]);\n\n obj.enumerableContentDidChange();\n deepEqual(observer._after, [obj, null, null]);\n });\n\n // API variation that included items only\n test('should notify when called with same length items', function() {\n var added = ['foo'], removed = ['bar'];\n obj.enumerableContentWillChange(removed, added);\n deepEqual(observer._before, [obj, removed, added]);\n\n obj.enumerableContentDidChange(removed, added);\n deepEqual(observer._after, [obj, removed, added]);\n });\n\n test('should notify when called with diff length items', function() {\n var added = ['foo', 'baz'], removed = ['bar'];\n obj.enumerableContentWillChange(removed, added);\n deepEqual(observer._before, [obj, removed, added]);\n\n obj.enumerableContentDidChange(removed, added);\n deepEqual(observer._after, [obj, removed, added]);\n });\n\n test('should not notify when passed with indexes only', function() {\n obj.enumerableContentWillChange(1, 2);\n deepEqual(observer._before, [obj, 1, 2]);\n\n obj.enumerableContentDidChange(1, 2);\n deepEqual(observer._after, [obj, 1, 2]);\n });\n\n test('removing enumerable observer should disable', function() {\n obj.removeEnumerableObserver(observer);\n obj.enumerableContentWillChange();\n deepEqual(observer._before, null);\n\n obj.enumerableContentDidChange();\n deepEqual(observer._after, null);\n });\n });\ndefine(\"ember-runtime/tests/mixins/mutable_array_test\",\n [\"ember-runtime/tests/suites/mutable_array\",\"ember-runtime/mixins/mutable_array\",\"ember-runtime/system/object\",\"ember-metal/computed\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var MutableArrayTests = __dependency1__[\"default\"];\n var MutableArray = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var computed = __dependency4__.computed;\n\n /*\n Implement a basic fake mutable array. This validates that any non-native\n enumerable can impl this API.\n */\n var TestMutableArray = EmberObject.extend(MutableArray, {\n\n _content: null,\n\n init: function(ary) {\n this._content = Ember.A(ary || []);\n },\n\n replace: function(idx, amt, objects) {\n\n var args = objects ? objects.slice() : [],\n removeAmt = amt,\n addAmt = args.length;\n\n this.arrayContentWillChange(idx, removeAmt, addAmt);\n\n args.unshift(amt);\n args.unshift(idx);\n this._content.splice.apply(this._content, args);\n this.arrayContentDidChange(idx, removeAmt, addAmt);\n return this;\n },\n\n objectAt: function(idx) {\n return this._content[idx];\n },\n\n length: computed(function() {\n return this._content.length;\n }),\n\n slice: function() {\n return this._content.slice();\n }\n\n });\n\n\n MutableArrayTests.extend({\n\n name: 'Basic Mutable Array',\n\n newObject: function(ary) {\n ary = ary ? ary.slice() : this.newFixture(3);\n return new TestMutableArray(ary);\n },\n\n // allows for testing of the basic enumerable after an internal mutation\n mutate: function(obj) {\n obj.addObject(this.getFixture(1)[0]);\n },\n\n toArray: function(obj) {\n return obj.slice();\n }\n\n }).run();\n });\ndefine(\"ember-runtime/tests/mixins/mutable_enumerable_test\",\n [\"ember-runtime/tests/suites/mutable_enumerable\",\"ember-runtime/mixins/mutable_enumerable\",\"ember-metal/enumerable_utils\",\"ember-runtime/system/object\",\"ember-metal/computed\",\"ember-metal/property_get\",\"ember-metal/property_set\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__) {\n \"use strict\";\n var MutableEnumerableTests = __dependency1__[\"default\"];\n var MutableEnumerable = __dependency2__[\"default\"];\n var EnumerableUtils = __dependency3__[\"default\"];\n var EmberObject = __dependency4__[\"default\"];\n var computed = __dependency5__.computed;\n var get = __dependency6__.get;\n var set = __dependency7__.set;\n\n var indexOf = EnumerableUtils.indexOf;\n\n /*\n Implement a basic fake mutable array. This validates that any non-native\n enumerable can impl this API.\n */\n var TestMutableEnumerable = EmberObject.extend(MutableEnumerable, {\n\n _content: null,\n\n addObject: function(obj) {\n if (indexOf(this._content, obj)>=0) return this;\n this.enumerableContentWillChange(null, [obj]);\n this._content.push(obj);\n this.enumerableContentDidChange(null, [obj]);\n },\n\n removeObject: function(obj) {\n var idx = indexOf(this._content, obj);\n if (idx<0) return this;\n\n this.enumerableContentWillChange([obj], null);\n this._content.splice(idx, 1);\n this.enumerableContentDidChange([obj], null);\n return this;\n },\n\n init: function(ary) {\n this._content = ary || [];\n },\n\n nextObject: function(idx) {\n return idx>=get(this, 'length') ? undefined : this._content[idx];\n },\n\n length: computed(function() {\n return this._content.length;\n }),\n\n slice: function() {\n return this._content.slice();\n }\n });\n\n\n MutableEnumerableTests.extend({\n\n name: 'Basic Mutable Array',\n\n newObject: function(ary) {\n ary = ary ? ary.slice() : this.newFixture(3);\n return new TestMutableEnumerable(ary);\n },\n\n // allows for testing of the basic enumerable after an internal mutation\n mutate: function(obj) {\n obj.addObject(this.getFixture(1)[0]);\n },\n\n toArray: function(obj) {\n return obj.slice();\n }\n\n }).run();\n });\ndefine(\"ember-runtime/tests/mixins/observable_test\",\n [\"ember-metal/computed\",\"ember-metal/observer\",\"ember-runtime/system/object\",\"ember-runtime/tests/props_helper\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var computed = __dependency1__.computed;\n var addObserver = __dependency2__.addObserver;\n var EmberObject = __dependency3__[\"default\"];\n var testBoth = __dependency4__.testBoth;\n\n module('mixins/observable');\n\n test('should be able to use getProperties to get a POJO of provided keys', function() {\n var obj = EmberObject.create({\n firstName: \"Steve\",\n lastName: \"Jobs\",\n companyName: \"Apple, Inc.\"\n });\n\n var pojo = obj.getProperties(\"firstName\", \"lastName\");\n equal(\"Steve\", pojo.firstName);\n equal(\"Jobs\", pojo.lastName);\n });\n\n test('should be able to use getProperties with array parameter to get a POJO of provided keys', function() {\n var obj = EmberObject.create({\n firstName: \"Steve\",\n lastName: \"Jobs\",\n companyName: \"Apple, Inc.\"\n });\n\n var pojo = obj.getProperties([\"firstName\", \"lastName\"]);\n equal(\"Steve\", pojo.firstName);\n equal(\"Jobs\", pojo.lastName);\n });\n\n test('should be able to use setProperties to set multiple properties at once', function() {\n var obj = EmberObject.create({\n firstName: \"Steve\",\n lastName: \"Jobs\",\n companyName: \"Apple, Inc.\"\n });\n\n obj.setProperties({firstName: \"Tim\", lastName: \"Cook\"});\n equal(\"Tim\", obj.get(\"firstName\"));\n equal(\"Cook\", obj.get(\"lastName\"));\n });\n\n testBoth('calling setProperties completes safely despite exceptions', function(get,set) {\n var exc = new Error(\"Something unexpected happened!\");\n var obj = EmberObject.createWithMixins({\n firstName: \"Steve\",\n lastName: \"Jobs\",\n companyName: computed(function(key, value) {\n if (value !== undefined) {\n throw exc;\n }\n return \"Apple, Inc.\";\n })\n });\n\n var firstNameChangedCount = 0;\n\n addObserver(obj, 'firstName', function() { firstNameChangedCount++; });\n\n try {\n obj.setProperties({\n firstName: 'Tim',\n lastName: 'Cook',\n companyName: 'Fruit Co., Inc.'\n });\n } catch(err) {\n if (err !== exc) {\n throw err;\n }\n }\n\n equal(firstNameChangedCount, 1, 'firstName should have fired once');\n });\n\n testBoth(\"should be able to retrieve cached values of computed properties without invoking the computed property\", function(get) {\n var obj = EmberObject.createWithMixins({\n foo: computed(function() {\n return \"foo\";\n }),\n\n bar: \"bar\"\n });\n\n equal(obj.cacheFor('foo'), undefined, \"should return undefined if no value has been cached\");\n get(obj, 'foo');\n\n equal(get(obj, 'foo'), \"foo\", \"precond - should cache the value\");\n equal(obj.cacheFor('foo'), \"foo\", \"should return the cached value after it is invoked\");\n\n equal(obj.cacheFor('bar'), undefined, \"returns undefined if the value is not a computed property\");\n });\n\n test('incrementProperty should work even if value is number in string', function() {\n var obj = EmberObject.create({\n age: \"24\"\n });\n obj.incrementProperty('age');\n equal(25, obj.get('age'));\n });\n });\ndefine(\"ember-runtime/tests/mixins/promise_proxy_test\",\n [\"ember-metal/core\",\"ember-metal/platform\",\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-runtime/system/object_proxy\",\"ember-runtime/mixins/promise_proxy\",\"ember-runtime/ext/rsvp\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var create = __dependency2__.create;\n var get = __dependency3__.get;\n var run = __dependency4__[\"default\"];\n var ObjectProxy = __dependency5__[\"default\"];\n var PromiseProxyMixin = __dependency6__[\"default\"];\n var RSVP = __dependency7__[\"default\"];\n var EmberRSVP = RSVP;\n RSVP = requireModule(\"rsvp\");\n\n var ObjectPromiseProxy;\n\n test(\"present on ember namespace\", function(){\n ok(PromiseProxyMixin, \"expected PromiseProxyMixin to exist\");\n });\n\n module(\"Ember.PromiseProxy - ObjectProxy\", {\n setup: function() {\n ObjectPromiseProxy = ObjectProxy.extend(PromiseProxyMixin);\n }\n });\n\n test(\"no promise, invoking then should raise\", function(){\n var value = {\n firstName: 'stef',\n lastName: 'penner'\n };\n\n var proxy = ObjectPromiseProxy.create();\n\n raises(function(){\n proxy.then(Ember.K, Ember.K);\n }, new RegExp(\"PromiseProxy's promise must be set\"));\n });\n\n test(\"fulfillment\", function(){\n var value = {\n firstName: 'stef',\n lastName: 'penner'\n };\n\n var deferred = RSVP.defer();\n\n var proxy = ObjectPromiseProxy.create({\n promise: deferred.promise\n });\n\n var didFulfillCount = 0;\n var didRejectCount = 0;\n\n proxy.then(function(){\n didFulfillCount++;\n }, function(){\n didRejectCount++;\n });\n\n equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content');\n equal(get(proxy, 'reason'), undefined, 'expects the proxy to have no reason');\n equal(get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading');\n equal(get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled');\n equal(get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected');\n equal(get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled');\n\n equal(didFulfillCount, 0, 'should not yet have been fulfilled');\n equal(didRejectCount, 0, 'should not yet have been rejected');\n\n run(deferred, 'resolve', value);\n\n equal(didFulfillCount, 1, 'should have been fulfilled');\n equal(didRejectCount, 0, 'should not have been rejected');\n\n equal(get(proxy, 'content'), value, 'expects the proxy to have content');\n equal(get(proxy, 'reason'), undefined, 'expects the proxy to still have no reason');\n equal(get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is no longer loading');\n equal(get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled');\n equal(get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected');\n equal(get(proxy, 'isFulfilled'), true, 'expects the proxy to indicate that it is fulfilled');\n\n run(deferred, 'resolve', value);\n\n equal(didFulfillCount, 1, 'should still have been only fulfilled once');\n equal(didRejectCount, 0, 'should still not have been rejected');\n\n run(deferred, 'reject', value);\n\n equal(didFulfillCount, 1, 'should still have been only fulfilled once');\n equal(didRejectCount, 0, 'should still not have been rejected');\n\n equal(get(proxy, 'content'), value, 'expects the proxy to have still have same content');\n equal(get(proxy, 'reason'), undefined, 'expects the proxy still to have no reason');\n equal(get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is no longer loading');\n equal(get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled');\n equal(get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected');\n equal(get(proxy, 'isFulfilled'), true, 'expects the proxy to indicate that it is fulfilled');\n\n // rest of the promise semantics are tested in directly in RSVP\n });\n\n test(\"rejection\", function(){\n var reason = new Error(\"failure\");\n var deferred = RSVP.defer();\n var proxy = ObjectPromiseProxy.create({\n promise: deferred.promise\n });\n\n var didFulfillCount = 0;\n var didRejectCount = 0;\n\n proxy.then(function(){\n didFulfillCount++;\n }, function(){\n didRejectCount++;\n });\n\n equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content');\n equal(get(proxy, 'reason'), undefined, 'expects the proxy to have no reason');\n equal(get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading');\n equal(get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled');\n equal(get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected');\n equal(get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled');\n\n equal(didFulfillCount, 0, 'should not yet have been fulfilled');\n equal(didRejectCount, 0, 'should not yet have been rejected');\n\n run(deferred, 'reject', reason);\n\n equal(didFulfillCount, 0, 'should not yet have been fulfilled');\n equal(didRejectCount, 1, 'should have been rejected');\n\n equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content');\n equal(get(proxy, 'reason'), reason, 'expects the proxy to have a reason');\n equal(get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is not longer loading');\n equal(get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled');\n equal(get(proxy, 'isRejected'), true, 'expects the proxy to indicate that it is rejected');\n equal(get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled');\n\n run(deferred, 'reject', reason);\n\n equal(didFulfillCount, 0, 'should stll not yet have been fulfilled');\n equal(didRejectCount, 1, 'should still remain rejected');\n\n run(deferred, 'resolve', 1);\n\n equal(didFulfillCount, 0, 'should stll not yet have been fulfilled');\n equal(didRejectCount, 1, 'should still remain rejected');\n\n equal(get(proxy, 'content'), undefined, 'expects the proxy to have no content');\n equal(get(proxy, 'reason'), reason, 'expects the proxy to have a reason');\n equal(get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is not longer loading');\n equal(get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled');\n equal(get(proxy, 'isRejected'), true, 'expects the proxy to indicate that it is rejected');\n equal(get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled');\n });\n\n test(\"unhandled rejects still propogate to RSVP.on('error', ...) \", function(){\n expect(1);\n\n RSVP.on('error', onerror);\n RSVP.off('error', RSVP.onerrorDefault);\n\n var expectedReason = new Error(\"failure\");\n var deferred = RSVP.defer();\n\n var proxy = ObjectPromiseProxy.create({\n promise: deferred.promise\n });\n\n var promise = proxy.get('promise');\n\n function onerror(reason) {\n equal(reason, expectedReason, 'expected reason');\n }\n\n RSVP.on('error', onerror);\n RSVP.off('error', RSVP.onerrorDefault);\n\n run(deferred, 'reject', expectedReason);\n\n RSVP.on('error', RSVP.onerrorDefault);\n RSVP.off('error', onerror);\n\n run(deferred, 'reject', expectedReason);\n\n RSVP.on('error', RSVP.onerrorDefault);\n RSVP.off('error', onerror);\n });\n\n test(\"should work with promise inheritance\", function(){\n function PromiseSubclass() {\n RSVP.Promise.apply(this, arguments);\n }\n\n PromiseSubclass.prototype = create(RSVP.Promise.prototype);\n PromiseSubclass.prototype.constructor = PromiseSubclass;\n PromiseSubclass.cast = RSVP.Promise.cast;\n\n var proxy = ObjectPromiseProxy.create({\n promise: new PromiseSubclass(function(){ })\n });\n\n ok(proxy.then() instanceof PromiseSubclass, 'promise proxy respected inheritence');\n });\n\n test(\"should reset isFulfilled and isRejected when promise is reset\", function() {\n var deferred = EmberRSVP.defer();\n\n var proxy = ObjectPromiseProxy.create({\n promise: deferred.promise\n });\n\n equal(get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading');\n equal(get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled');\n equal(get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected');\n equal(get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled');\n\n run(deferred, 'resolve');\n\n equal(get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is no longer loading');\n equal(get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled');\n equal(get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected');\n equal(get(proxy, 'isFulfilled'), true, 'expects the proxy to indicate that it is fulfilled');\n\n var anotherDeferred = EmberRSVP.defer();\n proxy.set('promise', anotherDeferred.promise);\n\n equal(get(proxy, 'isPending'), true, 'expects the proxy to indicate that it is loading');\n equal(get(proxy, 'isSettled'), false, 'expects the proxy to indicate that it is not settled');\n equal(get(proxy, 'isRejected'), false, 'expects the proxy to indicate that it is not rejected');\n equal(get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled');\n\n run(anotherDeferred, 'reject');\n\n equal(get(proxy, 'isPending'), false, 'expects the proxy to indicate that it is not longer loading');\n equal(get(proxy, 'isSettled'), true, 'expects the proxy to indicate that it is settled');\n equal(get(proxy, 'isRejected'), true, 'expects the proxy to indicate that it is rejected');\n equal(get(proxy, 'isFulfilled'), false, 'expects the proxy to indicate that it is not fulfilled');\n });\n });\ndefine(\"ember-runtime/tests/mixins/sortable_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-metal/mixin\",\"ember-metal/events\",\"ember-runtime/system/array_proxy\",\"ember-runtime/mixins/sortable\",\"ember-runtime/system/object\",\"ember-runtime/controllers/array_controller\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var run = __dependency4__[\"default\"];\n var emberObserver = __dependency5__.observer;\n var listenersFor = __dependency6__.listenersFor;\n var ArrayProxy = __dependency7__[\"default\"];\n var SortableMixin = __dependency8__[\"default\"];\n var EmberObject = __dependency9__[\"default\"];\n var ArrayController = __dependency10__[\"default\"];\n\n var unsortedArray, sortedArrayController;\n\n module(\"Ember.Sortable\");\n\n module(\"Ember.Sortable with content\", {\n setup: function() {\n run(function() {\n var array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }, { id: 3, name: \"Scumbag Bryn\" }];\n\n unsortedArray = Ember.A(Ember.A(array).copy());\n\n sortedArrayController = ArrayProxy.createWithMixins(SortableMixin, {\n content: unsortedArray\n });\n });\n },\n\n teardown: function() {\n run(function() {\n sortedArrayController.set('content', null);\n sortedArrayController.destroy();\n });\n }\n });\n\n test(\"if you do not specify `sortProperties` sortable have no effect\", function() {\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Dale', 'array is in it natural order');\n\n unsortedArray.pushObject({id: 4, name: 'Scumbag Chavard'});\n\n equal(sortedArrayController.get('length'), 4, 'array has 4 items');\n equal(sortedArrayController.objectAt(3).name, 'Scumbag Chavard', 'a new object was inserted in the natural order');\n });\n\n test(\"you can change sorted properties\", function() {\n sortedArrayController.set('sortProperties', ['id']);\n\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Dale', 'array is sorted by id');\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n\n sortedArrayController.set('sortAscending', false);\n\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Bryn', 'array is sorted by id in DESC order');\n equal(sortedArrayController.objectAt(2).name, 'Scumbag Dale', 'array is sorted by id in DESC order');\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n\n sortedArrayController.set('sortProperties', ['name']);\n\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Katz', 'array is sorted by name in DESC order');\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n });\n\n test(\"changing sort order triggers observers\", function() {\n var observer, changeCount = 0;\n observer = EmberObject.createWithMixins({\n array: sortedArrayController,\n arrangedDidChange: emberObserver('array.[]', function() {\n changeCount++;\n })\n });\n\n equal(changeCount, 0, 'precond - changeCount starts at 0');\n\n sortedArrayController.set('sortProperties', ['id']);\n\n equal(changeCount, 1, 'setting sortProperties increments changeCount');\n\n sortedArrayController.set('sortAscending', false);\n\n equal(changeCount, 2, 'changing sortAscending increments changeCount');\n\n sortedArrayController.set('sortAscending', true);\n\n equal(changeCount, 3, 'changing sortAscending again increments changeCount');\n\n run(function() { observer.destroy(); });\n });\n\n test(\"changing sortProperties and sortAscending with setProperties, sortProperties appearing first\", function() {\n sortedArrayController.set('sortProperties', ['name']);\n sortedArrayController.set('sortAscending', false);\n\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Katz', 'array is sorted by name in DESC order');\n equal(sortedArrayController.objectAt(2).name, 'Scumbag Bryn', 'array is sorted by name in DESC order');\n\n sortedArrayController.setProperties({ sortProperties: ['id'], sortAscending: true });\n\n equal(sortedArrayController.objectAt(0).id, 1, 'array is sorted by id in ASC order after setting sortAscending and sortProperties');\n equal(sortedArrayController.objectAt(2).id, 3, 'array is sorted by id in ASC order after setting sortAscending and sortProperties');\n\n sortedArrayController.setProperties({ sortProperties: ['name'], sortAscending: false });\n\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Katz', 'array is sorted by name in DESC order after setting sortAscending and sortProperties');\n equal(sortedArrayController.objectAt(2).name, 'Scumbag Bryn', 'array is sorted by name in DESC order after setting sortAscending and sortProperties');\n\n sortedArrayController.setProperties({ sortProperties: ['id'], sortAscending: false });\n\n equal(sortedArrayController.objectAt(0).id, 3, 'array is sorted by id in DESC order after setting sortAscending and sortProperties');\n equal(sortedArrayController.objectAt(2).id, 1, 'array is sorted by id in DESC order after setting sortAscending and sortProperties');\n\n sortedArrayController.setProperties({ sortProperties: ['id'], sortAscending: true });\n\n equal(sortedArrayController.objectAt(0).id, 1, 'array is sorted by id in ASC order after setting sortAscending and sortProperties');\n equal(sortedArrayController.objectAt(2).id, 3, 'array is sorted by id in ASC order after setting sortAscending and sortProperties');\n\n });\n\n test(\"changing sortProperties and sortAscending with setProperties, sortAscending appearing first\", function() {\n sortedArrayController.set('sortProperties', ['name']);\n sortedArrayController.set('sortAscending', false);\n\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Katz', 'array is sorted by name in DESC order');\n equal(sortedArrayController.objectAt(2).name, 'Scumbag Bryn', 'array is sorted by name in DESC order');\n\n sortedArrayController.setProperties({ sortAscending: true, sortProperties: ['id'] });\n\n equal(sortedArrayController.objectAt(0).id, 1, 'array is sorted by id in ASC order after setting sortAscending and sortProperties');\n equal(sortedArrayController.objectAt(2).id, 3, 'array is sorted by id in ASC order after setting sortAscending and sortProperties');\n\n sortedArrayController.setProperties({ sortAscending: false, sortProperties: ['name'] });\n\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Katz', 'array is sorted by name in DESC order after setting sortAscending and sortProperties');\n equal(sortedArrayController.objectAt(2).name, 'Scumbag Bryn', 'array is sorted by name in DESC order after setting sortAscending and sortProperties');\n\n sortedArrayController.setProperties({ sortAscending: false, sortProperties: ['id'] });\n\n equal(sortedArrayController.objectAt(0).id, 3, 'array is sorted by id in DESC order after setting sortAscending and sortProperties');\n equal(sortedArrayController.objectAt(2).id, 1, 'array is sorted by id in DESC order after setting sortAscending and sortProperties');\n\n sortedArrayController.setProperties({ sortAscending: true, sortProperties: ['id'] });\n\n equal(sortedArrayController.objectAt(0).id, 1, 'array is sorted by id in ASC order after setting sortAscending and sortProperties');\n equal(sortedArrayController.objectAt(2).id, 3, 'array is sorted by id in ASC order after setting sortAscending and sortProperties');\n\n });\n\n module(\"Ember.Sortable with content and sortProperties\", {\n setup: function() {\n run(function() {\n var array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }, { id: 3, name: \"Scumbag Bryn\" }];\n\n unsortedArray = Ember.A(Ember.A(array).copy());\n\n sortedArrayController = ArrayController.create({\n content: unsortedArray,\n sortProperties: ['name']\n });\n });\n },\n\n teardown: function() {\n run(function() {\n sortedArrayController.destroy();\n });\n }\n });\n\n test(\"sortable object will expose associated content in the right order\", function() {\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Bryn', 'array is sorted by name');\n });\n\n test(\"you can add objects in sorted order\", function() {\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n\n unsortedArray.pushObject({id: 4, name: 'Scumbag Chavard'});\n\n equal(sortedArrayController.get('length'), 4, 'array has 4 items');\n equal(sortedArrayController.objectAt(1).name, 'Scumbag Chavard', 'a new object added to content was inserted according to given constraint');\n\n sortedArrayController.addObject({id: 5, name: 'Scumbag Fucs'});\n\n equal(sortedArrayController.get('length'), 5, 'array has 5 items');\n equal(sortedArrayController.objectAt(3).name, 'Scumbag Fucs', 'a new object added to controller was inserted according to given constraint');\n });\n\n test(\"you can push objects in sorted order\", function() {\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n\n unsortedArray.pushObject({id: 4, name: 'Scumbag Chavard'});\n\n equal(sortedArrayController.get('length'), 4, 'array has 4 items');\n equal(sortedArrayController.objectAt(1).name, 'Scumbag Chavard', 'a new object added to content was inserted according to given constraint');\n\n sortedArrayController.pushObject({id: 5, name: 'Scumbag Fucs'});\n\n equal(sortedArrayController.get('length'), 5, 'array has 5 items');\n equal(sortedArrayController.objectAt(3).name, 'Scumbag Fucs', 'a new object added to controller was inserted according to given constraint');\n });\n\n test(\"you can unshift objects in sorted order\", function() {\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n\n unsortedArray.unshiftObject({id: 4, name: 'Scumbag Chavard'});\n\n equal(sortedArrayController.get('length'), 4, 'array has 4 items');\n equal(sortedArrayController.objectAt(1).name, 'Scumbag Chavard', 'a new object added to content was inserted according to given constraint');\n\n sortedArrayController.addObject({id: 5, name: 'Scumbag Fucs'});\n\n equal(sortedArrayController.get('length'), 5, 'array has 5 items');\n equal(sortedArrayController.objectAt(3).name, 'Scumbag Fucs', 'a new object added to controller was inserted according to given constraint');\n });\n\n test(\"addObject does not insert duplicates\", function() {\n var sortedArrayProxy, obj = {};\n sortedArrayProxy = ArrayProxy.createWithMixins(SortableMixin, {\n content: Ember.A([obj])\n });\n\n equal(sortedArrayProxy.get('length'), 1, 'array has 1 item');\n\n sortedArrayProxy.addObject(obj);\n\n equal(sortedArrayProxy.get('length'), 1, 'array still has 1 item');\n });\n\n test(\"you can change a sort property and the content will rearrenge\", function() {\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Bryn', 'bryn is first');\n\n set(sortedArrayController.objectAt(0), 'name', 'Scumbag Fucs');\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Dale', 'dale is first now');\n equal(sortedArrayController.objectAt(1).name, 'Scumbag Fucs', 'foucs is second');\n });\n\n test(\"you can change the position of the middle item\", function() {\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n\n equal(sortedArrayController.objectAt(1).name, 'Scumbag Dale', 'Dale is second');\n set(sortedArrayController.objectAt(1), 'name', 'Alice'); // Change Dale to Alice\n\n equal(sortedArrayController.objectAt(0).name, 'Alice', 'Alice (previously Dale) is first now');\n });\n\n test(\"don't remove and insert if position didn't change\", function() {\n var insertItemSortedCalled = false;\n\n sortedArrayController.reopen({\n insertItemSorted: function(item) {\n insertItemSortedCalled = true;\n this._super(item);\n }\n });\n\n sortedArrayController.set('sortProperties', ['name']);\n\n set(sortedArrayController.objectAt(0), 'name', 'Scumbag Brynjolfsson');\n\n ok(!insertItemSortedCalled, \"insertItemSorted should not have been called\");\n });\n\n test(\"sortProperties observers removed on content removal\", function() {\n var removedObject = unsortedArray.objectAt(2);\n equal(listenersFor(removedObject, 'name:change').length, 1,\n \"Before removal, there should be one listener for sortProperty change.\");\n unsortedArray.replace(2, 1, []);\n equal(listenersFor(removedObject, 'name:change').length, 0,\n \"After removal, there should be no listeners for sortProperty change.\");\n });\n\n module(\"Ember.Sortable with sortProperties\", {\n setup: function() {\n run(function() {\n sortedArrayController = ArrayController.create({\n sortProperties: ['name']\n });\n var array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }, { id: 3, name: \"Scumbag Bryn\" }];\n unsortedArray = Ember.A(Ember.A(array).copy());\n });\n },\n\n teardown: function() {\n run(function() {\n sortedArrayController.destroy();\n });\n }\n });\n\n test(\"you can set content later and it will be sorted\", function() {\n equal(sortedArrayController.get('length'), 0, 'array has 0 items');\n\n run(function() {\n sortedArrayController.set('content', unsortedArray);\n });\n\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Bryn', 'array is sorted by name');\n });\n\n module(\"Ember.Sortable with sortFunction and sortProperties\", {\n setup: function() {\n run(function() {\n sortedArrayController = ArrayController.create({\n sortProperties: ['name'],\n sortFunction: function(v, w) {\n var lowerV = v.toLowerCase(),\n lowerW = w.toLowerCase();\n\n if (lowerV < lowerW) {\n return -1;\n }\n if (lowerV > lowerW) {\n return 1;\n }\n return 0;\n }\n });\n var array = [{ id: 1, name: \"Scumbag Dale\" },\n { id: 2, name: \"Scumbag Katz\" },\n { id: 3, name: \"Scumbag bryn\" }];\n unsortedArray = Ember.A(Ember.A(array).copy());\n });\n },\n\n teardown: function() {\n run(function() {\n sortedArrayController.destroy();\n });\n }\n });\n\n test(\"you can sort with custom sorting function\", function() {\n equal(sortedArrayController.get('length'), 0, 'array has 0 items');\n\n run(function() {\n sortedArrayController.set('content', unsortedArray);\n });\n\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n equal(sortedArrayController.objectAt(0).name, 'Scumbag bryn', 'array is sorted by custom sort');\n });\n\n test(\"Ember.Sortable with sortFunction on ArrayProxy should work like ArrayController\", function() {\n run(function() {\n sortedArrayController = ArrayProxy.createWithMixins(SortableMixin, {\n sortProperties: ['name'],\n sortFunction: function(v, w) {\n var lowerV = v.toLowerCase(),\n lowerW = w.toLowerCase();\n\n if (lowerV < lowerW) {\n return -1;\n }\n if (lowerV > lowerW) {\n return 1;\n }\n return 0;\n }\n });\n var array = [{ id: 1, name: \"Scumbag Dale\" }, { id: 2, name: \"Scumbag Katz\" }, { id: 3, name: \"Scumbag Bryn\" }];\n unsortedArray = Ember.A(Ember.A(array).copy());\n });\n equal(sortedArrayController.get('length'), 0, 'array has 0 items');\n\n run(function() {\n sortedArrayController.set('content', unsortedArray);\n });\n\n equal(sortedArrayController.get('length'), 3, 'array has 3 items');\n equal(sortedArrayController.objectAt(0).name, 'Scumbag Bryn', 'array is sorted by name');\n });\n });\ndefine(\"ember-runtime/tests/mixins/target_action_support_test\",\n [\"ember-metal/core\",\"ember-runtime/system/object\",\"ember-runtime/mixins/target_action_support\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var EmberObject = __dependency2__[\"default\"];\n var TargetActionSupport = __dependency3__[\"default\"];\n\n var originalLookup;\n\n module(\"TargetActionSupport\", {\n setup: function() {\n originalLookup = Ember.lookup;\n },\n teardown: function() {\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"it should return false if no target or action are specified\", function() {\n expect(1);\n\n var obj = EmberObject.createWithMixins(TargetActionSupport);\n\n ok(false === obj.triggerAction(), \"no target or action was specified\");\n });\n\n test(\"it should support actions specified as strings\", function() {\n expect(2);\n\n var obj = EmberObject.createWithMixins(TargetActionSupport, {\n target: EmberObject.create({\n anEvent: function() {\n ok(true, \"anEvent method was called\");\n }\n }),\n\n action: 'anEvent'\n });\n\n ok(true === obj.triggerAction(), \"a valid target and action were specified\");\n });\n\n test(\"it should invoke the send() method on objects that implement it\", function() {\n expect(3);\n\n var obj = EmberObject.createWithMixins(TargetActionSupport, {\n target: EmberObject.create({\n send: function(evt, context) {\n equal(evt, 'anEvent', \"send() method was invoked with correct event name\");\n equal(context, obj, \"send() method was invoked with correct context\");\n }\n }),\n\n action: 'anEvent'\n });\n\n ok(true === obj.triggerAction(), \"a valid target and action were specified\");\n });\n\n test(\"it should find targets specified using a property path\", function() {\n expect(2);\n\n var Test = {};\n Ember.lookup = { Test: Test };\n\n Test.targetObj = EmberObject.create({\n anEvent: function() {\n ok(true, \"anEvent method was called on global object\");\n }\n });\n\n var myObj = EmberObject.createWithMixins(TargetActionSupport, {\n target: 'Test.targetObj',\n action: 'anEvent'\n });\n\n ok(true === myObj.triggerAction(), \"a valid target and action were specified\");\n });\n\n test(\"it should use an actionContext object specified as a property on the object\", function() {\n expect(2);\n var obj = EmberObject.createWithMixins(TargetActionSupport,{\n action: 'anEvent',\n actionContext: {},\n target: EmberObject.create({\n anEvent: function(ctx) {\n ok(obj.actionContext === ctx, \"anEvent method was called with the expected context\");\n }\n })\n });\n ok(true === obj.triggerAction(), \"a valid target and action were specified\");\n });\n\n test(\"it should find an actionContext specified as a property path\", function() {\n expect(2);\n\n var Test = {};\n Ember.lookup = { Test: Test };\n Test.aContext = {};\n\n var obj = EmberObject.createWithMixins(TargetActionSupport,{\n action: 'anEvent',\n actionContext: 'Test.aContext',\n target: EmberObject.create({\n anEvent: function(ctx) {\n ok(Test.aContext === ctx, \"anEvent method was called with the expected context\");\n }\n })\n });\n ok(true === obj.triggerAction(), \"a valid target and action were specified\");\n });\n\n test(\"it should use the target specified in the argument\", function() {\n expect(2);\n var targetObj = EmberObject.create({\n anEvent: function() {\n ok(true, \"anEvent method was called\");\n }\n }),\n obj = EmberObject.createWithMixins(TargetActionSupport,{\n action: 'anEvent'\n });\n ok(true === obj.triggerAction({target: targetObj}), \"a valid target and action were specified\");\n });\n\n test(\"it should use the action specified in the argument\", function() {\n expect(2);\n\n var obj = EmberObject.createWithMixins(TargetActionSupport,{\n target: EmberObject.create({\n anEvent: function() {\n ok(true, \"anEvent method was called\");\n }\n })\n });\n ok(true === obj.triggerAction({action: 'anEvent'}), \"a valid target and action were specified\");\n });\n\n test(\"it should use the actionContext specified in the argument\", function() {\n expect(2);\n var context = {},\n obj = EmberObject.createWithMixins(TargetActionSupport,{\n target: EmberObject.create({\n anEvent: function(ctx) {\n ok(context === ctx, \"anEvent method was called with the expected context\");\n }\n }),\n action: 'anEvent'\n });\n ok(true === obj.triggerAction({actionContext: context}), \"a valid target and action were specified\");\n });\n\n test(\"it should allow multiple arguments from actionContext\", function() {\n expect(3);\n var param1 = 'someParam',\n param2 = 'someOtherParam',\n obj = EmberObject.createWithMixins(TargetActionSupport,{\n target: EmberObject.create({\n anEvent: function(first, second) {\n ok(first === param1, \"anEvent method was called with the expected first argument\");\n ok(second === param2, \"anEvent method was called with the expected second argument\");\n }\n }),\n action: 'anEvent'\n });\n ok(true === obj.triggerAction({actionContext: [param1, param2]}), \"a valid target and action were specified\");\n });\n\n test(\"it should use a null value specified in the actionContext argument\", function() {\n expect(2);\n var obj = EmberObject.createWithMixins(TargetActionSupport,{\n target: EmberObject.create({\n anEvent: function(ctx) {\n ok(null === ctx, \"anEvent method was called with the expected context (null)\");\n }\n }),\n action: 'anEvent'\n });\n ok(true === obj.triggerAction({actionContext: null}), \"a valid target and action were specified\");\n });\n });\ndefine(\"ember-runtime/tests/props_helper\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"exports\"],\n function(__dependency1__, __dependency2__, __dependency3__, __exports__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var getFromEmberMetal = __dependency2__.get;\n var getWithDefaultFromEmberMetal = __dependency2__.getWithDefault;\n var setFromEmberMetal = __dependency3__.set;\n\n // used by unit tests to test both accessor mode and non-accessor mode\n var testBoth = function(testname, callback) {\n\n function emberget(x,y) { return getFromEmberMetal(x,y); }\n function emberset(x,y,z) { return setFromEmberMetal(x,y,z); }\n function aget(x,y) { return x[y]; }\n function aset(x,y,z) { return (x[y] = z); }\n\n test(testname+' using getFromEmberMetal()/Ember.set()', function() {\n callback(emberget, emberset);\n });\n\n test(testname+' using accessors', function() {\n if (Ember.USES_ACCESSORS) callback(aget, aset);\n else ok('SKIPPING ACCESSORS');\n });\n };\n\n var testWithDefault = function(testname, callback) {\n function get(x,y) { return x.get(y); }\n function emberget(x,y) { return getFromEmberMetal(x,y); }\n function embergetwithdefault(x,y,z) { return getWithDefaultFromEmberMetal(x,y,z); }\n function getwithdefault(x,y,z) { return x.getWithDefault(y,z); }\n function emberset(x,y,z) { return setFromEmberMetal(x,y,z); }\n function aget(x,y) { return x[y]; }\n function aset(x,y,z) { return (x[y] = z); }\n\n test(testname+' using obj.get()', function() {\n callback(emberget, emberset);\n });\n\n test(testname+' using obj.getWithDefault()', function() {\n callback(getwithdefault, emberset);\n });\n\n test(testname+' using getFromEmberMetal()', function() {\n callback(emberget, emberset);\n });\n\n test(testname+' using Ember.getWithDefault()', function() {\n callback(embergetwithdefault, emberset);\n });\n\n test(testname+' using accessors', function() {\n if (Ember.USES_ACCESSORS) callback(aget, aset);\n else ok('SKIPPING ACCESSORS');\n });\n };\n\n __exports__.testWithDefault = testWithDefault;\n __exports__.testBoth = testBoth;\n });\ndefine(\"ember-runtime/tests/suites/array\",\n [\"ember-runtime/tests/suites/enumerable\",\"ember-runtime/tests/suites/array/indexOf\",\"ember-runtime/tests/suites/array/lastIndexOf\",\"ember-runtime/tests/suites/array/objectAt\",\"exports\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {\n \"use strict\";\n var EnumerableTests = __dependency1__.EnumerableTests;\n var ObserverClass = __dependency1__.ObserverClass;\n var indexOfTests = __dependency2__[\"default\"];\n var lastIndexOfTests = __dependency3__[\"default\"];\n var objectAtTests = __dependency4__[\"default\"];\n\n\n var EnumerableTestsObserverClass = ObserverClass;\n\n ObserverClass = EnumerableTestsObserverClass.extend({\n\n observeArray: function(obj) {\n obj.addArrayObserver(this);\n return this;\n },\n\n stopObserveArray: function(obj) {\n obj.removeArrayObserver(this);\n return this;\n },\n\n arrayWillChange: function() {\n equal(this._before, null, 'should only call once');\n this._before = Array.prototype.slice.call(arguments);\n },\n\n arrayDidChange: function() {\n equal(this._after, null, 'should only call once');\n this._after = Array.prototype.slice.call(arguments);\n }\n\n });\n\n var ArrayTests = EnumerableTests.extend({\n\n observerClass: ObserverClass\n\n });\n\n ArrayTests.ObserverClass = ObserverClass;\n\n ArrayTests.importModuleTests(indexOfTests);\n ArrayTests.importModuleTests(lastIndexOfTests);\n ArrayTests.importModuleTests(objectAtTests);\n\n __exports__.ArrayTests = ArrayTests;\n __exports__.ObserverClass = ObserverClass;\n });\ndefine(\"ember-runtime/tests/suites/array/indexOf\",\n [\"ember-runtime/tests/suites/suite\",\"ember-runtime/system/string\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var fmt = __dependency2__.fmt;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('indexOf');\n\n suite.test(\"should return index of object\", function() {\n var expected = this.newFixture(3),\n obj = this.newObject(expected),\n len = 3,\n idx;\n\n for(idx=0;idx=0) obj.addBeforeObserver(keys[loc], this, 'propertyWillChange');\n }\n return this;\n },\n\n /**\n Begins observing the passed key names on the passed object. Any changes\n on the named properties will be recorded.\n\n @param {Ember.Enumerable} obj\n The enumerable to observe.\n\n @returns {Object} receiver\n */\n observe: function(obj) {\n if (obj.addObserver) {\n var keys = Array.prototype.slice.call(arguments, 1),\n loc = keys.length;\n while(--loc>=0) obj.addObserver(keys[loc], this, 'propertyDidChange');\n } else {\n this.isEnabled = false;\n }\n return this;\n },\n\n /**\n Returns true if the passed key was invoked. If you pass a value as\n well then validates that the values match.\n\n @param {String} key\n Key to validate\n\n @param {Object} value\n (Optional) value\n\n @returns {Boolean}\n */\n validate: function(key, value) {\n if (!this.isEnabled) return true;\n if (!this._keys[key]) return false;\n if (arguments.length>1) return this._values[key] === value;\n else return true;\n },\n\n /**\n Returns times the before observer as invoked.\n\n @param {String} key\n Key to check\n */\n timesCalledBefore: function(key) {\n return this._keysBefore[key] || 0;\n },\n\n /**\n Returns times the observer as invoked.\n\n @param {String} key\n Key to check\n */\n timesCalled: function(key) {\n return this._keys[key] || 0;\n },\n\n /**\n begins acting as an enumerable observer.\n */\n observeEnumerable: function(obj) {\n obj.addEnumerableObserver(this);\n return this;\n },\n\n stopObserveEnumerable: function(obj) {\n obj.removeEnumerableObserver(this);\n return this;\n },\n\n enumerableWillChange: function() {\n equal(this._before, null, 'should only call once');\n this._before = Array.prototype.slice.call(arguments);\n },\n\n enumerableDidChange: function() {\n equal(this._after, null, 'should only call once');\n this._after = Array.prototype.slice.call(arguments);\n }\n\n });\n\n\n var EnumerableTests = Suite.extend({\n /**\n Implement to return a new enumerable object for testing. Should accept\n either no parameters, a single number (indicating the desired length of\n the collection) or an array of objects.\n\n @param {Array} content\n An array of items to include in the enumerable optionally.\n\n @returns {Ember.Enumerable} a new enumerable\n */\n newObject: required(Function),\n\n /**\n Implement to return a set of new fixture objects that can be applied to\n the enumerable. This may be passed into the newObject method.\n\n @param {Number} count\n The number of items required.\n\n @returns {Array} array of items\n */\n newFixture: function(cnt) {\n var ret = [];\n while(--cnt>=0) ret.push(generateGuid());\n return ret;\n },\n\n /**\n Implement accept an instance of the enumerable and return an array\n containing the objects in the enumerable. This is used only for testing\n so performance is not important.\n\n @param {Ember.Enumerable} enumerable\n The enumerable to convert.\n\n @returns {Array} array of items\n */\n toArray: required(Function),\n\n /**\n Implement this method if your object can mutate internally (even if it\n does not support the MutableEnumerable API). The method should accept\n an object of your desired type and modify it somehow. Suite tests will\n use this to ensure that all appropriate caches, etc. clear when the\n mutation occurs.\n\n If you do not define this optional method, then mutation-related tests\n will be skipped.\n\n @param {Ember.Enumerable} enumerable\n The enumerable to mutate\n\n @returns {void}\n */\n mutate: function() {},\n\n /**\n Becomes true when you define a new mutate() method, indicating that\n mutation tests should run. This is calculated automatically.\n\n @type Boolean\n */\n canTestMutation: computed(function() {\n return this.mutate !== EnumerableTests.prototype.mutate;\n }),\n\n /**\n Invoked to actually run the test - overridden by mixins\n */\n run: function() {},\n\n\n /**\n Creates a new observer object for testing. You can add this object as an\n observer on an array and it will record results anytime it is invoked.\n After running the test, call the validate() method on the observer to\n validate the results.\n */\n newObserver: function(obj) {\n var ret = get(this, 'observerClass').create();\n if (arguments.length>0) ret.observeBefore.apply(ret, arguments);\n if (arguments.length>0) ret.observe.apply(ret, arguments);\n return ret;\n },\n\n observerClass: ObserverClass\n });\n\n var anyTests = __dependency7__[\"default\"];\n var isAnyTests = __dependency8__[\"default\"];\n var compactTests = __dependency9__[\"default\"];\n var containsTests = __dependency10__[\"default\"];\n var everyTests = __dependency11__[\"default\"];\n var filterTests = __dependency12__[\"default\"];\n var findTests = __dependency13__[\"default\"];\n var firstObjectTests = __dependency14__[\"default\"];\n var forEachTests = __dependency15__[\"default\"];\n var mapByTests = __dependency16__[\"default\"];\n var invokeTests = __dependency17__[\"default\"];\n var lastObjectTests = __dependency18__[\"default\"];\n var mapTests = __dependency19__[\"default\"];\n var reduceTests = __dependency20__[\"default\"];\n var rejectTests = __dependency21__[\"default\"];\n var sortByTests = __dependency22__[\"default\"];\n var toArrayTests = __dependency23__[\"default\"];\n var uniqTests = __dependency24__[\"default\"];\n var withoutTests = __dependency25__[\"default\"];\n\n EnumerableTests.importModuleTests(anyTests);\n EnumerableTests.importModuleTests(isAnyTests);\n EnumerableTests.importModuleTests(compactTests);\n EnumerableTests.importModuleTests(containsTests);\n EnumerableTests.importModuleTests(everyTests);\n EnumerableTests.importModuleTests(filterTests);\n EnumerableTests.importModuleTests(findTests);\n EnumerableTests.importModuleTests(firstObjectTests);\n EnumerableTests.importModuleTests(forEachTests);\n EnumerableTests.importModuleTests(mapByTests);\n EnumerableTests.importModuleTests(invokeTests);\n EnumerableTests.importModuleTests(lastObjectTests);\n EnumerableTests.importModuleTests(mapTests);\n EnumerableTests.importModuleTests(reduceTests);\n EnumerableTests.importModuleTests(rejectTests);\n EnumerableTests.importModuleTests(sortByTests);\n EnumerableTests.importModuleTests(toArrayTests);\n EnumerableTests.importModuleTests(uniqTests);\n EnumerableTests.importModuleTests(withoutTests);\n\n __exports__[\"default\"] = EnumerableTests;\n __exports__.EnumerableTests = EnumerableTests;\n __exports__.ObserverClass = ObserverClass;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/any\",\n [\"ember-metal/core\",\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var SuiteModuleBuilder = __dependency2__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n // ..........................................................\n // any()\n //\n\n suite.module('any');\n\n suite.test('any should should invoke callback on each item as long as you return false', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n found = [], result;\n\n result = obj.any(function(i) { found.push(i); return false; });\n equal(result, false, 'return value of obj.any');\n deepEqual(found, ary, 'items passed during any() should match');\n });\n\n suite.test('any should stop invoking when you return true', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n cnt = ary.length - 2,\n exp = cnt,\n found = [], result;\n\n result = obj.any(function(i) { found.push(i); return --cnt <= 0; });\n equal(result, true, 'return value of obj.any');\n equal(found.length, exp, 'should invoke proper number of times');\n deepEqual(found, ary.slice(0,-2), 'items passed during any() should match');\n });\n\n\n suite.test('any should return true if any object matches the callback', function() {\n var obj = Ember.A([0, 1, 2]), result;\n\n result = obj.any(function(i) { return !!i; });\n equal(result, true, 'return value of obj.any');\n });\n\n\n suite.test('any should return false if no object matches the callback', function() {\n var obj = Ember.A([0, null, false]), result;\n\n result = obj.any(function(i) { return !!i; });\n equal(result, false, 'return value of obj.any');\n });\n\n\n suite.test('any should produce correct results even if the matching element is undefined', function() {\n var obj = Ember.A([undefined]), result;\n\n result = obj.any(function(i) { return true; });\n equal(result, true, 'return value of obj.any');\n });\n\n\n suite.test('any should be aliased to some', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n anyFound = [], anyResult,\n someFound = [], someResult,\n cnt = ary.length - 2,\n exp = cnt;\n\n anyResult = obj.any(function(i) { anyFound.push(i); return false; });\n someResult = obj.some(function(i) { someFound.push(i); return false; });\n equal(someResult, anyResult);\n\n anyFound = [];\n someFound = [];\n\n cnt = ary.length - 2;\n anyResult = obj.any(function(i) { anyFound.push(i); return --cnt <= 0; });\n cnt = ary.length - 2;\n someResult = obj.some(function(i) { someFound.push(i); return --cnt <= 0; });\n\n equal(someResult, anyResult);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/compact\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('compact');\n\n suite.test('removes null and undefined values from enumerable', function() {\n var obj = this.newObject([null, 1, false, '', undefined, 0, null]);\n var ary = obj.compact();\n deepEqual(ary, [1, false, '', 0]);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/contains\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('contains');\n\n suite.test('contains returns true if items is in enumerable', function() {\n var data = this.newFixture(3);\n var obj = this.newObject(data);\n equal(obj.contains(data[1]), true, 'should return true if contained');\n });\n\n suite.test('contains returns false if item is not in enumerable', function() {\n var data = this.newFixture(1);\n var obj = this.newObject(this.newFixture(3));\n equal(obj.contains(data[0]), false, 'should return false if not contained');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/every\",\n [\"ember-runtime/system/object\",\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n var SuiteModuleBuilder = __dependency2__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n // ..........................................................\n // every()\n //\n\n suite.module('every');\n\n suite.test('every should should invoke callback on each item as long as you return true', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n found = [], result;\n\n result = obj.every(function(i) { found.push(i); return true; });\n equal(result, true, 'return value of obj.every');\n deepEqual(found, ary, 'items passed during every() should match');\n });\n\n suite.test('every should stop invoking when you return false', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n cnt = ary.length - 2,\n exp = cnt,\n found = [], result;\n\n result = obj.every(function(i) { found.push(i); return --cnt>0; });\n equal(result, false, 'return value of obj.every');\n equal(found.length, exp, 'should invoke proper number of times');\n deepEqual(found, ary.slice(0,-2), 'items passed during every() should match');\n });\n\n // ..........................................................\n // isEvery()\n //\n\n suite.module('isEvery');\n\n suite.test('should return true of every property matches', function() {\n var obj = this.newObject([\n { foo: 'foo', bar: 'BAZ' },\n EmberObject.create({ foo: 'foo', bar: 'bar' })\n ]);\n\n equal(obj.isEvery('foo', 'foo'), true, 'isEvery(foo)');\n equal(obj.isEvery('bar', 'bar'), false, 'isEvery(bar)');\n });\n\n suite.test('should return true of every property is true', function() {\n var obj = this.newObject([\n { foo: 'foo', bar: true },\n EmberObject.create({ foo: 'bar', bar: false })\n ]);\n\n // different values - all eval to true\n equal(obj.isEvery('foo'), true, 'isEvery(foo)');\n equal(obj.isEvery('bar'), false, 'isEvery(bar)');\n });\n\n suite.test('should return true if every property matches null', function() {\n var obj = this.newObject([\n { foo: null, bar: 'BAZ' },\n EmberObject.create({ foo: null, bar: null })\n ]);\n\n equal(obj.isEvery('foo', null), true, \"isEvery('foo', null)\");\n equal(obj.isEvery('bar', null), false, \"isEvery('bar', null)\");\n });\n\n suite.test('everyBy should be aliased to isEvery', function() {\n var obj = this.newObject();\n equal(obj.isEvery, obj.everyBy);\n });\n\n suite.test('everyProperty should be aliased to isEvery', function() {\n var obj = this.newObject();\n equal(obj.isEvery, obj.everyProperty);\n });\n\n suite.test('should return true if every property is undefined', function() {\n var obj = this.newObject([\n { foo: undefined, bar: 'BAZ' },\n EmberObject.create({ bar: undefined })\n ]);\n\n equal(obj.isEvery('foo', undefined), true, \"isEvery('foo', undefined)\");\n equal(obj.isEvery('bar', undefined), false, \"isEvery('bar', undefined)\");\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/filter\",\n [\"ember-runtime/system/object\",\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n var SuiteModuleBuilder = __dependency2__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n // ..........................................................\n // filter()\n //\n\n suite.module('filter');\n\n suite.test('filter should invoke on each item', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n cnt = ary.length - 2,\n found = [], result;\n\n // return true on all but the last two\n result = obj.filter(function(i) { found.push(i); return --cnt>=0; });\n deepEqual(found, ary, 'should have invoked on each item');\n deepEqual(result, ary.slice(0,-2), 'filtered array should exclude items');\n });\n\n // ..........................................................\n // filterBy()\n //\n\n suite.module('filterBy');\n\n suite.test('should filter based on object', function() {\n var obj, ary;\n\n ary = [\n { foo: 'foo', bar: 'BAZ' },\n EmberObject.create({ foo: 'foo', bar: 'bar' })\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.filterBy('foo', 'foo'), ary, 'filterBy(foo)');\n deepEqual(obj.filterBy('bar', 'bar'), [ary[1]], 'filterBy(bar)');\n });\n\n suite.test('should include in result if property is true', function() {\n var obj, ary;\n\n ary = [\n { foo: 'foo', bar: true },\n EmberObject.create({ foo: 'bar', bar: false })\n ];\n\n obj = this.newObject(ary);\n\n // different values - all eval to true\n deepEqual(obj.filterBy('foo'), ary, 'filterBy(foo)');\n deepEqual(obj.filterBy('bar'), [ary[0]], 'filterBy(bar)');\n });\n\n suite.test('should filter on second argument if provided', function() {\n var obj, ary;\n\n ary = [\n { name: 'obj1', foo: 3},\n EmberObject.create({ name: 'obj2', foo: 2}),\n { name: 'obj3', foo: 2},\n EmberObject.create({ name: 'obj4', foo: 3})\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.filterBy('foo', 3), [ary[0], ary[3]], \"filterBy('foo', 3)')\");\n });\n\n suite.test('should correctly filter null second argument', function() {\n var obj, ary;\n\n ary = [\n { name: 'obj1', foo: 3},\n EmberObject.create({ name: 'obj2', foo: null}),\n { name: 'obj3', foo: null},\n EmberObject.create({ name: 'obj4', foo: 3})\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.filterBy('foo', null), [ary[1], ary[2]], \"filterBy('foo', 3)')\");\n });\n\n suite.test('should not return all objects on undefined second argument', function() {\n var obj, ary;\n\n ary = [\n { name: 'obj1', foo: 3},\n EmberObject.create({ name: 'obj2', foo: 2})\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.filterBy('foo', undefined), [], \"filterBy('foo', 3)')\");\n });\n\n suite.test('should correctly filter explicit undefined second argument', function() {\n var obj, ary;\n\n ary = [\n { name: 'obj1', foo: 3},\n EmberObject.create({ name: 'obj2', foo: 3}),\n { name: 'obj3', foo: undefined},\n EmberObject.create({ name: 'obj4', foo: undefined}),\n { name: 'obj5'},\n EmberObject.create({ name: 'obj6'})\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.filterBy('foo', undefined), ary.slice(2), \"filterBy('foo', 3)')\");\n });\n\n suite.test('should not match undefined properties without second argument', function() {\n var obj, ary;\n\n ary = [\n { name: 'obj1', foo: 3},\n EmberObject.create({ name: 'obj2', foo: 3}),\n { name: 'obj3', foo: undefined},\n EmberObject.create({ name: 'obj4', foo: undefined}),\n { name: 'obj5'},\n EmberObject.create({ name: 'obj6'})\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.filterBy('foo'), ary.slice(0, 2), \"filterBy('foo', 3)')\");\n });\n\n suite.test('should be aliased to filterProperty', function() {\n var ary = [];\n\n equal(ary.filterProperty, ary.filterBy);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/find\",\n [\"ember-runtime/system/object\",\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n var SuiteModuleBuilder = __dependency2__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n // ..........................................................\n // find()\n //\n\n suite.module('find');\n\n suite.test('find should invoke callback on each item as long as you return false', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n found = [], result;\n\n result = obj.find(function(i) { found.push(i); return false; });\n equal(result, undefined, 'return value of obj.find');\n deepEqual(found, ary, 'items passed during find() should match');\n });\n\n suite.test('every should stop invoking when you return true', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n cnt = ary.length - 2,\n exp = cnt,\n found = [], result;\n\n result = obj.find(function(i) { found.push(i); return --cnt >= 0; });\n equal(result, ary[exp-1], 'return value of obj.find');\n equal(found.length, exp, 'should invoke proper number of times');\n deepEqual(found, ary.slice(0,-2), 'items passed during find() should match');\n });\n\n // ..........................................................\n // findBy()\n //\n\n suite.module('findBy');\n\n suite.test('should return first object of property matches', function() {\n var ary, obj;\n\n ary = [\n { foo: 'foo', bar: 'BAZ' },\n EmberObject.create({ foo: 'foo', bar: 'bar' })\n ];\n\n obj = this.newObject(ary);\n\n equal(obj.findBy('foo', 'foo'), ary[0], 'findBy(foo)');\n equal(obj.findBy('bar', 'bar'), ary[1], 'findBy(bar)');\n });\n\n suite.test('should return first object with truthy prop', function() {\n var ary, obj ;\n\n ary = [\n { foo: 'foo', bar: false },\n EmberObject.create({ foo: 'bar', bar: true })\n ];\n\n obj = this.newObject(ary);\n\n // different values - all eval to true\n equal(obj.findBy('foo'), ary[0], 'findBy(foo)');\n equal(obj.findBy('bar'), ary[1], 'findBy(bar)');\n });\n\n suite.test('should return first null property match', function() {\n var ary, obj;\n\n ary = [\n { foo: null, bar: 'BAZ' },\n EmberObject.create({ foo: null, bar: null })\n ];\n\n obj = this.newObject(ary);\n\n equal(obj.findBy('foo', null), ary[0], \"findBy('foo', null)\");\n equal(obj.findBy('bar', null), ary[1], \"findBy('bar', null)\");\n });\n\n suite.test('should return first undefined property match', function() {\n var ary, obj;\n\n ary = [\n { foo: undefined, bar: 'BAZ' },\n EmberObject.create({ })\n ];\n\n obj = this.newObject(ary);\n\n equal(obj.findBy('foo', undefined), ary[0], \"findBy('foo', undefined)\");\n equal(obj.findBy('bar', undefined), ary[1], \"findBy('bar', undefined)\");\n });\n\n suite.test('should be aliased to findProperty', function() {\n var obj;\n\n obj = this.newObject([]);\n\n equal(obj.findProperty, obj.findBy);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/firstObject\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('firstObject');\n\n suite.test('returns first item in enumerable', function() {\n var obj = this.newObject();\n equal(get(obj, 'firstObject'), this.toArray(obj)[0]);\n });\n\n suite.test('returns undefined if enumerable is empty', function() {\n var obj = this.newObject([]);\n equal(get(obj, 'firstObject'), undefined);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/forEach\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"ember-metal/utils\",\"exports\"],\n function(__dependency1__, __dependency2__, __dependency3__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n var guidFor = __dependency3__.guidFor;\n\n var suite = SuiteModuleBuilder.create();\n var global = this;\n\n suite.module('forEach');\n\n suite.test('forEach should iterate over list', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n found = [];\n\n obj.forEach(function(i) { found.push(i); });\n deepEqual(found, ary, 'items passed during forEach should match');\n });\n\n\n suite.test('forEach should iterate over list after mutation', function() {\n if (get(this, 'canTestMutation')) {\n expect(0);\n return ;\n }\n\n var obj = this.newObject(),\n ary = this.toArray(obj),\n found = [];\n\n obj.forEach(function(i) { found.push(i); });\n deepEqual(found, ary, 'items passed during forEach should match');\n\n this.mutate(obj);\n ary = this.toArray(obj);\n found = [];\n\n obj.forEach(function(i) { found.push(i); });\n deepEqual(found, ary, 'items passed during forEach should match');\n });\n\n suite.test('2nd target parameter', function() {\n var obj = this.newObject(), target = this;\n\n obj.forEach(function() {\n // ES6TODO: When transpiled we will end up with \"use strict\" which disables automatically binding to the global context.\n // Therefore, the following test can never pass in strict mode unless we modify the `map` function implementation to\n // use `Ember.lookup` if target is not specified.\n //\n // equal(guidFor(this), guidFor(global), 'should pass the global object as this if no context');\n });\n\n obj.forEach(function() {\n equal(guidFor(this), guidFor(target), 'should pass target as this if context');\n }, target);\n\n });\n\n\n suite.test('callback params', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n loc = 0;\n\n\n obj.forEach(function(item, idx, enumerable) {\n equal(item, ary[loc], 'item param');\n equal(idx, loc, 'idx param');\n equal(guidFor(enumerable), guidFor(obj), 'enumerable param');\n loc++;\n });\n\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/invoke\",\n [\"ember-runtime/system/object\",\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n var SuiteModuleBuilder = __dependency2__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('invoke');\n\n suite.test('invoke should call on each object that implements', function() {\n var cnt, ary, obj;\n\n function F(amt) {\n cnt += amt===undefined ? 1 : amt;\n }\n cnt = 0;\n ary = [\n { foo: F },\n EmberObject.create({ foo: F }),\n\n // NOTE: does not impl foo - invoke should just skip\n EmberObject.create({ bar: F }),\n\n { foo: F }\n ];\n\n obj = this.newObject(ary);\n obj.invoke('foo');\n equal(cnt, 3, 'should have invoked 3 times');\n\n cnt = 0;\n obj.invoke('foo', 2);\n equal(cnt, 6, 'should have invoked 3 times, passing param');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/is_any\",\n [\"ember-runtime/system/object\",\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n var SuiteModuleBuilder = __dependency2__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n // ..........................................................\n // isAny()\n //\n\n suite.module('isAny');\n\n suite.test('should return true of any property matches', function() {\n var obj = this.newObject([\n { foo: 'foo', bar: 'BAZ' },\n EmberObject.create({ foo: 'foo', bar: 'bar' })\n ]);\n\n equal(obj.isAny('foo', 'foo'), true, 'isAny(foo)');\n equal(obj.isAny('bar', 'bar'), true, 'isAny(bar)');\n equal(obj.isAny('bar', 'BIFF'), false, 'isAny(BIFF)');\n });\n\n suite.test('should return true of any property is true', function() {\n var obj = this.newObject([\n { foo: 'foo', bar: true },\n EmberObject.create({ foo: 'bar', bar: false })\n ]);\n\n // different values - all eval to true\n equal(obj.isAny('foo'), true, 'isAny(foo)');\n equal(obj.isAny('bar'), true, 'isAny(bar)');\n equal(obj.isAny('BIFF'), false, 'isAny(biff)');\n });\n\n suite.test('should return true if any property matches null', function() {\n var obj = this.newObject([\n { foo: null, bar: 'bar' },\n EmberObject.create({ foo: 'foo', bar: null })\n ]);\n\n equal(obj.isAny('foo', null), true, \"isAny('foo', null)\");\n equal(obj.isAny('bar', null), true, \"isAny('bar', null)\");\n });\n\n suite.test('should return true if any property is undefined', function() {\n var obj = this.newObject([\n { foo: undefined, bar: 'bar' },\n EmberObject.create({ foo: 'foo' })\n ]);\n\n equal(obj.isAny('foo', undefined), true, \"isAny('foo', undefined)\");\n equal(obj.isAny('bar', undefined), true, \"isAny('bar', undefined)\");\n });\n\n suite.test('should not match undefined properties without second argument', function() {\n var obj = this.newObject([\n { foo: undefined },\n EmberObject.create({ })\n ]);\n\n equal(obj.isAny('foo'), false, \"isAny('foo', undefined)\");\n });\n\n suite.test('anyBy should be aliased to isAny', function() {\n var obj = this.newObject();\n equal(obj.isAny, obj.anyBy);\n });\n\n suite.test('isAny should be aliased to someProperty', function() {\n var obj = this.newObject();\n equal(obj.someProperty, obj.isAny);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/lastObject\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('lastObject');\n\n suite.test('returns last item in enumerable', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj);\n equal(get(obj, 'lastObject'), ary[ary.length-1]);\n });\n\n suite.test('returns undefined if enumerable is empty', function() {\n var obj = this.newObject([]);\n equal(get(obj, 'lastObject'), undefined);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/map\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/enumerable_utils\",\"ember-metal/property_get\",\"ember-metal/utils\",\"exports\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var EnumerableUtils = __dependency2__[\"default\"];\n var get = __dependency3__.get;\n var guidFor = __dependency4__.guidFor;\n\n var suite = SuiteModuleBuilder.create(), global = this;\n\n suite.module('map');\n\n function mapFunc(item) { return item ? item.toString() : null; }\n\n suite.test('map should iterate over list', function() {\n var obj = this.newObject(),\n ary = EnumerableUtils.map(this.toArray(obj), mapFunc),\n found = [];\n\n found = obj.map(mapFunc);\n deepEqual(found, ary, 'mapped arrays should match');\n });\n\n\n suite.test('map should iterate over list after mutation', function() {\n if (get(this, 'canTestMutation')) {\n expect(0);\n return ;\n }\n\n var obj = this.newObject(),\n ary = this.toArray(obj).map(mapFunc),\n found;\n\n found = obj.map(mapFunc);\n deepEqual(found, ary, 'items passed during forEach should match');\n\n this.mutate(obj);\n ary = this.toArray(obj).map(mapFunc);\n found = obj.map(mapFunc);\n deepEqual(found, ary, 'items passed during forEach should match');\n });\n\n suite.test('2nd target parameter', function() {\n var obj = this.newObject(), target = this;\n\n\n obj.map(function() {\n // ES6TODO: When transpiled we will end up with \"use strict\" which disables automatically binding to the global context.\n // Therefore, the following test can never pass in strict mode unless we modify the `map` function implementation to\n // use `Ember.lookup` if target is not specified.\n //\n // equal(guidFor(this), guidFor(global), 'should pass the global object as this if no context');\n });\n\n obj.map(function() {\n equal(guidFor(this), guidFor(target), 'should pass target as this if context');\n }, target);\n\n });\n\n\n suite.test('callback params', function() {\n var obj = this.newObject(),\n ary = this.toArray(obj),\n loc = 0;\n\n\n obj.map(function(item, idx, enumerable) {\n equal(item, ary[loc], 'item param');\n equal(idx, loc, 'idx param');\n equal(guidFor(enumerable), guidFor(obj), 'enumerable param');\n loc++;\n });\n\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/mapBy\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('mapBy');\n\n suite.test('get value of each property', function() {\n var obj = this.newObject([{a: 1},{a: 2}]);\n equal(obj.mapBy('a').join(''), '12');\n });\n\n suite.test('should work also through getEach alias', function() {\n var obj = this.newObject([{a: 1},{a: 2}]);\n equal(obj.getEach('a').join(''), '12');\n });\n\n suite.test('should be aliased to mapProperty', function() {\n var obj = this.newObject([]);\n equal(obj.mapProperty, obj.mapBy);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/reduce\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('reduce');\n\n suite.test('collectes a summary value from an enumeration', function() {\n var obj = this.newObject([1, 2, 3]);\n var res = obj.reduce(function(previousValue, item, index, enumerable) { return previousValue + item; }, 0);\n equal(res, 6);\n });\n\n suite.test('passes index of item to callback', function() {\n var obj = this.newObject([1, 2, 3]);\n var res = obj.reduce(function(previousValue, item, index, enumerable) { return previousValue + index; }, 0);\n equal(res, 3);\n });\n\n suite.test('passes enumerable object to callback', function() {\n var obj = this.newObject([1, 2, 3]);\n var res = obj.reduce(function(previousValue, item, index, enumerable) { return enumerable; }, 0);\n equal(res, obj);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/reject\",\n [\"ember-runtime/system/object\",\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n var SuiteModuleBuilder = __dependency2__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n // ..........................................................\n // reject()\n //\n\n suite.module('reject');\n\n suite.test('should reject any item that does not meet the condition', function() {\n var obj = this.newObject([1,2,3,4]),\n result;\n\n result = obj.reject(function(i) { return i < 3; });\n deepEqual(result, [3,4], 'reject the correct items');\n });\n\n suite.test('should be the inverse of filter', function() {\n var obj = this.newObject([1,2,3,4]),\n isEven = function(i) { return i % 2 === 0; },\n filtered, rejected;\n\n filtered = obj.filter(isEven);\n rejected = obj.reject(isEven);\n\n deepEqual(filtered, [2,4], 'filtered evens');\n deepEqual(rejected, [1,3], 'rejected evens');\n });\n\n // ..........................................................\n // rejectBy()\n //\n\n suite.module('rejectBy');\n\n suite.test('should reject based on object', function() {\n var obj, ary;\n\n ary = [\n { foo: 'foo', bar: 'BAZ' },\n EmberObject.create({ foo: 'foo', bar: 'bar' })\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.rejectBy('foo', 'foo'), [], 'rejectBy(foo)');\n deepEqual(obj.rejectBy('bar', 'bar'), [ary[0]], 'rejectBy(bar)');\n });\n\n suite.test('should include in result if property is false', function() {\n var obj, ary;\n\n ary = [\n { foo: false, bar: true },\n EmberObject.create({ foo: false, bar: false })\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.rejectBy('foo'), ary, 'rejectBy(foo)');\n deepEqual(obj.rejectBy('bar'), [ary[1]], 'rejectBy(bar)');\n });\n\n suite.test('should reject on second argument if provided', function() {\n var obj, ary;\n\n ary = [\n { name: 'obj1', foo: 3},\n EmberObject.create({ name: 'obj2', foo: 2}),\n { name: 'obj3', foo: 2},\n EmberObject.create({ name: 'obj4', foo: 3})\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.rejectBy('foo', 3), [ary[1], ary[2]], \"rejectBy('foo', 3)')\");\n });\n\n suite.test('should correctly reject null second argument', function() {\n var obj, ary;\n\n ary = [\n { name: 'obj1', foo: 3},\n EmberObject.create({ name: 'obj2', foo: null}),\n { name: 'obj3', foo: null},\n EmberObject.create({ name: 'obj4', foo: 3})\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.rejectBy('foo', null), [ary[0], ary[3]], \"rejectBy('foo', null)')\");\n });\n\n suite.test('should correctly reject undefined second argument', function() {\n var obj, ary;\n\n ary = [\n { name: 'obj1', foo: 3},\n EmberObject.create({ name: 'obj2', foo: 2})\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.rejectBy('bar', undefined), [], \"rejectBy('bar', undefined)')\");\n });\n\n suite.test('should correctly reject explicit undefined second argument', function() {\n var obj, ary;\n\n ary = [\n { name: 'obj1', foo: 3},\n EmberObject.create({ name: 'obj2', foo: 3}),\n { name: 'obj3', foo: undefined},\n EmberObject.create({ name: 'obj4', foo: undefined}),\n { name: 'obj5'},\n EmberObject.create({ name: 'obj6'})\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.rejectBy('foo', undefined), ary.slice(0, 2), \"rejectBy('foo', undefined)')\");\n });\n\n suite.test('should match undefined, null, or false properties without second argument', function() {\n var obj, ary;\n\n ary = [\n { name: 'obj1', foo: 3},\n EmberObject.create({ name: 'obj2', foo: 3}),\n { name: 'obj3', foo: undefined},\n EmberObject.create({ name: 'obj4', foo: undefined}),\n { name: 'obj5'},\n EmberObject.create({ name: 'obj6'}),\n { name: 'obj7', foo: null },\n EmberObject.create({ name: 'obj8', foo: null }),\n { name: 'obj9', foo: false },\n EmberObject.create({ name: 'obj10', foo: false })\n ];\n\n obj = this.newObject(ary);\n\n deepEqual(obj.rejectBy('foo'), ary.slice(2), \"rejectBy('foo')')\");\n });\n\n suite.test('should be aliased to rejectProperty', function() {\n var ary =[];\n\n equal(ary.rejectProperty, ary.rejectBy);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/sortBy\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('sortBy');\n\n suite.test('sort by value of property', function() {\n var obj = this.newObject([{a: 2},{a: 1}]),\n sorted = obj.sortBy('a');\n equal(get(sorted[0], 'a'), 1);\n equal(get(sorted[1], 'a'), 2);\n });\n\n suite.test('supports multiple propertyNames', function() {\n var obj = this.newObject([{a: 1, b: 2},{a: 1, b: 1}]),\n sorted = obj.sortBy('a', 'b');\n equal(get(sorted[0], 'b'), 1);\n equal(get(sorted[1], 'b'), 2);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/toArray\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('toArray');\n\n suite.test('toArray should convert to an array', function() {\n var obj = this.newObject();\n deepEqual(obj.toArray(), this.toArray(obj));\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/uniq\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('uniq');\n\n suite.test('should return new instance with duplicates removed', function() {\n var before, after, obj, ret;\n\n after = this.newFixture(3);\n before = [after[0], after[1], after[2], after[1], after[0]];\n obj = this.newObject(before);\n before = obj.toArray(); // in case of set before will be different...\n\n ret = obj.uniq();\n deepEqual(this.toArray(ret), after, 'should have removed item');\n deepEqual(this.toArray(obj), before, 'should not have changed original');\n });\n\n suite.test('should return duplicate of same content if no duplicates found', function() {\n var item, obj, ret;\n obj = this.newObject(this.newFixture(3));\n ret = obj.uniq(item);\n ok(ret !== obj, 'should not be same object');\n deepEqual(this.toArray(ret), this.toArray(obj), 'should be the same content');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/enumerable/without\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('without');\n\n suite.test('should return new instance with item removed', function() {\n var before, after, obj, ret;\n\n before = this.newFixture(3);\n after = [before[0], before[2]];\n obj = this.newObject(before);\n\n ret = obj.without(before[1]);\n deepEqual(this.toArray(ret), after, 'should have removed item');\n deepEqual(this.toArray(obj), before, 'should not have changed original');\n });\n\n suite.test('should return same instance if object not found', function() {\n var item, obj, ret;\n\n item = this.newFixture(1)[0];\n obj = this.newObject(this.newFixture(3));\n\n ret = obj.without(item);\n equal(ret, obj, 'should be same instance');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array\",\n [\"ember-runtime/tests/suites/array\",\"ember-runtime/tests/suites/mutable_array/insertAt\",\"ember-runtime/tests/suites/mutable_array/popObject\",\"ember-runtime/tests/suites/mutable_array/pushObject\",\"ember-runtime/tests/suites/mutable_array/pushObjects\",\"ember-runtime/tests/suites/mutable_array/removeAt\",\"ember-runtime/tests/suites/mutable_array/replace\",\"ember-runtime/tests/suites/mutable_array/shiftObject\",\"ember-runtime/tests/suites/mutable_array/unshiftObject\",\"ember-runtime/tests/suites/mutable_array/reverseObjects\",\"exports\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __exports__) {\n \"use strict\";\n var ArrayTests = __dependency1__.ArrayTests;\n var ObserverClass = __dependency1__.ObserverClass;\n\n var insertAtTests = __dependency2__[\"default\"];\n var popObjectTests = __dependency3__[\"default\"];\n var pushObjectTests = __dependency4__[\"default\"];\n var pushObjectsTest = __dependency5__[\"default\"];\n var removeAtTests = __dependency6__[\"default\"];\n var replaceTests = __dependency7__[\"default\"];\n var shiftObjectTests = __dependency8__[\"default\"];\n var unshiftObjectTests = __dependency9__[\"default\"];\n var reverseObjectsTests = __dependency10__[\"default\"];\n\n var MutableArrayTests = ArrayTests.extend();\n MutableArrayTests.importModuleTests(insertAtTests);\n MutableArrayTests.importModuleTests(popObjectTests);\n MutableArrayTests.importModuleTests(pushObjectTests);\n MutableArrayTests.importModuleTests(pushObjectsTest);\n MutableArrayTests.importModuleTests(removeAtTests);\n MutableArrayTests.importModuleTests(replaceTests);\n MutableArrayTests.importModuleTests(shiftObjectTests);\n MutableArrayTests.importModuleTests(unshiftObjectTests);\n MutableArrayTests.importModuleTests(reverseObjectsTests);\n\n __exports__[\"default\"] = MutableArrayTests;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/addObject\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('addObject');\n\n suite.test(\"should return receiver\", function() {\n var before, obj;\n before = this.newFixture(3);\n obj = this.newObject(before);\n equal(obj.addObject(before[1]), obj, 'should return receiver');\n });\n\n suite.test(\"[A,B].addObject(C) => [A,B,C] + notify\", function() {\n var obj, before, after, observer, item;\n\n before = this.newFixture(2);\n item = this.newFixture(1)[0];\n after = [before[0], before[1], item];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.addObject(item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(Ember.get(obj, 'length'), after.length, 'length');\n\n if (observer.isEnabled) {\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n }\n });\n\n suite.test(\"[A,B,C].addObject(A) => [A,B,C] + NO notify\", function() {\n var obj, before, after, observer, item;\n\n before = this.newFixture(3);\n after = before;\n item = before[0];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.addObject(item); // note: item in set\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(Ember.get(obj, 'length'), after.length, 'length');\n\n if (observer.isEnabled) {\n equal(observer.validate('[]'), false, 'should NOT have notified []');\n equal(observer.validate('@each'), false, 'should NOT have notified @each');\n equal(observer.validate('length'), false, 'should NOT have notified length');\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n }\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/clear\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('clear');\n\n suite.test(\"[].clear() => [] + notify\", function () {\n var obj, before, after, observer;\n\n before = [];\n after = [];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.clear(), obj, 'return self');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(Ember.get(obj, 'length'), after.length, 'length');\n\n equal(observer.validate('[]'), false, 'should NOT have notified [] once');\n equal(observer.validate('@each'), false, 'should NOT have notified @each once');\n equal(observer.validate('length'), false, 'should NOT have notified length once');\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n });\n\n suite.test(\"[X].clear() => [] + notify\", function () {\n var obj, before, after, observer;\n\n before = this.newFixture(1);\n after = [];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.clear(), obj, 'return self');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(Ember.get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/insertAt\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('insertAt');\n\n suite.test(\"[].insertAt(0, X) => [X] + notify\", function() {\n var obj, after, observer;\n\n after = this.newFixture(1);\n obj = this.newObject([]);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.insertAt(0, after[0]);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n\n equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once');\n equal(observer.timesCalledBefore('@each'), 1, 'should have notified @each will change once');\n equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once');\n equal(observer.timesCalledBefore('firstObject'), 1, 'should have notified firstObject will change once');\n equal(observer.timesCalledBefore('lastObject'), 1, 'should have notified lastObject will change once');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] did change once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each did change once');\n equal(observer.timesCalled('length'), 1, 'should have notified length did change once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject did change once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject did change once');\n });\n\n suite.test(\"[].insertAt(200,X) => OUT_OF_RANGE_EXCEPTION exception\", function() {\n var obj = this.newObject([]), that = this;\n raises(function() {\n obj.insertAt(200, that.newFixture(1)[0]);\n }, Error);\n });\n\n suite.test(\"[A].insertAt(0, X) => [X,A] + notify\", function() {\n var obj, item, after, before, observer;\n\n item = this.newFixture(1)[0];\n before = this.newFixture(1);\n after = [item, before[0]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.insertAt(0, item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once');\n equal(observer.timesCalledBefore('@each'), 1, 'should have notified @each will change once');\n equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once');\n equal(observer.timesCalledBefore('firstObject'), 1, 'should have notified firstObject will change once');\n equal(observer.timesCalledBefore('lastObject'), 0, 'should NOT have notified lastObject will change once');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n });\n\n suite.test(\"[A].insertAt(1, X) => [A,X] + notify\", function() {\n var obj, item, after, before, observer;\n\n item = this.newFixture(1)[0];\n before = this.newFixture(1);\n after = [before[0], item];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.insertAt(1, item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once');\n equal(observer.timesCalledBefore('@each'), 1, 'should have notified @each will change once');\n equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once');\n equal(observer.timesCalledBefore('firstObject'), 0, 'should NOT have notified firstObject will change once');\n equal(observer.timesCalledBefore('lastObject'), 1, 'should have notified lastObject will change once');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n });\n\n suite.test(\"[A].insertAt(200,X) => OUT_OF_RANGE exception\", function() {\n var obj = this.newObject(this.newFixture(1)), that = this;\n raises(function() {\n obj.insertAt(200, that.newFixture(1)[0]);\n }, Error);\n });\n\n suite.test(\"[A,B,C].insertAt(0,X) => [X,A,B,C] + notify\", function() {\n var obj, item, after, before, observer;\n\n item = this.newFixture(1)[0];\n before = this.newFixture(3);\n after = [item, before[0], before[1], before[2]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.insertAt(0, item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once');\n equal(observer.timesCalledBefore('@each'), 1, 'should have notified @each will change once');\n equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once');\n equal(observer.timesCalledBefore('firstObject'), 1, 'should have notified firstObject will change once');\n equal(observer.timesCalledBefore('lastObject'), 0, 'should NOT have notified lastObject will change once');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n });\n\n suite.test(\"[A,B,C].insertAt(1,X) => [A,X,B,C] + notify\", function() {\n var obj, item, after, before, observer;\n\n item = this.newFixture(1)[0];\n before = this.newFixture(3);\n after = [before[0], item, before[1], before[2]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.insertAt(1, item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once');\n equal(observer.timesCalledBefore('@each'), 1, 'should have notified @each will change once');\n equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once');\n equal(observer.timesCalledBefore('firstObject'), 0, 'should NOT have notified firstObject will change once');\n equal(observer.timesCalledBefore('lastObject'), 0, 'should NOT have notified lastObject will change once');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n });\n\n suite.test(\"[A,B,C].insertAt(3,X) => [A,B,C,X] + notify\", function() {\n var obj, item, after, before, observer;\n\n item = this.newFixture(1)[0];\n before = this.newFixture(3);\n after = [before[0], before[1], before[2], item];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.insertAt(3, item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalledBefore('[]'), 1, 'should have notified [] will change once');\n equal(observer.timesCalledBefore('@each'), 1, 'should have notified @each will change once');\n equal(observer.timesCalledBefore('length'), 1, 'should have notified length will change once');\n equal(observer.timesCalledBefore('firstObject'), 0, 'should NOT have notified firstObject will change once');\n equal(observer.timesCalledBefore('lastObject'), 1, 'should have notified lastObject will change once');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/popObject\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('popObject');\n\n suite.test(\"[].popObject() => [] + returns undefined + NO notify\", function() {\n var obj, observer;\n\n obj = this.newObject([]);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.popObject(), undefined, 'popObject results');\n\n deepEqual(this.toArray(obj), [], 'post item results');\n\n equal(observer.validate('[]'), false, 'should NOT have notified []');\n equal(observer.validate('@each'), false, 'should NOT have notified @each');\n equal(observer.validate('length'), false, 'should NOT have notified length');\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n });\n\n suite.test(\"[X].popObject() => [] + notify\", function() {\n var obj, before, after, observer, ret;\n\n before = this.newFixture(1);\n after = [];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n ret = obj.popObject();\n\n equal(ret, before[0], 'return object');\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n suite.test(\"[A,B,C].popObject() => [A,B] + notify\", function() {\n var obj, before, after, observer, ret;\n\n before = this.newFixture(3);\n after = [before[0], before[1]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n ret = obj.popObject();\n\n equal(ret, before[2], 'return object');\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/pushObject\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('pushObject');\n\n suite.test(\"returns pushed object\", function() {\n var exp = this.newFixture(1)[0];\n var obj = this.newObject([]);\n equal(obj.pushObject(exp), exp, 'should return pushed object');\n });\n\n suite.test(\"[].pushObject(X) => [X] + notify\", function() {\n var obj, before, after, observer;\n\n before = [];\n after = this.newFixture(1);\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.pushObject(after[0]);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n suite.test(\"[A,B,C].pushObject(X) => [A,B,C,X] + notify\", function() {\n var obj, before, after, item, observer;\n\n before = this.newFixture(3);\n item = this.newFixture(1)[0];\n after = [before[0], before[1], before[2], item];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.pushObject(item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/pushObjects\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('pushObjects');\n\n suite.test(\"should raise exception if not Ember.Enumerable is passed to pushObjects\", function() {\n var obj = this.newObject([]);\n\n raises(function() {\n obj.pushObjects( \"string\" );\n });\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/removeAt\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('removeAt');\n\n suite.test(\"[X].removeAt(0) => [] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(1);\n after = [];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.removeAt(0), obj, 'return self');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n suite.test(\"[].removeAt(200) => OUT_OF_RANGE_EXCEPTION exception\", function() {\n var obj = this.newObject([]);\n raises(function() {\n obj.removeAt(200);\n }, Error);\n });\n\n suite.test(\"[A,B].removeAt(0) => [B] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(2);\n after = [before[1]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.removeAt(0), obj, 'return self');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n });\n\n suite.test(\"[A,B].removeAt(1) => [A] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(2);\n after = [before[0]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.removeAt(1), obj, 'return self');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n });\n\n suite.test(\"[A,B,C].removeAt(1) => [A,C] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(3);\n after = [before[0], before[2]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.removeAt(1), obj, 'return self');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n });\n\n suite.test(\"[A,B,C,D].removeAt(1,2) => [A,D] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(4);\n after = [before[0], before[3]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.removeAt(1,2), obj, 'return self');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/removeObject\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('removeObject');\n\n suite.test(\"should return receiver\", function() {\n var before, obj;\n before = this.newFixture(3);\n obj = this.newObject(before);\n equal(obj.removeObject(before[1]), obj, 'should return receiver');\n });\n\n suite.test(\"[A,B,C].removeObject(B) => [A,C] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(3);\n after = [before[0], before[2]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.removeObject(before[1]);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(Ember.get(obj, 'length'), after.length, 'length');\n\n if (observer.isEnabled) {\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n }\n });\n\n suite.test(\"[A,B,C].removeObject(D) => [A,B,C]\", function() {\n var obj, before, after, observer, item;\n\n before = this.newFixture(3);\n after = before;\n item = this.newFixture(1)[0];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.removeObject(item); // note: item not in set\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(Ember.get(obj, 'length'), after.length, 'length');\n\n if (observer.isEnabled) {\n equal(observer.validate('[]'), false, 'should NOT have notified []');\n equal(observer.validate('@each'), false, 'should NOT have notified @each');\n equal(observer.validate('length'), false, 'should NOT have notified length');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n }\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/replace\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('replace');\n\n suite.test(\"[].replace(0,0,'X') => ['X'] + notify\", function() {\n\n var obj, exp, observer;\n exp = this.newFixture(1);\n obj = this.newObject([]);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.replace(0,0,exp) ;\n\n deepEqual(this.toArray(obj), exp, 'post item results');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n suite.test(\"[A,B,C,D].replace(1,2,X) => [A,X,D] + notify\", function() {\n var obj, observer, before, replace, after;\n\n before = this.newFixture(4);\n replace = this.newFixture(1);\n after = [before[0], replace[0], before[3]];\n\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.replace(1,2,replace) ;\n\n deepEqual(this.toArray(obj), after, 'post item results');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n });\n\n suite.test(\"[A,B,C,D].replace(1,2,[X,Y]) => [A,X,Y,D] + notify\", function() {\n var obj, observer, before, replace, after;\n\n before = this.newFixture(4);\n replace = this.newFixture(2);\n after = [before[0], replace[0], replace[1], before[3]];\n\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.replace(1,2,replace) ;\n\n deepEqual(this.toArray(obj), after, 'post item results');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.validate('length'), false, 'should NOT have notified length');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n });\n\n suite.test(\"[A,B].replace(1,0,[X,Y]) => [A,X,Y,B] + notify\", function() {\n var obj, observer, before, replace, after;\n\n before = this.newFixture(2);\n replace = this.newFixture(2);\n after = [before[0], replace[0], replace[1], before[1]];\n\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.replace(1,0,replace) ;\n\n deepEqual(this.toArray(obj), after, 'post item results');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n });\n\n suite.test(\"[A,B,C,D].replace(2,2) => [A,B] + notify\", function() {\n var obj, observer, before, replace, after;\n\n before = this.newFixture(4);\n after = [before[0], before[1]];\n\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.replace(2,2);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n });\n\n suite.test('Adding object should notify enumerable observer', function() {\n\n var fixtures = this.newFixture(4);\n var obj = this.newObject(fixtures);\n var observer = this.newObserver(obj).observeEnumerable(obj);\n var item = this.newFixture(1)[0];\n\n obj.replace(2, 2, [item]);\n\n deepEqual(observer._before, [obj, [fixtures[2], fixtures[3]], 1], 'before');\n deepEqual(observer._after, [obj, 2, [item]], 'after');\n });\n\n suite.test('Adding object should notify array observer', function() {\n\n var fixtures = this.newFixture(4);\n var obj = this.newObject(fixtures);\n var observer = this.newObserver(obj).observeArray(obj);\n var item = this.newFixture(1)[0];\n\n obj.replace(2, 2, [item]);\n\n deepEqual(observer._before, [obj, 2, 2, 1], 'before');\n deepEqual(observer._after, [obj, 2, 2, 1], 'after');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/reverseObjects\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('reverseObjects');\n\n suite.test(\"[A,B,C].reverseObjects() => [] + notify\", function () {\n var obj, before, after, observer;\n\n before = this.newFixture(3);\n after = [before[2], before[1], before[0]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.reverseObjects(), obj, 'return self');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 0, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/setObjects\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('setObjects');\n\n suite.test(\"[A,B,C].setObjects([]) = > [] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(3);\n after = [];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.setObjects(after), obj, 'return self');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(Ember.get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n suite.test(\"[A,B,C].setObjects([D, E, F, G]) = > [D, E, F, G] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(3);\n after = this.newFixture(4);\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.setObjects(after), obj, 'return self');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(Ember.get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/shiftObject\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('shiftObject');\n\n suite.test(\"[].shiftObject() => [] + returns undefined + NO notify\", function() {\n var obj, before, after, observer;\n\n before = [];\n after = [];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.shiftObject(), undefined);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.validate('[]', undefined, 1), false, 'should NOT have notified [] once');\n equal(observer.validate('@each', undefined, 1), false, 'should NOT have notified @each once');\n equal(observer.validate('length', undefined, 1), false, 'should NOT have notified length once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject once');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n });\n\n suite.test(\"[X].shiftObject() => [] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(1);\n after = [];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.shiftObject(), before[0], 'should return object');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n suite.test(\"[A,B,C].shiftObject() => [B,C] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(3);\n after = [before[1], before[2]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n equal(obj.shiftObject(), before[0], 'should return object');\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject once');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/unshiftObject\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('unshiftObject');\n\n suite.test(\"returns unshifted object\", function() {\n var obj = this.newObject([]);\n var item = this.newFixture(1)[0];\n equal(obj.unshiftObject(item), item, 'should return unshifted object');\n });\n\n\n suite.test(\"[].unshiftObject(X) => [X] + notify\", function() {\n var obj, before, after, item, observer;\n\n before = [];\n item = this.newFixture(1)[0];\n after = [item];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.unshiftObject(item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n suite.test(\"[A,B,C].unshiftObject(X) => [X,A,B,C] + notify\", function() {\n var obj, before, after, item, observer;\n\n before = this.newFixture(3);\n item = this.newFixture(1)[0];\n after = [item, before[0], before[1], before[2]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.unshiftObject(item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n });\n\n suite.test(\"[A,B,C].unshiftObject(A) => [A,A,B,C] + notify\", function() {\n var obj, before, after, item, observer;\n\n before = this.newFixture(3);\n item = before[0]; // note same object as current head. should end up twice\n after = [item, before[0], before[1], before[2]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.unshiftObject(item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_array/unshiftObjects\",\n [\"ember-runtime/tests/suites/suite\",\"exports\"],\n function(__dependency1__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('unshiftObjects');\n\n suite.test(\"returns receiver\", function() {\n var obj = this.newObject([]);\n var items = this.newFixture(3);\n equal(obj.unshiftObjects(items), obj, 'should return receiver');\n });\n\n suite.test(\"[].unshiftObjects([A,B,C]) => [A,B,C] + notify\", function() {\n var obj, before, items, observer;\n\n before = [];\n items = this.newFixture(3);\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.unshiftObjects(items);\n\n deepEqual(this.toArray(obj), items, 'post item results');\n equal(Ember.get(obj, 'length'), items.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n });\n\n suite.test(\"[A,B,C].unshiftObjects([X,Y]) => [X,Y,A,B,C] + notify\", function() {\n var obj, before, items, after, observer;\n\n before = this.newFixture(3);\n items = this.newFixture(2);\n after = items.concat(before);\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.unshiftObjects(items);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(Ember.get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n });\n\n suite.test(\"[A,B,C].unshiftObjects([A,B]) => [A,B,A,B,C] + notify\", function() {\n var obj, before, after, items, observer;\n\n before = this.newFixture(3);\n items = [before[0], before[1]]; // note same object as current head. should end up twice\n after = items.concat(before);\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');\n obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */\n\n obj.unshiftObjects(items);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(Ember.get(obj, 'length'), after.length, 'length');\n\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('@each'), 1, 'should have notified @each once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_enumerable\",\n [\"ember-runtime/tests/suites/enumerable\",\"ember-runtime/tests/suites/mutable_enumerable/addObject\",\"ember-runtime/tests/suites/mutable_enumerable/removeObject\",\"exports\"],\n function(__dependency1__, __dependency2__, __dependency3__, __exports__) {\n \"use strict\";\n var EnumerableTests = __dependency1__.EnumerableTests;\n var ObserverClass = __dependency1__.ObserverClass;\n\n var addObjectTests = __dependency2__[\"default\"];\n var removeObjectTests = __dependency3__[\"default\"];\n\n var MutableEnumerableTests = EnumerableTests.extend();\n MutableEnumerableTests.importModuleTests(addObjectTests);\n MutableEnumerableTests.importModuleTests(removeObjectTests);\n\n __exports__[\"default\"] = MutableEnumerableTests;\n });\ndefine(\"ember-runtime/tests/suites/mutable_enumerable/addObject\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('addObject');\n\n suite.test(\"should return receiver\", function() {\n var before, obj;\n before = this.newFixture(3);\n obj = this.newObject(before);\n equal(obj.addObject(before[1]), obj, 'should return receiver');\n });\n\n suite.test(\"[A,B].addObject(C) => [A,B,C] + notify\", function() {\n var obj, before, after, observer, item;\n\n before = this.newFixture(2);\n item = this.newFixture(1)[0];\n after = [before[0], before[1], item];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject');\n get(obj, 'firstObject');\n get(obj, 'lastObject');\n\n obj.addObject(item);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n if (observer.isEnabled) {\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n equal(observer.timesCalled('lastObject'), 1, 'should have notified lastObject once');\n // This gets called since MutableEnumerable is naive about changes\n equal(observer.timesCalled('firstObject'), 1, 'should have notified firstObject once');\n }\n });\n\n suite.test(\"[A,B,C].addObject(A) => [A,B,C] + NO notify\", function() {\n var obj, before, after, observer, item;\n\n before = this.newFixture(3);\n after = before;\n item = before[0];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', 'length', 'firstObject', 'lastObject');\n\n obj.addObject(item); // note: item in set\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n if (observer.isEnabled) {\n equal(observer.validate('[]'), false, 'should NOT have notified []');\n equal(observer.validate('length'), false, 'should NOT have notified length');\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n }\n });\n\n suite.test('Adding object should notify enumerable observer', function() {\n var obj = this.newObject(this.newFixture(3));\n var observer = this.newObserver(obj).observeEnumerable(obj);\n var item = this.newFixture(1)[0];\n\n obj.addObject(item);\n\n deepEqual(observer._before, [obj, null, [item]]);\n deepEqual(observer._after, [obj, null, [item]]);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/mutable_enumerable/removeObject\",\n [\"ember-runtime/tests/suites/suite\",\"ember-metal/property_get\",\"exports\"],\n function(__dependency1__, __dependency2__, __exports__) {\n \"use strict\";\n var SuiteModuleBuilder = __dependency1__.SuiteModuleBuilder;\n var get = __dependency2__.get;\n\n var suite = SuiteModuleBuilder.create();\n\n suite.module('removeObject');\n\n suite.test(\"should return receiver\", function() {\n var before, obj;\n before = this.newFixture(3);\n obj = this.newObject(before);\n equal(obj.removeObject(before[1]), obj, 'should return receiver');\n });\n\n suite.test(\"[A,B,C].removeObject(B) => [A,C] + notify\", function() {\n var obj, before, after, observer;\n\n before = this.newFixture(3);\n after = [before[0], before[2]];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', 'length');\n\n obj.removeObject(before[1]);\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n if (observer.isEnabled) {\n equal(observer.timesCalled('[]'), 1, 'should have notified [] once');\n equal(observer.timesCalled('length'), 1, 'should have notified length once');\n\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n }\n });\n\n suite.test(\"[A,B,C].removeObject(D) => [A,B,C]\", function() {\n var obj, before, after, observer, item;\n\n before = this.newFixture(3);\n after = before;\n item = this.newFixture(1)[0];\n obj = this.newObject(before);\n observer = this.newObserver(obj, '[]', 'length');\n\n obj.removeObject(item); // note: item not in set\n\n deepEqual(this.toArray(obj), after, 'post item results');\n equal(get(obj, 'length'), after.length, 'length');\n\n if (observer.isEnabled) {\n equal(observer.validate('[]'), false, 'should NOT have notified []');\n equal(observer.validate('length'), false, 'should NOT have notified length');\n equal(observer.validate('firstObject'), false, 'should NOT have notified firstObject');\n equal(observer.validate('lastObject'), false, 'should NOT have notified lastObject');\n }\n });\n\n suite.test('Removing object should notify enumerable observer', function() {\n\n var fixtures = this.newFixture(3);\n var obj = this.newObject(fixtures);\n var observer = this.newObserver(obj).observeEnumerable(obj);\n var item = fixtures[1];\n\n obj.removeObject(item);\n\n deepEqual(observer._before, [obj, [item], null]);\n deepEqual(observer._after, [obj, [item], null]);\n });\n\n __exports__[\"default\"] = suite;\n });\ndefine(\"ember-runtime/tests/suites/suite\",\n [\"ember-runtime/system/object\",\"ember-metal/mixin\",\"ember-metal/utils\",\"ember-metal/property_get\",\"ember-metal/array\",\"exports\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n var required = __dependency2__.required;\n var guidFor = __dependency3__.guidFor;\n var generateGuid = __dependency3__.generateGuid;\n var get = __dependency4__.get;\n var forEach = __dependency5__.forEach;\n\n /**\n @class\n A Suite can be used to define a reusable set of unit tests that can be\n applied to any object. Suites are most useful for defining tests that\n work against a mixin or plugin API. Developers implementing objects that\n use the mixin or support the API can then run these tests against their\n own code to verify compliance.\n\n To define a suite, you need to define the tests themselves as well as a\n callback API implementors can use to tie your tests to thier specific class.\n\n ## Defining a Callback API\n\n To define the callback API, just extend this class and add your properties\n or methods that must be provided. Use Ember.required() placeholders for\n any properties that implementors must define themselves.\n\n ## Defining Unit Tests\n\n To add unit tests, use the suite.module() or suite.test() methods instead\n of a regular module() or test() method when defining your tests. This will\n add the tests to the suite.\n\n ## Using a Suite\n\n To use a Suite to test your own objects, extend the suite subclass and\n define any required methods. Then call run() on the new subclass. This\n will create an instance of your class and then defining the unit tests.\n\n @extends Ember.Object\n @private\n */\n var Suite = EmberObject.extend({\n\n /**\n Define a name for these tests - all modules are prefixed w/ it.\n\n @type String\n */\n name: required(String),\n\n /**\n Invoked to actually run the test - overridden by mixins\n */\n run: function() {}\n\n });\n\n Suite.reopenClass({\n\n plan: null,\n\n run: function() {\n var C = this;\n return new C().run();\n },\n\n module: function(desc, opts) {\n if (!opts) opts = {};\n var setup = opts.setup, teardown = opts.teardown;\n this.reopen({\n run: function() {\n this._super();\n var title = get(this, 'name')+': '+desc, ctx = this;\n module(title, {\n setup: function() {\n if (setup) setup.call(ctx);\n },\n\n teardown: function() {\n if (teardown) teardown.call(ctx);\n }\n });\n }\n });\n },\n\n test: function(name, func) {\n this.reopen({\n run: function() {\n this._super();\n var ctx = this;\n if (!func) test(name); // output warning\n else test(name, function() { func.call(ctx); });\n }\n });\n },\n\n // convert to guids to minimize logging.\n same: function(actual, exp, message) {\n actual = (actual && actual.map) ? actual.map(function(x) { return guidFor(x); }) : actual;\n exp = (exp && exp.map) ? exp.map(function(x) { return guidFor(x); }) : exp;\n return deepEqual(actual, exp, message);\n },\n\n // easy way to disable tests\n notest: function() {},\n\n importModuleTests: function(builder) {\n var self = this;\n this.module(builder._module);\n\n builder._tests.forEach(function(descAndFunc) {\n self.test.apply(self, descAndFunc);\n });\n }\n });\n\n var SuiteModuleBuilder = EmberObject.extend({\n _module: null,\n _tests: null,\n\n init: function(){\n this._tests = [];\n },\n\n module: function(name) { this._module = name; },\n\n test: function(name, func) {\n this._tests.push([name, func]);\n }\n });\n\n __exports__.SuiteModuleBuilder = SuiteModuleBuilder;\n __exports__.Suite = Suite;\n\n __exports__[\"default\"] = Suite;\n });\ndefine(\"ember-runtime/tests/system/application/base_test\",\n [\"ember-runtime/system/namespace\",\"ember-runtime/system/application\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Namespace = __dependency1__[\"default\"];\n var Application = __dependency2__[\"default\"];\n\n module('Ember.Application');\n\n test('Ember.Application should be a subclass of Ember.Namespace', function() {\n\n ok(Namespace.detect(Application), 'Ember.Application subclass of Ember.Namespace');\n });\n });\ndefine(\"ember-runtime/tests/system/array_proxy/arranged_content_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-metal/computed\",\"ember-runtime/system/array_proxy\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var computed = __dependency3__.computed;\n var ArrayProxy = __dependency4__[\"default\"];\n\n var array;\n\n module(\"ArrayProxy - arrangedContent\", {\n setup: function() {\n run(function() {\n array = ArrayProxy.createWithMixins({\n content: Ember.A([1,2,4,5]),\n arrangedContent: computed(function() {\n var content = this.get('content');\n return content && Ember.A(content.slice().sort(function(a,b) {\n if (a == null) { a = -1; }\n if (b == null) { b = -1; }\n return b - a;\n }));\n }).property('content.[]')\n });\n });\n },\n teardown: function() {\n run(function() {\n array.destroy();\n });\n }\n });\n\n test(\"addObject - adds to end of 'content' if not present\", function() {\n run(function() { array.addObject(3); });\n deepEqual(array.get('content'), [1,2,4,5,3], 'adds to end of content');\n deepEqual(array.get('arrangedContent'), [5,4,3,2,1], 'arrangedContent stays sorted');\n\n run(function() { array.addObject(1); });\n deepEqual(array.get('content'), [1,2,4,5,3], 'does not add existing number to content');\n });\n\n test(\"addObjects - adds to end of 'content' if not present\", function() {\n run(function() { array.addObjects([1,3,6]); });\n deepEqual(array.get('content'), [1,2,4,5,3,6], 'adds to end of content');\n deepEqual(array.get('arrangedContent'), [6,5,4,3,2,1], 'arrangedContent stays sorted');\n });\n\n test(\"compact - returns arrangedContent without nulls and undefined\", function() {\n run(function() { array.set('content', Ember.A([1,3,null,2,undefined])); });\n deepEqual(array.compact(), [3,2,1]);\n });\n\n test(\"indexOf - returns index of object in arrangedContent\", function() {\n equal(array.indexOf(4), 1, 'returns arranged index');\n });\n\n test(\"insertAt - raises, indeterminate behavior\", function() {\n raises(function() {\n run(function() { array.insertAt(2,3); });\n });\n });\n\n test(\"lastIndexOf - returns last index of object in arrangedContent\", function() {\n run(function() { array.pushObject(4); });\n equal(array.lastIndexOf(4), 2, 'returns last arranged index');\n });\n\n test(\"nextObject - returns object at index in arrangedContent\", function() {\n equal(array.nextObject(1), 4, 'returns object at index');\n });\n\n test(\"objectAt - returns object at index in arrangedContent\", function() {\n equal(array.objectAt(1), 4, 'returns object at index');\n });\n\n // Not sure if we need a specific test for it, since it's internal\n test(\"objectAtContent - returns object at index in arrangedContent\", function() {\n equal(array.objectAtContent(1), 4, 'returns object at index');\n });\n\n test(\"objectsAt - returns objects at indices in arrangedContent\", function() {\n deepEqual(array.objectsAt([0,2,4]), [5,2,undefined], 'returns objects at indices');\n });\n\n test(\"popObject - removes last object in arrangedContent\", function() {\n var popped;\n run(function() { popped = array.popObject(); });\n equal(popped, 1, 'returns last object');\n deepEqual(array.get('content'), [2,4,5], 'removes from content');\n });\n\n test(\"pushObject - adds to end of content even if it already exists\", function() {\n run(function() { array.pushObject(1); });\n deepEqual(array.get('content'), [1,2,4,5,1], 'adds to end of content');\n });\n\n test(\"pushObjects - adds multiple to end of content even if it already exists\", function() {\n run(function() { array.pushObjects([1,2,4]); });\n deepEqual(array.get('content'), [1,2,4,5,1,2,4], 'adds to end of content');\n });\n\n test(\"removeAt - removes from index in arrangedContent\", function() {\n run(function() { array.removeAt(1,2); });\n deepEqual(array.get('content'), [1,5]);\n });\n\n test(\"removeObject - removes object from content\", function() {\n run(function() { array.removeObject(2); });\n deepEqual(array.get('content'), [1,4,5]);\n });\n\n test(\"removeObjects - removes objects from content\", function() {\n run(function() { array.removeObjects([2,4,6]); });\n deepEqual(array.get('content'), [1,5]);\n });\n\n test(\"replace - raises, indeterminate behavior\", function() {\n raises(function() {\n run(function() { array.replace(1, 2, [3]); });\n });\n });\n\n test(\"replaceContent - does a standard array replace on content\", function() {\n run(function() { array.replaceContent(1, 2, [3]); });\n deepEqual(array.get('content'), [1,3,5]);\n });\n\n test(\"reverseObjects - raises, use Sortable#sortAscending\", function() {\n raises(function() {\n run(function() { array.reverseObjects(); });\n });\n });\n\n test(\"setObjects - replaces entire content\", function() {\n run(function() { array.setObjects([6,7,8]); });\n deepEqual(array.get('content'), [6,7,8], 'replaces content');\n });\n\n test(\"shiftObject - removes from start of arrangedContent\", function() {\n var shifted;\n run(function() { shifted = array.shiftObject(); });\n equal(shifted, 5, 'returns first object');\n deepEqual(array.get('content'), [1,2,4], 'removes object from content');\n });\n\n test(\"slice - returns a slice of the arrangedContent\", function() {\n deepEqual(array.slice(1,3), [4,2], 'returns sliced arrangedContent');\n });\n\n test(\"toArray - returns copy of arrangedContent\", function() {\n deepEqual(array.toArray(), [5,4,2,1]);\n });\n\n test(\"unshiftObject - adds to start of content\", function() {\n run(function() { array.unshiftObject(6); });\n deepEqual(array.get('content'), [6,1,2,4,5], 'adds to start of content');\n });\n\n test(\"unshiftObjects - adds to start of content\", function() {\n run(function() { array.unshiftObjects([6,7]); });\n deepEqual(array.get('content'), [6,7,1,2,4,5], 'adds to start of content');\n });\n\n test(\"without - returns arrangedContent without object\", function() {\n deepEqual(array.without(2), [5,4,1], 'returns arranged without object');\n });\n\n test(\"lastObject - returns last arranged object\", function() {\n equal(array.get('lastObject'), 1, 'returns last arranged object');\n });\n\n test(\"firstObject - returns first arranged object\", function() {\n equal(array.get('firstObject'), 5, 'returns first arranged object');\n });\n\n\n module(\"ArrayProxy - arrangedContent matching content\", {\n setup: function() {\n run(function() {\n array = ArrayProxy.createWithMixins({\n content: Ember.A([1,2,4,5])\n });\n });\n },\n teardown: function() {\n run(function() {\n array.destroy();\n });\n }\n });\n\n test(\"insertAt - inserts object at specified index\", function() {\n run(function() { array.insertAt(2, 3); });\n deepEqual(array.get('content'), [1,2,3,4,5]);\n });\n\n test(\"replace - does a standard array replace\", function() {\n run(function() { array.replace(1, 2, [3]); });\n deepEqual(array.get('content'), [1,3,5]);\n });\n\n test(\"reverseObjects - reverses content\", function() {\n run(function() { array.reverseObjects(); });\n deepEqual(array.get('content'), [5,4,2,1]);\n });\n\n module(\"ArrayProxy - arrangedContent with transforms\", {\n setup: function() {\n run(function() {\n array = ArrayProxy.createWithMixins({\n content: Ember.A([1,2,4,5]),\n\n arrangedContent: computed(function() {\n var content = this.get('content');\n return content && Ember.A(content.slice().sort(function(a,b) {\n if (a == null) { a = -1; }\n if (b == null) { b = -1; }\n return b - a;\n }));\n }).property('content.[]'),\n\n objectAtContent: function(idx) {\n var obj = this.get('arrangedContent').objectAt(idx);\n return obj && obj.toString();\n }\n });\n });\n },\n teardown: function() {\n run(function() {\n array.destroy();\n });\n }\n });\n\n test(\"indexOf - returns index of object in arrangedContent\", function() {\n equal(array.indexOf('4'), 1, 'returns arranged index');\n });\n\n test(\"lastIndexOf - returns last index of object in arrangedContent\", function() {\n run(function() { array.pushObject(4); });\n equal(array.lastIndexOf('4'), 2, 'returns last arranged index');\n });\n\n test(\"nextObject - returns object at index in arrangedContent\", function() {\n equal(array.nextObject(1), '4', 'returns object at index');\n });\n\n test(\"objectAt - returns object at index in arrangedContent\", function() {\n equal(array.objectAt(1), '4', 'returns object at index');\n });\n\n // Not sure if we need a specific test for it, since it's internal\n test(\"objectAtContent - returns object at index in arrangedContent\", function() {\n equal(array.objectAtContent(1), '4', 'returns object at index');\n });\n\n test(\"objectsAt - returns objects at indices in arrangedContent\", function() {\n deepEqual(array.objectsAt([0,2,4]), ['5','2',undefined], 'returns objects at indices');\n });\n\n test(\"popObject - removes last object in arrangedContent\", function() {\n var popped;\n run(function() { popped = array.popObject(); });\n equal(popped, '1', 'returns last object');\n deepEqual(array.get('content'), [2,4,5], 'removes from content');\n });\n\n test(\"removeObject - removes object from content\", function() {\n run(function() { array.removeObject('2'); });\n deepEqual(array.get('content'), [1,4,5]);\n });\n\n test(\"removeObjects - removes objects from content\", function() {\n run(function() { array.removeObjects(['2','4','6']); });\n deepEqual(array.get('content'), [1,5]);\n });\n\n test(\"shiftObject - removes from start of arrangedContent\", function() {\n var shifted;\n run(function() { shifted = array.shiftObject(); });\n equal(shifted, '5', 'returns first object');\n deepEqual(array.get('content'), [1,2,4], 'removes object from content');\n });\n\n test(\"slice - returns a slice of the arrangedContent\", function() {\n deepEqual(array.slice(1,3), ['4','2'], 'returns sliced arrangedContent');\n });\n\n test(\"toArray - returns copy of arrangedContent\", function() {\n deepEqual(array.toArray(), ['5','4','2','1']);\n });\n\n test(\"without - returns arrangedContent without object\", function() {\n deepEqual(array.without('2'), ['5','4','1'], 'returns arranged without object');\n });\n\n test(\"lastObject - returns last arranged object\", function() {\n equal(array.get('lastObject'), '1', 'returns last arranged object');\n });\n\n test(\"firstObject - returns first arranged object\", function() {\n equal(array.get('firstObject'), '5', 'returns first arranged object');\n });\n });\ndefine(\"ember-runtime/tests/system/array_proxy/content_change_test\",\n [\"ember-metal/core\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-runtime/system/array_proxy\",\"ember-runtime/controllers/array_controller\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var set = __dependency2__.set;\n var run = __dependency3__[\"default\"];\n var ArrayProxy = __dependency4__[\"default\"];\n var ArrayController = __dependency5__[\"default\"];\n\n module(\"ArrayProxy - content change\");\n\n test(\"should update length for null content\", function() {\n var proxy = ArrayProxy.create({\n content: Ember.A([1,2,3])\n });\n\n equal(proxy.get('length'), 3, \"precond - length is 3\");\n\n proxy.set('content', null);\n\n equal(proxy.get('length'), 0, \"length updates\");\n });\n\n test(\"The `arrangedContentWillChange` method is invoked before `content` is changed.\", function() {\n var callCount = 0,\n expectedLength;\n\n var proxy = ArrayProxy.extend({\n content: Ember.A([1, 2, 3]),\n\n arrangedContentWillChange: function() {\n equal(this.get('arrangedContent.length'), expectedLength, \"hook should be invoked before array has changed\");\n callCount++;\n }\n }).create();\n\n proxy.pushObject(4);\n equal(callCount, 0, \"pushing content onto the array doesn't trigger it\");\n\n proxy.get('content').pushObject(5);\n equal(callCount, 0, \"pushing content onto the content array doesn't trigger it\");\n\n expectedLength = 5;\n proxy.set('content', Ember.A(['a', 'b']));\n equal(callCount, 1, \"replacing the content array triggers the hook\");\n });\n\n test(\"The `arrangedContentDidChange` method is invoked after `content` is changed.\", function() {\n var callCount = 0,\n expectedLength;\n\n var proxy = ArrayProxy.extend({\n content: Ember.A([1, 2, 3]),\n\n arrangedContentDidChange: function() {\n equal(this.get('arrangedContent.length'), expectedLength, \"hook should be invoked after array has changed\");\n callCount++;\n }\n }).create();\n\n equal(callCount, 0, \"hook is not called after creating the object\");\n\n proxy.pushObject(4);\n equal(callCount, 0, \"pushing content onto the array doesn't trigger it\");\n\n proxy.get('content').pushObject(5);\n equal(callCount, 0, \"pushing content onto the content array doesn't trigger it\");\n\n expectedLength = 2;\n proxy.set('content', Ember.A(['a', 'b']));\n equal(callCount, 1, \"replacing the content array triggers the hook\");\n });\n\n test(\"The ArrayProxy doesn't explode when assigned a destroyed object\", function() {\n var arrayController = ArrayController.create();\n var proxy = ArrayProxy.create();\n\n run(function() {\n arrayController.destroy();\n });\n\n set(proxy, 'content', arrayController);\n\n ok(true, \"No exception was raised\");\n });\n });\ndefine(\"ember-runtime/tests/system/array_proxy/content_update_test\",\n [\"ember-metal/core\",\"ember-metal/computed\",\"ember-runtime/system/array_proxy\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var computed = __dependency2__.computed;\n var ArrayProxy = __dependency3__[\"default\"];\n\n module(\"Ember.ArrayProxy - content update\");\n\n test(\"The `contentArrayDidChange` method is invoked after `content` is updated.\", function() {\n\n var proxy, observerCalled = false;\n\n proxy = ArrayProxy.createWithMixins({\n content: Ember.A(),\n\n arrangedContent: computed('content', function(key, value) {\n // setup arrangedContent as a different object than content,\n // which is the default\n return Ember.A(this.get('content').slice());\n }),\n\n contentArrayDidChange: function(array, idx, removedCount, addedCount) {\n observerCalled = true;\n return this._super(array, idx, removedCount, addedCount);\n }\n });\n\n proxy.pushObject(1);\n\n ok(observerCalled, \"contentArrayDidChange is invoked\");\n });\n });\ndefine(\"ember-runtime/tests/system/array_proxy/suite_test\",\n [\"ember-metal/core\",\"ember-runtime/tests/suites/mutable_array\",\"ember-runtime/system/array_proxy\",\"ember-metal/property_get\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var MutableArrayTests = __dependency2__[\"default\"];\n var ArrayProxy = __dependency3__[\"default\"];\n var get = __dependency4__.get;\n\n MutableArrayTests.extend({\n\n name: 'Ember.ArrayProxy',\n\n newObject: function(ary) {\n var ret = ary ? ary.slice() : this.newFixture(3);\n return ArrayProxy.create({ content: Ember.A(ret) });\n },\n\n mutate: function(obj) {\n obj.pushObject(get(obj, 'length')+1);\n },\n\n toArray: function(obj) {\n return obj.toArray ? obj.toArray() : obj.slice();\n }\n\n }).run();\n });\ndefine(\"ember-runtime/tests/system/deferred_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-runtime/system/deferred\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var Deferred = __dependency3__[\"default\"];\n\n module(\"Ember.Deferred all-in-one\");\n\n asyncTest(\"Can resolve a promise\", function() {\n var value = { value: true };\n\n var promise = Deferred.promise(function(deferred) {\n setTimeout(function() {\n run(function() { deferred.resolve(value); });\n });\n });\n\n promise.then(function(resolveValue) {\n QUnit.start();\n equal(resolveValue, value, \"The resolved value should be correct\");\n });\n });\n\n asyncTest(\"Can reject a promise\", function() {\n var rejected = { rejected: true };\n\n var promise = Deferred.promise(function(deferred) {\n setTimeout(function() {\n run(function() { deferred.reject(rejected); });\n });\n });\n\n promise.then(null, function(rejectedValue) {\n QUnit.start();\n equal(rejectedValue, rejected, \"The resolved value should be correct\");\n });\n });\n });\ndefine(\"ember-runtime/tests/system/lazy_load_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-runtime/system/lazy_load\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var onLoad = __dependency3__.onLoad;\n var runLoadHooks = __dependency3__.runLoadHooks;\n\n module(\"Lazy Loading\");\n\n test(\"if a load hook is registered, it is executed when runLoadHooks are exected\", function() {\n var count = 0;\n\n run(function() {\n onLoad(\"__test_hook__\", function(object) {\n count += object;\n });\n });\n\n run(function() {\n runLoadHooks(\"__test_hook__\", 1);\n });\n\n equal(count, 1, \"the object was passed into the load hook\");\n });\n\n test(\"if runLoadHooks was already run, it executes newly added hooks immediately\", function() {\n var count = 0;\n run(function() {\n onLoad(\"__test_hook__\", function(object) {\n count += object;\n });\n });\n\n run(function() {\n runLoadHooks(\"__test_hook__\", 1);\n });\n\n count = 0;\n run(function() {\n onLoad(\"__test_hook__\", function(object) {\n count += object;\n });\n });\n\n equal(count, 1, \"the original object was passed into the load hook\");\n });\n\n test(\"hooks in ENV.EMBER_LOAD_HOOKS['hookName'] get executed\", function() {\n\n // Note that the necessary code to perform this test is run before\n // the Ember lib is loaded in tests/index.html\n\n run(function() {\n runLoadHooks(\"__before_ember_test_hook__\", 1);\n });\n\n equal(window.ENV.__test_hook_count__, 1, \"the object was passed into the load hook\");\n });\n\n if (typeof window === 'object' && typeof window.dispatchEvent === 'function' && typeof CustomEvent === \"function\") {\n test(\"load hooks trigger a custom event\", function() {\n var eventObject = \"super duper awesome events\";\n\n window.addEventListener('__test_hook_for_events__', function(e) {\n ok(true, 'custom event was fired');\n equal(e.detail, eventObject, 'event details are provided properly');\n });\n\n run(function() {\n runLoadHooks(\"__test_hook_for_events__\", eventObject);\n });\n });\n }\n });\ndefine(\"ember-runtime/tests/system/namespace/base_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-metal/property_get\",\"ember-runtime/system/object\",\"ember-runtime/mixins/array\",\"ember-runtime/system/namespace\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var get = __dependency3__.get;\n var EmberObject = __dependency4__[\"default\"];\n var EmberArray = __dependency5__[\"default\"];\n var Namespace = __dependency6__[\"default\"];\n\n var originalLookup, lookup;\n\n module('Namespace', {\n setup: function() {\n originalLookup = Ember.lookup;\n Ember.BOOTED = false;\n\n lookup = Ember.lookup = {};\n },\n teardown: function() {\n Ember.BOOTED = false;\n\n for(var prop in lookup) {\n if (lookup[prop]) { run(lookup[prop], 'destroy'); }\n }\n\n Ember.lookup = originalLookup;\n }\n });\n\n test('Namespace should be a subclass of EmberObject', function() {\n ok(EmberObject.detect(Namespace));\n });\n\n test(\"Namespace should be duck typed\", function() {\n ok(get(Namespace.create(), 'isNamespace'), \"isNamespace property is true\");\n });\n\n test('Namespace is found and named', function() {\n var nsA = lookup.NamespaceA = Namespace.create();\n equal(nsA.toString(), \"NamespaceA\", \"namespaces should have a name if they are on lookup\");\n\n var nsB = lookup.NamespaceB = Namespace.create();\n equal(nsB.toString(), \"NamespaceB\", \"namespaces work if created after the first namespace processing pass\");\n });\n\n test(\"Classes under an Namespace are properly named\", function() {\n var nsA = lookup.NamespaceA = Namespace.create();\n nsA.Foo = EmberObject.extend();\n equal(nsA.Foo.toString(), \"NamespaceA.Foo\", \"Classes pick up their parent namespace\");\n\n nsA.Bar = EmberObject.extend();\n equal(nsA.Bar.toString(), \"NamespaceA.Bar\", \"New Classes get the naming treatment too\");\n\n var nsB = lookup.NamespaceB = Namespace.create();\n nsB.Foo = EmberObject.extend();\n equal(nsB.Foo.toString(), \"NamespaceB.Foo\", \"Classes in new namespaces get the naming treatment\");\n });\n\n test(\"Classes under Ember are properly named\", function() {\n Ember.TestObject = EmberObject.extend({});\n equal(Ember.TestObject.toString(), \"Ember.TestObject\", \"class under Ember is given a string representation\");\n });\n\n test(\"Lowercase namespaces are no longer supported\", function() {\n var nsC = lookup.namespaceC = Namespace.create();\n equal(nsC.toString(), undefined);\n });\n\n test(\"A namespace can be assigned a custom name\", function() {\n var nsA = Namespace.create({\n name: \"NamespaceA\"\n });\n\n var nsB = lookup.NamespaceB = Namespace.create({\n name: \"CustomNamespaceB\"\n });\n\n nsA.Foo = EmberObject.extend();\n nsB.Foo = EmberObject.extend();\n\n equal(nsA.Foo.toString(), \"NamespaceA.Foo\", \"The namespace's name is used when the namespace is not in the lookup object\");\n equal(nsB.Foo.toString(), \"CustomNamespaceB.Foo\", \"The namespace's name is used when the namespace is in the lookup object\");\n });\n\n test(\"Calling namespace.nameClasses() eagerly names all classes\", function() {\n Ember.BOOTED = true;\n\n var namespace = lookup.NS = Namespace.create();\n\n namespace.ClassA = EmberObject.extend();\n namespace.ClassB = EmberObject.extend();\n\n Namespace.processAll();\n\n equal(namespace.ClassA.toString(), \"NS.ClassA\");\n equal(namespace.ClassB.toString(), \"NS.ClassB\");\n });\n\n test(\"A namespace can be looked up by its name\", function() {\n var NS = lookup.NS = Namespace.create();\n var UI = lookup.UI = Namespace.create();\n var CF = lookup.CF = Namespace.create();\n\n equal(Namespace.byName('NS'), NS);\n equal(Namespace.byName('UI'), UI);\n equal(Namespace.byName('CF'), CF);\n });\n\n test(\"A nested namespace can be looked up by its name\", function() {\n var UI = lookup.UI = Namespace.create();\n UI.Nav = Namespace.create();\n\n equal(Namespace.byName('UI.Nav'), UI.Nav);\n });\n\n test(\"Destroying a namespace before caching lookup removes it from the list of namespaces\", function(){\n var CF = lookup.CF = Namespace.create();\n\n run(CF,'destroy');\n equal(Namespace.byName('CF'), undefined, \"namespace can not be found after destroyed\");\n });\n\n test(\"Destroying a namespace after looking up removes it from the list of namespaces\", function(){\n var CF = lookup.CF = Namespace.create();\n\n equal(Namespace.byName('CF'), CF, \"precondition - namespace can be looked up by name\");\n\n run(CF,'destroy');\n equal(Namespace.byName('CF'), undefined, \"namespace can not be found after destroyed\");\n });\n });\ndefine(\"ember-runtime/tests/system/native_array/copyable_suite_test\",\n [\"ember-runtime/tests/suites/copyable\",\"ember-metal/utils\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var CopyableTests = __dependency1__[\"default\"];\n var generateGuid = __dependency2__.generateGuid;\n\n CopyableTests.extend({\n name: 'NativeArray Copyable',\n\n newObject: function() {\n return Ember.A([generateGuid()]);\n },\n\n isEqual: function(a,b) {\n if (!(a instanceof Array)) return false;\n if (!(b instanceof Array)) return false;\n if (a.length !== b.length) return false;\n return a[0]===b[0];\n },\n\n shouldBeFreezable: false\n }).run();\n\n module(\"NativeArray Copyable\");\n\n test(\"deep copy is respected\", function() {\n var array = Ember.A([ { id: 1 }, { id: 2 }, { id: 3 } ]);\n\n var copiedArray = array.copy(true);\n\n deepEqual(copiedArray, array, \"copied array is equivalent\");\n ok(copiedArray[0] !== array[0], \"objects inside should be unique\");\n });\n });\ndefine(\"ember-runtime/tests/system/native_array/suite_test\",\n [\"ember-runtime/tests/suites/mutable_array\"],\n function(__dependency1__) {\n \"use strict\";\n var MutableArrayTests = __dependency1__[\"default\"];\n\n MutableArrayTests.extend({\n\n name: 'Native Array',\n\n newObject: function(ary) {\n return Ember.A(ary ? ary.slice() : this.newFixture(3));\n },\n\n mutate: function(obj) {\n obj.pushObject(obj.length+1);\n },\n\n toArray: function(obj) {\n return obj.slice(); // make a copy.\n }\n\n }).run();\n });\ndefine(\"ember-runtime/tests/system/object/computed_test\",\n [\"ember-metal/computed\",\"ember-metal/property_get\",\"ember-metal/mixin\",\"ember-runtime/tests/props_helper\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var computed = __dependency1__.computed;\n var emberGet = __dependency2__.get;\n var observer = __dependency3__.observer;\n var testWithDefault = __dependency4__.testWithDefault;\n var testBoth = __dependency4__.testBoth;\n var EmberObject = __dependency5__[\"default\"];\n\n module('EmberObject computed property');\n\n testWithDefault('computed property on instance', function(get, set) {\n\n var MyClass = EmberObject.extend({\n foo: computed(function() { return 'FOO'; })\n });\n\n equal(get(new MyClass(), 'foo'), 'FOO');\n\n });\n\n\n testWithDefault('computed property on subclass', function(get, set) {\n\n var MyClass = EmberObject.extend({\n foo: computed(function() { return 'FOO'; })\n });\n\n var Subclass = MyClass.extend({\n foo: computed(function() { return 'BAR'; })\n });\n\n equal(get(new Subclass(), 'foo'), 'BAR');\n\n });\n\n\n testWithDefault('replacing computed property with regular val', function(get, set) {\n\n var MyClass = EmberObject.extend({\n foo: computed(function() { return 'FOO'; })\n });\n\n var Subclass = MyClass.extend({\n foo: 'BAR'\n });\n\n equal(get(new Subclass(), 'foo'), 'BAR');\n\n });\n\n testWithDefault('complex depndent keys', function(get, set) {\n\n var MyClass = EmberObject.extend({\n\n init: function() {\n this._super();\n set(this, 'bar', { baz: 'BIFF' });\n },\n\n count: 0,\n\n foo: computed(function() {\n set(this, 'count', get(this, 'count')+1);\n return emberGet(get(this, 'bar'), 'baz') + ' ' + get(this, 'count');\n }).property('bar.baz')\n\n });\n\n var Subclass = MyClass.extend({\n count: 20\n });\n\n var obj1 = new MyClass(),\n obj2 = new Subclass();\n\n equal(get(obj1, 'foo'), 'BIFF 1');\n equal(get(obj2, 'foo'), 'BIFF 21');\n\n set(get(obj1, 'bar'), 'baz', 'BLARG');\n\n equal(get(obj1, 'foo'), 'BLARG 2');\n equal(get(obj2, 'foo'), 'BIFF 21');\n\n set(get(obj2, 'bar'), 'baz', 'BOOM');\n\n equal(get(obj1, 'foo'), 'BLARG 2');\n equal(get(obj2, 'foo'), 'BOOM 22');\n });\n\n testWithDefault('complex depndent keys changing complex dependent keys', function(get, set) {\n\n var MyClass = EmberObject.extend({\n\n init: function() {\n this._super();\n set(this, 'bar', { baz: 'BIFF' });\n },\n\n count: 0,\n\n foo: computed(function() {\n set(this, 'count', get(this, 'count')+1);\n return emberGet(get(this, 'bar'), 'baz') + ' ' + get(this, 'count');\n }).property('bar.baz')\n\n });\n\n var Subclass = MyClass.extend({\n\n init: function() {\n this._super();\n set(this, 'bar2', { baz: 'BIFF2' });\n },\n\n count: 0,\n\n foo: computed(function() {\n set(this, 'count', get(this, 'count')+1);\n return emberGet(get(this, 'bar2'), 'baz') + ' ' + get(this, 'count');\n }).property('bar2.baz')\n });\n\n var obj2 = new Subclass();\n\n equal(get(obj2, 'foo'), 'BIFF2 1');\n\n set(get(obj2, 'bar'), 'baz', 'BLARG');\n equal(get(obj2, 'foo'), 'BIFF2 1', 'should not invalidate property');\n\n set(get(obj2, 'bar2'), 'baz', 'BLARG');\n equal(get(obj2, 'foo'), 'BLARG 2', 'should invalidate property');\n });\n\n test(\"can retrieve metadata for a computed property\", function() {\n var MyClass = EmberObject.extend({\n computedProperty: computed(function() {\n }).meta({ key: 'keyValue' })\n });\n\n equal(emberGet(MyClass.metaForProperty('computedProperty'), 'key'), 'keyValue', \"metadata saved on the computed property can be retrieved\");\n\n var ClassWithNoMetadata = EmberObject.extend({\n computedProperty: computed(function() {\n }).volatile(),\n\n staticProperty: 12\n });\n\n equal(typeof ClassWithNoMetadata.metaForProperty('computedProperty'), \"object\", \"returns empty hash if no metadata has been saved\");\n\n expectAssertion(function() {\n ClassWithNoMetadata.metaForProperty('nonexistentProperty');\n }, \"metaForProperty() could not find a computed property with key 'nonexistentProperty'.\");\n\n expectAssertion(function() {\n ClassWithNoMetadata.metaForProperty('staticProperty');\n }, \"metaForProperty() could not find a computed property with key 'staticProperty'.\");\n });\n\n testBoth(\"can iterate over a list of computed properties for a class\", function(get, set) {\n var MyClass = EmberObject.extend({\n foo: computed(function() {\n\n }),\n\n fooDidChange: observer('foo', function() {\n\n }),\n\n bar: computed(function() {\n\n })\n });\n\n var SubClass = MyClass.extend({\n baz: computed(function() {\n\n })\n });\n\n SubClass.reopen({\n bat: computed(function() {\n\n }).meta({ iAmBat: true })\n });\n\n var list = [];\n\n MyClass.eachComputedProperty(function(name) {\n list.push(name);\n });\n\n deepEqual(list.sort(), ['bar', 'foo'], \"watched and unwatched computed properties are iterated\");\n\n list = [];\n\n SubClass.eachComputedProperty(function(name, meta) {\n list.push(name);\n\n if (name === 'bat') {\n deepEqual(meta, { iAmBat: true });\n } else {\n deepEqual(meta, {});\n }\n });\n\n deepEqual(list.sort(), ['bar', 'bat', 'baz', 'foo'], \"all inherited properties are included\");\n });\n });\ndefine(\"ember-runtime/tests/system/object/create_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/utils\",\"ember-metal/computed\",\"ember-metal/mixin\",\"ember-metal/run_loop\",\"ember-metal/events\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var guidFor = __dependency4__.guidFor;\n var computed = __dependency5__.computed;\n var required = __dependency6__.required;\n var Mixin = __dependency6__.Mixin;\n var observer = __dependency6__.observer;\n var run = __dependency7__[\"default\"];\n var on = __dependency8__.on;\n var EmberObject = __dependency9__[\"default\"];\n\n var moduleOptions, originalLookup;\n\n moduleOptions = {\n setup: function(){\n originalLookup = Ember.lookup;\n Ember.lookup = {};\n },\n\n teardown: function(){\n Ember.lookup = originalLookup;\n }\n };\n\n module('EmberObject.create', moduleOptions);\n\n test(\"simple properties are set\", function() {\n var o = EmberObject.create({ohai: 'there'});\n equal(o.get('ohai'), 'there');\n });\n\n test(\"calls computed property setters\", function() {\n var MyClass = EmberObject.extend({\n foo: computed(function(key, val) {\n if (arguments.length === 2) { return val; }\n return \"this is not the value you're looking for\";\n })\n });\n\n var o = MyClass.create({foo: 'bar'});\n equal(o.get('foo'), 'bar');\n });\n\n if (Ember.ENV.MANDATORY_SETTER) {\n test(\"sets up mandatory setters for watched simple properties\", function() {\n\n var MyClass = EmberObject.extend({\n foo: null,\n bar: null,\n fooDidChange: observer('foo', function() {})\n });\n\n var o = MyClass.create({foo: 'bar', bar: 'baz'});\n equal(o.get('foo'), 'bar');\n\n // Catch IE8 where Object.getOwnPropertyDescriptor exists but only works on DOM elements\n try {\n Object.getOwnPropertyDescriptor({}, 'foo');\n } catch(e) {\n return;\n }\n\n var descriptor = Object.getOwnPropertyDescriptor(o, 'foo');\n ok(descriptor.set, 'Mandatory setter was setup');\n\n descriptor = Object.getOwnPropertyDescriptor(o, 'bar');\n ok(!descriptor.set, 'Mandatory setter was not setup');\n });\n }\n\n test(\"allows bindings to be defined\", function() {\n var obj = EmberObject.create({\n foo: 'foo',\n barBinding: 'foo'\n });\n\n equal(obj.get('bar'), 'foo', 'The binding value is correct');\n });\n\n test(\"calls setUnknownProperty if defined\", function() {\n var setUnknownPropertyCalled = false;\n\n var MyClass = EmberObject.extend({\n setUnknownProperty: function(key, value) {\n setUnknownPropertyCalled = true;\n }\n });\n\n var o = MyClass.create({foo: 'bar'});\n ok(setUnknownPropertyCalled, 'setUnknownProperty was called');\n });\n\n test(\"throws if you try to define a computed property\", function() {\n expectAssertion(function() {\n EmberObject.create({\n foo: computed(function() {})\n });\n }, 'Ember.Object.create no longer supports defining computed properties. Define computed properties using extend() or reopen() before calling create().');\n });\n\n test(\"throws if you try to call _super in a method\", function() {\n expectAssertion(function() {\n EmberObject.create({\n foo: function() {\n this._super();\n }\n });\n }, 'Ember.Object.create no longer supports defining methods that call _super.');\n });\n\n test(\"throws if you try to 'mixin' a definition\", function() {\n var myMixin = Mixin.create({\n adder: function(arg1, arg2) {\n return arg1 + arg2;\n }\n });\n\n expectAssertion(function() {\n var o = EmberObject.create(myMixin);\n }, \"Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.\");\n });\n\n // This test is for IE8.\n test(\"property name is the same as own prototype property\", function() {\n var MyClass = EmberObject.extend({\n toString: function() { return 'MyClass'; }\n });\n\n equal(MyClass.create().toString(), 'MyClass', \"should inherit property from the arguments of `EmberObject.create`\");\n });\n\n test(\"inherits properties from passed in EmberObject\", function() {\n var baseObj = EmberObject.create({ foo: 'bar' }),\n secondaryObj = EmberObject.create(baseObj);\n\n equal(secondaryObj.foo, baseObj.foo, \"Em.O.create inherits properties from EmberObject parameter\");\n });\n\n test(\"throws if you try to pass anything a string as a parameter\", function(){\n var expected = \"EmberObject.create only accepts an objects.\";\n\n throws(function() {\n var o = EmberObject.create(\"some-string\");\n }, expected);\n });\n\n test(\"EmberObject.create can take undefined as a parameter\", function(){\n var o = EmberObject.create(undefined);\n deepEqual(EmberObject.create(), o);\n });\n\n test(\"EmberObject.create can take null as a parameter\", function(){\n var o = EmberObject.create(null);\n deepEqual(EmberObject.create(), o);\n });\n\n module('EmberObject.createWithMixins', moduleOptions);\n\n test(\"Creates a new object that contains passed properties\", function() {\n\n var called = false;\n var obj = EmberObject.createWithMixins({\n prop: 'FOO',\n method: function() { called=true; }\n });\n\n equal(get(obj, 'prop'), 'FOO', 'obj.prop');\n obj.method();\n ok(called, 'method executed');\n });\n\n // ..........................................................\n // WORKING WITH MIXINS\n //\n\n test(\"Creates a new object that includes mixins and properties\", function() {\n\n var MixinA = Mixin.create({ mixinA: 'A' });\n var obj = EmberObject.createWithMixins(MixinA, { prop: 'FOO' });\n\n equal(get(obj, 'mixinA'), 'A', 'obj.mixinA');\n equal(get(obj, 'prop'), 'FOO', 'obj.prop');\n });\n\n // ..........................................................\n // LIFECYCLE\n //\n\n test(\"Configures _super() on methods with override\", function() {\n var completed = false;\n var MixinA = Mixin.create({ method: function() {} });\n var obj = EmberObject.createWithMixins(MixinA, {\n method: function() {\n this._super();\n completed = true;\n }\n });\n\n obj.method();\n ok(completed, 'should have run method without error');\n });\n\n test(\"Calls init if defined\", function() {\n var completed = false;\n var obj = EmberObject.createWithMixins({\n init: function() {\n this._super();\n completed = true;\n }\n });\n\n ok(completed, 'should have run init without error');\n });\n\n test(\"Calls all mixin inits if defined\", function() {\n var completed = 0;\n var Mixin1 = Mixin.create({\n init: function() { this._super(); completed++; }\n });\n\n var Mixin2 = Mixin.create({\n init: function() { this._super(); completed++; }\n });\n\n EmberObject.createWithMixins(Mixin1, Mixin2);\n equal(completed, 2, 'should have called init for both mixins.');\n });\n\n test(\"Triggers init\", function() {\n var completed = false;\n var obj = EmberObject.createWithMixins({\n markAsCompleted: on(\"init\", function(){\n completed = true;\n })\n });\n\n ok(completed, 'should have triggered init which should have run markAsCompleted');\n });\n\n test('creating an object with required properties', function() {\n var ClassA = EmberObject.extend({\n foo: required()\n });\n\n var obj = ClassA.createWithMixins({ foo: 'FOO' }); // should not throw\n equal(get(obj,'foo'), 'FOO');\n });\n\n\n // ..........................................................\n // BUGS\n //\n\n test('create should not break observed values', function() {\n\n var CountObject = EmberObject.extend({\n value: null,\n\n _count: 0,\n\n reset: function() {\n this._count = 0;\n return this;\n },\n\n valueDidChange: observer('value', function() {\n this._count++;\n })\n });\n\n var obj = CountObject.createWithMixins({ value: 'foo' });\n equal(obj._count, 0, 'should not fire yet');\n\n set(obj, 'value', 'BAR');\n equal(obj._count, 1, 'should fire');\n });\n\n test('bindings on a class should only sync on instances', function() {\n Ember.lookup['TestObject'] = EmberObject.createWithMixins({\n foo: 'FOO'\n });\n\n var Class, inst;\n\n run(function() {\n Class = EmberObject.extend({\n fooBinding: 'TestObject.foo'\n });\n\n inst = Class.createWithMixins();\n });\n\n equal(get(Class.prototype, 'foo'), undefined, 'should not sync binding');\n equal(get(inst, 'foo'), 'FOO', 'should sync binding');\n\n });\n\n\n test('inherited bindings should only sync on instances', function() {\n var TestObject;\n\n Ember.lookup['TestObject'] = TestObject = EmberObject.createWithMixins({\n foo: 'FOO'\n });\n\n var Class, Subclass, inst;\n\n run(function() {\n Class = EmberObject.extend({\n fooBinding: 'TestObject.foo'\n });\n });\n\n run(function() {\n Subclass = Class.extend();\n inst = Subclass.createWithMixins();\n });\n\n equal(get(Class.prototype, 'foo'), undefined, 'should not sync binding on Class');\n equal(get(Subclass.prototype, 'foo'), undefined, 'should not sync binding on Subclass');\n equal(get(inst, 'foo'), 'FOO', 'should sync binding on inst');\n\n run(function() {\n set(TestObject, 'foo', 'BAR');\n });\n\n equal(get(Class.prototype, 'foo'), undefined, 'should not sync binding on Class');\n equal(get(Subclass.prototype, 'foo'), undefined, 'should not sync binding on Subclass');\n equal(get(inst, 'foo'), 'BAR', 'should sync binding on inst');\n\n });\n\n test(\"created objects should not share a guid with their superclass\", function() {\n ok(guidFor(EmberObject), \"EmberObject has a guid\");\n\n var objA = EmberObject.createWithMixins(),\n objB = EmberObject.createWithMixins();\n\n ok(guidFor(objA) !== guidFor(objB), \"two instances do not share a guid\");\n });\n });\ndefine(\"ember-runtime/tests/system/object/destroy_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-metal/platform\",\"ember-metal/mixin\",\"ember-metal/property_set\",\"ember-metal/binding\",\"ember-metal/property_events\",\"ember-metal/utils\",\"ember-runtime/keys\",\"ember-runtime/tests/props_helper\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var platform = __dependency3__.platform;\n var observer = __dependency4__.observer;\n var set = __dependency5__.set;\n var bind = __dependency6__.bind;\n var beginPropertyChanges = __dependency7__.beginPropertyChanges;\n var endPropertyChanges = __dependency7__.endPropertyChanges;\n var META_KEY = __dependency8__.META_KEY;\n var objectKeys = __dependency9__[\"default\"];\n var testBoth = __dependency10__.testBoth;\n var EmberObject = __dependency11__[\"default\"];\n\n module('ember-runtime/system/object/destroy_test');\n\n testBoth(\"should schedule objects to be destroyed at the end of the run loop\", function(get, set) {\n var obj = EmberObject.create(), meta;\n\n run(function() {\n obj.destroy();\n meta = obj[META_KEY];\n ok(meta, \"meta is not destroyed immediately\");\n ok(get(obj, 'isDestroying'), \"object is marked as destroying immediately\");\n ok(!get(obj, 'isDestroyed'), \"object is not destroyed immediately\");\n });\n\n meta = obj[META_KEY];\n ok(!meta, \"meta is destroyed after run loop finishes\");\n ok(get(obj, 'isDestroyed'), \"object is destroyed after run loop finishes\");\n });\n\n test(\"should raise an exception when modifying watched properties on a destroyed object\", function() {\n if (platform.hasAccessors) {\n var obj = EmberObject.createWithMixins({\n foo: \"bar\",\n fooDidChange: observer('foo', function() { })\n });\n\n run(function() {\n obj.destroy();\n });\n\n raises(function() {\n set(obj, 'foo', 'baz');\n }, Error, \"raises an exception\");\n } else {\n expect(0);\n }\n });\n\n test(\"observers should not fire after an object has been destroyed\", function() {\n var count = 0;\n var obj = EmberObject.createWithMixins({\n fooDidChange: observer('foo', function() {\n count++;\n })\n });\n\n obj.set('foo', 'bar');\n\n equal(count, 1, \"observer was fired once\");\n\n run(function() {\n beginPropertyChanges();\n obj.set('foo', 'quux');\n obj.destroy();\n endPropertyChanges();\n });\n\n equal(count, 1, \"observer was not called after object was destroyed\");\n });\n\n test(\"destroyed objects should not see each others changes during teardown but a long lived object should\", function () {\n var shouldChange = 0, shouldNotChange = 0;\n\n var objs = {};\n\n var A = EmberObject.extend({\n objs: objs,\n isAlive: true,\n willDestroy: function () {\n this.set('isAlive', false);\n },\n bDidChange: observer('objs.b.isAlive', function () {\n shouldNotChange++;\n }),\n cDidChange: observer('objs.c.isAlive', function () {\n shouldNotChange++;\n })\n });\n\n var B = EmberObject.extend({\n objs: objs,\n isAlive: true,\n willDestroy: function () {\n this.set('isAlive', false);\n },\n aDidChange: observer('objs.a.isAlive', function () {\n shouldNotChange++;\n }),\n cDidChange: observer('objs.c.isAlive', function () {\n shouldNotChange++;\n })\n });\n\n var C = EmberObject.extend({\n objs: objs,\n isAlive: true,\n willDestroy: function () {\n this.set('isAlive', false);\n },\n aDidChange: observer('objs.a.isAlive', function () {\n shouldNotChange++;\n }),\n bDidChange: observer('objs.b.isAlive', function () {\n shouldNotChange++;\n })\n });\n\n var LongLivedObject = EmberObject.extend({\n objs: objs,\n isAliveDidChange: observer('objs.a.isAlive', function () {\n shouldChange++;\n })\n });\n\n objs.a = new A();\n\n objs.b = new B();\n\n objs.c = new C();\n\n var longLivedObject = new LongLivedObject();\n\n run(function () {\n var keys = objectKeys(objs);\n for (var i = 0, l = keys.length; i < l; i++) {\n objs[keys[i]].destroy();\n }\n });\n\n equal(shouldNotChange, 0, 'destroyed graph objs should not see change in willDestroy');\n equal(shouldChange, 1, 'long lived should see change in willDestroy');\n });\n\n test(\"bindings should be synced when are updated in the willDestroy hook\", function() {\n var bar = EmberObject.create({\n value: false,\n willDestroy: function() {\n this.set('value', true);\n }\n });\n\n var foo = EmberObject.create({\n value: null,\n bar: bar\n });\n\n run(function() {\n bind(foo, 'value', 'bar.value');\n });\n\n ok(bar.get('value') === false, 'the initial value has been bound');\n\n run(function() {\n bar.destroy();\n });\n\n ok(foo.get('value'), 'foo is synced when the binding is updated in the willDestroy hook');\n });\n });\ndefine(\"ember-runtime/tests/system/object/detectInstance_test\",\n [\"ember-runtime/system/object\"],\n function(__dependency1__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n\n module('system/object/detectInstance');\n\n test('detectInstance detects instances correctly', function() {\n\n var A = EmberObject.extend();\n var B = A.extend();\n var C = A.extend();\n\n var o = EmberObject.create(),\n a = A.create(),\n b = B.create(),\n c = C.create();\n\n ok( EmberObject.detectInstance(o), 'o is an instance of EmberObject' );\n ok( EmberObject.detectInstance(a), 'a is an instance of EmberObject' );\n ok( EmberObject.detectInstance(b), 'b is an instance of EmberObject' );\n ok( EmberObject.detectInstance(c), 'c is an instance of EmberObject' );\n\n ok( !A.detectInstance(o), 'o is not an instance of A');\n ok( A.detectInstance(a), 'a is an instance of A' );\n ok( A.detectInstance(b), 'b is an instance of A' );\n ok( A.detectInstance(c), 'c is an instance of A' );\n\n ok( !B.detectInstance(o), 'o is not an instance of B' );\n ok( !B.detectInstance(a), 'a is not an instance of B' );\n ok( B.detectInstance(b), 'b is an instance of B' );\n ok( !B.detectInstance(c), 'c is not an instance of B' );\n\n ok( !C.detectInstance(o), 'o is not an instance of C' );\n ok( !C.detectInstance(a), 'a is not an instance of C' );\n ok( !C.detectInstance(b), 'b is not an instance of C' );\n ok( C.detectInstance(c), 'c is an instance of C' );\n\n });\n });\ndefine(\"ember-runtime/tests/system/object/detect_test\",\n [\"ember-runtime/system/object\"],\n function(__dependency1__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n\n module('system/object/detect');\n\n test('detect detects classes correctly', function() {\n\n var A = EmberObject.extend();\n var B = A.extend();\n var C = A.extend();\n\n ok( EmberObject.detect(EmberObject), 'EmberObject is an EmberObject class' );\n ok( EmberObject.detect(A), 'A is an EmberObject class' );\n ok( EmberObject.detect(B), 'B is an EmberObject class' );\n ok( EmberObject.detect(C), 'C is an EmberObject class' );\n\n ok( !A.detect(EmberObject), 'EmberObject is not an A class' );\n ok( A.detect(A), 'A is an A class' );\n ok( A.detect(B), 'B is an A class' );\n ok( A.detect(C), 'C is an A class' );\n\n ok( !B.detect(EmberObject), 'EmberObject is not a B class' );\n ok( !B.detect(A), 'A is not a B class' );\n ok( B.detect(B), 'B is a B class' );\n ok( !B.detect(C), 'C is not a B class' );\n\n ok( !C.detect(EmberObject), 'EmberObject is not a C class' );\n ok( !C.detect(A), 'A is not a C class' );\n ok( !C.detect(B), 'B is not a C class' );\n ok( C.detect(C), 'C is a C class' );\n\n });\n });\ndefine(\"ember-runtime/tests/system/object/events_test\",\n [\"ember-runtime/system/object\",\"ember-runtime/mixins/evented\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var EmberObject = __dependency1__[\"default\"];\n var Evented = __dependency2__[\"default\"];\n\n module(\"Object events\");\n\n test(\"a listener can be added to an object\", function() {\n var count = 0;\n var F = function() { count++; };\n\n var obj = EmberObject.createWithMixins(Evented);\n\n obj.on('event!', F);\n obj.trigger('event!');\n\n equal(count, 1, \"the event was triggered\");\n\n obj.trigger('event!');\n\n equal(count, 2, \"the event was triggered\");\n });\n\n test(\"a listener can be added and removed automatically the first time it is triggered\", function() {\n var count = 0;\n var F = function() { count++; };\n\n var obj = EmberObject.createWithMixins(Evented);\n\n obj.one('event!', F);\n obj.trigger('event!');\n\n equal(count, 1, \"the event was triggered\");\n\n obj.trigger('event!');\n\n equal(count, 1, \"the event was not triggered again\");\n });\n\n test(\"triggering an event can have arguments\", function() {\n var self, args;\n\n var obj = EmberObject.createWithMixins(Evented);\n\n obj.on('event!', function() {\n args = [].slice.call(arguments);\n self = this;\n });\n\n obj.trigger('event!', \"foo\", \"bar\");\n\n deepEqual(args, [ \"foo\", \"bar\" ]);\n equal(self, obj);\n });\n\n test(\"a listener can be added and removed automatically and have arguments\", function() {\n var self, args, count = 0;\n\n var obj = EmberObject.createWithMixins(Evented);\n\n obj.one('event!', function() {\n args = [].slice.call(arguments);\n self = this;\n count++;\n });\n\n obj.trigger('event!', \"foo\", \"bar\");\n\n deepEqual(args, [ \"foo\", \"bar\" ]);\n equal(self, obj);\n equal(count, 1, \"the event is triggered once\");\n\n obj.trigger('event!', \"baz\", \"bat\");\n\n deepEqual(args, [ \"foo\", \"bar\" ]);\n equal(count, 1, \"the event was not triggered again\");\n equal(self, obj);\n });\n\n test(\"binding an event can specify a different target\", function() {\n var self, args;\n\n var obj = EmberObject.createWithMixins(Evented);\n var target = {};\n\n obj.on('event!', target, function() {\n args = [].slice.call(arguments);\n self = this;\n });\n\n obj.trigger('event!', \"foo\", \"bar\");\n\n deepEqual(args, [ \"foo\", \"bar\" ]);\n equal(self, target);\n });\n\n test(\"a listener registered with one can take method as string and can be added with different target\", function() {\n var count = 0;\n var target = {};\n target.fn = function() { count++; };\n\n var obj = EmberObject.createWithMixins(Evented);\n\n obj.one('event!', target, 'fn');\n obj.trigger('event!');\n\n equal(count, 1, \"the event was triggered\");\n\n obj.trigger('event!');\n\n equal(count, 1, \"the event was not triggered again\");\n });\n\n test(\"a listener registered with one can be removed with off\", function() {\n var obj = EmberObject.createWithMixins(Evented, {\n F: function() {}\n });\n var F = function() {};\n\n obj.one('event!', F);\n obj.one('event!', obj, 'F');\n\n equal(obj.has('event!'), true, 'has events');\n\n obj.off('event!', F);\n obj.off('event!', obj, 'F');\n\n equal(obj.has('event!'), false, 'has no more events');\n });\n\n test(\"adding and removing listeners should be chainable\", function() {\n var obj = EmberObject.createWithMixins(Evented);\n var F = function() {};\n\n var ret = obj.on('event!', F);\n equal(ret, obj, '#on returns self');\n\n ret = obj.off('event!', F);\n equal(ret, obj, '#off returns self');\n\n ret = obj.one('event!', F);\n equal(ret, obj, '#one returns self');\n });\n });\ndefine(\"ember-runtime/tests/system/object/extend_test\",\n [\"ember-metal/property_get\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var get = __dependency1__.get;\n var EmberObject = __dependency2__[\"default\"];\n\n module('EmberObject.extend');\n\n test('Basic extend', function() {\n var SomeClass = EmberObject.extend({ foo: 'BAR' });\n ok(SomeClass.isClass, \"A class has isClass of true\");\n var obj = new SomeClass();\n equal(obj.foo, 'BAR');\n });\n\n test('Sub-subclass', function() {\n var SomeClass = EmberObject.extend({ foo: 'BAR' });\n var AnotherClass = SomeClass.extend({ bar: 'FOO' });\n var obj = new AnotherClass();\n equal(obj.foo, 'BAR');\n equal(obj.bar, 'FOO');\n });\n\n test('Overriding a method several layers deep', function() {\n var SomeClass = EmberObject.extend({\n fooCnt: 0,\n foo: function() { this.fooCnt++; },\n\n barCnt: 0,\n bar: function() { this.barCnt++; }\n });\n\n var AnotherClass = SomeClass.extend({\n barCnt: 0,\n bar: function() { this.barCnt++; this._super(); }\n });\n\n var FinalClass = AnotherClass.extend({\n fooCnt: 0,\n foo: function() { this.fooCnt++; this._super(); }\n });\n\n var obj = new FinalClass();\n obj.foo();\n obj.bar();\n equal(obj.fooCnt, 2, 'should invoke both');\n equal(obj.barCnt, 2, 'should invoke both');\n\n // Try overriding on create also\n obj = FinalClass.createWithMixins({\n foo: function() { this.fooCnt++; this._super(); }\n });\n\n obj.foo();\n obj.bar();\n equal(obj.fooCnt, 3, 'should invoke final as well');\n equal(obj.barCnt, 2, 'should invoke both');\n });\n\n test('With concatenatedProperties', function(){\n var SomeClass = EmberObject.extend({ things: 'foo', concatenatedProperties: ['things'] });\n var AnotherClass = SomeClass.extend({ things: 'bar' });\n var YetAnotherClass = SomeClass.extend({ things: 'baz' });\n var some = new SomeClass();\n var another = new AnotherClass();\n var yetAnother = new YetAnotherClass();\n deepEqual(some.get('things'), ['foo'], 'base class should have just its value');\n deepEqual(another.get('things'), ['foo', 'bar'], \"subclass should have base class' and it's own\");\n deepEqual(yetAnother.get('things'), ['foo', 'baz'], \"subclass should have base class' and it's own\");\n });\n\n test('With concatenatedProperties class properties', function(){\n var SomeClass = EmberObject.extend();\n SomeClass.reopenClass({\n concatenatedProperties: ['things'],\n things: 'foo'\n });\n var AnotherClass = SomeClass.extend();\n AnotherClass.reopenClass({ things: 'bar' });\n var YetAnotherClass = SomeClass.extend();\n YetAnotherClass.reopenClass({ things: 'baz' });\n var some = new SomeClass();\n var another = new AnotherClass();\n var yetAnother = new YetAnotherClass();\n deepEqual(get(some.constructor, 'things'), ['foo'], 'base class should have just its value');\n deepEqual(get(another.constructor, 'things'), ['foo', 'bar'], \"subclass should have base class' and it's own\");\n deepEqual(get(yetAnother.constructor, 'things'), ['foo', 'baz'], \"subclass should have base class' and it's own\");\n });\n });\ndefine(\"ember-runtime/tests/system/object/observer_test\",\n [\"ember-metal/core\",\"ember-metal/mixin\",\"ember-metal/run_loop\",\"ember-runtime/tests/props_helper\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var observer = __dependency2__.observer;\n var run = __dependency3__[\"default\"];\n var testWithDefault = __dependency4__.testWithDefault;\n var testBoth = __dependency4__.testBoth;\n var EmberObject = __dependency5__[\"default\"];\n\n module('EmberObject observer');\n\n testBoth('observer on class', function(get, set) {\n\n var MyClass = EmberObject.extend({\n\n count: 0,\n\n foo: observer('bar', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n\n });\n\n var obj = new MyClass();\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj, 'bar', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n\n });\n\n testBoth('observer on subclass', function(get, set) {\n\n var MyClass = EmberObject.extend({\n\n count: 0,\n\n foo: observer('bar', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n\n });\n\n var Subclass = MyClass.extend({\n foo: observer('baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n var obj = new Subclass();\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj, 'bar', \"BAZ\");\n equal(get(obj, 'count'), 0, 'should not invoke observer after change');\n\n set(obj, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n\n });\n\n testBoth('observer on instance', function(get, set) {\n\n var obj = EmberObject.createWithMixins({\n\n count: 0,\n\n foo: observer('bar', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n\n });\n\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj, 'bar', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n\n });\n\n testBoth('observer on instance overridding class', function(get, set) {\n\n var MyClass = EmberObject.extend({\n\n count: 0,\n\n foo: observer('bar', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n\n });\n\n var obj = MyClass.createWithMixins({\n foo: observer('baz', function() { // <-- change property we observe\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n equal(get(obj, 'count'), 0, 'should not invoke observer immediately');\n\n set(obj, 'bar', \"BAZ\");\n equal(get(obj, 'count'), 0, 'should not invoke observer after change');\n\n set(obj, 'baz', \"BAZ\");\n equal(get(obj, 'count'), 1, 'should invoke observer after change');\n\n });\n\n testBoth('observer should not fire after being destroyed', function(get, set) {\n\n var obj = EmberObject.createWithMixins({\n count: 0,\n foo: observer('bar', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n equal(get(obj, 'count'), 0, 'precond - should not invoke observer immediately');\n\n run(function() { obj.destroy(); });\n\n if (Ember.assert) {\n expectAssertion(function() {\n set(obj, 'bar', \"BAZ\");\n }, \"calling set on destroyed object\");\n } else {\n set(obj, 'bar', \"BAZ\");\n }\n\n equal(get(obj, 'count'), 0, 'should not invoke observer after change');\n });\n // ..........................................................\n // COMPLEX PROPERTIES\n //\n\n\n testBoth('chain observer on class', function(get, set) {\n\n var MyClass = EmberObject.extend({\n count: 0,\n\n foo: observer('bar.baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n var obj1 = MyClass.create({\n bar: { baz: 'biff' }\n });\n\n var obj2 = MyClass.create({\n bar: { baz: 'biff2' }\n });\n\n equal(get(obj1, 'count'), 0, 'should not invoke yet');\n equal(get(obj2, 'count'), 0, 'should not invoke yet');\n\n set(get(obj1, 'bar'), 'baz', 'BIFF1');\n equal(get(obj1, 'count'), 1, 'should invoke observer on obj1');\n equal(get(obj2, 'count'), 0, 'should not invoke yet');\n\n set(get(obj2, 'bar'), 'baz', 'BIFF2');\n equal(get(obj1, 'count'), 1, 'should not invoke again');\n equal(get(obj2, 'count'), 1, 'should invoke observer on obj2');\n });\n\n\n testBoth('chain observer on class', function(get, set) {\n\n var MyClass = EmberObject.extend({\n count: 0,\n\n foo: observer('bar.baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n var obj1 = MyClass.createWithMixins({\n bar: { baz: 'biff' }\n });\n\n var obj2 = MyClass.createWithMixins({\n bar: { baz: 'biff2' },\n bar2: { baz: 'biff3' },\n\n foo: observer('bar2.baz', function() {\n set(this, 'count', get(this, 'count')+1);\n })\n });\n\n equal(get(obj1, 'count'), 0, 'should not invoke yet');\n equal(get(obj2, 'count'), 0, 'should not invoke yet');\n\n set(get(obj1, 'bar'), 'baz', 'BIFF1');\n equal(get(obj1, 'count'), 1, 'should invoke observer on obj1');\n equal(get(obj2, 'count'), 0, 'should not invoke yet');\n\n set(get(obj2, 'bar'), 'baz', 'BIFF2');\n equal(get(obj1, 'count'), 1, 'should not invoke again');\n equal(get(obj2, 'count'), 0, 'should not invoke yet');\n\n set(get(obj2, 'bar2'), 'baz', 'BIFF3');\n equal(get(obj1, 'count'), 1, 'should not invoke again');\n equal(get(obj2, 'count'), 1, 'should invoke observer on obj2');\n });\n });\ndefine(\"ember-runtime/tests/system/object/reopenClass_test\",\n [\"ember-metal/property_get\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var get = __dependency1__.get;\n var EmberObject = __dependency2__[\"default\"];\n\n module('system/object/reopenClass');\n\n test('adds new properties to subclass', function() {\n\n var Subclass = EmberObject.extend();\n Subclass.reopenClass({\n foo: function() { return 'FOO'; },\n bar: 'BAR'\n });\n\n equal(Subclass.foo(), 'FOO', 'Adds method');\n equal(get(Subclass, 'bar'), 'BAR', 'Adds property');\n });\n\n test('class properties inherited by subclasses', function() {\n\n var Subclass = EmberObject.extend();\n Subclass.reopenClass({\n foo: function() { return 'FOO'; },\n bar: 'BAR'\n });\n\n var SubSub = Subclass.extend();\n\n equal(SubSub.foo(), 'FOO', 'Adds method');\n equal(get(SubSub, 'bar'), 'BAR', 'Adds property');\n });\n });\ndefine(\"ember-runtime/tests/system/object/reopen_test\",\n [\"ember-metal/property_get\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var get = __dependency1__.get;\n var EmberObject = __dependency2__[\"default\"];\n\n module('system/core_object/reopen');\n\n test('adds new properties to subclass instance', function() {\n\n var Subclass = EmberObject.extend();\n Subclass.reopen({\n foo: function() { return 'FOO'; },\n bar: 'BAR'\n });\n\n equal( new Subclass().foo(), 'FOO', 'Adds method');\n equal(get(new Subclass(), 'bar'), 'BAR', 'Adds property');\n });\n\n test('reopened properties inherited by subclasses', function() {\n\n var Subclass = EmberObject.extend();\n var SubSub = Subclass.extend();\n\n Subclass.reopen({\n foo: function() { return 'FOO'; },\n bar: 'BAR'\n });\n\n\n equal( new SubSub().foo(), 'FOO', 'Adds method');\n equal(get(new SubSub(), 'bar'), 'BAR', 'Adds property');\n });\n\n // We plan to allow this in the future\n test('does not allow reopening already instantiated classes', function() {\n var Subclass = EmberObject.extend();\n\n Subclass.create();\n\n Subclass.reopen({\n trololol: true\n });\n\n equal(Subclass.create().get('trololol'), true, \"reopen works\");\n });\n });\ndefine(\"ember-runtime/tests/system/object/subclasses_test\",\n [\"ember-metal/run_loop\",\"ember-metal/computed\",\"ember-runtime/system/object\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var computed = __dependency2__.computed;\n var EmberObject = __dependency3__[\"default\"];\n\n module('system/object/subclasses');\n\n test('chains should copy forward to subclasses when prototype created', function () {\n var ObjectWithChains, objWithChains, SubWithChains, SubSub, subSub;\n run(function () {\n ObjectWithChains = EmberObject.extend({\n obj: {\n a: 'a',\n hi: 'hi'\n },\n aBinding: 'obj.a' // add chain\n });\n // realize prototype\n objWithChains = ObjectWithChains.create();\n // should not copy chains from parent yet\n SubWithChains = ObjectWithChains.extend({\n hiBinding: 'obj.hi', // add chain\n hello: computed(function() {\n return this.get('obj.hi') + ' world';\n }).property('hi'), // observe chain\n greetingBinding: 'hello'\n });\n SubSub = SubWithChains.extend();\n // should realize prototypes and copy forward chains\n subSub = SubSub.create();\n });\n equal(subSub.get('greeting'), 'hi world');\n run(function () {\n objWithChains.set('obj.hi', 'hello');\n });\n equal(subSub.get('greeting'), 'hello world');\n });\n });\ndefine(\"ember-runtime/tests/system/object/toString_test\",\n [\"ember-metal/core\",\"ember-metal/utils\",\"ember-runtime/system/object\",\"ember-runtime/system/namespace\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var guidFor = __dependency2__.guidFor;\n var GUID_KEY = __dependency2__.GUID_KEY;\n var EmberObject = __dependency3__[\"default\"];\n var Namespace = __dependency4__[\"default\"];\n\n var originalLookup, lookup;\n\n module('system/object/toString', {\n setup: function() {\n originalLookup = Ember.lookup;\n lookup = Ember.lookup = {};\n },\n teardown: function() {\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"toString() returns the same value if called twice\", function() {\n var Foo = Namespace.create();\n Foo.toString = function() { return \"Foo\"; };\n\n Foo.Bar = EmberObject.extend();\n\n equal(Foo.Bar.toString(), \"Foo.Bar\");\n equal(Foo.Bar.toString(), \"Foo.Bar\");\n\n var obj = Foo.Bar.create();\n\n equal(obj.toString(), \"\");\n equal(obj.toString(), \"\");\n\n equal(Foo.Bar.toString(), \"Foo.Bar\");\n });\n\n test(\"toString on a class returns a useful value when nested in a namespace\", function() {\n var obj;\n\n var Foo = Namespace.create();\n Foo.toString = function() { return \"Foo\"; };\n\n Foo.Bar = EmberObject.extend();\n equal(Foo.Bar.toString(), \"Foo.Bar\");\n\n obj = Foo.Bar.create();\n equal(obj.toString(), \"\");\n\n Foo.Baz = Foo.Bar.extend();\n equal(Foo.Baz.toString(), \"Foo.Baz\");\n\n obj = Foo.Baz.create();\n equal(obj.toString(), \"\");\n\n obj = Foo.Bar.create();\n equal(obj.toString(), \"\");\n });\n\n test(\"toString on a namespace finds the namespace in Ember.lookup\", function() {\n var Foo = lookup.Foo = Namespace.create();\n\n equal(Foo.toString(), \"Foo\");\n });\n\n test(\"toString on a namespace finds the namespace in Ember.lookup\", function() {\n var Foo = lookup.Foo = Namespace.create(), obj;\n\n Foo.Bar = EmberObject.extend();\n\n equal(Foo.Bar.toString(), \"Foo.Bar\");\n\n obj = Foo.Bar.create();\n equal(obj.toString(), \"\");\n });\n\n test('toString includes toStringExtension if defined', function() {\n var Foo = EmberObject.extend({\n toStringExtension: function() {\n return \"fooey\";\n }\n }),\n foo = Foo.create(),\n Bar = EmberObject.extend({}),\n bar = Bar.create();\n // simulate these classes being defined on a Namespace\n Foo[GUID_KEY+'_name'] = 'Foo';\n Bar[GUID_KEY+'_name'] = 'Bar';\n\n equal(bar.toString(), '', 'does not include toStringExtension part');\n equal(foo.toString(), '', 'Includes toStringExtension result');\n });\n });\ndefine(\"ember-runtime/tests/system/object_proxy_test\",\n [\"ember-metal/observer\",\"ember-metal/computed\",\"ember-metal/watching\",\"ember-runtime/tests/props_helper\",\"ember-runtime/system/object_proxy\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var addObserver = __dependency1__.addObserver;\n var removeObserver = __dependency1__.removeObserver;\n var computed = __dependency2__.computed;\n var isWatching = __dependency3__.isWatching;\n var testBoth = __dependency4__.testBoth;\n var ObjectProxy = __dependency5__[\"default\"];\n\n module(\"ObjectProxy\");\n\n testBoth(\"should not proxy properties passed to create\", function (get, set) {\n var Proxy = ObjectProxy.extend({\n cp: computed(function (key, value) {\n if (value) {\n this._cp = value;\n }\n return this._cp;\n })\n });\n var proxy = Proxy.create({\n prop: 'Foo',\n cp: 'Bar'\n });\n\n equal(get(proxy, 'prop'), 'Foo', 'should not have tried to proxy set');\n equal(proxy._cp, 'Bar', 'should use CP setter');\n });\n\n testBoth(\"should proxy properties to content\", function(get, set) {\n var content = {\n firstName: 'Tom',\n lastName: 'Dale',\n unknownProperty: function (key) { return key + ' unknown';}\n },\n proxy = ObjectProxy.create();\n\n equal(get(proxy, 'firstName'), undefined, 'get on proxy without content should return undefined');\n expectAssertion(function () {\n set(proxy, 'firstName', 'Foo');\n }, /Cannot delegate set\\('firstName', Foo\\) to the 'content'/i);\n\n set(proxy, 'content', content);\n\n equal(get(proxy, 'firstName'), 'Tom', 'get on proxy with content should forward to content');\n equal(get(proxy, 'lastName'), 'Dale', 'get on proxy with content should forward to content');\n equal(get(proxy, 'foo'), 'foo unknown', 'get on proxy with content should forward to content');\n\n set(proxy, 'lastName', 'Huda');\n\n equal(get(content, 'lastName'), 'Huda', 'content should have new value from set on proxy');\n equal(get(proxy, 'lastName'), 'Huda', 'proxy should have new value from set on proxy');\n\n set(proxy, 'content', {firstName: 'Yehuda', lastName: 'Katz'});\n\n equal(get(proxy, 'firstName'), 'Yehuda', 'proxy should reflect updated content');\n equal(get(proxy, 'lastName'), 'Katz', 'proxy should reflect updated content');\n });\n\n testBoth(\"should work with watched properties\", function(get, set) {\n var content1 = {firstName: 'Tom', lastName: 'Dale'},\n content2 = {firstName: 'Yehuda', lastName: 'Katz'},\n Proxy,\n proxy,\n count = 0,\n last;\n\n Proxy = ObjectProxy.extend({\n fullName: computed(function () {\n var firstName = this.get('firstName'),\n lastName = this.get('lastName');\n if (firstName && lastName) {\n return firstName + ' ' + lastName;\n }\n return firstName || lastName;\n }).property('firstName', 'lastName')\n });\n\n proxy = Proxy.create();\n\n addObserver(proxy, 'fullName', function () {\n last = get(proxy, 'fullName');\n count++;\n });\n\n // proxy without content returns undefined\n equal(get(proxy, 'fullName'), undefined);\n\n // setting content causes all watched properties to change\n set(proxy, 'content', content1);\n // both dependent keys changed\n equal(count, 2);\n equal(last, 'Tom Dale');\n\n // setting property in content causes proxy property to change\n set(content1, 'lastName', 'Huda');\n equal(count, 3);\n equal(last, 'Tom Huda');\n\n // replacing content causes all watched properties to change\n set(proxy, 'content', content2);\n // both dependent keys changed\n equal(count, 5);\n equal(last, 'Yehuda Katz');\n // content1 is no longer watched\n ok(!isWatching(content1, 'firstName'), 'not watching firstName');\n ok(!isWatching(content1, 'lastName'), 'not watching lastName');\n\n // setting property in new content\n set(content2, 'firstName', 'Tomhuda');\n equal(last, 'Tomhuda Katz');\n equal(count, 6);\n\n // setting property in proxy syncs with new content\n set(proxy, 'lastName', 'Katzdale');\n equal(count, 7);\n equal(last, 'Tomhuda Katzdale');\n equal(get(content2, 'firstName'), 'Tomhuda');\n equal(get(content2, 'lastName'), 'Katzdale');\n });\n\n test(\"set and get should work with paths\", function () {\n var content = {foo: {bar: 'baz'}},\n proxy = ObjectProxy.create({content: content}),\n count = 0;\n proxy.set('foo.bar', 'hello');\n equal(proxy.get('foo.bar'), 'hello');\n equal(proxy.get('content.foo.bar'), 'hello');\n\n proxy.addObserver('foo.bar', function () {\n count++;\n });\n\n proxy.set('foo.bar', 'bye');\n\n equal(count, 1);\n equal(proxy.get('foo.bar'), 'bye');\n equal(proxy.get('content.foo.bar'), 'bye');\n });\n\n testBoth(\"should transition between watched and unwatched strategies\", function(get, set) {\n var content = {foo: 'foo'},\n proxy = ObjectProxy.create({content: content}),\n count = 0;\n\n function observer() {\n count++;\n }\n\n equal(get(proxy, 'foo'), 'foo');\n\n set(content, 'foo', 'bar');\n\n equal(get(proxy, 'foo'), 'bar');\n\n set(proxy, 'foo', 'foo');\n\n equal(get(content, 'foo'), 'foo');\n equal(get(proxy, 'foo'), 'foo');\n\n addObserver(proxy, 'foo', observer);\n\n equal(count, 0);\n equal(get(proxy, 'foo'), 'foo');\n\n set(content, 'foo', 'bar');\n\n equal(count, 1);\n equal(get(proxy, 'foo'), 'bar');\n\n set(proxy, 'foo', 'foo');\n\n equal(count, 2);\n equal(get(content, 'foo'), 'foo');\n equal(get(proxy, 'foo'), 'foo');\n\n removeObserver(proxy, 'foo', observer);\n\n set(content, 'foo', 'bar');\n\n equal(get(proxy, 'foo'), 'bar');\n\n set(proxy, 'foo', 'foo');\n\n equal(get(content, 'foo'), 'foo');\n equal(get(proxy, 'foo'), 'foo');\n });\n\n testBoth('setting `undefined` to a proxied content property should override its existing value', function(get, set) {\n var proxyObject = ObjectProxy.create({\n content: {\n prop: 'emberjs'\n }\n });\n set(proxyObject, 'prop', undefined);\n equal(get(proxyObject, 'prop'), undefined, 'sets the `undefined` value to the proxied content');\n });\n });\ndefine(\"ember-runtime/tests/system/set/copyable_suite_test\",\n [\"ember-runtime/tests/suites/copyable\",\"ember-runtime/system/set\",\"ember-metal/utils\",\"ember-metal/property_get\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var CopyableTests = __dependency1__[\"default\"];\n var Set = __dependency2__[\"default\"];\n var generateGuid = __dependency3__.generateGuid;\n var get = __dependency4__.get;\n\n CopyableTests.extend({\n name: 'Ember.Set Copyable',\n\n newObject: function() {\n var set = new Set();\n set.addObject(generateGuid());\n return set;\n },\n\n isEqual: function(a,b) {\n if (!(a instanceof Set)) return false;\n if (!(b instanceof Set)) return false;\n return get(a, 'firstObject') === get(b, 'firstObject');\n },\n\n shouldBeFreezable: true\n }).run();\n });\ndefine(\"ember-runtime/tests/system/set/enumerable_suite_test\",\n [\"ember-runtime/tests/suites/mutable_enumerable\",\"ember-runtime/system/set\",\"ember-metal/property_get\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var MutableEnumerableTests = __dependency1__[\"default\"];\n var Set = __dependency2__[\"default\"];\n var get = __dependency3__.get;\n\n MutableEnumerableTests.extend({\n\n name: 'Ember.Set',\n\n newObject: function(ary) {\n ary = ary ? ary.slice() : this.newFixture(3);\n var ret = new Set();\n ret.addObjects(ary);\n return ret;\n },\n\n mutate: function(obj) {\n obj.addObject(get(obj, 'length')+1);\n },\n\n toArray: function(obj) {\n return obj.toArray ? obj.toArray() : obj.slice(); // make a copy.\n }\n\n }).run();\n });\ndefine(\"ember-runtime/tests/system/set/extra_test\",\n [\"ember-metal/enumerable_utils\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/observer\",\"ember-runtime/system/set\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var EnumerableUtils = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var addObserver = __dependency4__.addObserver;\n var Set = __dependency5__[\"default\"];\n\n module('Set.init');\n\n test('passing an array to new Set() should instantiate w/ items', function() {\n\n var ary = [1,2,3];\n var aSet = new Set(ary);\n var count = 0;\n\n equal(get(aSet, 'length'), 3, 'should have three items');\n aSet.forEach(function(x) {\n ok(EnumerableUtils.indexOf(ary, x)>=0, 'should find passed item in array');\n count++;\n });\n equal(count, 3, 'iterating should have returned three objects');\n });\n\n module('Set.clear');\n\n test('should clear a set of its content', function() {\n\n var aSet = new Set([1,2,3]);\n var count = 0;\n\n equal(get(aSet, 'length'), 3, 'should have three items');\n ok(get(aSet, 'firstObject'), 'firstObject should return an object');\n ok(get(aSet, 'lastObject'), 'lastObject should return an object');\n addObserver(aSet, '[]', function() { count++; });\n\n aSet.clear();\n equal(get(aSet, 'length'), 0, 'should have 0 items');\n equal(count, 1, 'should have notified of content change');\n equal(get(aSet, 'firstObject'), null, 'firstObject should return nothing');\n equal(get(aSet, 'lastObject'), null, 'lastObject should return nothing');\n\n count = 0;\n aSet.forEach(function() { count++; });\n equal(count, 0, 'iterating over items should not invoke callback');\n\n });\n\n // ..........................................................\n // Set.pop\n //\n\n module('Set.pop');\n\n test('calling pop should return an object and remove it', function() {\n\n var aSet = new Set([1,2,3]);\n var count = 0, obj;\n while(count<10 && (obj = aSet.pop())) {\n equal(aSet.contains(obj), false, 'set should no longer contain object');\n count++;\n equal(get(aSet, 'length'), 3-count, 'length should be shorter');\n }\n\n equal(count, 3, 'should only pop 3 objects');\n equal(get(aSet, 'length'), 0, 'final length should be zero');\n equal(aSet.pop(), null, 'extra pops should do nothing');\n });\n\n // ..........................................................\n // Set.aliases\n //\n\n module('Set aliases');\n\n test('method aliases', function() {\n var aSet = new Set();\n equal(aSet.add, aSet.addObject, 'add -> addObject');\n equal(aSet.remove, aSet.removeObject, 'remove -> removeObject');\n equal(aSet.addEach, aSet.addObjects, 'addEach -> addObjects');\n equal(aSet.removeEach, aSet.removeObjects, 'removeEach -> removeObjects');\n\n equal(aSet.push, aSet.addObject, 'push -> addObject');\n equal(aSet.unshift, aSet.addObject, 'unshift -> addObject');\n equal(aSet.shift, aSet.pop, 'shift -> pop');\n });\n });\ndefine(\"ember-runtime/tests/system/string/camelize\",\n [\"ember-metal/core\",\"ember-runtime/system/string\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var camelize = __dependency2__.camelize;\n\n module('EmberStringUtils.camelize');\n\n if (!Ember.EXTEND_PROTOTYPES && !Ember.EXTEND_PROTOTYPES.String) {\n test(\"String.prototype.camelize is not modified without EXTEND_PROTOTYPES\", function() {\n ok(\"undefined\" === typeof String.prototype.camelize, 'String.prototype helper disabled');\n });\n }\n\n test(\"camelize normal string\", function() {\n deepEqual(camelize('my favorite items'), 'myFavoriteItems');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('my favorite items'.camelize(), 'myFavoriteItems');\n }\n });\n\n test(\"camelize capitalized string\", function() {\n deepEqual(camelize('I Love Ramen'), 'iLoveRamen');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('I Love Ramen'.camelize(), 'iLoveRamen');\n }\n });\n\n test(\"camelize dasherized string\", function() {\n deepEqual(camelize('css-class-name'), 'cssClassName');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('css-class-name'.camelize(), 'cssClassName');\n }\n });\n\n test(\"camelize underscored string\", function() {\n deepEqual(camelize('action_name'), 'actionName');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('action_name'.camelize(), 'actionName');\n }\n });\n\n test(\"camelize dot notation string\", function() {\n deepEqual(camelize('action.name'), 'actionName');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('action.name'.camelize(), 'actionName');\n }\n });\n\n test(\"does nothing with camelcased string\", function() {\n deepEqual(camelize('innerHTML'), 'innerHTML');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('innerHTML'.camelize(), 'innerHTML');\n }\n });\n });\ndefine(\"ember-runtime/tests/system/string/capitalize\",\n [\"ember-metal/core\",\"ember-runtime/system/string\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var capitalize = __dependency2__.capitalize;\n\n module('EmberStringUtils.capitalize');\n\n if (!Ember.EXTEND_PROTOTYPES && !Ember.EXTEND_PROTOTYPES.String) {\n test(\"String.prototype.capitalize is not modified without EXTEND_PROTOTYPES\", function() {\n ok(\"undefined\" === typeof String.prototype.capitalize, 'String.prototype helper disabled');\n });\n }\n\n test(\"capitalize normal string\", function() {\n deepEqual(capitalize('my favorite items'), 'My favorite items');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('my favorite items'.capitalize(), 'My favorite items');\n }\n });\n\n test(\"capitalize dasherized string\", function() {\n deepEqual(capitalize('css-class-name'), 'Css-class-name');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('css-class-name'.capitalize(), 'Css-class-name');\n }\n });\n\n test(\"capitalize underscored string\", function() {\n deepEqual(capitalize('action_name'), 'Action_name');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('action_name'.capitalize(), 'Action_name');\n }\n });\n\n test(\"capitalize camelcased string\", function() {\n deepEqual(capitalize('innerHTML'), 'InnerHTML');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('innerHTML'.capitalize(), 'InnerHTML');\n }\n });\n\n test(\"does nothing with capitalized string\", function() {\n deepEqual(capitalize('Capitalized string'), 'Capitalized string');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('Capitalized string'.capitalize(), 'Capitalized string');\n }\n });\n });\ndefine(\"ember-runtime/tests/system/string/classify\",\n [\"ember-metal/core\",\"ember-runtime/system/string\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var classify = __dependency2__.classify;\n\n module('EmberStringUtils.classify');\n\n if (!Ember.EXTEND_PROTOTYPES && !Ember.EXTEND_PROTOTYPES.String) {\n test(\"String.prototype.classify is not modified without EXTEND_PROTOTYPES\", function() {\n ok(\"undefined\" === typeof String.prototype.classify, 'String.prototype helper disabled');\n });\n }\n\n test(\"classify normal string\", function() {\n deepEqual(classify('my favorite items'), 'MyFavoriteItems');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('my favorite items'.classify(), 'MyFavoriteItems');\n }\n });\n\n test(\"classify dasherized string\", function() {\n deepEqual(classify('css-class-name'), 'CssClassName');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('css-class-name'.classify(), 'CssClassName');\n }\n });\n\n test(\"classify underscored string\", function() {\n deepEqual(classify('action_name'), 'ActionName');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('action_name'.classify(), 'ActionName');\n }\n });\n\n test(\"does nothing with classified string\", function() {\n deepEqual(classify('InnerHTML'), 'InnerHTML');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('InnerHTML'.classify(), 'InnerHTML');\n }\n });\n });\ndefine(\"ember-runtime/tests/system/string/dasherize\",\n [\"ember-metal/core\",\"ember-runtime/system/string\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var dasherize = __dependency2__.dasherize;\n\n module('EmberStringUtils.dasherize');\n\n if (!Ember.EXTEND_PROTOTYPES && !Ember.EXTEND_PROTOTYPES.String) {\n test(\"String.prototype.dasherize is not modified without EXTEND_PROTOTYPES\", function() {\n ok(\"undefined\" === typeof String.prototype.dasherize, 'String.prototype helper disabled');\n });\n }\n\n test(\"dasherize normal string\", function() {\n deepEqual(dasherize('my favorite items'), 'my-favorite-items');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('my favorite items'.dasherize(), 'my-favorite-items');\n }\n });\n\n test(\"does nothing with dasherized string\", function() {\n deepEqual(dasherize('css-class-name'), 'css-class-name');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('css-class-name'.dasherize(), 'css-class-name');\n }\n });\n\n test(\"dasherize underscored string\", function() {\n deepEqual(dasherize('action_name'), 'action-name');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('action_name'.dasherize(), 'action-name');\n }\n });\n\n test(\"dasherize camelcased string\", function() {\n deepEqual(dasherize('innerHTML'), 'inner-html');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('innerHTML'.dasherize(), 'inner-html');\n }\n });\n\n test(\"dasherize string that is the property name of Object.prototype\", function() {\n deepEqual(dasherize('toString'), 'to-string');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('toString'.dasherize(), 'to-string');\n }\n });\n });\ndefine(\"ember-runtime/tests/system/string/decamelize\",\n [\"ember-metal/core\",\"ember-runtime/system/string\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var decamelize = __dependency2__.decamelize;\n\n module('EmberStringUtils.decamelize');\n\n if (!Ember.EXTEND_PROTOTYPES && !Ember.EXTEND_PROTOTYPES.String) {\n test(\"String.prototype.decamelize is not modified without EXTEND_PROTOTYPES\", function() {\n ok(\"undefined\" === typeof String.prototype.decamelize, 'String.prototype helper disabled');\n });\n }\n\n test(\"does nothing with normal string\", function() {\n deepEqual(decamelize('my favorite items'), 'my favorite items');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('my favorite items'.decamelize(), 'my favorite items');\n }\n });\n\n test(\"does nothing with dasherized string\", function() {\n deepEqual(decamelize('css-class-name'), 'css-class-name');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('css-class-name'.decamelize(), 'css-class-name');\n }\n });\n\n test(\"does nothing with underscored string\", function() {\n deepEqual(decamelize('action_name'), 'action_name');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('action_name'.decamelize(), 'action_name');\n }\n });\n\n test(\"converts a camelized string into all lower case separated by underscores.\", function() {\n deepEqual(decamelize('innerHTML'), 'inner_html');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('innerHTML'.decamelize(), 'inner_html');\n }\n });\n\n test(\"decamelizes strings with numbers\", function() {\n deepEqual(decamelize('size160Url'), 'size160_url');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('size160Url'.decamelize(), 'size160_url');\n }\n });\n });\ndefine(\"ember-runtime/tests/system/string/fmt_string\",\n [\"ember-metal/core\",\"ember-runtime/system/string\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var fmt = __dependency2__.fmt;\n\n module('EmberStringUtils.fmt');\n\n if (!Ember.EXTEND_PROTOTYPES && !Ember.EXTEND_PROTOTYPES.String) {\n test(\"String.prototype.fmt is not modified without EXTEND_PROTOTYPES\", function() {\n ok(\"undefined\" === typeof String.prototype.fmt, 'String.prototype helper disabled');\n });\n }\n\n test(\"'Hello %@ %@'.fmt('John', 'Doe') => 'Hello John Doe'\", function() {\n equal(fmt('Hello %@ %@', ['John', 'Doe']), 'Hello John Doe');\n if (Ember.EXTEND_PROTOTYPES) {\n equal('Hello %@ %@'.fmt('John', 'Doe'), 'Hello John Doe');\n }\n });\n\n test(\"'Hello %@2 %@1'.fmt('John', 'Doe') => 'Hello Doe John'\", function() {\n equal(fmt('Hello %@2 %@1', ['John', 'Doe']), 'Hello Doe John');\n if (Ember.EXTEND_PROTOTYPES) {\n equal('Hello %@2 %@1'.fmt('John', 'Doe'), 'Hello Doe John');\n }\n });\n\n test(\"'%@08 %@07 %@06 %@05 %@04 %@03 %@02 %@01'.fmt('One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight') => 'Eight Seven Six Five Four Three Two One'\", function() {\n equal(fmt('%@08 %@07 %@06 %@05 %@04 %@03 %@02 %@01', ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight']), 'Eight Seven Six Five Four Three Two One');\n\n if (Ember.EXTEND_PROTOTYPES) {\n equal('%@08 %@07 %@06 %@05 %@04 %@03 %@02 %@01'.fmt('One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight'), 'Eight Seven Six Five Four Three Two One');\n }\n });\n\n test(\"'data: %@'.fmt({id: 3}) => 'data: {id: 3}'\", function() {\n equal(fmt('data: %@', [{id: 3}]), 'data: {id: 3}');\n if (Ember.EXTEND_PROTOTYPES) {\n equal('data: %@'.fmt({id: 3}), 'data: {id: 3}');\n }\n });\n });\ndefine(\"ember-runtime/tests/system/string/loc_test\",\n [\"ember-metal/core\",\"ember-runtime/system/string\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var loc = __dependency2__.loc;\n\n var oldString;\n\n module('EmberStringUtils.loc', {\n setup: function() {\n oldString = Ember.STRINGS;\n Ember.STRINGS = {\n '_Hello World': 'Bonjour le monde',\n '_Hello %@ %@': 'Bonjour %@ %@',\n '_Hello %@# %@#': 'Bonjour %@2 %@1'\n };\n },\n\n teardown: function() {\n Ember.STRINGS = oldString;\n }\n });\n\n if (!Ember.EXTEND_PROTOTYPES && !Ember.EXTEND_PROTOTYPES.String) {\n test(\"String.prototype.loc is not available without EXTEND_PROTOTYPES\", function() {\n ok(\"undefined\" === typeof String.prototype.loc, 'String.prototype helper disabled');\n });\n }\n\n test(\"'_Hello World'.loc() => 'Bonjour le monde'\", function() {\n equal(loc('_Hello World'), 'Bonjour le monde');\n if (Ember.EXTEND_PROTOTYPES) {\n equal('_Hello World'.loc(), 'Bonjour le monde');\n }\n });\n\n test(\"'_Hello %@ %@'.loc('John', 'Doe') => 'Bonjour John Doe'\", function() {\n equal(loc('_Hello %@ %@', ['John', 'Doe']), 'Bonjour John Doe');\n if (Ember.EXTEND_PROTOTYPES) {\n equal('_Hello %@ %@'.loc('John', 'Doe'), 'Bonjour John Doe');\n }\n });\n\n test(\"'_Hello %@# %@#'.loc('John', 'Doe') => 'Bonjour Doe John'\", function() {\n equal(loc('_Hello %@# %@#', ['John', 'Doe']), 'Bonjour Doe John');\n if (Ember.EXTEND_PROTOTYPES) {\n equal('_Hello %@# %@#'.loc('John', 'Doe'), 'Bonjour Doe John');\n }\n });\n\n test(\"'_Not In Strings'.loc() => '_Not In Strings'\", function() {\n equal(loc('_Not In Strings'), '_Not In Strings');\n if (Ember.EXTEND_PROTOTYPES) {\n equal('_Not In Strings'.loc(), '_Not In Strings');\n }\n });\n });\ndefine(\"ember-runtime/tests/system/string/underscore\",\n [\"ember-metal/core\",\"ember-runtime/system/string\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var underscore = __dependency2__.underscore;\n\n module('EmberStringUtils.underscore');\n\n if (!Ember.EXTEND_PROTOTYPES && !Ember.EXTEND_PROTOTYPES.String) {\n test(\"String.prototype.underscore is not available without EXTEND_PROTOTYPES\", function() {\n ok(\"undefined\" === typeof String.prototype.underscore, 'String.prototype helper disabled');\n });\n }\n\n test(\"with normal string\", function() {\n deepEqual(underscore('my favorite items'), 'my_favorite_items');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('my favorite items'.underscore(), 'my_favorite_items');\n }\n });\n\n test(\"with dasherized string\", function() {\n deepEqual(underscore('css-class-name'), 'css_class_name');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('css-class-name'.underscore(), 'css_class_name');\n }\n });\n\n test(\"does nothing with underscored string\", function() {\n deepEqual(underscore('action_name'), 'action_name');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('action_name'.underscore(), 'action_name');\n }\n });\n\n test(\"with camelcased string\", function() {\n deepEqual(underscore('innerHTML'), 'inner_html');\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('innerHTML'.underscore(), 'inner_html');\n }\n });\n });\ndefine(\"ember-runtime/tests/system/string/w_test\",\n [\"ember-metal/core\",\"ember-runtime/system/string\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var w = __dependency2__.w;\n\n module('EmberStringUtils.w');\n\n if (!Ember.EXTEND_PROTOTYPES && !Ember.EXTEND_PROTOTYPES.String) {\n test(\"String.prototype.w is not available without EXTEND_PROTOTYPES\", function() {\n ok(\"undefined\" === typeof String.prototype.w, 'String.prototype helper disabled');\n });\n }\n\n test(\"'one two three'.w() => ['one','two','three']\", function() {\n deepEqual(w('one two three'), ['one','two','three']);\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('one two three'.w(), ['one','two','three']);\n }\n });\n\n test(\"'one two three'.w() with extra spaces between words => ['one','two','three']\", function() {\n deepEqual(w('one two three'), ['one','two','three']);\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('one two three'.w(), ['one','two','three']);\n }\n });\n\n test(\"'one two three'.w() with tabs\", function() {\n deepEqual(w('one\\ttwo three'), ['one','two','three']);\n if (Ember.EXTEND_PROTOTYPES) {\n deepEqual('one\\ttwo three'.w(), ['one','two','three']);\n }\n });\n });\ndefine(\"ember-runtime/tests/system/subarray_test\",\n [\"ember-metal/enumerable_utils\",\"ember-runtime/system/subarray\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var EnumerableUtils = __dependency1__[\"default\"];\n var SubArray = __dependency2__[\"default\"];\n\n var forEach = EnumerableUtils.forEach, subarray;\n\n module('SubArray', {\n setup: function () {\n subarray = new SubArray();\n }\n });\n\n function operationsString() {\n var str = \"\";\n forEach(subarray._operations, function (operation) {\n str += \" \" + operation.type + \":\" + operation.count;\n });\n return str.substring(1);\n }\n\n test(\"Subarray operations are initially retain:n\", function() {\n subarray = new SubArray(10);\n\n equal(operationsString(), \"r:10\", \"subarray operations are initially retain n\");\n });\n\n test(\"Retains compose with retains on insert\", function() {\n subarray.addItem(0, true);\n subarray.addItem(1, true);\n subarray.addItem(2, true);\n\n equal(operationsString(), \"r:3\", \"Retains compose with retains on insert.\");\n });\n\n test(\"Retains compose with retains on removal\", function() {\n subarray.addItem(0, true);\n subarray.addItem(1, false);\n subarray.addItem(2, true);\n\n equal(operationsString(), \"r:1 f:1 r:1\", \"precond - operations are initially correct.\");\n\n subarray.removeItem(1);\n\n equal(operationsString(), \"r:2\", \"Retains compose with retains on removal.\");\n });\n\n test(\"Filters compose with filters on insert\", function() {\n subarray.addItem(0, false);\n subarray.addItem(1, false);\n subarray.addItem(2, false);\n\n equal(operationsString(), \"f:3\", \"Retains compose with retains on insert.\");\n });\n\n test(\"Filters compose with filters on removal\", function() {\n subarray.addItem(0, false);\n subarray.addItem(1, true);\n subarray.addItem(2, false);\n\n equal(operationsString(), \"f:1 r:1 f:1\", \"precond - operations are initially correct.\");\n\n subarray.removeItem(1);\n\n equal(operationsString(), \"f:2\", \"Filters compose with filters on removal.\");\n });\n\n test(\"Filters split retains\", function() {\n subarray.addItem(0, true);\n subarray.addItem(1, true);\n subarray.addItem(1, false);\n\n equal(operationsString(), \"r:1 f:1 r:1\", \"Filters split retains.\");\n });\n\n test(\"Retains split filters\", function() {\n subarray.addItem(0, false);\n subarray.addItem(1, false);\n subarray.addItem(1, true);\n\n equal(operationsString(), \"f:1 r:1 f:1\", \"Retains split filters.\");\n });\n\n test(\"`addItem` returns the index of the item in the subarray\", function() {\n var indexes = [];\n\n equal(subarray.addItem(0, true), 0, \"`addItem` returns the index of the item in the subarray\");\n subarray.addItem(1, false);\n equal(subarray.addItem(2, true), 1, \"`addItem` returns the index of the item in the subarray\");\n\n equal(operationsString(), \"r:1 f:1 r:1\", \"Operations are correct.\");\n });\n\n test(\"`addItem` returns -1 if the new item is not in the subarray\", function() {\n equal(subarray.addItem(0, false), -1, \"`addItem` returns -1 if the item is not in the subarray\");\n });\n\n test(\"`removeItem` returns the index of the item in the subarray\", function() {\n subarray.addItem(0, true);\n subarray.addItem(1, false);\n subarray.addItem(2, true);\n\n equal(subarray.removeItem(2), 1, \"`removeItem` returns the index of the item in the subarray\");\n equal(subarray.removeItem(0), 0, \"`removeItem` returns the index of the item in the subarray\");\n });\n\n test(\"`removeItem` returns -1 if the item was not in the subarray\", function() {\n subarray.addItem(0, true);\n subarray.addItem(1, false);\n\n equal(subarray.removeItem(1), -1, \"`removeItem` returns -1 if the item is not in the subarray\");\n });\n\n test(\"`removeItem` raises a sensible exception when there are no operations in the subarray\", function() {\n var subarrayExploder = function() {\n subarray.removeItem(9);\n };\n throws(subarrayExploder, /never\\ been\\ added/, \"`removeItem` raises a sensible exception when there are no operations in the subarray\");\n });\n\n test(\"left composition does not confuse a subsequent right non-composition\", function() {\n subarray.addItem(0, true);\n subarray.addItem(1, false);\n subarray.addItem(2, true);\n equal(operationsString(), \"r:1 f:1 r:1\", \"precond - initial state of subarray is as expected\");\n\n subarray.addItem(1, true);\n equal(operationsString(), \"r:2 f:1 r:1\", \"left-composition does not confuse right non-composition\");\n });\n });\ndefine(\"ember-runtime/tests/system/tracked_array_test\",\n [\"ember-metal/enumerable_utils\",\"ember-runtime/system/tracked_array\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var EnumerableUtils = __dependency1__[\"default\"];\n var TrackedArray = __dependency2__[\"default\"];\n\n var forEach = EnumerableUtils.forEach, trackedArray,\n RETAIN = TrackedArray.RETAIN,\n INSERT = TrackedArray.INSERT,\n DELETE = TrackedArray.DELETE;\n\n module('Ember.TrackedArray');\n\n test(\"operations for a tracked array of length n are initially retain:n\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n\n equal(\"r:4\", trackedArray.toString(), \"initial mutation is retain n\");\n });\n\n test(\"insert zero items is a no-op\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n\n trackedArray.addItems(2, []);\n\n equal(trackedArray.toString(), \"r:4\", \"insert:0 is a no-op\");\n\n deepEqual(trackedArray._operations[0].items, [1,2,3,4], \"after a no-op, existing operation has right items\");\n });\n\n test(\"inserts can split retains\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n\n trackedArray.addItems(2, ['a']);\n\n equal(trackedArray.toString(), \"r:2 i:1 r:2\", \"inserts can split retains\");\n\n deepEqual(trackedArray._operations[0].items, [1,2], \"split retains have the right items\");\n deepEqual(trackedArray._operations[1].items, ['a'], \"inserts have the right items\");\n deepEqual(trackedArray._operations[2].items, [3,4], \"split retains have the right items\");\n });\n\n test(\"inserts can expand (split/compose) inserts\", function() {\n trackedArray = new TrackedArray([]);\n\n trackedArray.addItems(0, [1,2,3,4]);\n trackedArray.addItems(2, ['a']);\n\n equal(trackedArray.toString(), \"i:5\", \"inserts can expand inserts\");\n\n deepEqual(trackedArray._operations[0].items, [1,2,'a',3,4], \"expanded inserts have the right items\");\n });\n\n test(\"inserts left of inserts compose\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n\n trackedArray.addItems(2, ['b']);\n trackedArray.addItems(2, ['a']);\n\n equal(trackedArray.toString(), \"r:2 i:2 r:2\", \"inserts left of inserts compose\");\n\n deepEqual(trackedArray._operations[0].items, [1,2], \"split retains have the right items\");\n deepEqual(trackedArray._operations[1].items, ['a', 'b'], \"composed inserts have the right items\");\n deepEqual(trackedArray._operations[2].items, [3,4], \"split retains have the right items\");\n });\n\n test(\"inserts right of inserts compose\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n\n trackedArray.addItems(2, ['a']);\n trackedArray.addItems(3, ['b']);\n\n equal(trackedArray.toString(), \"r:2 i:2 r:2\", \"inserts right of inserts compose\");\n\n deepEqual(trackedArray._operations[0].items, [1,2], \"split retains have the right items\");\n deepEqual(trackedArray._operations[1].items, ['a', 'b'], \"composed inserts have the right items\");\n deepEqual(trackedArray._operations[2].items, [3,4], \"split retains have the right items\");\n });\n\n test(\"delete zero items is a no-op\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n\n trackedArray.addItems(2, []);\n\n equal(trackedArray.toString(), \"r:4\", \"insert:0 is a no-op\");\n\n deepEqual(trackedArray._operations[0].items, [1,2,3,4], \"after a no-op, existing operation has right items\");\n });\n\n test(\"deletes compose with several inserts and retains\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n\n trackedArray.addItems(4, ['e']);\n trackedArray.addItems(3, ['d']);\n trackedArray.addItems(2, ['c']);\n trackedArray.addItems(1, ['b']);\n trackedArray.addItems(0, ['a']); // a1b2c3d4e i1r1i1r1i1r1i1r1i1\n\n trackedArray.removeItems(0, 9);\n equal(trackedArray.toString(), \"d:4\", \"deletes compose with several inserts and retains\");\n });\n\n test(\"deletes compose with several inserts and retains and an adjacent delete\", function() {\n trackedArray = new TrackedArray([1,2,3,4,5]);\n\n trackedArray.removeItems(0, 1);\n trackedArray.addItems(4, ['e']);\n trackedArray.addItems(3, ['d']);\n trackedArray.addItems(2, ['c']);\n trackedArray.addItems(1, ['b']);\n trackedArray.addItems(0, ['a']); // a2b3c4d5e d1i1r1i1r1i1r1i1r1i1\n\n trackedArray.removeItems(0, 9);\n equal(trackedArray.toString(), \"d:5\", \"deletes compose with several inserts, retains, and a single prior delete\");\n });\n\n test(\"deletes compose with several inserts and retains and can reduce the last one\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n\n trackedArray.addItems(4, ['e', 'f']);\n trackedArray.addItems(3, ['d']);\n trackedArray.addItems(2, ['c']);\n trackedArray.addItems(1, ['b']);\n trackedArray.addItems(0, ['a']); // a1b2c3d4e i1r1i1r1i1r1i1r1i2\n\n trackedArray.removeItems(0, 9);\n equal(trackedArray.toString(), \"d:4 i:1\", \"deletes compose with several inserts and retains, reducing the last one\");\n deepEqual(trackedArray._operations[1].items, ['f'], \"last mutation's items is correct\");\n });\n\n test(\"deletes can split retains\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n trackedArray.removeItems(0, 2);\n\n equal(trackedArray.toString(), \"d:2 r:2\", \"deletes can split retains\");\n deepEqual(trackedArray._operations[1].items, [3,4], \"retains reduced by delete have the right items\");\n });\n\n test(\"deletes can trim retains on the right\", function() {\n trackedArray = new TrackedArray([1,2,3]);\n trackedArray.removeItems(2, 1);\n\n equal(trackedArray.toString(), \"r:2 d:1\", \"deletes can trim retains on the right\");\n deepEqual(trackedArray._operations[0].items, [1,2], \"retains reduced by delete have the right items\");\n });\n\n test(\"deletes can trim retains on the left\", function() {\n trackedArray = new TrackedArray([1,2,3]);\n trackedArray.removeItems(0, 1);\n\n equal(trackedArray.toString(), \"d:1 r:2\", \"deletes can trim retains on the left\");\n deepEqual(trackedArray._operations[1].items, [2,3], \"retains reduced by delete have the right items\");\n });\n\n test(\"deletes can split inserts\", function() {\n trackedArray = new TrackedArray([]);\n trackedArray.addItems(0, ['a','b','c']);\n trackedArray.removeItems(0, 1);\n\n equal(trackedArray.toString(), \"i:2\", \"deletes can split inserts\");\n deepEqual(trackedArray._operations[0].items, ['b', 'c'], \"inserts reduced by delete have the right items\");\n });\n\n test(\"deletes can trim inserts on the right\", function() {\n trackedArray = new TrackedArray([]);\n trackedArray.addItems(0, ['a','b','c']);\n trackedArray.removeItems(2, 1);\n\n equal(trackedArray.toString(), \"i:2\", \"deletes can trim inserts on the right\");\n deepEqual(trackedArray._operations[0].items, ['a', 'b'], \"inserts reduced by delete have the right items\");\n });\n\n test(\"deletes can trim inserts on the left\", function() {\n trackedArray = new TrackedArray([]);\n trackedArray.addItems(0, ['a','b','c']);\n trackedArray.removeItems(0, 1);\n\n equal(trackedArray.toString(), \"i:2\", \"deletes can trim inserts on the right\");\n deepEqual(trackedArray._operations[0].items, ['b', 'c'], \"inserts reduced by delete have the right items\");\n });\n\n test(\"deletes can trim inserts on the left while composing with a delete on the left\", function() {\n trackedArray = new TrackedArray(['a']);\n trackedArray.removeItems(0, 1);\n trackedArray.addItems(0, ['b', 'c']);\n trackedArray.removeItems(0, 1);\n\n equal(trackedArray.toString(), \"d:1 i:1\", \"deletes can trim inserts and compose with a delete on the left\");\n deepEqual(trackedArray._operations[1].items, ['c'], \"inserts reduced by delete have the right items\");\n });\n\n test(\"deletes can reduce an insert or retain, compose with several mutations of different types and reduce the last mutation if it is non-delete\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n\n trackedArray.addItems(4, ['e', 'f']); // 1234ef\n trackedArray.addItems(3, ['d']); // 123d4ef\n trackedArray.addItems(2, ['c']); // 12c3d4ef\n trackedArray.addItems(1, ['b']); // 1b2c3d4ef\n trackedArray.addItems(0, ['a','a','a']); // aaa1b2c3d4ef i3r1i1r1i1r1i1r1i2\n\n trackedArray.removeItems(1, 10);\n equal(trackedArray.toString(), \"i:1 d:4 i:1\", \"deletes reduce an insert, compose with several inserts and retains, reducing the last one\");\n deepEqual(trackedArray._operations[0].items, ['a'], \"first reduced mutation's items is correct\");\n deepEqual(trackedArray._operations[2].items, ['f'], \"last reduced mutation's items is correct\");\n });\n\n test(\"removeItems returns the removed items\", function() {\n trackedArray = new TrackedArray([1,2,3,4]);\n deepEqual(trackedArray.removeItems(1, 2), [2,3], \"`removeItems` returns the removed items\");\n });\n\n test(\"apply invokes the callback with each group of items and the mutation's calculated offset\", function() {\n var i = 0;\n trackedArray = new TrackedArray([1,2,3,4]);\n\n trackedArray.addItems(2, ['a','b','c']); // 12abc34\n trackedArray.removeItems(4, 2); // 12ab4\n trackedArray.addItems(1, ['d']); // 1d2ab4 r1 i1 r1 i2 d1 r1\n\n equal(trackedArray.toString(), \"r:1 i:1 r:1 i:2 d:1 r:1\", \"precond - trackedArray is in expected state\");\n\n trackedArray.apply(function (items, offset, operation) {\n switch (i++) {\n case 0:\n deepEqual(items, [1], \"callback passed right items\");\n equal(offset, 0, \"callback passed right offset\");\n equal(operation, RETAIN, \"callback passed right operation\");\n break;\n case 1:\n deepEqual(items, ['d'], \"callback passed right items\");\n equal(offset, 1, \"callback passed right offset\");\n equal(operation, INSERT, \"callback passed right operation\");\n break;\n case 2:\n deepEqual(items, [2], \"callback passed right items\");\n equal(offset, 2, \"callback passed right offset\");\n equal(operation, RETAIN, \"callback passed right operation\");\n break;\n case 3:\n deepEqual(items, ['a','b'], \"callback passed right items\");\n equal(offset, 3, \"callback passed right offset\");\n equal(operation, INSERT, \"callback passed right operation\");\n break;\n case 4:\n // deletes not passed items at the moment; that might need to be added\n // if TrackedArray is used more widely\n equal(offset, 5, \"callback passed right offset\");\n equal(operation, DELETE, \"callback passed right operation\");\n break;\n case 5:\n deepEqual(items, [4], \"callback passed right items\");\n equal(offset, 5, \"callback passed right offset\");\n equal(operation, RETAIN, \"callback passed right operation\");\n break;\n }\n });\n equal(i, 6, \"`apply` invoked callback right number of times\");\n\n equal(trackedArray.toString(), \"r:6\", \"after `apply` operations become retain:n\");\n });\n });\n})();\n//@ sourceURL=ember-runtime/~tests/ember-runtime");minispade.register('ember-runtime/~tests/ember-runtime_test', "(function() {minispade.require(\"ember-metal/~tests/ember-metal\");\nminispade.require(\"ember-runtime/~tests/ember-runtime\");\nrequireModule(\"ember-runtime/tests/computed/compose_computed_test\");\nrequireModule(\"ember-runtime/tests/computed/computed_macros_test\");\nrequireModule(\"ember-runtime/tests/computed/reduce_computed_macros_test\");\nrequireModule(\"ember-runtime/tests/computed/reduce_computed_test\");\nrequireModule(\"ember-runtime/tests/controllers/array_controller_test\");\nrequireModule(\"ember-runtime/tests/controllers/controller_test\");\nrequireModule(\"ember-runtime/tests/controllers/item_controller_class_test\");\nrequireModule(\"ember-runtime/tests/controllers/object_controller_tests\");\nrequireModule(\"ember-runtime/tests/core/compare_test\");\nrequireModule(\"ember-runtime/tests/core/copy_test\");\nrequireModule(\"ember-runtime/tests/core/isEqual_test\");\nrequireModule(\"ember-runtime/tests/core/is_array_test\");\nrequireModule(\"ember-runtime/tests/core/is_empty_test\");\nrequireModule(\"ember-runtime/tests/core/keys_test\");\nrequireModule(\"ember-runtime/tests/core/type_test\");\nrequireModule(\"ember-runtime/tests/ext/function_test\");\nrequireModule(\"ember-runtime/tests/ext/mixin_test\");\nrequireModule(\"ember-runtime/tests/ext/rsvp_test\");\nrequireModule(\"ember-runtime/tests/legacy_1x/mixins/observable/chained_test\");\nrequireModule(\"ember-runtime/tests/legacy_1x/mixins/observable/observable_test\");\nrequireModule(\"ember-runtime/tests/legacy_1x/mixins/observable/observersForKey_test\");\nrequireModule(\"ember-runtime/tests/legacy_1x/mixins/observable/propertyChanges_test\");\nrequireModule(\"ember-runtime/tests/legacy_1x/system/binding_test\");\nrequireModule(\"ember-runtime/tests/legacy_1x/system/object/base_test\");\nrequireModule(\"ember-runtime/tests/legacy_1x/system/object/bindings_test\");\nrequireModule(\"ember-runtime/tests/legacy_1x/system/object/concatenated_test\");\nrequireModule(\"ember-runtime/tests/legacy_1x/system/run_loop_test\");\nrequireModule(\"ember-runtime/tests/legacy_1x/system/set_test\");\nrequireModule(\"ember-runtime/tests/mixins/action_handler_test\");\nrequireModule(\"ember-runtime/tests/mixins/array_test\");\nrequireModule(\"ember-runtime/tests/mixins/comparable_test\");\nrequireModule(\"ember-runtime/tests/mixins/copyable_test\");\nrequireModule(\"ember-runtime/tests/mixins/deferred_test\");\nrequireModule(\"ember-runtime/tests/mixins/enumerable_test\");\nrequireModule(\"ember-runtime/tests/mixins/mutable_array_test\");\nrequireModule(\"ember-runtime/tests/mixins/mutable_enumerable_test\");\nrequireModule(\"ember-runtime/tests/mixins/observable_test\");\nrequireModule(\"ember-runtime/tests/mixins/promise_proxy_test\");\nrequireModule(\"ember-runtime/tests/mixins/sortable_test\");\nrequireModule(\"ember-runtime/tests/mixins/target_action_support_test\");\nrequireModule(\"ember-runtime/tests/system/application/base_test\");\nrequireModule(\"ember-runtime/tests/system/array_proxy/arranged_content_test\");\nrequireModule(\"ember-runtime/tests/system/array_proxy/content_change_test\");\nrequireModule(\"ember-runtime/tests/system/array_proxy/content_update_test\");\nrequireModule(\"ember-runtime/tests/system/array_proxy/suite_test\");\nrequireModule(\"ember-runtime/tests/system/deferred_test\");\nrequireModule(\"ember-runtime/tests/system/lazy_load_test\");\nrequireModule(\"ember-runtime/tests/system/namespace/base_test\");\nrequireModule(\"ember-runtime/tests/system/native_array/copyable_suite_test\");\nrequireModule(\"ember-runtime/tests/system/native_array/suite_test\");\nrequireModule(\"ember-runtime/tests/system/object/computed_test\");\nrequireModule(\"ember-runtime/tests/system/object/create_test\");\nrequireModule(\"ember-runtime/tests/system/object/destroy_test\");\nrequireModule(\"ember-runtime/tests/system/object/detectInstance_test\");\nrequireModule(\"ember-runtime/tests/system/object/detect_test\");\nrequireModule(\"ember-runtime/tests/system/object/events_test\");\nrequireModule(\"ember-runtime/tests/system/object/extend_test\");\nrequireModule(\"ember-runtime/tests/system/object/observer_test\");\nrequireModule(\"ember-runtime/tests/system/object/reopenClass_test\");\nrequireModule(\"ember-runtime/tests/system/object/reopen_test\");\nrequireModule(\"ember-runtime/tests/system/object/subclasses_test\");\nrequireModule(\"ember-runtime/tests/system/object/toString_test\");\nrequireModule(\"ember-runtime/tests/system/object_proxy_test\");\nrequireModule(\"ember-runtime/tests/system/set/copyable_suite_test\");\nrequireModule(\"ember-runtime/tests/system/set/enumerable_suite_test\");\nrequireModule(\"ember-runtime/tests/system/set/extra_test\");\nrequireModule(\"ember-runtime/tests/system/string/loc_test\");\nrequireModule(\"ember-runtime/tests/system/string/w_test\");\nrequireModule(\"ember-runtime/tests/system/subarray_test\");\nrequireModule(\"ember-runtime/tests/system/tracked_array_test\");\n})();\n//@ sourceURL=ember-runtime/~tests/ember-runtime_test");minispade.register('ember-testing/~tests/ember-testing', "(function() {define(\"ember-testing/tests/acceptance_test\",\n [\"ember-metal/run_loop\",\"ember-views/system/jquery\",\"ember-testing/test\",\"ember-testing/adapters/qunit\",\"ember-views/views/view\",\"ember-testing/initializers\",\"ember-application/system/application\",\"ember-routing/system/route\",\"ember-handlebars\",\"ember-routing\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var jQuery = __dependency2__[\"default\"];\n var Test = __dependency3__[\"default\"];\n var QUnitAdapter = __dependency4__[\"default\"];\n var EmberView = __dependency5__.View;\n // ensure the initializer is setup\n var EmberApplication = __dependency7__[\"default\"];\n var EmberRoute = __dependency8__[\"default\"];\n var EmberHandlebars = __dependency9__[\"default\"];\n\n //ES6TODO: we need {{link-to}} and {{outlet}} to exist here\n //ES6TODO: fixme?\n\n var App, find, click, fillIn, currentRoute, visit, originalAdapter, andThen, indexHitCount;\n\n module(\"ember-testing Acceptance\", {\n setup: function() {\n jQuery('').appendTo('head');\n jQuery('
    ').appendTo('body');\n run(function() {\n indexHitCount = 0;\n\n App = EmberApplication.create({\n rootElement: '#ember-testing'\n });\n\n App.Router.map(function() {\n this.route('posts');\n this.route('comments');\n\n this.route('abort_transition');\n });\n\n App.IndexRoute = EmberRoute.extend({\n model: function(){\n indexHitCount += 1;\n }\n });\n\n App.PostsRoute = EmberRoute.extend({\n renderTemplate: function() {\n currentRoute = 'posts';\n this._super();\n }\n });\n\n App.PostsView = EmberView.extend({\n defaultTemplate: EmberHandlebars.compile(\"
    {{#link-to 'comments'}}Comments{{/link-to}}
    \"),\n classNames: ['posts-view']\n });\n\n App.CommentsRoute = EmberRoute.extend({\n renderTemplate: function() {\n currentRoute = 'comments';\n this._super();\n }\n });\n\n App.CommentsView = EmberView.extend({\n defaultTemplate: EmberHandlebars.compile(\"{{input type=text}}\")\n });\n\n App.AbortTransitionRoute = EmberRoute.extend({\n beforeModel: function(transition) {\n transition.abort();\n }\n });\n\n App.setupForTesting();\n });\n\n App.injectTestHelpers();\n\n find = window.find;\n click = window.click;\n fillIn = window.fillIn;\n visit = window.visit;\n andThen = window.andThen;\n\n originalAdapter = Test.adapter;\n },\n\n teardown: function() {\n App.removeTestHelpers();\n jQuery('#ember-testing-container, #ember-testing').remove();\n run(App, App.destroy);\n App = null;\n Test.adapter = originalAdapter;\n indexHitCount = 0;\n }\n });\n\n test(\"helpers can be chained with then\", function() {\n expect(5);\n\n currentRoute = 'index';\n\n visit('/posts').then(function() {\n equal(currentRoute, 'posts', \"Successfully visited posts route\");\n return click('a:contains(\"Comments\")');\n }).then(function() {\n equal(currentRoute, 'comments', \"visit chained with click\");\n return fillIn('.ember-text-field', \"yeah\");\n }).then(function() {\n equal(jQuery('.ember-text-field').val(), 'yeah', \"chained with fillIn\");\n return fillIn('.ember-text-field', '#ember-testing-container', \"context working\");\n }).then(function() {\n equal(jQuery('.ember-text-field').val(), 'context working', \"chained with fillIn\");\n return click(\".does-not-exist\");\n }).then(null, function(e) {\n equal(e.message, \"Element .does-not-exist not found.\", \"Non-existent click exception caught\");\n });\n });\n\n\n\n // Keep this for backwards compatibility\n\n test(\"helpers can be chained to each other\", function() {\n expect(5);\n\n currentRoute = 'index';\n\n visit('/posts')\n .click('a:first', '#comments-link')\n .fillIn('.ember-text-field', \"hello\")\n .then(function() {\n equal(currentRoute, 'comments', \"Successfully visited comments route\");\n equal(jQuery('.ember-text-field').val(), 'hello', \"Fillin successfully works\");\n find('.ember-text-field').one('keypress', function(e) {\n equal(e.keyCode, 13, \"keyevent chained with correct keyCode.\");\n equal(e.which, 13, \"keyevent chained with correct which.\");\n });\n })\n .keyEvent('.ember-text-field', 'keypress', 13)\n .visit('/posts')\n .then(function() {\n equal(currentRoute, 'posts', \"Thens can also be chained to helpers\");\n });\n });\n\n test(\"helpers don't need to be chained\", function() {\n expect(3);\n\n currentRoute = 'index';\n\n visit('/posts');\n\n click('a:first', '#comments-link');\n\n fillIn('.ember-text-field', \"hello\");\n\n andThen(function() {\n equal(currentRoute, 'comments', \"Successfully visited comments route\");\n equal(find('.ember-text-field').val(), 'hello', \"Fillin successfully works\");\n });\n\n visit('/posts');\n\n andThen(function() {\n equal(currentRoute, 'posts');\n });\n });\n\n test(\"Nested async helpers\", function() {\n expect(3);\n\n currentRoute = 'index';\n\n visit('/posts');\n\n andThen(function() {\n click('a:first', '#comments-link');\n\n fillIn('.ember-text-field', \"hello\");\n });\n\n andThen(function() {\n equal(currentRoute, 'comments', \"Successfully visited comments route\");\n equal(find('.ember-text-field').val(), 'hello', \"Fillin successfully works\");\n });\n\n visit('/posts');\n\n andThen(function() {\n equal(currentRoute, 'posts');\n });\n });\n\n test(\"Helpers nested in thens\", function() {\n expect(3);\n\n currentRoute = 'index';\n\n visit('/posts').then(function() {\n click('a:first', '#comments-link');\n });\n\n andThen(function() {\n fillIn('.ember-text-field', \"hello\");\n });\n\n andThen(function() {\n equal(currentRoute, 'comments', \"Successfully visited comments route\");\n equal(find('.ember-text-field').val(), 'hello', \"Fillin successfully works\");\n });\n\n visit('/posts');\n\n andThen(function() {\n equal(currentRoute, 'posts');\n });\n });\n\n test(\"Aborted transitions are not logged via Ember.Test.adapter#exception\", function () {\n expect(0);\n\n Test.adapter = QUnitAdapter.create({\n exception: function(error) {\n ok(false, \"aborted transitions are not logged\");\n }\n });\n\n visit(\"/abort_transition\");\n });\n\n test(\"Unhandled exceptions are logged via Ember.Test.adapter#exception\", function () {\n expect(2);\n\n var asyncHandled;\n Test.adapter = QUnitAdapter.create({\n exception: function(error) {\n equal(error.message, \"Element .does-not-exist not found.\", \"Exception successfully caught and passed to Ember.Test.adapter.exception\");\n asyncHandled['catch'](function(){ }); // handle the rejection so it doesn't leak later.\n }\n });\n\n visit('/posts');\n\n click(\".invalid-element\").then(null, function(error) {\n equal(error.message, \"Element .invalid-element not found.\", \"Exception successfully handled in the rejection handler\");\n });\n\n asyncHandled = click(\".does-not-exist\");\n });\n\n test(\"should not start routing on the root URL when visiting another\", function(){\n visit('/posts');\n\n andThen(function(){\n ok(find('#comments-link'), 'found comments-link');\n equal(currentRoute, 'posts', \"Successfully visited posts route\");\n equal(indexHitCount, 0, 'should not hit index route when visiting another route');\n });\n });\n\n test(\"only enters the index route once when visiting /\", function(){\n visit('/');\n\n andThen(function(){\n equal(indexHitCount, 1, 'should hit index once when visiting /');\n });\n });\n });\ndefine(\"ember-testing/tests/adapters/adapter_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-testing/adapters/adapter\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // Ember.K\n var run = __dependency2__[\"default\"];\n var Adapter = __dependency3__[\"default\"];\n\n var adapter;\n\n module(\"ember-testing Adapter\", {\n setup: function() {\n adapter = new Adapter();\n },\n teardown: function() {\n run(adapter, adapter.destroy);\n }\n });\n\n test(\"asyncStart is a noop\", function() {\n equal(adapter.asyncStart, Ember.K);\n });\n\n test(\"asyncEnd is a noop\", function() {\n equal(adapter.asyncEnd, Ember.K);\n });\n\n test(\"exception throws\", function() {\n var error = \"Hai\", thrown;\n try {\n adapter.exception(error);\n } catch (e) {\n thrown = e;\n }\n equal(thrown, error);\n });\n });\ndefine(\"ember-testing/tests/adapters/qunit_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-testing/adapters/qunit\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // Ember.K\n var run = __dependency2__[\"default\"];\n var QUnitAdapter = __dependency3__[\"default\"];\n\n var adapter;\n\n module(\"ember-testing QUnitAdapter\", {\n setup: function() {\n adapter = new QUnitAdapter();\n },\n teardown: function() {\n run(adapter, adapter.destroy);\n }\n });\n\n test(\"asyncStart calls stop\", function() {\n var originalStop = QUnit.stop;\n try {\n QUnit.stop = function(){\n ok(true, \"stop called\");\n };\n adapter.asyncStart();\n } finally {\n QUnit.stop = originalStop;\n }\n });\n\n test(\"asyncEnd calls start\", function() {\n var originalStart = QUnit.start;\n try {\n QUnit.start = function(){\n ok(true, \"start called\");\n };\n adapter.asyncEnd();\n } finally {\n QUnit.start = originalStart;\n }\n });\n\n test(\"exception causes a failing assertion\", function() {\n var error = {err: 'hai'}, originalOk = window.ok;\n try {\n window.ok = function(val, msg){\n originalOk(!val, \"ok is called with false\");\n originalOk(msg, '{err: \"hai\"}');\n };\n adapter.exception(error);\n } finally {\n window.ok = originalOk;\n }\n });\n });\ndefine(\"ember-testing/tests/adapters_test\",\n [\"ember-metal/run_loop\",\"ember-testing/test\",\"ember-testing/adapters/adapter\",\"ember-testing/adapters/qunit\",\"ember-application/system/application\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var Test = __dependency2__[\"default\"];\n var Adapter = __dependency3__[\"default\"];\n var QUnitAdapter = __dependency4__[\"default\"];\n var EmberApplication = __dependency5__[\"default\"];\n\n var App, originalAdapter;\n\n module(\"ember-testing Adapters\", {\n setup: function() {\n originalAdapter = Test.adapter;\n },\n teardown: function() {\n run(App, App.destroy);\n App.removeTestHelpers();\n App = null;\n\n Test.adapter = originalAdapter;\n }\n });\n\n test(\"Setting a test adapter manually\", function() {\n expect(1);\n var CustomAdapter;\n\n CustomAdapter = Adapter.extend({\n asyncStart: function() {\n ok(true, \"Correct adapter was used\");\n }\n });\n\n run(function() {\n App = EmberApplication.create();\n Test.adapter = CustomAdapter.create();\n App.setupForTesting();\n });\n\n Test.adapter.asyncStart();\n });\n\n test(\"QUnitAdapter is used by default\", function() {\n expect(1);\n\n Test.adapter = null;\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n ok(Test.adapter instanceof QUnitAdapter);\n });\n });\ndefine(\"ember-testing/tests/helper_registration_test\",\n [\"ember-metal/run_loop\",\"ember-testing/test\",\"ember-application/system/application\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var Test = __dependency2__[\"default\"];\n var EmberApplication = __dependency3__[\"default\"];\n\n var App, appBooted, helperContainer;\n\n function registerHelper(){\n Test.registerHelper('boot', function(app) {\n run(app, app.advanceReadiness);\n appBooted = true;\n return app.testHelpers.wait();\n });\n }\n\n function unregisterHelper(){\n Test.unregisterHelper('boot');\n }\n\n var originalAdapter = Test.adapter;\n\n function setupApp(){\n appBooted = false;\n helperContainer = {};\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n App.injectTestHelpers(helperContainer);\n });\n }\n\n function destroyApp(){\n if (App) {\n run(App, 'destroy');\n App = null;\n }\n }\n\n module(\"Test - registerHelper/unregisterHelper\", {\n teardown: function(){\n Test.adapter = originalAdapter;\n destroyApp();\n }\n });\n\n test(\"Helper gets registered\", function() {\n expect(2);\n\n registerHelper();\n setupApp();\n\n ok(App.testHelpers.boot);\n ok(helperContainer.boot);\n });\n\n test(\"Helper is ran when called\", function(){\n expect(1);\n\n registerHelper();\n setupApp();\n\n App.testHelpers.boot().then(function() {\n ok(appBooted);\n });\n });\n\n test(\"Helper can be unregistered\", function(){\n expect(4);\n\n registerHelper();\n setupApp();\n\n ok(App.testHelpers.boot);\n ok(helperContainer.boot);\n\n unregisterHelper();\n\n setupApp();\n\n ok(!App.testHelpers.boot, \"once unregistered the helper is not added to App.testHelpers\");\n ok(!helperContainer.boot, \"once unregistered the helper is not added to the helperContainer\");\n });\n });\ndefine(\"ember-testing/tests/helpers_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-runtime/ext/rsvp\",\"ember-views/views/view\",\"ember-views/system/jquery\",\"ember-testing/test\",\"ember-testing/helpers\",\"ember-testing/initializers\",\"ember-testing/setup_for_testing\",\"ember-routing/system/router\",\"ember-routing/system/route\",\"ember-application/system/application\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__, __dependency13__, __dependency14__, __dependency15__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var run = __dependency4__[\"default\"];\n var EmberObject = __dependency5__[\"default\"];\n var RSVP = __dependency6__[\"default\"];\n var EmberView = __dependency7__.View;\n var jQuery = __dependency8__[\"default\"];\n\n var Test = __dependency9__[\"default\"];\n // ensure that the helpers are loaded\n // ensure the initializer is setup\n var setupForTesting = __dependency12__[\"default\"];\n var EmberRouter = __dependency13__[\"default\"];\n var EmberRoute = __dependency14__[\"default\"];\n var EmberApplication = __dependency15__[\"default\"];\n\n var App, originalAdapter = Test.adapter;\n\n function cleanup(){\n\n // Teardown setupForTesting\n\n Test.adapter = originalAdapter;\n run(function(){\n jQuery(document).off('ajaxSend');\n jQuery(document).off('ajaxComplete');\n });\n Test.pendingAjaxRequests = null;\n\n // Other cleanup\n\n if (App) {\n run(App, App.destroy);\n App.removeTestHelpers();\n App = null;\n }\n\n Ember.TEMPLATES = {};\n }\n\n function assertHelpers(application, helperContainer, expected){\n if (!helperContainer) { helperContainer = window; }\n if (expected === undefined) { expected = true; }\n\n function checkHelperPresent(helper, expected){\n var presentInHelperContainer = !!helperContainer[helper],\n presentInTestHelpers = !!application.testHelpers[helper];\n\n ok(presentInHelperContainer === expected, \"Expected '\" + helper + \"' to be present in the helper container (defaults to window).\");\n ok(presentInTestHelpers === expected, \"Expected '\" + helper + \"' to be present in App.testHelpers.\");\n }\n\n checkHelperPresent('visit', expected);\n checkHelperPresent('click', expected);\n checkHelperPresent('keyEvent', expected);\n checkHelperPresent('fillIn', expected);\n checkHelperPresent('wait', expected);\n checkHelperPresent('triggerEvent', expected);\n }\n\n function assertNoHelpers(application, helperContainer) {\n assertHelpers(application, helperContainer, false);\n }\n\n function currentRouteName(app){\n if(Ember.FEATURES.isEnabled('ember-testing-route-helpers')) {\n return app.testHelpers.currentRouteName();\n } else {\n var appController = app.__container__.lookup('controller:application');\n\n return get(appController, 'currentRouteName');\n }\n }\n\n function currentPath(app){\n if(Ember.FEATURES.isEnabled('ember-testing-route-helpers')) {\n return app.testHelpers.currentPath();\n } else {\n var appController = app.__container__.lookup('controller:application');\n\n return get(appController, 'currentPath');\n }\n }\n\n function currentURL(app){\n if(Ember.FEATURES.isEnabled('ember-testing-route-helpers')) {\n return app.testHelpers.currentURL();\n } else {\n var router = app.__container__.lookup('router:main');\n\n return get(router, 'location').getURL();\n }\n }\n\n module(\"ember-testing Helpers\", {\n setup: function(){ cleanup(); },\n teardown: function() { cleanup(); }\n });\n\n test(\"Ember.Application#injectTestHelpers/#removeTestHelpers\", function() {\n App = run(EmberApplication, EmberApplication.create);\n assertNoHelpers(App);\n\n App.injectTestHelpers();\n assertHelpers(App);\n\n App.removeTestHelpers();\n assertNoHelpers(App);\n });\n\n test(\"Ember.Application#setupForTesting\", function() {\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n equal(App.__container__.lookup('router:main').location.implementation, 'none');\n });\n\n test(\"Ember.Application.setupForTesting sets the application to `testing`.\", function(){\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n equal(App.testing, true, \"Application instance is set to testing.\");\n });\n\n test(\"Ember.Application.setupForTesting leaves the system in a deferred state.\", function(){\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n equal(App._readinessDeferrals, 1, \"App is in deferred state after setupForTesting.\");\n });\n\n test(\"App.reset() after Application.setupForTesting leaves the system in a deferred state.\", function(){\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n equal(App._readinessDeferrals, 1, \"App is in deferred state after setupForTesting.\");\n\n App.reset();\n equal(App._readinessDeferrals, 1, \"App is in deferred state after setupForTesting.\");\n });\n\n test(\"`visit` advances readiness.\", function(){\n expect(2);\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n App.injectTestHelpers();\n });\n\n equal(App._readinessDeferrals, 1, \"App is in deferred state after setupForTesting.\");\n\n App.testHelpers.visit('/').then(function(){\n equal(App._readinessDeferrals, 0, \"App's readiness was advanced by visit.\");\n });\n });\n\n test(\"`wait` helper can be passed a resolution value\", function() {\n expect(4);\n\n var promise, wait;\n\n promise = new RSVP.Promise(function(resolve) {\n run(null, resolve, 'promise');\n });\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n App.injectTestHelpers();\n\n run(App, App.advanceReadiness);\n\n wait = App.testHelpers.wait;\n\n wait('text').then(function(val) {\n equal(val, 'text', 'can resolve to a string');\n return wait(1);\n }).then(function(val) {\n equal(val, 1, 'can resolve to an integer');\n return wait({ age: 10 });\n }).then(function(val) {\n deepEqual(val, { age: 10 }, 'can resolve to an object');\n return wait(promise);\n }).then(function(val) {\n equal(val, 'promise', 'can resolve to a promise resolution value');\n });\n\n });\n\n test(\"`click` triggers appropriate events in order\", function() {\n expect(4);\n\n var click, wait, events;\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n App.IndexView = EmberView.extend({\n classNames: 'index-view',\n\n didInsertElement: function() {\n this.$().on('mousedown focusin mouseup click', function(e) {\n events.push(e.type);\n });\n },\n\n Checkbox: Ember.Checkbox.extend({\n click: function() {\n events.push('click:' + this.get('checked'));\n },\n\n change: function() {\n events.push('change:' + this.get('checked'));\n }\n })\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile('{{input type=\"text\"}} {{view view.Checkbox}} {{textarea}}');\n\n App.injectTestHelpers();\n\n run(App, App.advanceReadiness);\n\n click = App.testHelpers.click;\n wait = App.testHelpers.wait;\n\n wait().then(function() {\n events = [];\n return click('.index-view');\n }).then(function() {\n deepEqual(events,\n ['mousedown', 'mouseup', 'click'],\n 'fires events in order');\n }).then(function() {\n events = [];\n return click('.index-view input[type=text]');\n }).then(function() {\n deepEqual(events,\n ['mousedown', 'focusin', 'mouseup', 'click'],\n 'fires focus events on inputs');\n }).then(function() {\n events = [];\n return click('.index-view textarea');\n }).then(function() {\n deepEqual(events,\n ['mousedown', 'focusin', 'mouseup', 'click'],\n 'fires focus events on textareas');\n }).then(function() {\n // In IE (< 8), the change event only fires when the value changes before element focused.\n jQuery('.index-view input[type=checkbox]').focus();\n events = [];\n return click('.index-view input[type=checkbox]');\n }).then(function() {\n // i.e. mousedown, mouseup, change:true, click, click:true\n // Firefox differs so we can't assert the exact ordering here.\n // See https://bugzilla.mozilla.org/show_bug.cgi?id=843554.\n equal(events.length, 5, 'fires click and change on checkboxes');\n });\n });\n\n test(\"Ember.Application#setupForTesting attaches ajax listeners\", function() {\n var documentEvents;\n\n documentEvents = jQuery._data(document, 'events');\n\n if (!documentEvents) {\n documentEvents = {};\n }\n\n ok(documentEvents['ajaxSend'] === undefined, 'there are no ajaxSend listers setup prior to calling injectTestHelpers');\n ok(documentEvents['ajaxComplete'] === undefined, 'there are no ajaxComplete listers setup prior to calling injectTestHelpers');\n\n run(function() {\n setupForTesting();\n });\n\n documentEvents = jQuery._data(document, 'events');\n\n equal(documentEvents['ajaxSend'].length, 1, 'calling injectTestHelpers registers an ajaxSend handler');\n equal(documentEvents['ajaxComplete'].length, 1, 'calling injectTestHelpers registers an ajaxComplete handler');\n });\n\n test(\"Ember.Application#setupForTesting attaches ajax listeners only once\", function() {\n var documentEvents;\n\n documentEvents = jQuery._data(document, 'events');\n\n if (!documentEvents) {\n documentEvents = {};\n }\n\n ok(documentEvents['ajaxSend'] === undefined, 'there are no ajaxSend listers setup prior to calling injectTestHelpers');\n ok(documentEvents['ajaxComplete'] === undefined, 'there are no ajaxComplete listers setup prior to calling injectTestHelpers');\n\n run(function() {\n setupForTesting();\n });\n run(function() {\n setupForTesting();\n });\n\n documentEvents = jQuery._data(document, 'events');\n\n equal(documentEvents['ajaxSend'].length, 1, 'calling injectTestHelpers registers an ajaxSend handler');\n equal(documentEvents['ajaxComplete'].length, 1, 'calling injectTestHelpers registers an ajaxComplete handler');\n });\n\n test(\"Ember.Application#injectTestHelpers calls callbacks registered with onInjectHelpers\", function(){\n var injected = 0;\n\n Test.onInjectHelpers(function(){\n injected++;\n });\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n equal(injected, 0, 'onInjectHelpers are not called before injectTestHelpers');\n\n App.injectTestHelpers();\n\n equal(injected, 1, 'onInjectHelpers are called after injectTestHelpers');\n });\n\n test(\"Ember.Application#injectTestHelpers adds helpers to provided object.\", function(){\n var helpers = {};\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n App.injectTestHelpers(helpers);\n assertHelpers(App, helpers);\n\n App.removeTestHelpers();\n assertNoHelpers(App, helpers);\n });\n\n test(\"Ember.Application#removeTestHelpers resets the helperContainer's original values\", function(){\n var helpers = {visit: 'snazzleflabber'};\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n App.injectTestHelpers(helpers);\n\n ok(helpers['visit'] !== 'snazzleflabber', \"helper added to container\");\n App.removeTestHelpers();\n\n ok(helpers['visit'] === 'snazzleflabber', \"original value added back to container\");\n });\n\n test(\"`wait` respects registerWaiters\", function() {\n expect(2);\n\n var counter=0;\n function waiter() {\n return ++counter > 2;\n }\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n App.injectTestHelpers();\n\n run(App, App.advanceReadiness);\n Test.registerWaiter(waiter);\n\n App.testHelpers.wait().then(function() {\n equal(waiter(), true, 'should not resolve until our waiter is ready');\n Test.unregisterWaiter(waiter);\n equal(Test.waiters.length, 0, 'should not leave a waiter registered');\n });\n });\n\n test(\"`wait` waits for outstanding timers\", function() {\n expect(1);\n\n var wait_done = false;\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n App.injectTestHelpers();\n\n run(App, App.advanceReadiness);\n\n run.later(this, function() {\n wait_done = true;\n }, 500);\n\n App.testHelpers.wait().then(function() {\n equal(wait_done, true, 'should wait for the timer to be fired.');\n });\n });\n\n\n test(\"`wait` respects registerWaiters with optional context\", function() {\n expect(2);\n\n var obj = {\n counter: 0,\n ready: function() {\n return ++this.counter > 2;\n }\n };\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n App.injectTestHelpers();\n\n run(App, App.advanceReadiness);\n Test.registerWaiter(obj, obj.ready);\n\n App.testHelpers.wait().then(function() {\n equal(obj.ready(), true, 'should not resolve until our waiter is ready');\n Test.unregisterWaiter(obj, obj.ready);\n equal(Test.waiters.length, 0, 'should not leave a waiter registered');\n });\n\n\n });\n\n module(\"ember-testing routing helpers\", {\n setup: function(){\n cleanup();\n\n run(function() {\n App = EmberApplication.create();\n App.Router = EmberRouter.extend({\n location: 'none'\n });\n\n App.Router.map(function() {\n this.resource(\"posts\", function() {\n this.route(\"new\");\n });\n });\n\n App.setupForTesting();\n });\n\n App.injectTestHelpers();\n run(App, 'advanceReadiness');\n },\n\n teardown: function(){\n cleanup();\n }\n });\n\n test(\"currentRouteName for '/'\", function(){\n expect(3);\n\n App.testHelpers.visit('/').then(function(){\n equal(App.testHelpers.currentRouteName(), 'index', \"should equal 'index'.\");\n equal(App.testHelpers.currentPath(), 'index', \"should equal 'index'.\");\n equal(App.testHelpers.currentURL(), '/', \"should equal '/'.\");\n });\n });\n\n\n test(\"currentRouteName for '/posts'\", function(){\n expect(3);\n\n App.testHelpers.visit('/posts').then(function(){\n equal(App.testHelpers.currentRouteName(), 'posts.index', \"should equal 'posts.index'.\");\n equal(App.testHelpers.currentPath(), 'posts.index', \"should equal 'posts.index'.\");\n equal(App.testHelpers.currentURL(), '/posts', \"should equal '/posts'.\");\n });\n });\n\n test(\"currentRouteName for '/posts/new'\", function(){\n expect(3);\n\n App.testHelpers.visit('/posts/new').then(function(){\n equal(App.testHelpers.currentRouteName(), 'posts.new', \"should equal 'posts.new'.\");\n equal(App.testHelpers.currentPath(), 'posts.new', \"should equal 'posts.new'.\");\n equal(App.testHelpers.currentURL(), '/posts/new', \"should equal '/posts/new'.\");\n });\n });\n\n module(\"ember-testing pendingAjaxRequests\", {\n setup: function(){\n cleanup();\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n App.injectTestHelpers();\n },\n\n teardown: function() { cleanup(); }\n });\n\n test(\"pendingAjaxRequests is incremented on each document ajaxSend event\", function() {\n Test.pendingAjaxRequests = 0;\n jQuery(document).trigger('ajaxSend');\n equal(Test.pendingAjaxRequests, 1, 'Ember.Test.pendingAjaxRequests was incremented');\n });\n\n test(\"pendingAjaxRequests is decremented on each document ajaxComplete event\", function() {\n Test.pendingAjaxRequests = 1;\n jQuery(document).trigger('ajaxComplete');\n equal(Test.pendingAjaxRequests, 0, 'Ember.Test.pendingAjaxRequests was decremented');\n });\n\n test(\"pendingAjaxRequests is not reset by setupForTesting\", function() {\n Test.pendingAjaxRequests = 1;\n Ember.run(function(){\n setupForTesting();\n });\n equal(Test.pendingAjaxRequests, 1, 'pendingAjaxRequests is not reset');\n });\n\n test(\"it should raise an assertion error if ajaxComplete is called without pendingAjaxRequests\", function() {\n Test.pendingAjaxRequests = 0;\n expectAssertion(function() {\n jQuery(document).trigger('ajaxComplete');\n });\n });\n\n test(\"`trigger` can be used to trigger arbitrary events\", function() {\n expect(2);\n\n var triggerEvent, wait, event;\n\n run(function() {\n App = EmberApplication.create();\n App.setupForTesting();\n });\n\n App.IndexView = EmberView.extend({\n template: Ember.Handlebars.compile('{{input type=\"text\" id=\"foo\"}}'),\n\n didInsertElement: function() {\n this.$('#foo').on('blur change', function(e) {\n event = e;\n });\n }\n });\n\n App.injectTestHelpers();\n\n run(App, App.advanceReadiness);\n\n triggerEvent = App.testHelpers.triggerEvent;\n wait = App.testHelpers.wait;\n\n wait().then(function() {\n return triggerEvent('#foo', 'blur');\n }).then(function() {\n equal(event.type, 'blur', 'correct event was triggered');\n equal(event.target.getAttribute('id'), 'foo', 'triggered on the correct element');\n });\n });\n\n module(\"ember-testing async router\", {\n setup: function(){\n cleanup();\n\n run(function() {\n App = EmberApplication.create();\n App.Router = EmberRouter.extend({\n location: 'none'\n });\n\n App.Router.map(function() {\n this.resource(\"user\", function() {\n this.route(\"profile\");\n this.route(\"edit\");\n });\n });\n\n App.UserRoute = EmberRoute.extend({\n model: function() {\n return resolveLater();\n }\n });\n\n App.UserProfileRoute = EmberRoute.extend({\n beforeModel: function() {\n var self = this;\n return resolveLater().then(function() {\n self.transitionTo('user.edit');\n });\n }\n });\n\n // Emulates a long-running unscheduled async operation.\n function resolveLater() {\n var promise;\n\n run(function() {\n promise = new RSVP.Promise(function(resolve) {\n // The wait() helper has a 10ms tick. We should resolve() after at least one tick\n // to test whether wait() held off while the async router was still loading. 20ms\n // should be enough.\n setTimeout(function() {\n run(function() {\n resolve(EmberObject.create({firstName: 'Tom'}));\n });\n }, 20);\n });\n });\n\n return promise;\n }\n\n App.setupForTesting();\n });\n\n App.injectTestHelpers();\n run(App, 'advanceReadiness');\n },\n\n teardown: function(){\n cleanup();\n }\n });\n\n test(\"currentRouteName for '/user'\", function(){\n expect(4);\n\n App.testHelpers.visit('/user').then(function(){\n equal(currentRouteName(App), 'user.index', \"should equal 'user.index'.\");\n equal(currentPath(App), 'user.index', \"should equal 'user.index'.\");\n equal(currentURL(App), '/user', \"should equal '/user'.\");\n equal(App.__container__.lookup('route:user').get('controller.content.firstName'), 'Tom', \"should equal 'Tom'.\");\n });\n });\n\n test(\"currentRouteName for '/user/profile'\", function(){\n expect(4);\n\n App.testHelpers.visit('/user/profile').then(function(){\n equal(currentRouteName(App), 'user.edit', \"should equal 'user.edit'.\");\n equal(currentPath(App), 'user.edit', \"should equal 'user.edit'.\");\n equal(currentURL(App), '/user/edit', \"should equal '/user/edit'.\");\n equal(App.__container__.lookup('route:user').get('controller.content.firstName'), 'Tom', \"should equal 'Tom'.\");\n });\n });\n });\ndefine(\"ember-testing/tests/integration_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-runtime/controllers/array_controller\",\"ember-views/system/jquery\",\"ember-views/views/view\",\"ember-testing/test\",\"ember-routing/system/route\",\"ember-application/system/application\",\"ember-handlebars\",\"ember-application\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var ArrayController = __dependency4__[\"default\"];\n var jQuery = __dependency5__[\"default\"];\n var EmberView = __dependency6__.View;\n var Test = __dependency7__[\"default\"];\n var EmberRoute = __dependency8__[\"default\"];\n var EmberApplication = __dependency9__[\"default\"];\n var EmberHandlebars = __dependency10__[\"default\"];\n\n\n var App, find, visit, originalAdapter = Test.adapter;\n\n module(\"ember-testing Integration\", {\n setup: function() {\n jQuery('
    ').appendTo('body');\n run(function() {\n App = EmberApplication.create({\n rootElement: '#ember-testing'\n });\n\n App.Router.map(function() {\n this.resource(\"people\", { path: \"/\" });\n });\n\n App.PeopleRoute = EmberRoute.extend({\n model: function() {\n return App.Person.find();\n }\n });\n\n App.PeopleView = EmberView.extend({\n defaultTemplate: EmberHandlebars.compile(\"{{#each person in controller}}
    {{person.firstName}}
    {{/each}}\")\n });\n\n App.PeopleController = ArrayController.extend({});\n\n App.Person = EmberObject.extend({\n firstName: ''\n });\n\n App.Person.reopenClass({\n find: function() {\n return Ember.A();\n }\n });\n\n App.ApplicationView = EmberView.extend({\n defaultTemplate: EmberHandlebars.compile(\"{{outlet}}\")\n });\n\n App.setupForTesting();\n });\n\n run(function() {\n App.reset();\n });\n\n App.injectTestHelpers();\n\n find = window.find;\n visit = window.visit;\n },\n\n teardown: function() {\n App.removeTestHelpers();\n jQuery('#ember-testing-container, #ember-testing').remove();\n run(App, App.destroy);\n App = null;\n Test.adapter = originalAdapter;\n }\n });\n\n test(\"template is bound to empty array of people\", function() {\n App.Person.find = function() {\n return Ember.A();\n };\n run(App, 'advanceReadiness');\n visit(\"/\").then(function() {\n var rows = find(\".name\").length;\n equal(rows, 0, \"successfully stubbed an empty array of people\");\n });\n });\n\n test(\"template is bound to array of 2 people\", function() {\n App.Person.find = function() {\n var people = Ember.A();\n var first = App.Person.create({firstName: \"x\"});\n var last = App.Person.create({firstName: \"y\"});\n run(people, people.pushObject, first);\n run(people, people.pushObject, last);\n return people;\n };\n run(App, 'advanceReadiness');\n visit(\"/\").then(function() {\n var rows = find(\".name\").length;\n equal(rows, 2, \"successfully stubbed a non empty array of people\");\n });\n });\n\n test(\"template is again bound to empty array of people\", function() {\n App.Person.find = function() {\n return Ember.A();\n };\n run(App, 'advanceReadiness');\n visit(\"/\").then(function() {\n var rows = find(\".name\").length;\n equal(rows, 0, \"successfully stubbed another empty array of people\");\n });\n });\n\n test(\"`visit` can be called without advancedReadiness.\", function(){\n App.Person.find = function() {\n return Ember.A();\n };\n\n visit(\"/\").then(function() {\n var rows = find(\".name\").length;\n equal(rows, 0, \"stubbed an empty array of people without calling advancedReadiness.\");\n });\n });\n });\ndefine(\"ember-testing/tests/simple_setup\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-views/system/jquery\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n var jQuery = __dependency3__[\"default\"];\n\n var App;\n\n module('Simple Testing Setup', {\n teardown: function() {\n if (App) {\n App.removeTestHelpers();\n jQuery('#ember-testing-container, #ember-testing').remove();\n run(App, 'destroy');\n App = null;\n }\n }\n });\n });\n})();\n//@ sourceURL=ember-testing/~tests/ember-testing");minispade.register('ember-testing/~tests/ember-testing_test', "(function() {minispade.require(\"ember-testing/~tests/ember-testing\");\nrequireModule(\"ember-testing/tests/acceptance_test\");\nrequireModule(\"ember-testing/tests/adapters/adapter_test\");\nrequireModule(\"ember-testing/tests/adapters/qunit_test\");\nrequireModule(\"ember-testing/tests/adapters_test\");\nrequireModule(\"ember-testing/tests/helper_registration_test\");\nrequireModule(\"ember-testing/tests/helpers_test\");\nrequireModule(\"ember-testing/tests/integration_test\");\n})();\n//@ sourceURL=ember-testing/~tests/ember-testing_test");minispade.register('ember-views/~tests/ember-views', "(function() {define(\"ember-views/tests/mixins/view_target_action_support_test\",\n [\"ember-metal/core\",\"ember-runtime/system/object\",\"ember-views/views/view\",\"ember-views/mixins/view_target_action_support\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var EmberObject = __dependency2__[\"default\"];\n var View = __dependency3__.View;\n var ViewTargetActionSupport = __dependency4__[\"default\"];\n\n var originalLookup;\n\n module(\"ViewTargetActionSupport\", {\n setup: function() {\n originalLookup = Ember.lookup;\n },\n teardown: function() {\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"it should return false if no action is specified\", function() {\n expect(1);\n\n var view = View.createWithMixins(ViewTargetActionSupport, {\n controller: EmberObject.create()\n });\n\n ok(false === view.triggerAction(), \"a valid target and action were specified\");\n });\n\n test(\"it should support actions specified as strings\", function() {\n expect(2);\n\n var view = View.createWithMixins(ViewTargetActionSupport, {\n controller: EmberObject.create({\n anEvent: function() {\n ok(true, \"anEvent method was called\");\n }\n }),\n action: 'anEvent'\n });\n\n ok(true === view.triggerAction(), \"a valid target and action were specified\");\n });\n\n test(\"it should invoke the send() method on the controller with the view's context\", function() {\n expect(3);\n\n var view = View.createWithMixins(ViewTargetActionSupport, {\n context: {},\n controller: EmberObject.create({\n send: function(evt, context) {\n equal(evt, 'anEvent', \"send() method was invoked with correct event name\");\n equal(context, view.context, \"send() method was invoked with correct context\");\n }\n }),\n action: 'anEvent'\n });\n\n ok(true === view.triggerAction(), \"a valid target and action were specified\");\n });\n });\ndefine(\"ember-views/tests/system/event_dispatcher_test\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-views/system/jquery\",\"ember-views/views/view\",\"ember-views/system/event_dispatcher\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n var run = __dependency3__[\"default\"];\n\n var EmberObject = __dependency4__[\"default\"];\n\n var jQuery = __dependency5__[\"default\"];\n var View = __dependency6__.View;\n var EventDispatcher = __dependency7__[\"default\"];\n var ContainerView = __dependency8__[\"default\"];\n\n var view;\n var dispatcher;\n\n module(\"EventDispatcher\", {\n setup: function() {\n run(function() {\n dispatcher = EventDispatcher.create();\n dispatcher.setup();\n });\n },\n\n teardown: function() {\n run(function() {\n if (view) { view.destroy(); }\n dispatcher.destroy();\n });\n }\n });\n\n test(\"should dispatch events to views\", function() {\n var receivedEvent;\n var parentMouseDownCalled = 0;\n var childKeyDownCalled = 0;\n var parentKeyDownCalled = 0;\n\n view = ContainerView.createWithMixins({\n childViews: ['child'],\n\n child: View.extend({\n render: function(buffer) {\n buffer.push('ewot');\n },\n\n keyDown: function(evt) {\n childKeyDownCalled++;\n\n return false;\n }\n }),\n\n render: function(buffer) {\n buffer.push('some awesome content');\n this._super(buffer);\n },\n\n mouseDown: function(evt) {\n parentMouseDownCalled++;\n receivedEvent = evt;\n },\n\n keyDown: function(evt) {\n parentKeyDownCalled++;\n }\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n view.$().trigger('mousedown');\n\n ok(receivedEvent, \"passes event to associated event method\");\n receivedEvent = null;\n parentMouseDownCalled = 0;\n\n view.$('span#awesome').trigger('mousedown');\n ok(receivedEvent, \"event bubbles up to nearest View\");\n equal(parentMouseDownCalled, 1, \"does not trigger the parent handlers twice because of browser bubbling\");\n receivedEvent = null;\n\n jQuery('#wot').trigger('mousedown');\n ok(receivedEvent, \"event bubbles up to nearest View\");\n\n jQuery('#wot').trigger('keydown');\n equal(childKeyDownCalled, 1, \"calls keyDown on child view\");\n equal(parentKeyDownCalled, 0, \"does not call keyDown on parent if child handles event\");\n });\n\n test(\"should not dispatch events to views not inDOM\", function() {\n var receivedEvent;\n\n view = View.createWithMixins({\n render: function(buffer) {\n buffer.push('some awesome content');\n this._super(buffer);\n },\n\n mouseDown: function(evt) {\n receivedEvent = evt;\n }\n });\n\n run(function() {\n view.append();\n });\n\n var $element = view.$();\n\n run(function() {\n view.set('element', null); // Force into preRender\n });\n\n $element.trigger('mousedown');\n\n ok(!receivedEvent, \"does not pass event to associated event method\");\n receivedEvent = null;\n\n $element.find('span#awesome').trigger('mousedown');\n ok(!receivedEvent, \"event does not bubble up to nearest View\");\n receivedEvent = null;\n\n // Cleanup\n $element.remove();\n });\n\n test(\"should send change events up view hierarchy if view contains form elements\", function() {\n var receivedEvent;\n view = View.create({\n render: function(buffer) {\n buffer.push('');\n },\n\n change: function(evt) {\n receivedEvent = evt;\n }\n });\n\n run(function() {\n view.append();\n });\n\n jQuery('#is-done').trigger('change');\n ok(receivedEvent, \"calls change method when a child element is changed\");\n equal(receivedEvent.target, jQuery('#is-done')[0], \"target property is the element that was clicked\");\n });\n\n test(\"events should stop propagating if the view is destroyed\", function() {\n var parentViewReceived, receivedEvent;\n\n var parentView = ContainerView.create({\n change: function(evt) {\n parentViewReceived = true;\n }\n });\n\n view = parentView.createChildView(View, {\n render: function(buffer) {\n buffer.push('');\n },\n\n change: function(evt) {\n receivedEvent = true;\n var self = this;\n run(function() {\n get(self, 'parentView').destroy();\n });\n }\n });\n\n parentView.pushObject(view);\n\n run(function() {\n parentView.append();\n });\n\n ok(jQuery('#is-done').length, \"precond - view is in the DOM\");\n jQuery('#is-done').trigger('change');\n ok(!jQuery('#is-done').length, \"precond - view is not in the DOM\");\n ok(receivedEvent, \"calls change method when a child element is changed\");\n ok(!parentViewReceived, \"parent view does not receive the event\");\n });\n\n test(\"should not interfere with event propagation\", function() {\n var receivedEvent;\n view = View.create({\n render: function(buffer) {\n buffer.push('
    ');\n }\n });\n\n run(function() {\n view.append();\n });\n\n jQuery(window).bind('click', function(evt) {\n receivedEvent = evt;\n });\n\n jQuery('#propagate-test-div').click();\n\n ok(receivedEvent, \"allowed event to propagate outside Ember\");\n deepEqual(receivedEvent.target, jQuery('#propagate-test-div')[0], \"target property is the element that was clicked\");\n });\n\n test(\"should dispatch events to nearest event manager\", function() {\n var receivedEvent=0;\n view = ContainerView.create({\n render: function(buffer) {\n buffer.push('');\n },\n\n eventManager: EmberObject.create({\n mouseDown: function() {\n receivedEvent++;\n }\n }),\n\n mouseDown: function() {}\n });\n\n run(function() {\n view.append();\n });\n\n jQuery('#is-done').trigger('mousedown');\n equal(receivedEvent, 1, \"event should go to manager and not view\");\n });\n\n test(\"event manager should be able to re-dispatch events to view\", function() {\n\n var receivedEvent=0;\n view = ContainerView.createWithMixins({\n elementId: 'containerView',\n\n eventManager: EmberObject.create({\n mouseDown: function(evt, view) {\n // Re-dispatch event when you get it.\n //\n // The second parameter tells the dispatcher\n // that this event has been handled. This\n // API will clearly need to be reworked since\n // multiple eventManagers in a single view\n // hierarchy would break, but it shows that\n // re-dispatching works\n view.$().trigger('mousedown',this);\n }\n }),\n\n childViews: ['child'],\n\n child: View.extend({\n elementId: 'nestedView',\n\n mouseDown: function(evt) {\n receivedEvent++;\n }\n }),\n\n mouseDown: function(evt) {\n receivedEvent++;\n }\n });\n\n run(function() { view.append(); });\n\n jQuery('#nestedView').trigger('mousedown');\n equal(receivedEvent, 2, \"event should go to manager and not view\");\n });\n\n test(\"event handlers should be wrapped in a run loop\", function() {\n expect(1);\n\n view = View.createWithMixins({\n elementId: 'test-view',\n\n eventManager: EmberObject.create({\n mouseDown: function() {\n ok(run.currentRunLoop, 'a run loop should have started');\n }\n })\n });\n\n run(function() { view.append(); });\n\n jQuery('#test-view').trigger('mousedown');\n });\n\n module(\"EventDispatcher#setup\", {\n setup: function() {\n run(function() {\n dispatcher = EventDispatcher.create({\n rootElement: \"#qunit-fixture\"\n });\n });\n },\n\n teardown: function() {\n run(function() {\n if (view) { view.destroy(); }\n dispatcher.destroy();\n });\n }\n });\n\n test(\"additional events which should be listened on can be passed\", function () {\n expect(1);\n\n run(function () {\n dispatcher.setup({ myevent: \"myEvent\" });\n\n view = View.create({\n elementId: \"leView\",\n myEvent: function() {\n ok(true, \"custom event has been triggered\");\n }\n }).appendTo( dispatcher.get(\"rootElement\") );\n });\n\n jQuery(\"#leView\").trigger(\"myevent\");\n });\n\n test(\"additional events and rootElement can be specified\", function () {\n expect(3);\n\n jQuery(\"#qunit-fixture\").append(\"
    \");\n\n run(function () {\n dispatcher.setup({ myevent: \"myEvent\" }, \".custom-root\");\n\n view = View.create({\n elementId: \"leView\",\n myEvent: function() {\n ok(true, \"custom event has been triggered\");\n }\n }).appendTo( dispatcher.get(\"rootElement\") );\n });\n\n ok(jQuery(\".custom-root\").hasClass(\"ember-application\"), \"the custom rootElement is used\");\n equal(dispatcher.get(\"rootElement\"), \".custom-root\", \"the rootElement is updated\");\n\n jQuery(\"#leView\").trigger(\"myevent\");\n });\n });\ndefine(\"ember-views/tests/system/ext_test\",\n [\"ember-metal/run_loop\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var View = __dependency2__.View;\n\n module(\"Ember.View additions to run queue\");\n\n test(\"View hierarchy is done rendering to DOM when functions queued in afterRender execute\", function() {\n var lookup1, lookup2;\n var childView = View.create({\n elementId: 'child_view',\n render: function(buffer) {\n buffer.push('child');\n },\n didInsertElement: function() {\n this.$().addClass('extra-class');\n }\n });\n var parentView = View.create({\n elementId: 'parent_view',\n render: function(buffer) {\n buffer.push('parent');\n this.appendChild(childView);\n },\n didInsertElement: function() {\n lookup1 = this.$('.extra-class');\n run.scheduleOnce('afterRender', this, function() {\n lookup2 = this.$('.extra-class');\n });\n }\n });\n\n run(function() {\n parentView.appendTo('#qunit-fixture');\n });\n\n equal(lookup1.length, 0, \"doesn't not find child in DOM on didInsertElement\");\n equal(lookup2.length, 1, \"finds child in DOM afterRender\");\n\n run(function() {\n parentView.destroy();\n });\n });\n });\ndefine(\"ember-views/tests/system/jquery_ext_test\",\n [\"ember-metal/run_loop\",\"ember-views/system/event_dispatcher\",\"ember-views/system/jquery\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var run = __dependency1__[\"default\"];\n var EventDispatcher = __dependency2__[\"default\"];\n var jQuery = __dependency3__[\"default\"];\n var View = __dependency4__.View;\n\n var view, dispatcher;\n\n // Adapted from https://github.com/jquery/jquery/blob/f30f7732e7775b6e417c4c22ced7adb2bf76bf89/test/data/testinit.js\n var canDataTransfer,\n fireNativeWithDataTransfer;\n if (document.createEvent) {\n canDataTransfer = !!document.createEvent('HTMLEvents').dataTransfer;\n fireNativeWithDataTransfer = function(node, type, dataTransfer) {\n var event = document.createEvent('HTMLEvents');\n event.initEvent(type, true, true);\n event.dataTransfer = dataTransfer;\n node.dispatchEvent(event);\n };\n } else {\n canDataTransfer = !!document.createEventObject().dataTransfer;\n fireNativeWithDataTransfer = function(node, type, dataTransfer) {\n var event = document.createEventObject();\n event.dataTransfer = dataTransfer;\n node.fireEvent('on' + type, event);\n };\n }\n\n module(\"EventDispatcher\", {\n setup: function() {\n run(function() {\n dispatcher = EventDispatcher.create();\n dispatcher.setup();\n });\n },\n\n teardown: function() {\n run(function() {\n if (view) { view.destroy(); }\n dispatcher.destroy();\n });\n }\n });\n\n if (canDataTransfer) {\n test(\"jQuery.event.fix copies over the dataTransfer property\", function() {\n var originalEvent;\n var receivedEvent;\n\n originalEvent = {\n type: 'drop',\n dataTransfer: 'success',\n target: document.body\n };\n\n receivedEvent = jQuery.event.fix(originalEvent);\n\n ok(receivedEvent !== originalEvent, \"attributes are copied to a new event object\");\n equal(receivedEvent.dataTransfer, originalEvent.dataTransfer, \"copies dataTransfer property to jQuery event\");\n });\n\n test(\"drop handler should receive event with dataTransfer property\", function() {\n var receivedEvent;\n var dropCalled = 0;\n\n view = View.createWithMixins({\n render: function(buffer) {\n buffer.push('please drop stuff on me');\n this._super(buffer);\n },\n\n drop: function(evt) {\n receivedEvent = evt;\n dropCalled++;\n }\n });\n\n run(function() {\n view.append();\n });\n\n fireNativeWithDataTransfer(view.$().get(0), 'drop', 'success');\n\n equal(dropCalled, 1, \"called drop handler once\");\n equal(receivedEvent.dataTransfer, 'success', \"copies dataTransfer property to jQuery event\");\n });\n }\n });\ndefine(\"ember-views/tests/system/render_buffer_test\",\n [\"ember-metal/property_set\",\"ember-metal/property_get\",\"ember-views/system/jquery\",\"ember-views/system/render_buffer\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var set = __dependency1__.set;\n var get = __dependency2__.get;\n var jQuery = __dependency3__[\"default\"];\n var RenderBuffer = __dependency4__[\"default\"];\n\n var trim = jQuery.trim;\n\n // .......................................................\n // render()\n //\n module(\"RenderBuffer\");\n\n test(\"RenderBuffers combine strings\", function() {\n var buffer = new RenderBuffer('div');\n buffer.pushOpeningTag();\n\n buffer.push('a');\n buffer.push('b');\n\n // IE8 returns `element name as upper case with extra whitespace.\n equal(\"
    ab
    \", trim(buffer.string().toLowerCase()), \"Multiple pushes should concatenate\");\n });\n\n test(\"value of 0 is included in output\", function() {\n var buffer, $el;\n\n buffer = new RenderBuffer('input');\n buffer.prop('value', 0);\n buffer.pushOpeningTag();\n $el = buffer.element();\n\n strictEqual($el.value, '0', \"generated element has value of '0'\");\n\n buffer = new RenderBuffer('input');\n buffer.prop('value', 0);\n buffer.push('
    ');\n buffer.pushOpeningTag();\n buffer.push('
    ');\n $el = jQuery(buffer.innerString());\n\n strictEqual($el.find('input').val(), '0', \"raw tag has value of '0'\");\n });\n\n test(\"prevents XSS injection via `id`\", function() {\n var buffer = new RenderBuffer('div');\n\n buffer.push(''); // We need the buffer to not be empty so we use the string path\n buffer.id('hacked\" megahax=\"yes');\n buffer.pushOpeningTag();\n\n equal('
    ', buffer.string());\n });\n\n test(\"prevents XSS injection via `attr`\", function() {\n var buffer = new RenderBuffer('div');\n\n buffer.push(''); // We need the buffer to not be empty so we use the string path\n buffer.attr('id', 'trololol\" onmouseover=\"pwn()');\n buffer.attr('class', \"hax>
    ', buffer.string());\n });\n\n test(\"prevents XSS injection via `addClass`\", function() {\n var buffer = new RenderBuffer('div');\n\n buffer.push(''); // We need the buffer to not be empty so we use the string path\n buffer.addClass('megahax\" xss=\"true');\n buffer.pushOpeningTag();\n\n // Regular check then check for IE\n equal('
    ', buffer.string());\n });\n\n test(\"prevents XSS injection via `style`\", function() {\n var buffer = new RenderBuffer('div');\n\n buffer.push(''); // We need the buffer to not be empty so we use the string path\n buffer.style('color', 'blue;\" xss=\"true\" style=\"color:red');\n buffer.pushOpeningTag();\n\n equal('
    ', buffer.string());\n });\n\n test(\"prevents XSS injection via `tagName`\", function() {\n var buffer = new RenderBuffer('cool-div>
    '); // We need the buffer to not be empty so we use the string path\n buffer.pushOpeningTag();\n buffer.begin('span>', buffer.string());\n });\n\n test(\"handles null props - Issue #2019\", function() {\n var buffer = new RenderBuffer('div');\n\n buffer.push(''); // We need the buffer to not be empty so we use the string path\n buffer.prop('value', null);\n buffer.pushOpeningTag();\n\n equal('
    ', buffer.string());\n });\n\n test(\"handles browsers like Firefox < 11 that don't support outerHTML Issue #1952\", function() {\n var buffer = new RenderBuffer('div');\n buffer.pushOpeningTag();\n // Make sure element.outerHTML is falsy to trigger the fallback.\n var elementStub = '
    ';\n buffer.element = function() { return elementStub; };\n // IE8 returns `element name as upper case with extra whitespace.\n equal(elementStub, trim(buffer.string().toLowerCase()));\n });\n\n test(\"resets classes after pushing the opening tag\", function() {\n var buffer = new RenderBuffer('div');\n buffer.addClass('foo');\n buffer.pushOpeningTag();\n buffer.begin('div');\n buffer.addClass('bar');\n buffer.pushOpeningTag();\n buffer.pushClosingTag();\n buffer.pushClosingTag();\n equal(buffer.string(), '
    ');\n });\n\n test(\"lets `setClasses` and `addClass` work together\", function() {\n var buffer = new RenderBuffer('div');\n buffer.setClasses(['foo', 'bar']);\n buffer.addClass('baz');\n buffer.pushOpeningTag();\n buffer.pushClosingTag();\n equal(buffer.string(), '
    ');\n });\n\n module(\"RenderBuffer - without tagName\");\n\n test(\"It is possible to create a RenderBuffer without a tagName\", function() {\n var buffer = new RenderBuffer();\n buffer.push('a');\n buffer.push('b');\n buffer.push('c');\n\n equal(buffer.string(), \"abc\", \"Buffers without tagNames do not wrap the content in a tag\");\n });\n\n module(\"RenderBuffer#element\");\n\n test(\"properly handles old IE's zero-scope bug\", function() {\n var buffer = new RenderBuffer('div');\n buffer.pushOpeningTag();\n buffer.push('foo');\n\n var element = buffer.element();\n ok(jQuery(element).html().match(/script/i), \"should have script tag\");\n ok(!jQuery(element).html().match(/­/), \"should not have ­\");\n });\n });\ndefine(\"ember-views/tests/views/collection_test\",\n [\"ember-metal/core\",\"ember-metal/property_set\",\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-metal/enumerable_utils\",\"ember-metal/mixin\",\"ember-runtime/system/string\",\"ember-runtime/system/array_proxy\",\"ember-runtime/controllers/array_controller\",\"ember-views/system/jquery\",\"ember-views/views/collection_view\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__, __dependency9__, __dependency10__, __dependency11__, __dependency12__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n // Ember.A\n var set = __dependency2__.set;\n var get = __dependency3__.get;\n var run = __dependency4__[\"default\"];\n var EnumerableUtils = __dependency5__[\"default\"];\n var Mixin = __dependency6__.Mixin;\n var fmt = __dependency7__.fmt;\n var ArrayProxy = __dependency8__[\"default\"];\n var ArrayController = __dependency9__[\"default\"];\n var jQuery = __dependency10__[\"default\"];\n var CollectionView = __dependency11__[\"default\"];\n var View = __dependency12__.View;\n\n var forEach = EnumerableUtils.forEach;\n var trim = jQuery.trim;\n var view;\n\n var originalLookup;\n\n module(\"CollectionView\", {\n setup: function() {\n CollectionView.CONTAINER_MAP.del = 'em';\n originalLookup = Ember.lookup;\n },\n teardown: function() {\n delete CollectionView.CONTAINER_MAP.del;\n run(function() {\n if (view) { view.destroy(); }\n });\n\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"should render a view for each item in its content array\", function() {\n view = CollectionView.create({\n content: Ember.A([1, 2, 3, 4])\n });\n\n run(function() {\n view.append();\n });\n equal(view.$('div').length, 4);\n });\n\n test(\"should render the emptyView if content array is empty (view class)\", function() {\n view = CollectionView.create({\n tagName: 'del',\n content: Ember.A(),\n\n emptyView: View.extend({\n tagName: 'kbd',\n render: function(buf) {\n buf.push(\"OY SORRY GUVNAH NO NEWS TODAY EH\");\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n ok(view.$().find('kbd:contains(\"OY SORRY GUVNAH\")').length, \"displays empty view\");\n });\n\n test(\"should render the emptyView if content array is empty (view instance)\", function() {\n view = CollectionView.create({\n tagName: 'del',\n content: Ember.A(),\n\n emptyView: View.create({\n tagName: 'kbd',\n render: function(buf) {\n buf.push(\"OY SORRY GUVNAH NO NEWS TODAY EH\");\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n ok(view.$().find('kbd:contains(\"OY SORRY GUVNAH\")').length, \"displays empty view\");\n });\n\n test(\"should be able to override the tag name of itemViewClass even if tag is in default mapping\", function() {\n view = CollectionView.create({\n tagName: 'del',\n content: Ember.A(['NEWS GUVNAH']),\n\n itemViewClass: View.extend({\n tagName: 'kbd',\n render: function(buf) {\n buf.push(get(this, 'content'));\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n ok(view.$().find('kbd:contains(\"NEWS GUVNAH\")').length, \"displays the item view with proper tag name\");\n });\n\n test(\"should allow custom item views by setting itemViewClass\", function() {\n var passedContents = [];\n view = CollectionView.create({\n content: Ember.A(['foo', 'bar', 'baz']),\n\n itemViewClass: View.extend({\n render: function(buf) {\n passedContents.push(get(this, 'content'));\n buf.push(get(this, 'content'));\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n deepEqual(passedContents, ['foo', 'bar', 'baz'], \"sets the content property on each item view\");\n\n forEach(passedContents, function(item) {\n equal(view.$(':contains(\"'+item+'\")').length, 1);\n });\n });\n\n test(\"should insert a new item in DOM when an item is added to the content array\", function() {\n var content = Ember.A(['foo', 'bar', 'baz']);\n\n view = CollectionView.create({\n content: content,\n\n itemViewClass: View.extend({\n render: function(buf) {\n buf.push(get(this, 'content'));\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n forEach(content, function(item) {\n equal(view.$(':contains(\"'+item+'\")').length, 1, \"precond - generates pre-existing items\");\n });\n\n run(function() {\n content.insertAt(1, 'quux');\n });\n\n equal(jQuery.trim(view.$(':nth-child(2)').text()), 'quux');\n });\n\n test(\"should remove an item from DOM when an item is removed from the content array\", function() {\n var content = Ember.A(['foo', 'bar', 'baz']);\n\n view = CollectionView.create({\n content: content,\n\n itemViewClass: View.extend({\n render: function(buf) {\n buf.push(get(this, 'content'));\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n forEach(content, function(item) {\n equal(view.$(':contains(\"'+item+'\")').length, 1, \"precond - generates pre-existing items\");\n });\n\n run(function() {\n content.removeAt(1);\n });\n\n forEach(content, function(item, idx) {\n equal(view.$(fmt(':nth-child(%@)', [String(idx+1)])).text(), item);\n });\n });\n\n test(\"it updates the view if an item is replaced\", function() {\n var content = Ember.A(['foo', 'bar', 'baz']);\n view = CollectionView.create({\n content: content,\n\n itemViewClass: View.extend({\n render: function(buf) {\n buf.push(get(this, 'content'));\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n forEach(content, function(item) {\n equal(view.$(':contains(\"'+item+'\")').length, 1, \"precond - generates pre-existing items\");\n });\n\n run(function() {\n content.removeAt(1);\n content.insertAt(1, \"Kazuki\" );\n });\n\n forEach(content, function(item, idx) {\n equal(jQuery.trim(view.$(fmt(':nth-child(%@)', [String(idx+1)])).text()), item, \"postcond - correct array update\");\n });\n });\n\n test(\"can add and replace in the same runloop\", function() {\n var content = Ember.A(['foo', 'bar', 'baz']);\n view = CollectionView.create({\n content: content,\n\n itemViewClass: View.extend({\n render: function(buf) {\n buf.push(get(this, 'content'));\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n forEach(content, function(item) {\n equal(view.$(':contains(\"'+item+'\")').length, 1, \"precond - generates pre-existing items\");\n });\n\n run(function() {\n content.pushObject(\"Tom Dale\" );\n content.removeAt(0);\n content.insertAt(0, \"Kazuki\" );\n });\n\n forEach(content, function(item, idx) {\n equal(jQuery.trim(view.$(fmt(':nth-child(%@)', [String(idx+1)])).text()), item, \"postcond - correct array update\");\n });\n\n });\n\n test(\"can add and replace the object before the add in the same runloop\", function() {\n var content = Ember.A(['foo', 'bar', 'baz']);\n view = CollectionView.create({\n content: content,\n\n itemViewClass: View.extend({\n render: function(buf) {\n buf.push(get(this, 'content'));\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n forEach(content, function(item) {\n equal(view.$(':contains(\"'+item+'\")').length, 1, \"precond - generates pre-existing items\");\n });\n\n run(function() {\n content.pushObject(\"Tom Dale\" );\n content.removeAt(1);\n content.insertAt(1, \"Kazuki\" );\n });\n\n forEach(content, function(item, idx) {\n equal(jQuery.trim(view.$(fmt(':nth-child(%@)', [String(idx+1)])).text()), item, \"postcond - correct array update\");\n });\n });\n\n test(\"can add and replace complicatedly\", function() {\n var content = Ember.A(['foo', 'bar', 'baz']);\n view = CollectionView.create({\n content: content,\n\n itemViewClass: View.extend({\n render: function(buf) {\n buf.push(get(this, 'content'));\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n forEach(content, function(item) {\n equal(view.$(':contains(\"'+item+'\")').length, 1, \"precond - generates pre-existing items\");\n });\n\n run(function() {\n content.pushObject(\"Tom Dale\" );\n content.removeAt(1);\n content.insertAt(1, \"Kazuki\" );\n content.pushObject(\"Firestone\" );\n content.pushObject(\"McMunch\" );\n });\n\n forEach(content, function(item, idx) {\n equal(jQuery.trim(view.$(fmt(':nth-child(%@)', [String(idx+1)])).text()), item, \"postcond - correct array update: \"+item.name+\"!=\"+view.$(fmt(':nth-child(%@)', [String(idx+1)])).text());\n });\n });\n\n test(\"can add and replace complicatedly harder\", function() {\n var content = Ember.A(['foo', 'bar', 'baz']);\n view = CollectionView.create({\n content: content,\n\n itemViewClass: View.extend({\n render: function(buf) {\n buf.push(get(this, 'content'));\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n forEach(content, function(item) {\n equal(view.$(':contains(\"'+item+'\")').length, 1, \"precond - generates pre-existing items\");\n });\n\n run(function() {\n content.pushObject(\"Tom Dale\" );\n content.removeAt(1);\n content.insertAt(1, \"Kazuki\" );\n content.pushObject(\"Firestone\" );\n content.pushObject(\"McMunch\" );\n content.removeAt(2);\n });\n\n forEach(content, function(item, idx) {\n equal(jQuery.trim(view.$(fmt(':nth-child(%@)', [String(idx+1)])).text()), item, \"postcond - correct array update\");\n });\n });\n\n test(\"should allow changes to content object before layer is created\", function() {\n view = CollectionView.create({\n content: null\n });\n\n\n run(function() {\n set(view, 'content', Ember.A());\n set(view, 'content', Ember.A([1, 2, 3]));\n set(view, 'content', Ember.A([1, 2]));\n view.append();\n });\n\n ok(view.$().children().length);\n });\n\n test(\"should fire life cycle events when elements are added and removed\", function() {\n var view,\n didInsertElement = 0,\n willDestroyElement = 0,\n willDestroy = 0,\n destroy = 0,\n content = Ember.A([1, 2, 3]);\n run(function () {\n view = CollectionView.create({\n content: content,\n itemViewClass: View.extend({\n render: function(buf) {\n buf.push(get(this, 'content'));\n },\n didInsertElement: function () {\n didInsertElement++;\n },\n willDestroyElement: function () {\n willDestroyElement++;\n },\n willDestroy: function () {\n willDestroy++;\n this._super();\n },\n destroy: function() {\n destroy++;\n this._super();\n }\n })\n });\n view.appendTo('#qunit-fixture');\n });\n\n equal(didInsertElement, 3);\n equal(willDestroyElement, 0);\n equal(willDestroy, 0);\n equal(destroy, 0);\n equal(view.$().text(), '123');\n\n run(function () {\n content.pushObject(4);\n content.unshiftObject(0);\n });\n\n\n equal(didInsertElement, 5);\n equal(willDestroyElement, 0);\n equal(willDestroy, 0);\n equal(destroy, 0);\n // Remove whitspace added by IE 8\n equal(trim(view.$().text()), '01234');\n\n run(function () {\n content.popObject();\n content.shiftObject();\n });\n\n equal(didInsertElement, 5);\n equal(willDestroyElement, 2);\n equal(willDestroy, 2);\n equal(destroy, 2);\n // Remove whitspace added by IE 8\n equal(trim(view.$().text()), '123');\n\n run(function () {\n view.set('content', Ember.A([7,8,9]));\n });\n\n equal(didInsertElement, 8);\n equal(willDestroyElement, 5);\n equal(willDestroy, 5);\n equal(destroy, 5);\n // Remove whitspace added by IE 8\n equal(trim(view.$().text()), '789');\n\n run(function () {\n view.destroy();\n });\n\n equal(didInsertElement, 8);\n equal(willDestroyElement, 8);\n equal(willDestroy, 8);\n equal(destroy, 8);\n });\n\n test(\"should allow changing content property to be null\", function() {\n view = CollectionView.create({\n content: Ember.A([1, 2, 3]),\n\n emptyView: View.extend({\n template: function() { return \"(empty)\"; }\n })\n });\n\n run(function() {\n view.append();\n });\n\n equal(view.$().children().length, 3, \"precond - creates three elements\");\n\n run(function() {\n set(view, 'content', null);\n });\n\n equal(jQuery.trim(view.$().children().text()), \"(empty)\", \"should display empty view\");\n });\n\n test(\"should allow items to access to the CollectionView's current index in the content array\", function() {\n view = CollectionView.create({\n content: Ember.A(['zero', 'one', 'two']),\n itemViewClass: View.extend({\n render: function(buf) {\n buf.push(get(this, 'contentIndex'));\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n deepEqual(view.$(':nth-child(1)').text(), \"0\");\n deepEqual(view.$(':nth-child(2)').text(), \"1\");\n deepEqual(view.$(':nth-child(3)').text(), \"2\");\n });\n\n test(\"should allow declaration of itemViewClass as a string\", function() {\n Ember.lookup = {\n \"Ember\": {\n \"View\": View\n }\n };\n\n view = CollectionView.create({\n content: Ember.A([1, 2, 3]),\n itemViewClass: 'Ember.View'\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('.ember-view').length, 3);\n });\n\n test(\"should not render the emptyView if content is emptied and refilled in the same run loop\", function() {\n view = CollectionView.create({\n tagName: 'div',\n content: Ember.A(['NEWS GUVNAH']),\n\n emptyView: View.extend({\n tagName: 'kbd',\n render: function(buf) {\n buf.push(\"OY SORRY GUVNAH NO NEWS TODAY EH\");\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n equal(view.$().find('kbd:contains(\"OY SORRY GUVNAH\")').length, 0);\n\n run(function() {\n view.get('content').popObject();\n view.get('content').pushObject(['NEWS GUVNAH']);\n });\n equal(view.$('div').length, 1);\n equal(view.$().find('kbd:contains(\"OY SORRY GUVNAH\")').length, 0);\n });\n\n test(\"a array_proxy that backs an sorted array_controller that backs a collection view functions properly\", function() {\n\n var array = Ember.A([{ name: \"Other Katz\" }]);\n var arrayProxy = ArrayProxy.create({content: array});\n\n var sortedController = ArrayController.create({\n content: arrayProxy,\n sortProperties: ['name']\n });\n\n var container = CollectionView.create({\n content: sortedController\n });\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n run(function() {\n arrayProxy.addObjects([{ name: \"Scumbag Demon\" }, { name: \"Lord British\" }]);\n });\n\n equal(container.get('content.length'), 3, 'ArrayController should have 3 entries');\n equal(container.get('content.content.length'), 3, 'RecordArray should have 3 entries');\n equal(container.get('childViews.length'), 3, 'CollectionView should have 3 entries');\n\n run(function() {\n container.destroy();\n });\n });\n\n test(\"when a collection view is emptied, deeply nested views elements are not removed from the DOM and then destroyed again\", function() {\n var assertProperDestruction = Mixin.create({\n destroyElement: function() {\n if (this.state === 'inDOM') {\n ok(this.get('element'), this + ' still exists in DOM');\n }\n return this._super();\n }\n });\n\n var ChildView = View.extend(assertProperDestruction, {\n render: function(buf) {\n // emulate nested template\n this.appendChild(View.createWithMixins(assertProperDestruction, {\n template: function() { return \"
    \"; }\n }));\n }\n });\n\n var view = CollectionView.create({\n content: Ember.A([1]),\n itemViewClass: ChildView\n });\n\n\n run(function() {\n view.append();\n });\n equal(jQuery('.inner_element').length, 1, \"precond - generates inner element\");\n\n run(function() {\n view.get('content').clear();\n });\n equal(jQuery('.inner_element').length, 0, \"elements removed\");\n\n run(function() {\n view.remove();\n });\n });\n\n test(\"should render the emptyView if content array is empty and emptyView is given as string\", function() {\n Ember.lookup = {\n App: {\n EmptyView: View.extend({\n tagName: 'kbd',\n render: function(buf) {\n buf.push(\"THIS IS AN EMPTY VIEW\");\n }\n })\n }\n };\n view = CollectionView.create({\n tagName: 'del',\n content: Ember.A(),\n\n emptyView: 'App.EmptyView'\n });\n\n run(function() {\n view.append();\n });\n\n ok(view.$().find('kbd:contains(\"THIS IS AN EMPTY VIEW\")').length, \"displays empty view\");\n });\n\n test(\"should lookup against the container if itemViewClass is given as a string\", function() {\n\n var ItemView = View.extend({\n render: function(buf) {\n buf.push(get(this, 'content'));\n }\n });\n\n var container = {\n lookupFactory: lookupFactory\n };\n\n view = CollectionView.create({\n container: container,\n content: Ember.A([1, 2, 3, 4]),\n itemViewClass: 'item'\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(view.$('.ember-view').length, 4);\n\n function lookupFactory(fullName) {\n equal(fullName, 'view:item');\n\n return ItemView;\n }\n });\n\n test(\"should lookup against the container and render the emptyView if emptyView is given as string and content array is empty \", function() {\n var EmptyView = View.extend({\n tagName: 'kbd',\n render: function(buf) {\n buf.push(\"THIS IS AN EMPTY VIEW\");\n }\n });\n\n var container = {\n lookupFactory: lookupFactory\n };\n\n view = CollectionView.create({\n container: container,\n tagName: 'del',\n content: Ember.A(),\n\n emptyView: 'empty'\n });\n\n run(function() {\n view.append();\n });\n\n ok(view.$().find('kbd:contains(\"THIS IS AN EMPTY VIEW\")').length, \"displays empty view\");\n\n function lookupFactory(fullName) {\n equal(fullName, 'view:empty');\n\n return EmptyView;\n }\n });\n });\ndefine(\"ember-views/tests/views/component_test\",\n [\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-views/views/view\",\"ember-views/views/component\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var set = __dependency1__.set;\n var run = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n\n var EmberView = __dependency4__.View;\n var Component = __dependency5__[\"default\"];\n\n var a_slice = Array.prototype.slice;\n\n var component, controller, actionCounts, sendCount, actionArguments;\n\n module(\"Ember.Component\", {\n setup: function(){\n component = Component.create();\n },\n teardown: function() {\n run(function() {\n if(component) { component.destroy(); }\n if(controller) { controller.destroy(); }\n });\n }\n });\n\n test(\"The context of an Ember.Component is itself\", function() {\n strictEqual(component, component.get('context'), \"A components's context is itself\");\n });\n\n test(\"The controller (target of `action`) of an Ember.Component is itself\", function() {\n strictEqual(component, component.get('controller'), \"A components's controller is itself\");\n });\n\n test(\"A templateName specified to a component is moved to the layoutName\", function(){\n expectDeprecation(/Do not specify templateName on a Component, use layoutName instead/);\n component = Component.extend({\n templateName: 'blah-blah'\n }).create();\n\n equal(component.get('layoutName'), 'blah-blah', \"The layoutName now contains the templateName specified.\");\n });\n\n test(\"A template specified to a component is moved to the layout\", function(){\n expectDeprecation(/Do not specify template on a Component, use layout instead/);\n component = Component.extend({\n template: 'blah-blah'\n }).create();\n\n equal(component.get('layout'), 'blah-blah', \"The layoutName now contains the templateName specified.\");\n });\n\n test(\"A template specified to a component is deprecated\", function(){\n expectDeprecation(function(){\n component = Component.extend({\n template: 'blah-blah'\n }).create();\n }, 'Do not specify template on a Component, use layout instead.');\n });\n\n test(\"A templateName specified to a component is deprecated\", function(){\n expectDeprecation(function(){\n component = Component.extend({\n templateName: 'blah-blah'\n }).create();\n }, 'Do not specify templateName on a Component, use layoutName instead.');\n });\n\n test(\"Specifying both templateName and layoutName to a component is NOT deprecated\", function(){\n expectNoDeprecation();\n component = Component.extend({\n templateName: 'blah-blah',\n layoutName: 'hum-drum'\n }).create();\n });\n\n test(\"Specifying a templateName on a component with a layoutName specified in a superclass is NOT deprecated\", function(){\n expectNoDeprecation();\n var Parent = Component.extend({\n layoutName: 'hum-drum'\n });\n component = Parent.extend({\n templateName: 'blah-blah'\n }).create();\n });\n\n module(\"Ember.Component - Actions\", {\n setup: function() {\n actionCounts = {};\n sendCount = 0;\n actionArguments = null;\n\n controller = EmberObject.create({\n send: function(actionName) {\n sendCount++;\n actionCounts[actionName] = actionCounts[actionName] || 0;\n actionCounts[actionName]++;\n actionArguments = a_slice.call(arguments, 1);\n }\n });\n\n component = Component.create({\n _parentView: EmberView.create({\n controller: controller\n })\n });\n },\n\n teardown: function() {\n run(function() {\n component.destroy();\n controller.destroy();\n });\n }\n });\n\n test(\"Calling sendAction on a component without an action defined does nothing\", function() {\n component.sendAction();\n equal(sendCount, 0, \"addItem action was not invoked\");\n });\n\n test(\"Calling sendAction on a component with an action defined calls send on the controller\", function() {\n set(component, 'action', \"addItem\");\n\n component.sendAction();\n\n equal(sendCount, 1, \"send was called once\");\n equal(actionCounts['addItem'], 1, \"addItem event was sent once\");\n });\n\n test(\"Calling sendAction with a named action uses the component's property as the action name\", function() {\n set(component, 'playing', \"didStartPlaying\");\n set(component, 'action', \"didDoSomeBusiness\");\n\n component.sendAction('playing');\n\n equal(sendCount, 1, \"send was called once\");\n equal(actionCounts['didStartPlaying'], 1, \"named action was sent\");\n\n component.sendAction('playing');\n\n equal(sendCount, 2, \"send was called twice\");\n equal(actionCounts['didStartPlaying'], 2, \"named action was sent\");\n\n component.sendAction();\n\n equal(sendCount, 3, \"send was called three times\");\n equal(actionCounts['didDoSomeBusiness'], 1, \"default action was sent\");\n });\n\n test(\"Calling sendAction when the action name is not a string raises an exception\", function() {\n set(component, 'action', {});\n set(component, 'playing', {});\n\n expectAssertion(function() {\n component.sendAction();\n });\n\n expectAssertion(function() {\n component.sendAction('playing');\n });\n });\n\n test(\"Calling sendAction on a component with a context\", function() {\n set(component, 'playing', \"didStartPlaying\");\n\n var testContext = {song: 'She Broke My Ember'};\n\n component.sendAction('playing', testContext);\n\n deepEqual(actionArguments, [testContext], \"context was sent with the action\");\n });\n\n test(\"Calling sendAction on a component with multiple parameters\", function() {\n set(component, 'playing', \"didStartPlaying\");\n\n var firstContext = {song: 'She Broke My Ember'},\n secondContext = {song: 'My Achey Breaky Ember'};\n\n component.sendAction('playing', firstContext, secondContext);\n\n deepEqual(actionArguments, [firstContext, secondContext], \"arguments were sent to the action\");\n });\n });\ndefine(\"ember-views/tests/views/container_view_test\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-metal/computed\",\"ember-runtime/controllers/controller\",\"ember-views/system/jquery\",\"ember-views/views/view\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n var run = __dependency3__[\"default\"];\n var computed = __dependency4__.computed;\n var Controller = __dependency5__.Controller;\n var jQuery = __dependency6__[\"default\"];\n var View = __dependency7__.View;\n var ContainerView = __dependency8__[\"default\"];\n\n var trim = jQuery.trim, container, view, otherContainer;\n\n module(\"ember-views/views/container_view_test\", {\n teardown: function() {\n run(function() {\n container.destroy();\n if (view) { view.destroy(); }\n if (otherContainer) { otherContainer.destroy(); }\n });\n }\n });\n\n test(\"should be able to insert views after the DOM representation is created\", function() {\n container = ContainerView.create({\n classNameBindings: ['name'],\n name: 'foo',\n container: {}\n });\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n view = View.create({\n template: function() {\n return \"This is my moment\";\n }\n });\n\n run(function() {\n container.pushObject(view);\n });\n\n equal(view.container, container.container, 'view gains its containerViews container');\n equal(view._parentView, container, 'view\\'s _parentView is the container');\n equal(jQuery.trim(container.$().text()), \"This is my moment\");\n\n run(function() {\n container.destroy();\n });\n\n });\n\n test(\"should be able to observe properties that contain child views\", function() {\n run(function() {\n var Container = ContainerView.extend({\n childViews: ['displayView'],\n displayIsDisplayed: computed.alias('displayView.isDisplayed'),\n\n displayView: View.extend({\n isDisplayed: true\n })\n });\n\n container = Container.create();\n container.appendTo('#qunit-fixture');\n });\n equal(container.get('displayIsDisplayed'), true, \"can bind to child view\");\n\n run(function () {\n container.set('displayView.isDisplayed', false);\n });\n\n equal(container.get('displayIsDisplayed'), false, \"can bind to child view\");\n });\n\n test(\"childViews inherit their parents iocContainer, and retain the original container even when moved\", function() {\n container = ContainerView.create({\n container: {}\n });\n\n otherContainer = ContainerView.create({\n container: {}\n });\n\n view = View.create();\n\n container.pushObject(view);\n\n equal(view.get('parentView'), container, \"sets the parent view after the childView is appended\");\n equal(get(view, 'container'), container.container, \"inherits its parentViews iocContainer\");\n\n container.removeObject(view);\n\n equal(get(view, 'container'), container.container, \"leaves existing iocContainer alone\");\n\n otherContainer.pushObject(view);\n\n equal(view.get('parentView'), otherContainer, \"sets the new parent view after the childView is appended\");\n equal(get(view, 'container'), container.container, \"still inherits its original parentViews iocContainer\");\n });\n\n test(\"should set the parentView property on views that are added to the child views array\", function() {\n container = ContainerView.create();\n\n var ViewKlass = View.extend({\n template: function() {\n return \"This is my moment\";\n }\n });\n\n view = ViewKlass.create();\n\n container.pushObject(view);\n equal(view.get('parentView'), container, \"sets the parent view after the childView is appended\");\n\n run(function() {\n container.removeObject(view);\n });\n equal(get(view, 'parentView'), null, \"sets parentView to null when a view is removed\");\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n run(function() {\n container.pushObject(view);\n });\n\n equal(get(view, 'parentView'), container, \"sets the parent view after the childView is appended\");\n\n var secondView = ViewKlass.create(),\n thirdView = ViewKlass.create(),\n fourthView = ViewKlass.create();\n\n run(function() {\n container.pushObject(secondView);\n container.replace(1, 0, [thirdView, fourthView]);\n });\n\n equal(get(secondView, 'parentView'), container, \"sets the parent view of the second view\");\n equal(get(thirdView, 'parentView'), container, \"sets the parent view of the third view\");\n equal(get(fourthView, 'parentView'), container, \"sets the parent view of the fourth view\");\n\n run(function() {\n container.replace(2, 2);\n });\n\n equal(get(view, 'parentView'), container, \"doesn't change non-removed view\");\n equal(get(thirdView, 'parentView'), container, \"doesn't change non-removed view\");\n equal(get(secondView, 'parentView'), null, \"clears the parent view of the third view\");\n equal(get(fourthView, 'parentView'), null, \"clears the parent view of the fourth view\");\n\n run(function() {\n secondView.destroy();\n thirdView.destroy();\n fourthView.destroy();\n });\n });\n\n test(\"should trigger parentViewDidChange when parentView is changed\", function() {\n container = ContainerView.create();\n\n var secondContainer = ContainerView.create();\n var parentViewChanged = 0;\n\n var ViewKlass = View.extend({\n parentViewDidChange: function() { parentViewChanged++; }\n });\n\n view = ViewKlass.create();\n\n container.pushObject(view);\n container.removeChild(view);\n secondContainer.pushObject(view);\n\n equal(parentViewChanged, 3);\n\n run(function() {\n secondContainer.destroy();\n });\n });\n\n test(\"should be able to push initial views onto the ContainerView and have it behave\", function() {\n var Container = ContainerView.extend({\n init: function () {\n this._super();\n this.pushObject(View.create({\n name: 'A',\n template: function () {\n return 'A';\n }\n }));\n this.pushObject(View.create({\n name: 'B',\n template: function () {\n return 'B';\n }\n }));\n },\n lengthSquared: computed(function () {\n return this.get('length') * this.get('length');\n }).property('length'),\n\n names: computed(function () {\n return this.mapBy('name');\n }).property('@each.name')\n });\n\n container = Container.create();\n\n equal(container.get('lengthSquared'), 4);\n\n deepEqual(container.get('names'), ['A','B']);\n\n run(container, 'appendTo', '#qunit-fixture');\n\n equal(container.$().text(), 'AB');\n\n run(function () {\n container.pushObject(View.create({\n name: 'C',\n template: function () {\n return 'C';\n }\n }));\n });\n\n equal(container.get('lengthSquared'), 9);\n\n deepEqual(container.get('names'), ['A','B','C']);\n\n equal(container.$().text(), 'ABC');\n\n run(container, 'destroy');\n });\n\n test(\"views that are removed from a ContainerView should have their child views cleared\", function() {\n container = ContainerView.create();\n view = View.createWithMixins({\n remove: function() {\n this._super();\n },\n template: function(context, options) {\n options.data.view.appendChild(View);\n }\n });\n\n container.pushObject(view);\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n equal(get(view, 'childViews.length'), 1, \"precond - renders one child view\");\n run(function() {\n container.removeObject(view);\n });\n equal(get(view, 'childViews.length'), 0, \"child views are cleared when removed from container view\");\n equal(container.$().html(),'', \"the child view is removed from the DOM\");\n });\n\n test(\"if a ContainerView starts with an empy currentView, nothing is displayed\", function() {\n container = ContainerView.create();\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n equal(container.$().text(), '', \"has a empty contents\");\n equal(get(container, 'childViews.length'), 0, \"should not have any child views\");\n });\n\n test(\"if a ContainerView starts with a currentView, it is rendered as a child view\", function() {\n var controller = Controller.create();\n container = ContainerView.create({\n controller: controller\n });\n var context = null;\n var templateData = null;\n var mainView = View.create({\n template: function(ctx, opts) {\n context = ctx;\n templateData = opts.data;\n return \"This is the main view.\";\n }\n });\n\n set(container, 'currentView', mainView);\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n equal(jQuery.trim(container.$().text()), \"This is the main view.\", \"should render its child\");\n equal(get(container, 'length'), 1, \"should have one child view\");\n equal(container.objectAt(0), mainView, \"should have the currentView as the only child view\");\n equal(mainView.get('parentView'), container, \"parentView is setup\");\n equal(context, container.get('context'), 'context preserved');\n equal(templateData.keywords.controller, controller, 'templateData is setup');\n equal(templateData.keywords.view, mainView, 'templateData is setup');\n });\n\n test(\"if a ContainerView is created with a currentView, it is rendered as a child view\", function() {\n var context = null;\n var templateData = null;\n var mainView = View.create({\n template: function(ctx, opts) {\n context = ctx;\n templateData = opts.data;\n return \"This is the main view.\";\n }\n });\n\n var controller = Controller.create();\n\n container = ContainerView.create({\n currentView: mainView,\n controller: controller\n });\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n equal(container.$().text(), \"This is the main view.\", \"should render its child\");\n equal(get(container, 'length'), 1, \"should have one child view\");\n equal(container.objectAt(0), mainView, \"should have the currentView as the only child view\");\n equal(mainView.get('parentView'), container, \"parentView is setup\");\n equal(context, container.get('context'), 'context preserved');\n equal(templateData.keywords.controller, controller, 'templateData is setup');\n equal(templateData.keywords.view, mainView, 'templateData is setup');\n });\n\n test(\"if a ContainerView starts with no currentView and then one is set, the ContainerView is updated\", function() {\n var context = null;\n var templateData = null;\n var mainView = View.create({\n template: function(ctx, opts) {\n context = ctx;\n templateData = opts.data;\n return \"This is the main view.\";\n }\n });\n\n var controller = Controller.create();\n\n container = ContainerView.create({\n controller: controller\n });\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n equal(container.$().text(), '', \"has a empty contents\");\n equal(get(container, 'childViews.length'), 0, \"should not have any child views\");\n\n run(function() {\n set(container, 'currentView', mainView);\n });\n\n equal(container.$().text(), \"This is the main view.\", \"should render its child\");\n equal(get(container, 'length'), 1, \"should have one child view\");\n equal(container.objectAt(0), mainView, \"should have the currentView as the only child view\");\n equal(mainView.get('parentView'), container, \"parentView is setup\");\n equal(context, container.get('context'), 'context preserved');\n equal(templateData.keywords.controller, controller, 'templateData is setup');\n equal(templateData.keywords.view, mainView, 'templateData is setup');\n });\n\n test(\"if a ContainerView starts with a currentView and then is set to null, the ContainerView is updated\", function() {\n var context = null;\n var templateData = null;\n var mainView = View.create({\n template: function(ctx, opts) {\n context = ctx;\n templateData = opts.data;\n return \"This is the main view.\";\n }\n });\n\n var controller = Controller.create();\n\n container = ContainerView.create({\n controller: controller\n });\n\n container.set('currentView', mainView);\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n equal(container.$().text(), \"This is the main view.\", \"should render its child\");\n equal(get(container, 'length'), 1, \"should have one child view\");\n equal(container.objectAt(0), mainView, \"should have the currentView as the only child view\");\n equal(mainView.get('parentView'), container, \"parentView is setup\");\n equal(context, container.get('context'), 'context preserved');\n equal(templateData.keywords.controller, controller, 'templateData is setup');\n equal(templateData.keywords.view, mainView, 'templateData is setup');\n\n run(function() {\n set(container, 'currentView', null);\n });\n\n equal(container.$().text(), '', \"has a empty contents\");\n equal(get(container, 'childViews.length'), 0, \"should not have any child views\");\n });\n\n test(\"if a ContainerView starts with a currentView and then is set to null, the ContainerView is updated and the previous currentView is destroyed\", function() {\n var context = null;\n var templateData = null;\n var mainView = View.create({\n template: function(ctx, opts) {\n context = ctx;\n templateData = opts.data;\n return \"This is the main view.\";\n }\n });\n\n var controller = Controller.create();\n\n container = ContainerView.create({\n controller: controller\n });\n\n container.set('currentView', mainView);\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n equal(container.$().text(), \"This is the main view.\", \"should render its child\");\n equal(get(container, 'length'), 1, \"should have one child view\");\n equal(container.objectAt(0), mainView, \"should have the currentView as the only child view\");\n equal(mainView.get('parentView'), container, \"parentView is setup\");\n equal(context, container.get('context'), 'context preserved');\n equal(templateData.keywords.controller, controller, 'templateData is setup');\n equal(templateData.keywords.view, mainView, 'templateData is setup');\n\n run(function() {\n set(container, 'currentView', null);\n });\n\n equal(mainView.isDestroyed, true, 'should destroy the previous currentView.');\n\n equal(container.$().text(), '', \"has a empty contents\");\n equal(get(container, 'childViews.length'), 0, \"should not have any child views\");\n });\n\n test(\"if a ContainerView starts with a currentView and then a different currentView is set, the old view is destroyed and the new one is added\", function() {\n container = ContainerView.create();\n var mainView = View.create({\n template: function() {\n return \"This is the main view.\";\n }\n });\n\n var secondaryView = View.create({\n template: function() {\n return \"This is the secondary view.\";\n }\n });\n\n var tertiaryView = View.create({\n template: function() {\n return \"This is the tertiary view.\";\n }\n });\n\n container.set('currentView', mainView);\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n equal(container.$().text(), \"This is the main view.\", \"should render its child\");\n equal(get(container, 'length'), 1, \"should have one child view\");\n equal(container.objectAt(0), mainView, \"should have the currentView as the only child view\");\n\n run(function() {\n set(container, 'currentView', secondaryView);\n });\n\n\n equal(get(container, 'length'), 1, \"should have one child view\");\n equal(container.objectAt(0), secondaryView, \"should have the currentView as the only child view\");\n equal(mainView.isDestroyed, true, 'should destroy the previous currentView: mainView.');\n\n equal(jQuery.trim(container.$().text()), \"This is the secondary view.\", \"should render its child\");\n\n run(function() {\n set(container, 'currentView', tertiaryView);\n });\n\n equal(get(container, 'length'), 1, \"should have one child view\");\n equal(container.objectAt(0), tertiaryView, \"should have the currentView as the only child view\");\n equal(secondaryView.isDestroyed, true, 'should destroy the previous currentView: secondaryView.');\n\n equal(jQuery.trim(container.$().text()), \"This is the tertiary view.\", \"should render its child\");\n });\n\n test(\"should be able to modify childViews many times during an run loop\", function () {\n\n container = ContainerView.create();\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n var one = View.create({\n template: function() {\n return 'one';\n }\n });\n\n var two = View.create({\n template: function() {\n return 'two';\n }\n });\n\n var three = View.create({\n template: function() {\n return 'three';\n }\n });\n\n run(function() {\n // initial order\n container.pushObjects([three, one, two]);\n // sort\n container.removeObject(three);\n container.pushObject(three);\n });\n\n // Remove whitespace added by IE 8\n equal(trim(container.$().text()), 'onetwothree');\n });\n\n test(\"should be able to modify childViews then remove the ContainerView in same run loop\", function () {\n container = ContainerView.create();\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n var count = 0;\n var child = View.create({\n template: function () { count++; return 'child'; }\n });\n\n run(function() {\n container.pushObject(child);\n container.remove();\n });\n\n equal(count, 0, 'did not render child');\n });\n\n test(\"should be able to modify childViews then destroy the ContainerView in same run loop\", function () {\n container = ContainerView.create();\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n var count = 0;\n var child = View.create({\n template: function () { count++; return 'child'; }\n });\n\n run(function() {\n container.pushObject(child);\n container.destroy();\n });\n\n equal(count, 0, 'did not render child');\n });\n\n\n test(\"should be able to modify childViews then rerender the ContainerView in same run loop\", function () {\n container = ContainerView.create();\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n var count = 0;\n var child = View.create({\n template: function () { count++; return 'child'; }\n });\n\n run(function() {\n container.pushObject(child);\n container.rerender();\n });\n\n equal(count, 1, 'rendered child only once');\n });\n\n test(\"should be able to modify childViews then rerender then modify again the ContainerView in same run loop\", function () {\n container = ContainerView.create();\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n var Child = View.extend({\n count: 0,\n render: function (buffer) {\n this.count++;\n buffer.push(this.label);\n }\n });\n var one = Child.create({label: 'one'});\n var two = Child.create({label: 'two'});\n\n run(function() {\n container.pushObject(one);\n container.pushObject(two);\n });\n\n equal(one.count, 1, 'rendered child only once');\n equal(two.count, 1, 'rendered child only once');\n // Remove whitespace added by IE 8\n equal(trim(container.$().text()), 'onetwo');\n });\n\n test(\"should be able to modify childViews then rerender again the ContainerView in same run loop and then modify again\", function () {\n container = ContainerView.create();\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n var Child = View.extend({\n count: 0,\n render: function (buffer) {\n this.count++;\n buffer.push(this.label);\n }\n });\n var one = Child.create({label: 'one'});\n var two = Child.create({label: 'two'});\n\n run(function() {\n container.pushObject(one);\n container.rerender();\n });\n\n equal(one.count, 1, 'rendered child only once');\n equal(container.$().text(), 'one');\n\n run(function () {\n container.pushObject(two);\n });\n\n equal(one.count, 1, 'rendered child only once');\n equal(two.count, 1, 'rendered child only once');\n // IE 8 adds a line break but this shouldn't affect validity\n equal(trim(container.$().text()), 'onetwo');\n });\n\n test(\"should invalidate `element` on itself and childViews when being rendered by ensureChildrenAreInDOM\", function () {\n var root = ContainerView.create();\n\n view = View.create({ template: function() {} });\n container = ContainerView.create({ childViews: ['child'], child: view });\n\n run(function() {\n root.appendTo('#qunit-fixture');\n });\n\n run(function() {\n root.pushObject(container);\n\n // Get the parent and child's elements to cause them to be cached as null\n container.get('element');\n view.get('element');\n });\n\n ok(!!container.get('element'), \"Parent's element should have been recomputed after being rendered\");\n ok(!!view.get('element'), \"Child's element should have been recomputed after being rendered\");\n\n run(function() {\n root.destroy();\n });\n });\n\n test(\"Child view can only be added to one container at a time\", function () {\n expect(2);\n\n container = ContainerView.create();\n var secondContainer = ContainerView.create();\n\n run(function() {\n container.appendTo('#qunit-fixture');\n });\n\n var view = View.create();\n\n run(function() {\n container.set('currentView', view);\n });\n\n expectAssertion(function() {\n run(function() {\n secondContainer.set('currentView', view);\n });\n });\n\n expectAssertion(function() {\n run(function() {\n secondContainer.pushObject(view);\n });\n });\n\n run(function() {\n secondContainer.destroy();\n });\n });\n\n test(\"if a containerView appends a child in its didInsertElement event, the didInsertElement event of the child view should be fired once\", function () {\n\n var counter = 0,\n root = ContainerView.create({});\n\n container = ContainerView.create({\n\n didInsertElement: function() {\n\n var view = ContainerView.create({\n didInsertElement: function() {\n counter++;\n }\n });\n\n this.pushObject(view);\n\n }\n\n });\n\n\n run(function() {\n root.appendTo('#qunit-fixture');\n });\n\n run(function() {\n root.pushObject(container);\n });\n\n equal(container.get('childViews').get('length'), 1 , \"containerView should only have a child\");\n equal(counter, 1 , \"didInsertElement should be fired once\");\n\n run(function() {\n root.destroy();\n });\n\n });\n });\ndefine(\"ember-views/tests/views/view/actions_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-metal/mixin\",\"ember-runtime/controllers/controller\",\"ember-runtime/system/object\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var run = __dependency4__[\"default\"];\n var Mixin = __dependency5__.Mixin;\n var Controller = __dependency6__.Controller;\n var EmberObject = __dependency7__[\"default\"];\n var View = __dependency8__.View;\n\n var view;\n\n module(\"View action handling\", {\n teardown: function() {\n run(function() {\n if (view) { view.destroy(); }\n });\n }\n });\n\n test(\"Action can be handled by a function on actions object\", function() {\n expect(1);\n view = View.extend({\n actions: {\n poke: function() {\n ok(true, 'poked');\n }\n }\n }).create();\n view.send(\"poke\");\n });\n\n if (!Ember.FEATURES.isEnabled('ember-routing-drop-deprecated-action-style')) {\n test(\"Action can be handled by a function on the view (DEPRECATED)\", function() {\n expect(2);\n expectDeprecation(/Action handlers implemented directly on views are deprecated/);\n view = View.extend({\n poke: function() {\n ok(true, 'poked');\n }\n }).create();\n view.send(\"poke\");\n });\n }\n\n test(\"A handled action can be bubbled to the target for continued processing\", function() {\n expect(2);\n view = View.extend({\n actions: {\n poke: function() {\n ok(true, 'poked 1');\n return true;\n }\n },\n target: Controller.extend({\n actions: {\n poke: function() {\n ok(true, 'poked 2');\n }\n }\n }).create()\n }).create();\n view.send(\"poke\");\n });\n\n test(\"Action can be handled by a superclass' actions object\", function() {\n expect(4);\n\n var SuperView = View.extend({\n actions: {\n foo: function() {\n ok(true, 'foo');\n },\n bar: function(msg) {\n equal(msg, \"HELLO\");\n }\n }\n });\n\n var BarViewMixin = Mixin.create({\n actions: {\n bar: function(msg) {\n equal(msg, \"HELLO\");\n this._super(msg);\n }\n }\n });\n\n var IndexView = SuperView.extend(BarViewMixin, {\n actions: {\n baz: function() {\n ok(true, 'baz');\n }\n }\n });\n\n view = IndexView.create();\n view.send(\"foo\");\n view.send(\"bar\", \"HELLO\");\n view.send(\"baz\");\n });\n\n test(\"Actions cannot be provided at create time\", function() {\n expectAssertion(function() {\n view = View.create({\n actions: {\n foo: function() {\n ok(true, 'foo');\n }\n }\n });\n });\n // but should be OK on an object that doesn't mix in Ember.ActionHandler\n var obj = EmberObject.create({\n actions: ['foo']\n });\n });\n });\ndefine(\"ember-views/tests/views/view/append_to_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-views/system/jquery\",\"ember-views/views/view\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var run = __dependency4__[\"default\"];\n\n var jQuery = __dependency5__[\"default\"];\n var EmberView = __dependency6__.View;\n var ContainerView = __dependency7__[\"default\"];\n\n var View, view, willDestroyCalled, childView;\n\n module(\"EmberView - append() and appendTo()\", {\n setup: function() {\n View = EmberView.extend({});\n },\n\n teardown: function() {\n run(function() {\n if (!view.isDestroyed) { view.destroy(); }\n });\n }\n });\n\n test(\"should be added to the specified element when calling appendTo()\", function() {\n jQuery(\"#qunit-fixture\").html('
    ');\n\n view = View.create();\n\n ok(!get(view, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.appendTo('#menu');\n });\n\n var viewElem = jQuery('#menu').children();\n ok(viewElem.length > 0, \"creates and appends the view's element\");\n });\n\n test(\"should be added to the document body when calling append()\", function() {\n view = View.create({\n render: function(buffer) {\n buffer.push(\"foo bar baz\");\n }\n });\n\n ok(!get(view, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.append();\n });\n\n var viewElem = jQuery(document.body).find(':contains(\"foo bar baz\")');\n ok(viewElem.length > 0, \"creates and appends the view's element\");\n });\n\n test(\"raises an assert when a target does not exist in the DOM\", function() {\n view = View.create();\n\n expectAssertion(function() {\n run(function() {\n view.appendTo('does-not-exist-in-dom');\n });\n });\n });\n\n test(\"append calls willInsertElement and didInsertElement callbacks\", function() {\n var willInsertElementCalled = false;\n var willInsertElementCalledInChild = false;\n var didInsertElementCalled = false;\n\n var ViewWithCallback = View.extend({\n willInsertElement: function() {\n willInsertElementCalled = true;\n },\n didInsertElement: function() {\n didInsertElementCalled = true;\n },\n render: function(buffer) {\n this.appendChild(EmberView.create({\n willInsertElement: function() {\n willInsertElementCalledInChild = true;\n }\n }));\n }\n });\n\n view = ViewWithCallback.create();\n\n run(function() {\n view.append();\n });\n\n ok(willInsertElementCalled, \"willInsertElement called\");\n ok(willInsertElementCalledInChild, \"willInsertElement called in child\");\n ok(didInsertElementCalled, \"didInsertElement called\");\n });\n\n test(\"remove removes an element from the DOM\", function() {\n willDestroyCalled = 0;\n\n view = View.create({\n willDestroyElement: function() {\n willDestroyCalled++;\n }\n });\n\n ok(!get(view, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.append();\n });\n\n ok(jQuery(\"#\" + get(view, 'elementId')).length === 1, \"precond - element was inserted\");\n\n run(function() {\n view.remove();\n });\n\n ok(jQuery(\"#\" + get(view, 'elementId')).length === 0, \"remove removes an element from the DOM\");\n ok(EmberView.views[get(view, 'elementId')] === undefined, \"remove does not remove the view from the view hash\");\n ok(!get(view, 'element'), \"remove nulls out the element\");\n equal(willDestroyCalled, 1, \"the willDestroyElement hook was called once\");\n });\n\n test(\"destroy more forcibly removes the view\", function() {\n willDestroyCalled = 0;\n\n view = View.create({\n willDestroyElement: function() {\n willDestroyCalled++;\n }\n });\n\n ok(!get(view, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.append();\n });\n\n ok(jQuery(\"#\" + get(view, 'elementId')).length === 1, \"precond - element was inserted\");\n\n run(function() {\n view.destroy();\n });\n\n ok(jQuery(\"#\" + get(view, 'elementId')).length === 0, \"destroy removes an element from the DOM\");\n ok(EmberView.views[get(view, 'elementId')] === undefined, \"destroy removes a view from the global views hash\");\n equal(get(view, 'isDestroyed'), true, \"the view is marked as destroyed\");\n ok(!get(view, 'element'), \"the view no longer has an element\");\n equal(willDestroyCalled, 1, \"the willDestroyElement hook was called once\");\n });\n\n module(\"EmberView - append() and appendTo() in a view hierarchy\", {\n setup: function() {\n View = ContainerView.extend({\n childViews: ['child'],\n child: EmberView.extend({\n elementId: 'child'\n })\n });\n },\n\n teardown: function() {\n run(function() {\n if (!view.isDestroyed) { view.destroy(); }\n });\n }\n });\n\n test(\"should be added to the specified element when calling appendTo()\", function() {\n jQuery(\"#qunit-fixture\").html('
    ');\n\n view = View.create();\n\n ok(!get(view, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.appendTo('#menu');\n });\n\n var viewElem = jQuery('#menu #child');\n ok(viewElem.length > 0, \"creates and appends the view's element\");\n });\n\n test(\"should be added to the document body when calling append()\", function() {\n jQuery(\"#qunit-fixture\").html('
    ');\n\n view = View.create();\n\n ok(!get(view, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.append();\n });\n\n var viewElem = jQuery('#child');\n ok(viewElem.length > 0, \"creates and appends the view's element\");\n });\n\n module(\"EmberView - removing views in a view hierarchy\", {\n setup: function() {\n willDestroyCalled = 0;\n\n view = ContainerView.create({\n childViews: ['child'],\n child: EmberView.create({\n willDestroyElement: function() {\n willDestroyCalled++;\n }\n })\n });\n\n childView = get(view, 'child');\n },\n\n teardown: function() {\n run(function() {\n if (!view.isDestroyed) { view.destroy(); }\n });\n }\n });\n\n test(\"remove removes child elements from the DOM\", function() {\n ok(!get(childView, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.append();\n });\n\n ok(jQuery(\"#\" + get(childView, 'elementId')).length === 1, \"precond - element was inserted\");\n\n // remove parent view\n run(function() {\n view.remove();\n });\n\n ok(jQuery(\"#\" + get(childView, 'elementId')).length === 0, \"remove removes child elements the DOM\");\n ok(EmberView.views[get(childView, 'elementId')] === undefined, \"remove does not remove child views from the view hash\");\n ok(!get(childView, 'element'), \"remove nulls out child elements\");\n equal(willDestroyCalled, 1, \"the willDestroyElement hook was called once\");\n });\n\n test(\"destroy more forcibly removes child views\", function() {\n ok(!get(childView, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.append();\n });\n\n ok(jQuery(\"#\" + get(childView, 'elementId')).length === 1, \"precond - child element was inserted\");\n\n willDestroyCalled = 0;\n\n run(function() {\n view.destroy();\n });\n\n ok(jQuery(\"#\" + get(childView, 'elementId')).length === 0, \"destroy removes child elements from the DOM\");\n ok(EmberView.views[get(childView, 'elementId')] === undefined, \"destroy removes a child views from the global views hash\");\n equal(get(childView, 'isDestroyed'), true, \"child views are marked as destroyed\");\n ok(!get(childView, 'element'), \"child views no longer have an element\");\n equal(willDestroyCalled, 1, \"the willDestroyElement hook was called once on children\");\n });\n\n test(\"destroy removes a child view from its parent\", function() {\n ok(!get(childView, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.append();\n });\n\n ok(jQuery(\"#\" + get(childView, 'elementId')).length === 1, \"precond - child element was inserted\");\n\n run(function() {\n childView.destroy();\n });\n\n ok(get(view, 'childViews.length') === 0, \"Destroyed child views should be removed from their parent\");\n });\n });\ndefine(\"ember-views/tests/views/view/attribute_bindings_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-metal/observer\",\"ember-metal/property_events\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var run = __dependency3__[\"default\"];\n var observersFor = __dependency4__.observersFor;\n var changeProperties = __dependency5__.changeProperties;\n\n var EmberView = __dependency6__.View;\n\n var originalLookup = Ember.lookup, lookup, view;\n\n var appendView = function() {\n run(function() { view.appendTo('#qunit-fixture'); });\n };\n\n module(\"EmberView - Attribute Bindings\", {\n setup: function() {\n Ember.lookup = lookup = {};\n },\n teardown: function() {\n if (view) {\n run(function() {\n view.destroy();\n });\n view = null;\n }\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"should render attribute bindings\", function() {\n view = EmberView.create({\n classNameBindings: ['priority', 'isUrgent', 'isClassified:classified', 'canIgnore'],\n attributeBindings: ['type', 'isDisabled:disabled', 'exploded', 'destroyed', 'exists', 'nothing', 'notDefined', 'notNumber', 'explosions'],\n\n type: 'submit',\n isDisabled: true,\n exploded: false,\n destroyed: false,\n exists: true,\n nothing: null,\n notDefined: undefined,\n notNumber: NaN\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(view.$().attr('type'), 'submit', \"updates type attribute\");\n ok(view.$().prop('disabled'), \"supports customizing attribute name for Boolean values\");\n ok(!view.$().prop('exploded'), \"removes exploded attribute when false\");\n ok(!view.$().prop('destroyed'), \"removes destroyed attribute when false\");\n ok(view.$().prop('exists'), \"adds exists attribute when true\");\n ok(!view.$().attr('nothing'), \"removes nothing attribute when null\");\n ok(!view.$().attr('notDefined'), \"removes notDefined attribute when undefined\");\n ok(!view.$().attr('notNumber'), \"removes notNumber attribute when NaN\");\n });\n\n test(\"should update attribute bindings\", function() {\n view = EmberView.create({\n classNameBindings: ['priority', 'isUrgent', 'isClassified:classified', 'canIgnore'],\n attributeBindings: ['type', 'isDisabled:disabled', 'exploded', 'destroyed', 'exists', 'nothing', 'notDefined', 'notNumber', 'explosions'],\n\n type: 'reset',\n isDisabled: true,\n exploded: true,\n destroyed: true,\n exists: false,\n nothing: true,\n notDefined: true,\n notNumber: true,\n explosions: 15\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(view.$().attr('type'), 'reset', \"adds type attribute\");\n ok(view.$().prop('disabled'), \"adds disabled attribute when true\");\n ok(view.$().prop('exploded'), \"adds exploded attribute when true\");\n ok(view.$().prop('destroyed'), \"adds destroyed attribute when true\");\n ok(!view.$().prop('exists'), \"does not add exists attribute when false\");\n ok(view.$().prop('nothing'), \"adds nothing attribute when true\");\n ok(view.$().prop('notDefined'), \"adds notDefined attribute when true\");\n ok(view.$().prop('notNumber'), \"adds notNumber attribute when true\");\n equal(view.$().attr('explosions'), \"15\", \"adds integer attributes\");\n\n run(function() {\n view.set('type', 'submit');\n view.set('isDisabled', false);\n view.set('exploded', false);\n view.set('destroyed', false);\n view.set('exists', true);\n view.set('nothing', null);\n view.set('notDefined', undefined);\n view.set('notNumber', NaN);\n });\n\n equal(view.$().attr('type'), 'submit', \"updates type attribute\");\n ok(!view.$().prop('disabled'), \"removes disabled attribute when false\");\n ok(!view.$().prop('exploded'), \"removes exploded attribute when false\");\n ok(!view.$().prop('destroyed'), \"removes destroyed attribute when false\");\n ok(view.$().prop('exists'), \"adds exists attribute when true\");\n ok(!view.$().attr('nothing'), \"removes nothing attribute when null\");\n ok(!view.$().attr('notDefined'), \"removes notDefined attribute when undefined\");\n ok(!view.$().attr('notNumber'), \"removes notNumber attribute when NaN\");\n });\n\n // This comes into play when using the {{#each}} helper. If the\n // passed array item is a String, it will be converted into a\n // String object instead of a normal string.\n test(\"should allow binding to String objects\", function() {\n view = EmberView.create({\n attributeBindings: ['foo'],\n // JSHint doesn't like `new String` so we'll create it the same way it gets created in practice\n foo: (function() { return this; }).call(\"bar\")\n });\n\n run(function() {\n view.createElement();\n });\n\n\n equal(view.$().attr('foo'), 'bar', \"should convert String object to bare string\");\n\n run(function() {\n view.set('foo', false);\n });\n\n ok(!view.$().attr('foo'), \"removes foo attribute when false\");\n });\n\n test(\"should teardown observers on rerender\", function() {\n view = EmberView.create({\n attributeBindings: ['foo'],\n classNameBindings: ['foo'],\n foo: 'bar'\n });\n\n appendView();\n\n equal(observersFor(view, 'foo').length, 2);\n\n run(function() {\n view.rerender();\n });\n\n equal(observersFor(view, 'foo').length, 2);\n });\n\n test(\"handles attribute bindings for properties\", function() {\n view = EmberView.create({\n attributeBindings: ['checked'],\n checked: null\n });\n\n appendView();\n\n equal(!!view.$().prop('checked'), false, 'precond - is not checked');\n\n run(function() {\n view.set('checked', true);\n });\n\n equal(view.$().prop('checked'), true, 'changes to checked');\n\n run(function() {\n view.set('checked', false);\n });\n\n equal(!!view.$().prop('checked'), false, 'changes to unchecked');\n });\n\n test(\"handles `undefined` value for properties\", function() {\n view = EmberView.create({\n attributeBindings: ['value'],\n value: \"test\"\n });\n\n appendView();\n\n equal(view.$().prop('value'), \"test\", \"value is defined\");\n\n run(function() {\n view.set('value', undefined);\n });\n\n equal(!!view.$().prop('value'), false, \"value is not defined\");\n });\n\n test(\"handles null value for attributes on text fields\", function() {\n view = EmberView.create({\n tagName: 'input',\n attributeBindings: ['value']\n });\n\n appendView();\n\n view.$().attr('value', 'test');\n\n equal(view.$().attr('value'), \"test\", \"value is defined\");\n\n run(function() {\n view.set('value', null);\n });\n\n equal(!!view.$().prop('value'), false, \"value is not defined\");\n });\n\n test(\"handles a 0 value attribute on text fields\", function() {\n view = EmberView.create({\n tagName: 'input',\n attributeBindings: ['value']\n });\n\n appendView();\n\n view.$().attr('value', 'test');\n equal(view.$().attr('value'), \"test\", \"value is defined\");\n\n run(function() {\n view.set('value', 0);\n });\n strictEqual(view.$().prop('value'), \"0\", \"value should be 0\");\n });\n\n test(\"attributeBindings should not fail if view has been removed\", function() {\n run(function() {\n view = EmberView.create({\n attributeBindings: ['checked'],\n checked: true\n });\n });\n run(function() {\n view.createElement();\n });\n var error;\n try {\n run(function() {\n changeProperties(function() {\n view.set('checked', false);\n view.remove();\n });\n });\n } catch(e) {\n error = e;\n }\n ok(!error, error);\n });\n\n test(\"attributeBindings should not fail if view has been destroyed\", function() {\n run(function() {\n view = EmberView.create({\n attributeBindings: ['checked'],\n checked: true\n });\n });\n run(function() {\n view.createElement();\n });\n var error;\n try {\n run(function() {\n changeProperties(function() {\n view.set('checked', false);\n view.destroy();\n });\n });\n } catch(e) {\n error = e;\n }\n ok(!error, error);\n });\n });\ndefine(\"ember-views/tests/views/view/child_views_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var run = __dependency3__[\"default\"];\n\n var EmberView = __dependency4__.View;\n\n var parentView, childView, childViews;\n\n module('tests/views/view/child_views_tests.js', {\n setup: function() {\n parentView = EmberView.create({\n render: function(buffer) {\n buffer.push('Em');\n this.appendChild(childView);\n }\n });\n\n childView = EmberView.create({\n template: function() { return 'ber'; }\n });\n },\n\n teardown: function() {\n run(function() {\n parentView.destroy();\n childView.destroy();\n });\n\n childViews = null;\n }\n });\n\n // no parent element, buffer, no element\n // parent element\n\n // no parent element, no buffer, no element\n test(\"should render an inserted child view when the child is inserted before a DOM element is created\", function() {\n run(function() {\n parentView.append();\n });\n\n equal(parentView.$().text(), 'Ember', 'renders the child view after the parent view');\n });\n\n test(\"should not duplicate childViews when rerendering in buffer\", function() {\n\n var Inner = EmberView.extend({\n template: function() { return ''; }\n });\n\n var Inner2 = EmberView.extend({\n template: function() { return ''; }\n });\n\n var Middle = EmberView.extend({\n render: function(buffer) {\n this.appendChild(Inner);\n this.appendChild(Inner2);\n }\n });\n\n var outer = EmberView.create({\n render: function(buffer) {\n this.middle = this.appendChild(Middle);\n }\n });\n\n run(function() {\n outer.renderToBuffer();\n });\n\n equal(outer.get('middle.childViews.length'), 2, 'precond middle has 2 child views rendered to buffer');\n\n raises(function() {\n run(function() {\n outer.middle.rerender();\n });\n }, /Something you did caused a view to re-render after it rendered but before it was inserted into the DOM./);\n\n equal(outer.get('middle.childViews.length'), 2, 'middle has 2 child views rendered to buffer');\n\n run(function() {\n outer.destroy();\n });\n });\n });\ndefine(\"ember-views/tests/views/view/class_name_bindings_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-metal/property_events\",\"ember-metal/watching\",\"ember-runtime/system/object\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__, __dependency8__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var set = __dependency3__.set;\n var run = __dependency4__[\"default\"];\n var changeProperties = __dependency5__.changeProperties;\n var isWatching = __dependency6__.isWatching;\n var EmberObject = __dependency7__[\"default\"];\n var EmberView = __dependency8__.View;\n\n var view;\n\n module(\"EmberView - Class Name Bindings\", {\n teardown: function() {\n run(function() {\n view.destroy();\n });\n }\n });\n\n test(\"should apply bound class names to the element\", function() {\n view = EmberView.create({\n classNameBindings: ['priority', 'isUrgent', 'isClassified:classified',\n 'canIgnore', 'messages.count', 'messages.resent:is-resent',\n 'isNumber:is-number', 'isFalsy::is-falsy', 'isTruthy::is-not-truthy',\n 'isEnabled:enabled:disabled'],\n\n priority: 'high',\n isUrgent: true,\n isClassified: true,\n canIgnore: false,\n isNumber: 5,\n isFalsy: 0,\n isTruthy: 'abc',\n isEnabled: true,\n\n messages: {\n count: 'five-messages',\n resent: true\n }\n });\n\n run(function() {\n view.createElement();\n });\n\n ok(view.$().hasClass('high'), \"adds string values as class name\");\n ok(view.$().hasClass('is-urgent'), \"adds true Boolean values by dasherizing\");\n ok(view.$().hasClass('classified'), \"supports customizing class name for Boolean values\");\n ok(view.$().hasClass('five-messages'), \"supports paths in bindings\");\n ok(view.$().hasClass('is-resent'), \"supports customing class name for paths\");\n ok(view.$().hasClass('is-number'), \"supports colon syntax with truthy properties\");\n ok(view.$().hasClass('is-falsy'), \"supports colon syntax with falsy properties\");\n ok(!view.$().hasClass('abc'), \"does not add values as classes when falsy classes have been specified\");\n ok(!view.$().hasClass('is-not-truthy'), \"does not add falsy classes when values are truthy\");\n ok(!view.$().hasClass('can-ignore'), \"does not add false Boolean values as class\");\n ok(view.$().hasClass('enabled'), \"supports customizing class name for Boolean values with negation\");\n ok(!view.$().hasClass('disabled'), \"does not add class name for negated binding\");\n });\n\n test(\"should add, remove, or change class names if changed after element is created\", function() {\n view = EmberView.create({\n classNameBindings: ['priority', 'isUrgent', 'isClassified:classified',\n 'canIgnore', 'messages.count', 'messages.resent:is-resent',\n 'isEnabled:enabled:disabled'],\n\n priority: 'high',\n isUrgent: true,\n isClassified: true,\n canIgnore: false,\n isEnabled: true,\n\n messages: EmberObject.create({\n count: 'five-messages',\n resent: false\n })\n });\n\n run(function() {\n view.createElement();\n set(view, 'priority', 'orange');\n set(view, 'isUrgent', false);\n set(view, 'canIgnore', true);\n set(view, 'isEnabled', false);\n set(view, 'messages.count', 'six-messages');\n set(view, 'messages.resent', true );\n });\n\n ok(view.$().hasClass('orange'), \"updates string values\");\n ok(!view.$().hasClass('high'), \"removes old string value\");\n\n ok(!view.$().hasClass('is-urgent', \"removes dasherized class when changed from true to false\"));\n ok(view.$().hasClass('can-ignore'), \"adds dasherized class when changed from false to true\");\n\n ok(view.$().hasClass('six-messages'), \"adds new value when path changes\");\n ok(!view.$().hasClass('five-messages'), \"removes old value when path changes\");\n\n ok(view.$().hasClass('is-resent'), \"adds customized class name when path changes\");\n\n ok(!view.$().hasClass('enabled'), \"updates class name for negated binding\");\n ok(view.$().hasClass('disabled'), \"adds negated class name for negated binding\");\n });\n\n test(\":: class name syntax works with an empty true class\", function() {\n view = EmberView.create({\n isEnabled: false,\n classNameBindings: ['isEnabled::not-enabled']\n });\n\n run(function() { view.createElement(); });\n\n equal(view.$().attr('class'), 'ember-view not-enabled', \"false class is rendered when property is false\");\n\n run(function() { view.set('isEnabled', true); });\n\n equal(view.$().attr('class'), 'ember-view', \"no class is added when property is true and the class is empty\");\n });\n\n test(\"classNames should not be duplicated on rerender\", function() {\n run(function() {\n view = EmberView.create({\n classNameBindings: ['priority'],\n priority: 'high'\n });\n });\n\n\n run(function() {\n view.createElement();\n });\n\n equal(view.$().attr('class'), 'ember-view high');\n\n run(function() {\n view.rerender();\n });\n\n equal(view.$().attr('class'), 'ember-view high');\n });\n\n test(\"classNameBindings should work when the binding property is updated and the view has been removed of the DOM\", function() {\n run(function() {\n view = EmberView.create({\n classNameBindings: ['priority'],\n priority: 'high'\n });\n });\n\n\n run(function() {\n view.createElement();\n });\n\n equal(view.$().attr('class'), 'ember-view high');\n\n run(function() {\n view.remove();\n });\n\n view.set('priority', 'low');\n\n run(function() {\n view.append();\n });\n\n equal(view.$().attr('class'), 'ember-view low');\n\n });\n\n test(\"classNames removed by a classNameBindings observer should not re-appear on rerender\", function() {\n view = EmberView.create({\n classNameBindings: ['isUrgent'],\n isUrgent: true\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(view.$().attr('class'), 'ember-view is-urgent');\n\n run(function() {\n view.set('isUrgent', false);\n });\n\n equal(view.$().attr('class'), 'ember-view');\n\n run(function() {\n view.rerender();\n });\n\n equal(view.$().attr('class'), 'ember-view');\n });\n\n test(\"classNameBindings lifecycle test\", function() {\n run(function() {\n view = EmberView.create({\n classNameBindings: ['priority'],\n priority: 'high'\n });\n });\n\n equal(isWatching(view, 'priority'), false);\n\n run(function() {\n view.createElement();\n });\n\n equal(view.$().attr('class'), 'ember-view high');\n equal(isWatching(view, 'priority'), true);\n\n run(function() {\n view.remove();\n view.set('priority', 'low');\n });\n\n equal(isWatching(view, 'priority'), false);\n });\n\n test(\"classNameBindings should not fail if view has been removed\", function() {\n run(function() {\n view = EmberView.create({\n classNameBindings: ['priority'],\n priority: 'high'\n });\n });\n run(function() {\n view.createElement();\n });\n var error;\n try {\n run(function() {\n changeProperties(function() {\n view.set('priority', 'low');\n view.remove();\n });\n });\n } catch(e) {\n error = e;\n }\n ok(!error, error);\n });\n\n test(\"classNameBindings should not fail if view has been destroyed\", function() {\n run(function() {\n view = EmberView.create({\n classNameBindings: ['priority'],\n priority: 'high'\n });\n });\n run(function() {\n view.createElement();\n });\n var error;\n try {\n run(function() {\n changeProperties(function() {\n view.set('priority', 'low');\n view.destroy();\n });\n });\n } catch(e) {\n error = e;\n }\n ok(!error, error);\n });\n\n test(\"Providing a binding with a space in it asserts\", function() {\n view = EmberView.create({\n classNameBindings: 'i:think:i am:so:clever'\n });\n\n expectAssertion(function() {\n view.createElement();\n }, /classNameBindings must not have spaces in them/i);\n });\n });\ndefine(\"ember-views/tests/views/view/class_string_for_value_test\",\n [\"ember-views/views/view\"],\n function(__dependency1__) {\n \"use strict\";\n var View = __dependency1__.View;\n\n module(\"View - _classStringForValue\");\n\n var cSFV = View._classStringForValue;\n\n test(\"returns dasherized version of last path part if value is true\", function() {\n equal(cSFV(\"propertyName\", true), \"property-name\", \"class is dasherized\");\n equal(cSFV(\"content.propertyName\", true), \"property-name\", \"class is dasherized\");\n });\n\n test(\"returns className if value is true and className is specified\", function() {\n equal(cSFV(\"propertyName\", true, \"truthyClass\"), \"truthyClass\", \"returns className if given\");\n equal(cSFV(\"content.propertyName\", true, \"truthyClass\"), \"truthyClass\", \"returns className if given\");\n });\n\n test(\"returns falsyClassName if value is false and falsyClassName is specified\", function() {\n equal(cSFV(\"propertyName\", false, \"truthyClass\", \"falsyClass\"), \"falsyClass\", \"returns falsyClassName if given\");\n equal(cSFV(\"content.propertyName\", false, \"truthyClass\", \"falsyClass\"), \"falsyClass\", \"returns falsyClassName if given\");\n });\n\n test(\"returns null if value is false and falsyClassName is not specified\", function() {\n equal(cSFV(\"propertyName\", false, \"truthyClass\"), null, \"returns null if falsyClassName is not specified\");\n equal(cSFV(\"content.propertyName\", false, \"truthyClass\"), null, \"returns null if falsyClassName is not specified\");\n });\n\n test(\"returns null if value is false\", function() {\n equal(cSFV(\"propertyName\", false), null, \"returns null if value is false\");\n equal(cSFV(\"content.propertyName\", false), null, \"returns null if value is false\");\n });\n\n test(\"returns null if value is true and className is not specified and falsyClassName is specified\", function() {\n equal(cSFV(\"propertyName\", true, undefined, \"falsyClassName\"), null, \"returns null if value is true\");\n equal(cSFV(\"content.propertyName\", true, undefined, \"falsyClassName\"), null, \"returns null if value is true\");\n });\n\n test(\"returns the value if the value is truthy\", function() {\n equal(cSFV(\"propertyName\", \"myString\"), \"myString\", \"returns value if the value is truthy\");\n equal(cSFV(\"content.propertyName\", \"myString\"), \"myString\", \"returns value if the value is truthy\");\n\n equal(cSFV(\"propertyName\", \"123\"), 123, \"returns value if the value is truthy\");\n equal(cSFV(\"content.propertyName\", 123), 123, \"returns value if the value is truthy\");\n });\n\n test(\"treat empty array as falsy value and return null\", function() {\n equal(cSFV(\"propertyName\", [], \"truthyClass\"), null, \"returns null if value is false\");\n equal(cSFV(\"content.propertyName\", [], \"truthyClass\"), null, \"returns null if value is false\");\n });\n\n test(\"treat non-empty array as truthy value and return the className if specified\", function() {\n equal(cSFV(\"propertyName\", ['emberjs'], \"truthyClass\"), \"truthyClass\", \"returns className if given\");\n equal(cSFV(\"content.propertyName\", ['emberjs'], \"truthyClass\"), \"truthyClass\", \"returns className if given\");\n });\n });\ndefine(\"ember-views/tests/views/view/context_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-views/views/view\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n\n var EmberView = __dependency3__.View;\n var ContainerView = __dependency4__[\"default\"];\n\n module(\"EmberView - context property\");\n\n test(\"setting a controller on an inner view should change it context\", function() {\n var App = {};\n var a = { name: 'a' };\n var b = { name: 'b' };\n\n var innerView = EmberView.create();\n var middleView = ContainerView.create();\n var outerView = App.outerView = ContainerView.create({\n controller: a\n });\n\n run(function() {\n outerView.appendTo('#qunit-fixture');\n });\n\n run(function () {\n outerView.set('currentView', middleView);\n });\n\n run(function () {\n innerView.set('controller', b);\n middleView.set('currentView', innerView);\n });\n\n // assert\n equal(outerView.get('context'), a, 'outer context correct');\n equal(middleView.get('context'), a, 'middle context correct');\n equal(innerView.get('context'), b, 'inner context correct');\n\n run(function() {\n innerView.destroy();\n middleView.destroy();\n outerView.destroy();\n });\n });\n });\ndefine(\"ember-views/tests/views/view/controller_test\",\n [\"ember-metal/core\",\"ember-metal/run_loop\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var run = __dependency2__[\"default\"];\n\n var ContainerView = __dependency3__[\"default\"];\n\n module(\"Ember.View - controller property\");\n\n test(\"controller property should be inherited from nearest ancestor with controller\", function() {\n var grandparent = ContainerView.create();\n var parent = ContainerView.create();\n var child = ContainerView.create();\n var grandchild = ContainerView.create();\n\n var grandparentController = {};\n var parentController = {};\n\n run(function() {\n grandparent.set('controller', grandparentController);\n parent.set('controller', parentController);\n\n grandparent.pushObject(parent);\n parent.pushObject(child);\n });\n\n strictEqual(grandparent.get('controller'), grandparentController);\n strictEqual(parent.get('controller'), parentController);\n strictEqual(child.get('controller'), parentController);\n strictEqual(grandchild.get('controller'), null);\n\n run(function() {\n child.pushObject(grandchild);\n });\n\n strictEqual(grandchild.get('controller'), parentController);\n\n var newController = {};\n run(function() {\n parent.set('controller', newController);\n });\n\n strictEqual(parent.get('controller'), newController);\n strictEqual(child.get('controller'), newController);\n strictEqual(grandchild.get('controller'), newController);\n\n run(function() {\n grandparent.destroy();\n parent.destroy();\n child.destroy();\n grandchild.destroy();\n });\n });\n });\ndefine(\"ember-views/tests/views/view/create_child_view_test\",\n [\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var get = __dependency1__.get;\n var run = __dependency2__[\"default\"];\n var EmberView = __dependency3__.View;\n\n var view, myViewClass, newView, container;\n\n module(\"EmberView#createChildView\", {\n setup: function() {\n container = { };\n\n view = EmberView.create({\n container: container\n });\n\n myViewClass = EmberView.extend({ isMyView: true, foo: 'bar' });\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n if(newView) { newView.destroy(); }\n });\n }\n });\n\n test(\"should create view from class with any passed attributes\", function() {\n var attrs = {\n foo: \"baz\"\n };\n\n newView = view.createChildView(myViewClass, attrs);\n\n equal(newView.container, container, 'expects to share container with parent');\n ok(get(newView, 'isMyView'), 'newView is instance of myView');\n equal(get(newView, 'foo'), 'baz', 'view did get custom attributes');\n ok(!attrs.parentView, \"the original attributes hash was not mutated\");\n });\n\n test(\"should set newView.parentView to receiver\", function() {\n newView = view.createChildView(myViewClass) ;\n\n equal(newView.container, container, 'expects to share container with parent');\n equal(get(newView, 'parentView'), view, 'newView.parentView == view');\n });\n\n test(\"should create property on parentView to a childView instance if provided a viewName\", function() {\n var attrs = {\n viewName: \"someChildView\"\n };\n\n newView = view.createChildView(myViewClass, attrs);\n equal(newView.container, container, 'expects to share container with parent');\n\n equal(get(view, 'someChildView'), newView);\n });\n\n test(\"should update a view instances attributes, including the _parentView and container properties\", function() {\n var attrs = {\n foo: \"baz\"\n };\n\n var myView = myViewClass.create();\n newView = view.createChildView(myView, attrs);\n\n equal(newView.container, container, 'expects to share container with parent');\n equal(newView._parentView, view, 'expects to have the correct parent');\n equal(get(newView, 'foo'), 'baz', 'view did get custom attributes');\n\n deepEqual(newView, myView);\n });\n\n test(\"should create from string via container lookup\", function() {\n var ChildViewClass = EmberView.extend(),\n fullName = 'view:bro';\n\n view.container.lookupFactory = function(viewName) {\n equal(fullName, viewName);\n\n return ChildViewClass.extend({\n container: container\n });\n };\n\n newView = view.createChildView('bro');\n\n equal(newView.container, container, 'expects to share container with parent');\n equal(newView._parentView, view, 'expects to have the correct parent');\n });\n\n test(\"should assert when trying to create childView from string, but no such view is registered\", function() {\n view.container.lookupFactory = function() {};\n\n expectAssertion(function(){\n view.createChildView('bro');\n });\n });\n });\ndefine(\"ember-views/tests/views/view/create_element_test\",\n [\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-views/views/view\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var get = __dependency1__.get;\n var run = __dependency2__[\"default\"];\n var EmberView = __dependency3__.View;\n var ContainerView = __dependency4__[\"default\"];\n\n var view;\n\n module(\"Ember.View#createElement\", {\n teardown: function() {\n run(function() {\n view.destroy();\n });\n }\n });\n\n test(\"returns the receiver\", function() {\n var ret;\n\n view = EmberView.create();\n\n run(function() {\n ret = view.createElement();\n });\n\n equal(ret, view, 'returns receiver');\n });\n\n test(\"calls render and turns resultant string into element\", function() {\n view = EmberView.create({\n tagName: 'span',\n\n render: function(buffer) {\n buffer.push(\"foo\");\n }\n });\n\n equal(get(view, 'element'), null, 'precondition - has no element');\n run(function() {\n view.createElement();\n });\n\n\n var elem = get(view, 'element');\n ok(elem, 'has element now');\n equal(elem.innerHTML, 'foo', 'has innerHTML from context');\n equal(elem.tagName.toString().toLowerCase(), 'span', 'has tagName from view');\n });\n\n test(\"generated element include HTML from child views as well\", function() {\n view = ContainerView.create({\n childViews: [ EmberView.create({ elementId: \"foo\" })]\n });\n\n run(function() {\n view.createElement();\n });\n\n ok(view.$('#foo').length, 'has element with child elementId');\n });\n });\ndefine(\"ember-views/tests/views/view/destroy_element_test\",\n [\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-views/views/view\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var get = __dependency1__.get;\n var run = __dependency2__[\"default\"];\n var EmberView = __dependency3__.View;\n var ContainerView = __dependency4__[\"default\"];\n\n var view;\n\n module(\"EmberView#destroyElement\", {\n teardown: function() {\n run(function() {\n view.destroy();\n });\n }\n });\n\n test(\"if it has no element, does nothing\", function() {\n var callCount = 0;\n view = EmberView.create({\n willDestroyElement: function() { callCount++; }\n });\n\n ok(!get(view, 'element'), 'precond - does NOT have element');\n\n run(function() {\n view.destroyElement();\n });\n\n equal(callCount, 0, 'did not invoke callback');\n });\n\n test(\"if it has a element, calls willDestroyElement on receiver and child views then deletes the element\", function() {\n var parentCount = 0, childCount = 0;\n\n view = ContainerView.create({\n willDestroyElement: function() { parentCount++; },\n childViews: [ContainerView.extend({\n // no willDestroyElement here... make sure no errors are thrown\n childViews: [EmberView.extend({\n willDestroyElement: function() { childCount++; }\n })]\n })]\n });\n\n run(function() {\n view.createElement();\n });\n\n ok(get(view, 'element'), 'precond - view has element');\n\n run(function() {\n view.destroyElement();\n });\n\n equal(parentCount, 1, 'invoked destroy element on the parent');\n equal(childCount, 1, 'invoked destroy element on the child');\n ok(!get(view, 'element'), 'view no longer has element');\n ok(!get(get(view, 'childViews').objectAt(0), 'element'), 'child no longer has an element');\n });\n\n test(\"returns receiver\", function() {\n var ret;\n view = EmberView.create();\n\n run(function() {\n view.createElement();\n ret = view.destroyElement();\n });\n\n equal(ret, view, 'returns receiver');\n });\n\n test(\"removes element from parentNode if in DOM\", function() {\n view = EmberView.create();\n\n run(function() {\n view.append();\n });\n\n var parent = view.$().parent();\n\n ok(get(view, 'element'), 'precond - has element');\n\n run(function() {\n view.destroyElement();\n });\n\n equal(view.$(), undefined, 'view has no selector');\n ok(!parent.find('#'+view.get('elementId')).length, 'element no longer in parent node');\n });\n });\ndefine(\"ember-views/tests/views/view/destroy_test\",\n [\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__) {\n \"use strict\";\n var get = __dependency1__.get;\n var run = __dependency2__[\"default\"];\n var EmberView = __dependency3__.View;\n\n module(\"Ember.View#destroy\");\n\n test(\"should teardown viewName on parentView when childView is destroyed\", function() {\n var viewName = \"someChildView\",\n parentView = EmberView.create(),\n childView = parentView.createChildView(EmberView, {viewName: viewName});\n\n equal(get(parentView, viewName), childView, \"Precond - child view was registered on parent\");\n\n run(function() {\n childView.destroy();\n });\n\n equal(get(parentView, viewName), null, \"viewName reference was removed on parent\");\n\n run(function() {\n parentView.destroy();\n });\n });\n });\ndefine(\"ember-views/tests/views/view/element_test\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-views/system/jquery\",\"ember-views/views/view\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n var run = __dependency3__[\"default\"];\n\n var jQuery = __dependency4__[\"default\"];\n var EmberView = __dependency5__.View;\n var ContainerView = __dependency6__[\"default\"];\n\n var parentView, child, parentDom, childDom, view;\n\n module(\"Ember.View#element\", {\n teardown: function() {\n run(function() {\n if (parentView) { parentView.destroy(); }\n view.destroy();\n });\n }\n });\n\n test(\"returns null if the view has no element and no parent view\", function() {\n view = EmberView.create() ;\n equal(get(view, 'parentView'), null, 'precond - has no parentView');\n equal(get(view, 'element'), null, 'has no element');\n });\n\n test(\"returns null if the view has no element and parent view has no element\", function() {\n parentView = ContainerView.create({\n childViews: [ EmberView.extend() ]\n });\n view = get(parentView, 'childViews').objectAt(0);\n\n equal(get(view, 'parentView'), parentView, 'precond - has parent view');\n equal(get(parentView, 'element'), null, 'parentView has no element');\n equal(get(view, 'element'), null, ' has no element');\n });\n\n test(\"returns element if you set the value\", function() {\n view = EmberView.create();\n equal(get(view, 'element'), null, 'precond- has no element');\n\n var dom = document.createElement('div');\n set(view, 'element', dom);\n\n equal(get(view, 'element'), dom, 'now has set element');\n });\n\n\n module(\"Ember.View#element - autodiscovery\", {\n setup: function() {\n parentView = ContainerView.create({\n childViews: [ EmberView.extend({\n elementId: 'child-view'\n }) ]\n });\n\n child = get(parentView, 'childViews').objectAt(0);\n\n // setup parent/child dom\n parentDom = jQuery(\"
    \")[0];\n\n // set parent element...\n set(parentView, 'element', parentDom);\n },\n\n teardown: function() {\n run(function() {\n parentView.destroy();\n if (view) { view.destroy(); }\n });\n parentView = child = parentDom = childDom = null ;\n }\n });\n\n test(\"discovers element if has no element but parent view does have element\", function() {\n equal(get(parentView, 'element'), parentDom, 'precond - parent has element');\n ok(parentDom.firstChild, 'precond - parentDom has first child');\n\n equal(child.$().attr('id'), 'child-view', 'view discovered child');\n });\n\n test(\"should not allow the elementId to be changed after inserted\", function() {\n view = EmberView.create({\n elementId: 'one'\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n raises(function() {\n view.set('elementId', 'two');\n }, \"raises elementId changed exception\");\n\n equal(view.get('elementId'), 'one', 'elementId is still \"one\"');\n });\n });\ndefine(\"ember-views/tests/views/view/evented_test\",\n [\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var get = __dependency1__.get;\n var run = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var EmberView = __dependency4__.View;\n\n var view;\n\n module(\"EmberView evented helpers\", {\n teardown: function() {\n run(function() {\n view.destroy();\n });\n }\n });\n\n test(\"fire should call method sharing event name if it exists on the view\", function() {\n var eventFired = false;\n\n view = EmberView.create({\n fireMyEvent: function() {\n this.trigger('myEvent');\n },\n\n myEvent: function() {\n eventFired = true;\n }\n });\n\n run(function() {\n view.fireMyEvent();\n });\n\n equal(eventFired, true, \"fired the view method sharing the event name\");\n });\n\n test(\"fire does not require a view method with the same name\", function() {\n var eventFired = false;\n\n view = EmberView.create({\n fireMyEvent: function() {\n this.trigger('myEvent');\n }\n });\n\n var listenObject = EmberObject.create({\n onMyEvent: function() {\n eventFired = true;\n }\n });\n\n view.on('myEvent', listenObject, 'onMyEvent');\n\n run(function() {\n view.fireMyEvent();\n });\n\n equal(eventFired, true, \"fired the event without a view method sharing its name\");\n\n run(function() {\n listenObject.destroy();\n });\n });\n });\ndefine(\"ember-views/tests/views/view/init_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-metal/computed\",\"ember-runtime/system/object\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var run = __dependency3__[\"default\"];\n var computed = __dependency4__.computed;\n var EmberObject = __dependency5__[\"default\"];\n var EmberView = __dependency6__.View;\n\n var originalLookup = Ember.lookup, lookup, view;\n\n module(\"EmberView.create\", {\n setup: function() {\n Ember.lookup = lookup = {};\n },\n teardown: function() {\n run(function() {\n view.destroy();\n });\n\n Ember.lookup = originalLookup;\n }\n });\n\n test(\"registers view in the global views hash using layerId for event targeted\", function() {\n view = EmberView.create();\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n equal(EmberView.views[get(view, 'elementId')], view, 'registers view');\n });\n\n module(\"EmberView.createWithMixins\");\n\n test(\"should warn if a non-array is used for classNames\", function() {\n expectAssertion(function() {\n EmberView.createWithMixins({\n elementId: 'test',\n classNames: computed(function() {\n return ['className'];\n }).volatile()\n });\n }, /Only arrays are allowed/i);\n });\n\n test(\"should warn if a non-array is used for classNamesBindings\", function() {\n expectAssertion(function() {\n EmberView.createWithMixins({\n elementId: 'test',\n classNameBindings: computed(function() {\n return ['className'];\n }).volatile()\n });\n }, /Only arrays are allowed/i);\n });\n });\ndefine(\"ember-views/tests/views/view/is_visible_test\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-views/views/view\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n var run = __dependency3__[\"default\"];\n var EmberObject = __dependency4__[\"default\"];\n var EmberView = __dependency5__.View;\n var ContainerView = __dependency6__[\"default\"];\n\n var View, view, parentBecameVisible, childBecameVisible, grandchildBecameVisible;\n var parentBecameHidden, childBecameHidden, grandchildBecameHidden;\n\n module(\"EmberView#isVisible\", {\n setup: function() {\n parentBecameVisible=0;\n childBecameVisible=0;\n grandchildBecameVisible=0;\n parentBecameHidden=0;\n childBecameHidden=0;\n grandchildBecameHidden=0;\n\n View = ContainerView.extend({\n childViews: ['child'],\n becameVisible: function() { parentBecameVisible++; },\n becameHidden: function() { parentBecameHidden++; },\n\n child: ContainerView.extend({\n childViews: ['grandchild'],\n becameVisible: function() { childBecameVisible++; },\n becameHidden: function() { childBecameHidden++; },\n\n grandchild: EmberView.extend({\n template: function() { return \"seems weird bro\"; },\n becameVisible: function() { grandchildBecameVisible++; },\n becameHidden: function() { grandchildBecameHidden++; }\n })\n })\n });\n },\n\n teardown: function() {\n if (view) {\n run(function() { view.destroy(); });\n }\n }\n });\n\n test(\"should hide views when isVisible is false\", function() {\n view = EmberView.create({\n isVisible: false\n });\n\n run(function() {\n view.append();\n });\n\n ok(view.$().is(':hidden'), \"the view is hidden\");\n\n run(function(){\n set(view, 'isVisible', true);\n });\n\n ok(view.$().is(':visible'), \"the view is visible\");\n run(function() {\n view.remove();\n });\n });\n\n test(\"should hide element if isVisible is false before element is created\", function() {\n view = EmberView.create({\n isVisible: false\n });\n\n ok(!get(view, 'isVisible'), \"precond - view is not visible\");\n\n set(view, 'template', function() { return \"foo\"; });\n\n run(function() {\n view.append();\n });\n\n ok(view.$().is(':hidden'), \"should be hidden\");\n\n run(function() {\n view.remove();\n });\n\n run(function(){\n set(view, 'isVisible', true);\n });\n\n run(function() {\n view.append();\n });\n\n ok(view.$().is(':visible'), \"view should be visible\");\n\n run(function() {\n view.remove();\n });\n });\n\n test(\"view should be notified after isVisible is set to false and the element has been hidden\", function() {\n run(function() {\n view = View.create({ isVisible: false });\n view.append();\n });\n\n ok(view.$().is(':hidden'), \"precond - view is hidden when appended\");\n\n run(function() {\n view.set('isVisible', true);\n });\n\n ok(view.$().is(':visible'), \"precond - view is now visible\");\n equal(parentBecameVisible, 1);\n equal(childBecameVisible, 1);\n equal(grandchildBecameVisible, 1);\n });\n\n test(\"view should be notified after isVisible is set to false and the element has been hidden\", function() {\n view = View.create({ isVisible: true });\n var childView = view.get('childViews').objectAt(0);\n var grandchildView = childView.get('childViews').objectAt(0);\n\n run(function() {\n view.append();\n });\n\n ok(view.$().is(':visible'), \"precond - view is visible when appended\");\n\n run(function() {\n childView.set('isVisible', false);\n });\n\n ok(childView.$().is(':hidden'), \"precond - view is now hidden\");\n\n equal(childBecameHidden, 1);\n equal(grandchildBecameHidden, 1);\n });\n\n test(\"view should be notified after isVisible is set to true and the element has been shown\", function() {\n view = View.create({ isVisible: false });\n var childView = view.get('childViews').objectAt(0);\n var grandchildView = childView.get('childViews').objectAt(0);\n\n run(function() {\n view.append();\n });\n\n ok(view.$().is(':hidden'), \"precond - view is hidden when appended\");\n\n run(function() {\n view.set('isVisible', true);\n });\n\n ok(view.$().is(':visible'), \"precond - view is now visible\");\n\n equal(parentBecameVisible, 1);\n equal(childBecameVisible, 1);\n equal(grandchildBecameVisible, 1);\n });\n\n test(\"if a view descends from a hidden view, making isVisible true should not trigger becameVisible\", function() {\n view = View.create({ isVisible: true });\n var childView = view.get('childViews').objectAt(0);\n var grandchildView = childView.get('childViews').objectAt(0);\n\n run(function() {\n view.append();\n });\n\n ok(view.$().is(':visible'), \"precond - view is visible when appended\");\n\n run(function() {\n childView.set('isVisible', false);\n });\n\n run(function() {\n view.set('isVisible', false);\n });\n\n childBecameVisible = 0;\n grandchildBecameVisible = 0;\n\n run(function() {\n childView.set('isVisible', true);\n });\n\n equal(childBecameVisible, 0, \"the child did not become visible\");\n equal(grandchildBecameVisible, 0, \"the grandchild did not become visible\");\n });\n\n test(\"if a child view becomes visible while its parent is hidden, if its parent later becomes visible, it receives a becameVisible callback\", function() {\n view = View.create({ isVisible: false });\n var childView = view.get('childViews').objectAt(0);\n var grandchildView = childView.get('childViews').objectAt(0);\n\n run(function() {\n view.append();\n });\n\n ok(view.$().is(':hidden'), \"precond - view is hidden when appended\");\n\n run(function() {\n childView.set('isVisible', true);\n });\n\n equal(childBecameVisible, 0, \"child did not become visible since parent is hidden\");\n equal(grandchildBecameVisible, 0, \"grandchild did not become visible since parent is hidden\");\n\n run(function() {\n view.set('isVisible', true);\n });\n\n equal(parentBecameVisible, 1);\n equal(childBecameVisible, 1);\n equal(grandchildBecameVisible, 1);\n });\n });\ndefine(\"ember-views/tests/views/view/jquery_test\",\n [\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var get = __dependency1__.get;\n var run = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var EmberView = __dependency4__.View;\n\n var view ;\n module(\"EmberView#$\", {\n setup: function() {\n view = EmberView.extend({\n render: function(context, firstTime) {\n context.push('');\n }\n }).create();\n\n run(function() {\n view.append();\n });\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n });\n }\n });\n\n test(\"returns undefined if no element\", function() {\n var view = EmberView.create();\n ok(!get(view, 'element'), 'precond - should have no element');\n equal(view.$(), undefined, 'should return undefined');\n equal(view.$('span'), undefined, 'should undefined if filter passed');\n\n run(function() {\n view.destroy();\n });\n });\n\n test(\"returns jQuery object selecting element if provided\", function() {\n ok(get(view, 'element'), 'precond - should have element');\n\n var jquery = view.$();\n equal(jquery.length, 1, 'view.$() should have one element');\n equal(jquery[0], get(view, 'element'), 'element should be element');\n });\n\n test(\"returns jQuery object selecting element inside element if provided\", function() {\n ok(get(view, 'element'), 'precond - should have element');\n\n var jquery = view.$('span');\n equal(jquery.length, 1, 'view.$() should have one element');\n equal(jquery[0].parentNode, get(view, 'element'), 'element should be in element');\n });\n\n test(\"returns empty jQuery object if filter passed that does not match item in parent\", function() {\n ok(get(view, 'element'), 'precond - should have element');\n\n var jquery = view.$('body'); // would normally work if not scoped to view\n equal(jquery.length, 0, 'view.$(body) should have no elements');\n });\n });\ndefine(\"ember-views/tests/views/view/layout_test\",\n [\"container\",\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) {\n \"use strict\";\n var Container = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var run = __dependency3__[\"default\"];\n var EmberView = __dependency4__.View;\n\n var container, view;\n\n module(\"EmberView - Layout Functionality\", {\n setup: function() {\n container = new Container();\n container.optionsForType('template', { instantiate: false });\n },\n teardown: function() {\n run(function() {\n view.destroy();\n });\n }\n });\n\n test(\"should call the function of the associated layout\", function() {\n var templateCalled = 0, layoutCalled = 0;\n\n container.register('template:template', function() { templateCalled++; });\n container.register('template:layout', function() { layoutCalled++; });\n\n view = EmberView.create({\n container: container,\n layoutName: 'layout',\n templateName: 'template'\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(templateCalled, 0, \"template is not called when layout is present\");\n equal(layoutCalled, 1, \"layout is called when layout is present\");\n });\n\n test(\"should call the function of the associated template with itself as the context\", function() {\n container.register('template:testTemplate', function(dataSource) {\n return \"

    template was called for \" + get(dataSource, 'personName') + \"

    \";\n });\n\n view = EmberView.create({\n container: container,\n layoutName: 'testTemplate',\n\n context: {\n personName: \"Tom DAAAALE\"\n }\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(\"template was called for Tom DAAAALE\", view.$('#twas-called').text(), \"the named template was called with the view as the data source\");\n });\n\n test(\"should fall back to defaultTemplate if neither template nor templateName are provided\", function() {\n var View;\n\n View = EmberView.extend({\n defaultLayout: function(dataSource) { return \"

    template was called for \" + get(dataSource, 'personName') + \"

    \"; }\n });\n\n view = View.create({\n context: {\n personName: \"Tom DAAAALE\"\n }\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(\"template was called for Tom DAAAALE\", view.$('#twas-called').text(), \"the named template was called with the view as the data source\");\n });\n\n test(\"should not use defaultLayout if layout is provided\", function() {\n var View;\n\n View = EmberView.extend({\n layout: function() { return \"foo\"; },\n defaultLayout: function(dataSource) { return \"

    template was called for \" + get(dataSource, 'personName') + \"

    \"; }\n });\n\n view = View.create();\n run(function() {\n view.createElement();\n });\n\n\n equal(\"foo\", view.$().text(), \"default layout was not printed\");\n });\n\n test(\"the template property is available to the layout template\", function() {\n view = EmberView.create({\n template: function(context, options) {\n options.data.buffer.push(\" derp\");\n },\n\n layout: function(context, options) {\n options.data.buffer.push(\"Herp\");\n get(options.data.view, 'template')(context, options);\n }\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(\"Herp derp\", view.$().text(), \"the layout has access to the template\");\n });\n });\ndefine(\"ember-views/tests/views/view/nearest_of_type_test\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-metal/mixin\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n var run = __dependency3__[\"default\"];\n var EmberMixin = __dependency4__.Mixin;\n var View = __dependency5__.View;\n\n var parentView, view;\n\n module(\"View#nearest*\", {\n teardown: function() {\n run(function() {\n if (parentView) { parentView.destroy(); }\n if (view) { view.destroy(); }\n });\n }\n });\n\n (function() {\n var Mixin = EmberMixin.create({}),\n Parent = View.extend(Mixin, {\n render: function(buffer) {\n this.appendChild( View.create() );\n }\n });\n\n test(\"nearestOfType should find the closest view by view class\", function() {\n var child;\n\n run(function() {\n parentView = Parent.create();\n parentView.appendTo('#qunit-fixture');\n });\n\n child = parentView.get('childViews')[0];\n equal(child.nearestOfType(Parent), parentView, \"finds closest view in the hierarchy by class\");\n });\n\n test(\"nearestOfType should find the closest view by mixin\", function() {\n var child;\n\n run(function() {\n parentView = Parent.create();\n parentView.appendTo('#qunit-fixture');\n });\n\n child = parentView.get('childViews')[0];\n equal(child.nearestOfType(Mixin), parentView, \"finds closest view in the hierarchy by class\");\n });\n\n test(\"nearestWithProperty should search immediate parent\", function() {\n var childView;\n\n view = View.create({\n myProp: true,\n\n render: function(buffer) {\n this.appendChild(View.create());\n }\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n childView = view.get('childViews')[0];\n equal(childView.nearestWithProperty('myProp'), view);\n\n });\n\n }());\n });\ndefine(\"ember-views/tests/views/view/parse_property_path_test\",\n [\"ember-views/views/view\"],\n function(__dependency1__) {\n \"use strict\";\n var EmberView = __dependency1__.View;\n\n module(\"EmberView - _parsePropertyPath\");\n\n test(\"it works with a simple property path\", function() {\n var parsed = EmberView._parsePropertyPath(\"simpleProperty\");\n\n equal(parsed.path, \"simpleProperty\", \"path is parsed correctly\");\n equal(parsed.className, undefined, \"there is no className\");\n equal(parsed.falsyClassName, undefined, \"there is no falsyClassName\");\n equal(parsed.classNames, \"\", \"there is no classNames\");\n });\n\n test(\"it works with a more complex property path\", function() {\n var parsed = EmberView._parsePropertyPath(\"content.simpleProperty\");\n\n equal(parsed.path, \"content.simpleProperty\", \"path is parsed correctly\");\n equal(parsed.className, undefined, \"there is no className\");\n equal(parsed.falsyClassName, undefined, \"there is no falsyClassName\");\n equal(parsed.classNames, \"\", \"there is no classNames\");\n });\n\n test(\"className is extracted\", function() {\n var parsed = EmberView._parsePropertyPath(\"content.simpleProperty:class\");\n\n equal(parsed.path, \"content.simpleProperty\", \"path is parsed correctly\");\n equal(parsed.className, \"class\", \"className is extracted\");\n equal(parsed.falsyClassName, undefined, \"there is no falsyClassName\");\n equal(parsed.classNames, \":class\", \"there is a classNames\");\n });\n\n test(\"falsyClassName is extracted\", function() {\n var parsed = EmberView._parsePropertyPath(\"content.simpleProperty:class:falsyClass\");\n\n equal(parsed.path, \"content.simpleProperty\", \"path is parsed correctly\");\n equal(parsed.className, \"class\", \"className is extracted\");\n equal(parsed.falsyClassName, \"falsyClass\", \"falsyClassName is extracted\");\n equal(parsed.classNames, \":class:falsyClass\", \"there is a classNames\");\n });\n\n test(\"it works with an empty true class\", function() {\n var parsed = EmberView._parsePropertyPath(\"content.simpleProperty::falsyClass\");\n\n equal(parsed.path, \"content.simpleProperty\", \"path is parsed correctly\");\n equal(parsed.className, undefined, \"className is undefined\");\n equal(parsed.falsyClassName, \"falsyClass\", \"falsyClassName is extracted\");\n equal(parsed.classNames, \"::falsyClass\", \"there is a classNames\");\n });\n });\ndefine(\"ember-views/tests/views/view/remove_test\",\n [\"ember-metal/property_get\",\"ember-metal/property_set\",\"ember-metal/run_loop\",\"ember-metal/enumerable_utils\",\"ember-views/system/jquery\",\"ember-views/views/view\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__, __dependency7__) {\n \"use strict\";\n var get = __dependency1__.get;\n var set = __dependency2__.set;\n var run = __dependency3__[\"default\"];\n var EnumerableUtils = __dependency4__[\"default\"];\n var jQuery = __dependency5__[\"default\"];\n var View = __dependency6__.View;\n var ContainerView = __dependency7__[\"default\"];\n\n var indexOf = EnumerableUtils.indexOf;\n\n // .......................................................\n // removeChild()\n //\n\n var parentView, child;\n module(\"View#removeChild\", {\n setup: function() {\n parentView = ContainerView.create({ childViews: [View] });\n child = get(parentView, 'childViews').objectAt(0);\n },\n teardown: function() {\n run(function() {\n parentView.destroy();\n child.destroy();\n });\n }\n });\n\n test(\"returns receiver\", function() {\n equal(parentView.removeChild(child), parentView, 'receiver');\n });\n\n test(\"removes child from parent.childViews array\", function() {\n ok(indexOf(get(parentView, 'childViews'), child)>=0, 'precond - has child in childViews array before remove');\n parentView.removeChild(child);\n ok(indexOf(get(parentView, 'childViews'), child)<0, 'removed child');\n });\n\n test(\"sets parentView property to null\", function() {\n ok(get(child, 'parentView'), 'precond - has parentView');\n parentView.removeChild(child);\n ok(!get(child, 'parentView'), 'parentView is now null');\n });\n\n // .......................................................\n // removeAllChildren()\n //\n var view, childViews;\n module(\"View#removeAllChildren\", {\n setup: function() {\n view = ContainerView.create({\n childViews: [View, View, View]\n });\n childViews = view.get('childViews');\n },\n teardown: function() {\n run(function() {\n childViews.forEach(function(v) { v.destroy(); });\n view.destroy();\n });\n }\n });\n\n test(\"removes all child views\", function() {\n equal(get(view, 'childViews.length'), 3, 'precond - has child views');\n\n view.removeAllChildren();\n equal(get(view, 'childViews.length'), 0, 'removed all children');\n });\n\n test(\"returns receiver\", function() {\n equal(view.removeAllChildren(), view, 'receiver');\n });\n\n // .......................................................\n // removeFromParent()\n //\n module(\"View#removeFromParent\", {\n teardown: function() {\n run(function() {\n if (parentView) { parentView.destroy(); }\n if (child) { child.destroy(); }\n if (view) { view.destroy(); }\n });\n }\n });\n\n test(\"removes view from parent view\", function() {\n parentView = ContainerView.create({ childViews: [View] });\n child = get(parentView, 'childViews').objectAt(0);\n ok(get(child, 'parentView'), 'precond - has parentView');\n\n run(function() {\n parentView.createElement();\n });\n\n ok(parentView.$('div').length, \"precond - has a child DOM element\");\n\n run(function() {\n child.removeFromParent();\n });\n\n ok(!get(child, 'parentView'), 'no longer has parentView');\n ok(indexOf(get(parentView, 'childViews'), child)<0, 'no longer in parent childViews');\n equal(parentView.$('div').length, 0, \"removes DOM element from parent\");\n });\n\n test(\"returns receiver\", function() {\n parentView = ContainerView.create({ childViews: [View] });\n child = get(parentView, 'childViews').objectAt(0);\n var removed = run(function() {\n return child.removeFromParent();\n });\n\n equal(removed, child, 'receiver');\n });\n\n test(\"does nothing if not in parentView\", function() {\n var callCount = 0;\n child = View.create();\n\n // monkey patch for testing...\n ok(!get(child, 'parentView'), 'precond - has no parent');\n\n child.removeFromParent();\n\n run(function() {\n child.destroy();\n });\n });\n\n\n test(\"the DOM element is gone after doing append and remove in two separate runloops\", function() {\n view = View.create();\n run(function() {\n view.append();\n });\n run(function() {\n view.remove();\n });\n\n var viewElem = jQuery('#'+get(view, 'elementId'));\n ok(viewElem.length === 0, \"view's element doesn't exist in DOM\");\n });\n\n test(\"the DOM element is gone after doing append and remove in a single runloop\", function() {\n view = View.create();\n run(function() {\n view.append();\n view.remove();\n });\n\n var viewElem = jQuery('#'+get(view, 'elementId'));\n ok(viewElem.length === 0, \"view's element doesn't exist in DOM\");\n });\n });\ndefine(\"ember-views/tests/views/view/render_test\",\n [\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-views/system/jquery\",\"ember-views/views/view\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var get = __dependency1__.get;\n var run = __dependency2__[\"default\"];\n var EmberObject = __dependency3__[\"default\"];\n var jQuery = __dependency4__[\"default\"];\n var EmberView = __dependency5__.View;\n var ContainerView = __dependency6__[\"default\"];\n\n var view;\n\n // .......................................................\n // render()\n //\n module(\"EmberView#render\", {\n teardown: function() {\n run(function() {\n view.destroy();\n });\n }\n });\n\n test(\"default implementation does not render child views\", function() {\n\n var rendered = 0, updated = 0, parentRendered = 0, parentUpdated = 0 ;\n view = ContainerView.createWithMixins({\n childViews: [\"child\"],\n\n render: function(buffer) {\n parentRendered++;\n this._super(buffer);\n },\n\n child: EmberView.createWithMixins({\n render: function(buffer) {\n rendered++;\n this._super(buffer);\n }\n })\n });\n\n run(function() {\n view.createElement();\n });\n equal(rendered, 1, 'rendered the child once');\n equal(parentRendered, 1);\n equal(view.$('div').length, 1);\n\n });\n\n test(\"should invoke renderChildViews if layer is destroyed then re-rendered\", function() {\n\n var rendered = 0, parentRendered = 0, parentUpdated = 0 ;\n view = ContainerView.createWithMixins({\n childViews: [\"child\"],\n\n render: function(buffer) {\n parentRendered++;\n this._super(buffer);\n },\n\n child: EmberView.createWithMixins({\n render: function(buffer) {\n rendered++;\n this._super(buffer);\n }\n })\n });\n\n run(function() {\n view.append();\n });\n\n equal(rendered, 1, 'rendered the child once');\n equal(parentRendered, 1);\n equal(view.$('div').length, 1);\n\n run(function() {\n view.rerender();\n });\n\n equal(rendered, 2, 'rendered the child twice');\n equal(parentRendered, 2);\n equal(view.$('div').length, 1);\n\n run(function() {\n view.destroy();\n });\n });\n\n test(\"should render child views with a different tagName\", function() {\n var rendered = 0, parentRendered = 0, parentUpdated = 0 ;\n\n view = ContainerView.create({\n childViews: [\"child\"],\n\n child: EmberView.create({\n tagName: 'aside'\n })\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(view.$('aside').length, 1);\n });\n\n test(\"should add ember-view to views\", function() {\n view = EmberView.create();\n\n run(function() {\n view.createElement();\n });\n\n ok(view.$().hasClass('ember-view'), \"the view has ember-view\");\n });\n\n test(\"should allow hX tags as tagName\", function() {\n\n view = ContainerView.create({\n childViews: [\"child\"],\n\n child: EmberView.create({\n tagName: 'h3'\n })\n });\n\n run(function() {\n view.createElement();\n });\n\n ok(view.$('h3').length, \"does not render the h3 tag correctly\");\n });\n\n test(\"should not add role attribute unless one is specified\", function() {\n view = EmberView.create();\n\n run(function() {\n view.createElement();\n });\n\n ok(view.$().attr('role') === undefined, \"does not have a role attribute\");\n });\n\n test(\"should re-render if the context is changed\", function() {\n view = EmberView.create({\n elementId: 'template-context-test',\n context: { foo: \"bar\" },\n render: function(buffer) {\n var value = get(get(this, 'context'), 'foo');\n buffer.push(value);\n }\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n equal(jQuery('#qunit-fixture #template-context-test').text(), \"bar\", \"precond - renders the view with the initial value\");\n\n run(function() {\n view.set('context', {\n foo: \"bang baz\"\n });\n });\n\n equal(jQuery('#qunit-fixture #template-context-test').text(), \"bang baz\", \"re-renders the view with the updated context\");\n });\n });\ndefine(\"ember-views/tests/views/view/replace_in_test\",\n [\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-views/system/jquery\",\"ember-views/views/view\",\"ember-views/views/container_view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var get = __dependency1__.get;\n var run = __dependency2__[\"default\"];\n var jQuery = __dependency3__[\"default\"];\n var EmberView = __dependency4__.View;\n var ContainerView = __dependency5__[\"default\"];\n\n var View, view, willDestroyCalled, childView;\n\n module(\"EmberView - replaceIn()\", {\n setup: function() {\n View = EmberView.extend({});\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n });\n }\n });\n\n test(\"should be added to the specified element when calling replaceIn()\", function() {\n jQuery(\"#qunit-fixture\").html('
    ');\n\n view = View.create();\n\n ok(!get(view, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.replaceIn('#menu');\n });\n\n var viewElem = jQuery('#menu').children();\n ok(viewElem.length > 0, \"creates and replaces the view's element\");\n });\n\n test(\"raises an assert when a target does not exist in the DOM\", function() {\n view = View.create();\n\n expectAssertion(function() {\n run(function() {\n view.replaceIn('made-up-target');\n });\n });\n });\n\n\n test(\"should remove previous elements when calling replaceIn()\", function() {\n jQuery(\"#qunit-fixture\").html('

    Foo

    ');\n var viewElem = jQuery('#menu').children();\n\n view = View.create();\n\n ok(viewElem.length === 1, \"should have one element\");\n\n run(function() {\n view.replaceIn('#menu');\n });\n\n ok(viewElem.length === 1, \"should have one element\");\n\n });\n\n test(\"should move the view to the inDOM state after replacing\", function() {\n jQuery(\"#qunit-fixture\").html('
    ');\n view = View.create();\n\n run(function() {\n view.replaceIn('#menu');\n });\n\n equal(view.currentState, view.states.inDOM, \"the view is in the inDOM state\");\n });\n\n module(\"EmberView - replaceIn() in a view hierarchy\", {\n setup: function() {\n View = ContainerView.extend({\n childViews: ['child'],\n child: EmberView.extend({\n elementId: 'child'\n })\n });\n },\n\n teardown: function() {\n run(function() {\n view.destroy();\n });\n }\n });\n\n test(\"should be added to the specified element when calling replaceIn()\", function() {\n jQuery(\"#qunit-fixture\").html('
    ');\n\n view = View.create();\n\n ok(!get(view, 'element'), \"precond - should not have an element\");\n\n run(function() {\n view.replaceIn('#menu');\n });\n\n var viewElem = jQuery('#menu #child');\n ok(viewElem.length > 0, \"creates and replaces the view's element\");\n });\n });\ndefine(\"ember-views/tests/views/view/template_test\",\n [\"container\",\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {\n \"use strict\";\n var Container = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var run = __dependency3__[\"default\"];\n var EmberObject = __dependency4__[\"default\"];\n var EmberView = __dependency5__.View;\n\n var container, view;\n\n module(\"EmberView - Template Functionality\", {\n setup: function() {\n container = new Container();\n container.optionsForType('template', { instantiate: false });\n },\n teardown: function() {\n run(function() {\n if (view) { view.destroy(); }\n });\n }\n });\n\n test(\"should call the function of the associated template\", function() {\n container.register('template:testTemplate', function() {\n return \"

    template was called

    \";\n });\n\n view = EmberView.create({\n container: container,\n templateName: 'testTemplate'\n });\n\n run(function() {\n view.createElement();\n });\n\n ok(view.$('#twas-called').length, \"the named template was called\");\n });\n\n test(\"should call the function of the associated template with itself as the context\", function() {\n container.register('template:testTemplate', function(dataSource) {\n return \"

    template was called for \" + get(dataSource, 'personName') + \"

    \";\n });\n\n view = EmberView.create({\n container: container,\n templateName: 'testTemplate',\n\n context: {\n personName: \"Tom DAAAALE\"\n }\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(\"template was called for Tom DAAAALE\", view.$('#twas-called').text(), \"the named template was called with the view as the data source\");\n });\n\n test(\"should fall back to defaultTemplate if neither template nor templateName are provided\", function() {\n var View;\n\n View = EmberView.extend({\n defaultTemplate: function(dataSource) { return \"

    template was called for \" + get(dataSource, 'personName') + \"

    \"; }\n });\n\n view = View.create({\n context: {\n personName: \"Tom DAAAALE\"\n }\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(\"template was called for Tom DAAAALE\", view.$('#twas-called').text(), \"the named template was called with the view as the data source\");\n });\n\n test(\"should not use defaultTemplate if template is provided\", function() {\n var View;\n\n View = EmberView.extend({\n template: function() { return \"foo\"; },\n defaultTemplate: function(dataSource) { return \"

    template was called for \" + get(dataSource, 'personName') + \"

    \"; }\n });\n\n view = View.create();\n run(function() {\n view.createElement();\n });\n\n equal(\"foo\", view.$().text(), \"default template was not printed\");\n });\n\n test(\"should not use defaultTemplate if template is provided\", function() {\n var View;\n\n container.register('template:foobar', function() { return 'foo'; });\n\n View = EmberView.extend({\n container: container,\n templateName: 'foobar',\n defaultTemplate: function(dataSource) { return \"

    template was called for \" + get(dataSource, 'personName') + \"

    \"; }\n });\n\n view = View.create();\n run(function() {\n view.createElement();\n });\n\n equal(\"foo\", view.$().text(), \"default template was not printed\");\n });\n\n test(\"should render an empty element if no template is specified\", function() {\n view = EmberView.create();\n run(function() {\n view.createElement();\n });\n\n equal(view.$().html(), '', \"view div should be empty\");\n });\n\n test(\"should provide a controller to the template if a controller is specified on the view\", function() {\n expect(7);\n\n var Controller1 = EmberObject.extend({\n toString: function() { return \"Controller1\"; }\n });\n\n var Controller2 = EmberObject.extend({\n toString: function() { return \"Controller2\"; }\n });\n\n var controller1 = Controller1.create(),\n controller2 = Controller2.create(),\n optionsDataKeywordsControllerForView,\n optionsDataKeywordsControllerForChildView,\n contextForView,\n contextForControllerlessView;\n\n view = EmberView.create({\n controller: controller1,\n\n template: function(buffer, options) {\n optionsDataKeywordsControllerForView = options.data.keywords.controller;\n }\n });\n\n run(function() {\n view.appendTo('#qunit-fixture');\n });\n\n strictEqual(optionsDataKeywordsControllerForView, controller1, \"passes the controller in the data\");\n\n run(function() {\n view.destroy();\n });\n\n var parentView = EmberView.create({\n controller: controller1,\n\n template: function(buffer, options) {\n options.data.view.appendChild(EmberView.create({\n controller: controller2,\n templateData: options.data,\n template: function(context, options) {\n contextForView = context;\n optionsDataKeywordsControllerForChildView = options.data.keywords.controller;\n }\n }));\n optionsDataKeywordsControllerForView = options.data.keywords.controller;\n }\n });\n\n run(function() {\n parentView.appendTo('#qunit-fixture');\n });\n\n strictEqual(optionsDataKeywordsControllerForView, controller1, \"passes the controller in the data\");\n strictEqual(optionsDataKeywordsControllerForChildView, controller2, \"passes the child view's controller in the data\");\n\n run(function() {\n parentView.destroy();\n });\n\n var parentViewWithControllerlessChild = EmberView.create({\n controller: controller1,\n\n template: function(buffer, options) {\n options.data.view.appendChild(EmberView.create({\n templateData: options.data,\n template: function(context, options) {\n contextForControllerlessView = context;\n optionsDataKeywordsControllerForChildView = options.data.keywords.controller;\n }\n }));\n optionsDataKeywordsControllerForView = options.data.keywords.controller;\n }\n });\n\n run(function() {\n parentViewWithControllerlessChild.appendTo('#qunit-fixture');\n });\n\n strictEqual(optionsDataKeywordsControllerForView, controller1, \"passes the original controller in the data\");\n strictEqual(optionsDataKeywordsControllerForChildView, controller1, \"passes the controller in the data to child views\");\n strictEqual(contextForView, controller2, \"passes the controller in as the main context of the parent view\");\n strictEqual(contextForControllerlessView, controller1, \"passes the controller in as the main context of the child view\");\n\n run(function() {\n parentView.destroy();\n parentViewWithControllerlessChild.destroy();\n });\n });\n });\ndefine(\"ember-views/tests/views/view/view_lifecycle_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-views/system/jquery\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var run = __dependency3__[\"default\"];\n var EmberObject = __dependency4__[\"default\"];\n var jQuery = __dependency5__[\"default\"];\n var EmberView = __dependency6__.View;\n\n var originalLookup = Ember.lookup, lookup, view;\n\n module(\"views/view/view_lifecycle_test - pre-render\", {\n setup: function() {\n Ember.lookup = lookup = {};\n },\n\n teardown: function() {\n if (view) {\n run(function() {\n view.destroy();\n });\n }\n Ember.lookup = originalLookup;\n }\n });\n\n function tmpl(str) {\n return function(context, options) {\n options.data.buffer.push(str);\n };\n }\n\n test(\"should create and append a DOM element after bindings have synced\", function() {\n var ViewTest;\n\n lookup.ViewTest = ViewTest = {};\n\n run(function() {\n ViewTest.fakeController = EmberObject.create({\n fakeThing: 'controllerPropertyValue'\n });\n\n view = EmberView.createWithMixins({\n fooBinding: 'ViewTest.fakeController.fakeThing',\n\n render: function(buffer) {\n buffer.push(this.get('foo'));\n }\n });\n\n ok(!view.get('element'), \"precond - does not have an element before appending\");\n\n view.append();\n });\n\n equal(view.$().text(), 'controllerPropertyValue', \"renders and appends after bindings have synced\");\n });\n\n test(\"should throw an exception if trying to append a child before rendering has begun\", function() {\n run(function() {\n view = EmberView.create();\n });\n\n raises(function() {\n view.appendChild(EmberView, {});\n }, null, \"throws an error when calling appendChild()\");\n });\n\n test(\"should not affect rendering if rerender is called before initial render happens\", function() {\n run(function() {\n view = EmberView.create({\n template: tmpl(\"Rerender me!\")\n });\n\n view.rerender();\n view.append();\n });\n\n equal(view.$().text(), \"Rerender me!\", \"renders correctly if rerender is called first\");\n });\n\n test(\"should not affect rendering if destroyElement is called before initial render happens\", function() {\n run(function() {\n view = EmberView.create({\n template: tmpl(\"Don't destroy me!\")\n });\n\n view.destroyElement();\n view.append();\n });\n\n equal(view.$().text(), \"Don't destroy me!\", \"renders correctly if destroyElement is called first\");\n });\n\n module(\"views/view/view_lifecycle_test - in render\", {\n setup: function() {\n\n },\n\n teardown: function() {\n if (view) {\n run(function() {\n view.destroy();\n });\n }\n }\n });\n\n test(\"appendChild should work inside a template\", function() {\n run(function() {\n view = EmberView.create({\n template: function(context, options) {\n var buffer = options.data.buffer;\n\n buffer.push(\"

    Hi!

    \");\n\n options.data.view.appendChild(EmberView, {\n template: tmpl(\"Inception reached\")\n });\n\n buffer.push(\"\");\n }\n });\n\n view.appendTo(\"#qunit-fixture\");\n });\n\n ok(view.$('h1').length === 1 && view.$('div').length === 2,\n \"The appended child is visible\");\n });\n\n test(\"rerender should throw inside a template\", function() {\n raises(function() {\n run(function() {\n var renderCount = 0;\n view = EmberView.create({\n template: function(context, options) {\n var view = options.data.view;\n\n var child1 = view.appendChild(EmberView, {\n template: function(context, options) {\n renderCount++;\n options.data.buffer.push(String(renderCount));\n }\n });\n\n var child2 = view.appendChild(EmberView, {\n template: function(context, options) {\n options.data.buffer.push(\"Inside child2\");\n child1.rerender();\n }\n });\n }\n });\n\n view.appendTo(\"#qunit-fixture\");\n });\n }, /Something you did caused a view to re-render after it rendered but before it was inserted into the DOM./);\n });\n\n module(\"views/view/view_lifecycle_test - hasElement\", {\n teardown: function() {\n if (view) {\n run(function() {\n view.destroy();\n });\n }\n }\n });\n\n test(\"createElement puts the view into the hasElement state\", function() {\n view = EmberView.create({\n render: function(buffer) { buffer.push('hello'); }\n });\n\n run(function() {\n view.createElement();\n });\n\n equal(view.currentState, view.states.hasElement, \"the view is in the hasElement state\");\n });\n\n test(\"trigger rerender on a view in the hasElement state doesn't change its state to inDOM\", function() {\n view = EmberView.create({\n render: function(buffer) { buffer.push('hello'); }\n });\n\n run(function() {\n view.createElement();\n view.rerender();\n });\n\n equal(view.currentState, view.states.hasElement, \"the view is still in the hasElement state\");\n });\n\n\n module(\"views/view/view_lifecycle_test - in DOM\", {\n teardown: function() {\n if (view) {\n run(function() {\n view.destroy();\n });\n }\n }\n });\n\n test(\"should throw an exception when calling appendChild when DOM element exists\", function() {\n run(function() {\n view = EmberView.create({\n template: tmpl(\"Wait for the kick\")\n });\n\n view.append();\n });\n\n raises(function() {\n view.appendChild(EmberView, {\n template: tmpl(\"Ah ah ah! You didn't say the magic word!\")\n });\n }, null, \"throws an exception when calling appendChild after element is created\");\n });\n\n test(\"should replace DOM representation if rerender() is called after element is created\", function() {\n run(function() {\n view = EmberView.create({\n template: function(context, options) {\n var buffer = options.data.buffer;\n var value = context.get('shape');\n\n buffer.push(\"Do not taunt happy fun \"+value);\n },\n\n context: EmberObject.create({\n shape: 'sphere'\n })\n });\n\n view.append();\n });\n\n equal(view.$().text(), \"Do not taunt happy fun sphere\", \"precond - creates DOM element\");\n\n view.set('context.shape', 'ball');\n run(function() {\n view.rerender();\n });\n\n equal(view.$().text(), \"Do not taunt happy fun ball\", \"rerenders DOM element when rerender() is called\");\n });\n\n test(\"should destroy DOM representation when destroyElement is called\", function() {\n run(function() {\n view = EmberView.create({\n template: tmpl(\"Don't fear the reaper\")\n });\n\n view.append();\n });\n\n ok(view.get('element'), \"precond - generates a DOM element\");\n\n run(function() {\n view.destroyElement();\n });\n\n ok(!view.get('element'), \"destroys view when destroyElement() is called\");\n });\n\n test(\"should destroy DOM representation when destroy is called\", function() {\n run(function() {\n view = EmberView.create({\n template: tmpl(\"
    Don't fear the reaper
    \")\n });\n\n view.append();\n });\n\n ok(view.get('element'), \"precond - generates a DOM element\");\n\n run(function() {\n view.destroy();\n });\n\n ok(jQuery('#warning').length === 0, \"destroys element when destroy() is called\");\n });\n\n test(\"should throw an exception if trying to append an element that is already in DOM\", function() {\n run(function() {\n view = EmberView.create({\n template: tmpl('Broseidon, King of the Brocean')\n });\n\n view.append();\n });\n\n ok(view.get('element'), \"precond - creates DOM element\");\n\n raises(function() {\n run(function() {\n view.append();\n });\n }, null, \"raises an exception on second append\");\n });\n\n module(\"views/view/view_lifecycle_test - destroyed\");\n\n test(\"should throw an exception when calling appendChild after view is destroyed\", function() {\n run(function() {\n view = EmberView.create({\n template: tmpl(\"Wait for the kick\")\n });\n\n view.append();\n });\n\n run(function() {\n view.destroy();\n });\n\n raises(function() {\n view.appendChild(EmberView, {\n template: tmpl(\"Ah ah ah! You didn't say the magic word!\")\n });\n }, null, \"throws an exception when calling appendChild\");\n });\n\n test(\"should throw an exception when rerender is called after view is destroyed\", function() {\n run(function() {\n view = EmberView.create({\n template: tmpl('foo')\n });\n\n view.append();\n });\n\n run(function() {\n view.destroy();\n });\n\n raises(function() {\n view.rerender();\n }, null, \"throws an exception when calling rerender\");\n });\n\n test(\"should throw an exception when destroyElement is called after view is destroyed\", function() {\n run(function() {\n view = EmberView.create({\n template: tmpl('foo')\n });\n\n view.append();\n });\n\n run(function() {\n view.destroy();\n });\n\n raises(function() {\n view.destroyElement();\n }, null, \"throws an exception when calling destroyElement\");\n });\n\n test(\"trigger rerender on a view in the inDOM state keeps its state as inDOM\", function() {\n run(function() {\n view = EmberView.create({\n template: tmpl('foo')\n });\n\n view.append();\n });\n\n run(function() {\n view.rerender();\n });\n\n equal(view.currentState, view.states.inDOM, \"the view is still in the inDOM state\");\n\n run(function() {\n view.destroy();\n });\n });\n });\ndefine(\"ember-views/tests/views/view/virtual_views_test\",\n [\"ember-metal/core\",\"ember-metal/property_get\",\"ember-metal/run_loop\",\"ember-runtime/system/object\",\"ember-views/system/jquery\",\"ember-views/views/view\"],\n function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __dependency6__) {\n \"use strict\";\n var Ember = __dependency1__[\"default\"];\n var get = __dependency2__.get;\n var run = __dependency3__[\"default\"];\n var EmberObject = __dependency4__[\"default\"];\n var jQuery = __dependency5__[\"default\"];\n var EmberView = __dependency6__.View;\n\n var rootView, childView;\n\n module(\"virtual views\", {\n teardown: function() {\n run(function() {\n rootView.destroy();\n childView.destroy();\n });\n }\n });\n\n test(\"a virtual view does not appear as a view's parentView\", function() {\n rootView = EmberView.create({\n elementId: 'root-view',\n\n render: function(buffer) {\n buffer.push(\"

    Hi

    \");\n this.appendChild(virtualView);\n }\n });\n\n var virtualView = EmberView.create({\n isVirtual: true,\n tagName: '',\n\n render: function(buffer) {\n buffer.push(\"

    Virtual

    \");\n this.appendChild(childView);\n }\n });\n\n childView = EmberView.create({\n render: function(buffer) {\n buffer.push(\"

    Bye!

    \");\n }\n });\n\n run(function() {\n jQuery(\"#qunit-fixture\").empty();\n rootView.appendTo(\"#qunit-fixture\");\n });\n\n equal(jQuery(\"#root-view > h2\").length, 1, \"nodes with '' tagName do not create wrappers\");\n equal(get(childView, 'parentView'), rootView);\n\n var children = get(rootView, 'childViews');\n\n equal(get(children, 'length'), 1, \"there is one child element\");\n equal(children.objectAt(0), childView, \"the child element skips through the virtual view\");\n });\n\n test(\"when a virtual view's child views change, the parent's childViews should reflect\", function() {\n rootView = EmberView.create({\n elementId: 'root-view',\n\n render: function(buffer) {\n buffer.push(\"

    Hi

    \");\n this.appendChild(virtualView);\n }\n });\n\n var virtualView = EmberView.create({\n isVirtual: true,\n tagName: '',\n\n render: function(buffer) {\n buffer.push(\"

    Virtual

    \");\n this.appendChild(childView);\n }\n });\n\n childView = EmberView.create({\n render: function(buffer) {\n buffer.push(\"

    Bye!

    \");\n }\n });\n\n run(function() {\n jQuery(\"#qunit-fixture\").empty();\n rootView.appendTo(\"#qunit-fixture\");\n });\n\n equal(virtualView.get('childViews.length'), 1, \"has childView - precond\");\n equal(rootView.get('childViews.length'), 1, \"has childView - precond\");\n\n run(function() {\n childView.removeFromParent();\n });\n\n equal(virtualView.get('childViews.length'), 0, \"has no childView\");\n equal(rootView.get('childViews.length'), 0, \"has no childView\");\n });\n });\n})();\n//@ sourceURL=ember-views/~tests/ember-views");minispade.register('ember-views/~tests/ember-views_test', "(function() {minispade.require(\"ember-views/~tests/ember-views\");\nrequireModule(\"ember-views/tests/mixins/view_target_action_support_test\");\nrequireModule(\"ember-views/tests/system/event_dispatcher_test\");\nrequireModule(\"ember-views/tests/system/ext_test\");\nrequireModule(\"ember-views/tests/system/jquery_ext_test\");\nrequireModule(\"ember-views/tests/system/render_buffer_test\");\nrequireModule(\"ember-views/tests/views/collection_test\");\nrequireModule(\"ember-views/tests/views/component_test\");\nrequireModule(\"ember-views/tests/views/container_view_test\");\nrequireModule(\"ember-views/tests/views/view/actions_test\");\nrequireModule(\"ember-views/tests/views/view/append_to_test\");\nrequireModule(\"ember-views/tests/views/view/attribute_bindings_test\");\nrequireModule(\"ember-views/tests/views/view/child_views_test\");\nrequireModule(\"ember-views/tests/views/view/class_name_bindings_test\");\nrequireModule(\"ember-views/tests/views/view/class_string_for_value_test\");\nrequireModule(\"ember-views/tests/views/view/context_test\");\nrequireModule(\"ember-views/tests/views/view/controller_test\");\nrequireModule(\"ember-views/tests/views/view/create_child_view_test\");\nrequireModule(\"ember-views/tests/views/view/create_element_test\");\nrequireModule(\"ember-views/tests/views/view/destroy_element_test\");\nrequireModule(\"ember-views/tests/views/view/destroy_test\");\nrequireModule(\"ember-views/tests/views/view/element_test\");\nrequireModule(\"ember-views/tests/views/view/evented_test\");\nrequireModule(\"ember-views/tests/views/view/init_test\");\nrequireModule(\"ember-views/tests/views/view/is_visible_test\");\nrequireModule(\"ember-views/tests/views/view/jquery_test\");\nrequireModule(\"ember-views/tests/views/view/layout_test\");\nrequireModule(\"ember-views/tests/views/view/nearest_of_type_test\");\nrequireModule(\"ember-views/tests/views/view/parse_property_path_test\");\nrequireModule(\"ember-views/tests/views/view/remove_test\");\nrequireModule(\"ember-views/tests/views/view/render_test\");\nrequireModule(\"ember-views/tests/views/view/replace_in_test\");\nrequireModule(\"ember-views/tests/views/view/template_test\");\nrequireModule(\"ember-views/tests/views/view/view_lifecycle_test\");\nrequireModule(\"ember-views/tests/views/view/virtual_views_test\");\n})();\n//@ sourceURL=ember-views/~tests/ember-views_test");minispade.register('ember/~tests/application_lifecycle', "(function() {requireModule('ember-metal');\nrequireModule('ember-runtime');\nrequireModule('ember-handlebars-compiler');\nrequireModule('ember-handlebars');\nrequireModule('ember-views');\nrequireModule('ember-routing');\nrequireModule('ember-application');\nrequireModule('ember-extension-support');\n\nvar App, container, router;\n\nmodule(\"Application Lifecycle\", {\n setup: function() {\n Ember.run(function() {\n App = Ember.Application.create({\n rootElement: '#qunit-fixture'\n });\n\n App.Router.extend({\n location: 'none'\n });\n\n App.deferReadiness();\n\n container = App.__container__;\n });\n },\n\n teardown: function() {\n router = null;\n Ember.run(App, 'destroy');\n }\n});\n\nfunction handleURL(path) {\n router = container.lookup('router:main');\n return Ember.run(function() {\n return router.handleURL(path).then(function(value) {\n ok(true, 'url: `' + path + '` was handled');\n return value;\n }, function(reason) {\n ok(false, reason);\n throw reason;\n });\n });\n}\n\n\ntest(\"Resetting the application allows controller properties to be set when a route deactivates\", function() {\n App.Router.map(function() {\n this.route('home', { path: '/' });\n });\n\n App.HomeRoute = Ember.Route.extend({\n setupController: function() {\n this.controllerFor('home').set('selectedMenuItem', 'home');\n },\n deactivate: function() {\n this.controllerFor('home').set('selectedMenuItem', null);\n }\n });\n App.ApplicationRoute = Ember.Route.extend({\n setupController: function() {\n this.controllerFor('application').set('selectedMenuItem', 'home');\n },\n deactivate: function() {\n this.controllerFor('application').set('selectedMenuItem', null);\n }\n });\n\n var router = container.lookup('router:main');\n\n Ember.run(App, 'advanceReadiness');\n\n handleURL('/');\n\n equal(Ember.controllerFor(container, 'home').get('selectedMenuItem'), 'home');\n equal(Ember.controllerFor(container, 'application').get('selectedMenuItem'), 'home');\n\n App.reset();\n\n equal(Ember.controllerFor(container, 'home').get('selectedMenuItem'), null);\n equal(Ember.controllerFor(container, 'application').get('selectedMenuItem'), null);\n});\n\ntest(\"Destroying the application resets the router before the container is destroyed\", function() {\n App.Router.map(function() {\n this.route('home', { path: '/' });\n });\n\n App.HomeRoute = Ember.Route.extend({\n setupController: function() {\n this.controllerFor('home').set('selectedMenuItem', 'home');\n },\n deactivate: function() {\n this.controllerFor('home').set('selectedMenuItem', null);\n }\n });\n App.ApplicationRoute = Ember.Route.extend({\n setupController: function() {\n this.controllerFor('application').set('selectedMenuItem', 'home');\n },\n deactivate: function() {\n this.controllerFor('application').set('selectedMenuItem', null);\n }\n });\n\n var router = container.lookup('router:main');\n\n Ember.run(App, 'advanceReadiness');\n\n handleURL('/');\n\n equal(Ember.controllerFor(container, 'home').get('selectedMenuItem'), 'home');\n equal(Ember.controllerFor(container, 'application').get('selectedMenuItem'), 'home');\n\n Ember.run(App, 'destroy');\n\n equal(Ember.controllerFor(container, 'home').get('selectedMenuItem'), null);\n equal(Ember.controllerFor(container, 'application').get('selectedMenuItem'), null);\n});\n\n})();\n//@ sourceURL=ember/~tests/application_lifecycle");minispade.register('ember/~tests/component_registration_test', "(function() {requireModule('ember-metal');\nrequireModule('ember-runtime');\nrequireModule('ember-handlebars-compiler');\nrequireModule('ember-handlebars');\nrequireModule('ember-views');\nrequireModule('ember-routing');\nrequireModule('ember-application');\nrequireModule('ember-extension-support');\n\nvar App, container;\nvar compile = Ember.Handlebars.compile;\nvar originalHelpers;\n\nfunction prepare(){\n Ember.TEMPLATES[\"components/expand-it\"] = compile(\"

    hello {{yield}}

    \");\n Ember.TEMPLATES.application = compile(\"Hello world {{#expand-it}}world{{/expand-it}}\");\n\n originalHelpers = Ember.A(Ember.keys(Ember.Handlebars.helpers));\n}\n\nfunction cleanup(){\n Ember.run(function() {\n App.destroy();\n App = null;\n Ember.TEMPLATES = {};\n\n cleanupHandlebarsHelpers();\n });\n}\n\nfunction cleanupHandlebarsHelpers(){\n var currentHelpers = Ember.A(Ember.keys(Ember.Handlebars.helpers));\n\n currentHelpers.forEach(function(name){\n if (!originalHelpers.contains(name)) {\n delete Ember.Handlebars.helpers[name];\n }\n });\n}\n\nmodule(\"Application Lifecycle - Component Registration\", {\n setup: prepare,\n teardown: cleanup\n});\n\nfunction boot(callback) {\n Ember.run(function() {\n App = Ember.Application.create({\n name: 'App',\n rootElement: '#qunit-fixture'\n });\n\n App.deferReadiness();\n\n App.Router = Ember.Router.extend({\n location: 'none'\n });\n\n container = App.__container__;\n\n if (callback) { callback(); }\n });\n\n var router = container.lookup('router:main');\n\n Ember.run(App, 'advanceReadiness');\n Ember.run(function() {\n router.handleURL('/');\n });\n}\n\ntest(\"The helper becomes the body of the component\", function() {\n boot();\n equal(Ember.$('div.ember-view > div.ember-view', '#qunit-fixture').text(), \"hello world\", \"The component is composed correctly\");\n});\n\ntest(\"If a component is registered, it is used\", function() {\n boot(function() {\n container.register('component:expand-it', Ember.Component.extend({\n classNames: 'testing123'\n }));\n });\n\n equal(Ember.$('div.testing123', '#qunit-fixture').text(), \"hello world\", \"The component is composed correctly\");\n});\n\n\ntest(\"Late-registered components can be rendered with custom `template` property (DEPRECATED)\", function() {\n\n Ember.TEMPLATES.application = compile(\"
    there goes {{my-hero}}
    \");\n\n expectDeprecation(/Do not specify template on a Component/);\n\n boot(function() {\n container.register('component:my-hero', Ember.Component.extend({\n classNames: 'testing123',\n template: function() { return \"watch him as he GOES\"; }\n }));\n });\n\n equal(Ember.$('#wrapper').text(), \"there goes watch him as he GOES\", \"The component is composed correctly\");\n ok(!Ember.Handlebars.helpers['my-hero'], \"Component wasn't saved to global Handlebars.helpers hash\");\n});\n\ntest(\"Late-registered components can be rendered with template registered on the container\", function() {\n\n Ember.TEMPLATES.application = compile(\"
    hello world {{sally-rutherford}}-{{#sally-rutherford}}!!!{{/sally-rutherford}}
    \");\n\n boot(function() {\n container.register('template:components/sally-rutherford', compile(\"funkytowny{{yield}}\"));\n container.register('component:sally-rutherford', Ember.Component);\n });\n\n equal(Ember.$('#wrapper').text(), \"hello world funkytowny-funkytowny!!!\", \"The component is composed correctly\");\n ok(!Ember.Handlebars.helpers['sally-rutherford'], \"Component wasn't saved to global Handlebars.helpers hash\");\n});\n\ntest(\"Late-registered components can be rendered with ONLY the template registered on the container\", function() {\n\n Ember.TEMPLATES.application = compile(\"
    hello world {{borf-snorlax}}-{{#borf-snorlax}}!!!{{/borf-snorlax}}
    \");\n\n boot(function() {\n container.register('template:components/borf-snorlax', compile(\"goodfreakingTIMES{{yield}}\"));\n });\n\n equal(Ember.$('#wrapper').text(), \"hello world goodfreakingTIMES-goodfreakingTIMES!!!\", \"The component is composed correctly\");\n ok(!Ember.Handlebars.helpers['borf-snorlax'], \"Component wasn't saved to global Handlebars.helpers hash\");\n});\n\ntest(\"Component-like invocations are treated as bound paths if neither template nor component are registered on the container\", function() {\n\n Ember.TEMPLATES.application = compile(\"
    {{user-name}} hello {{api-key}} world
    \");\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n 'user-name': 'machty'\n }));\n });\n\n equal(Ember.$('#wrapper').text(), \"machty hello world\", \"The component is composed correctly\");\n});\n\ntest(\"Component lookups should take place on components' subcontainers\", function() {\n expect(1);\n\n Ember.TEMPLATES.application = compile(\"
    {{#sally-rutherford}}{{mach-ty}}{{/sally-rutherford}}
    \");\n\n boot(function() {\n container.register('component:sally-rutherford', Ember.Component.extend({\n init: function() {\n this._super();\n this.container = new Ember.Container(this.container);\n this.container.register('component:mach-ty', Ember.Component.extend({\n didInsertElement: function() {\n ok(true, \"mach-ty was rendered\");\n }\n }));\n }\n }));\n });\n});\n\ntest(\"Assigning templateName to a component should setup the template as a layout (DEPRECATED)\", function(){\n expect(2);\n\n Ember.TEMPLATES.application = compile(\"
    {{#my-component}}{{text}}{{/my-component}}
    \");\n Ember.TEMPLATES['foo-bar-baz'] = compile(\"{{text}}-{{yield}}\");\n\n expectDeprecation(/Do not specify templateName on a Component/);\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n 'text': 'outer'\n }));\n\n container.register('component:my-component', Ember.Component.extend({\n text: 'inner',\n templateName: 'foo-bar-baz'\n }));\n });\n\n equal(Ember.$('#wrapper').text(), \"inner-outer\", \"The component is composed correctly\");\n});\n\ntest(\"Assigning templateName and layoutName should use the templates specified\", function(){\n expect(1);\n\n Ember.TEMPLATES.application = compile(\"
    {{my-component}}
    \");\n Ember.TEMPLATES['foo'] = compile(\"{{text}}\");\n Ember.TEMPLATES['bar'] = compile(\"{{text}}-{{yield}}\");\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n 'text': 'outer'\n }));\n\n container.register('component:my-component', Ember.Component.extend({\n text: 'inner',\n layoutName: 'bar',\n templateName: 'foo'\n }));\n });\n\n equal(Ember.$('#wrapper').text(), \"inner-outer\", \"The component is composed correctly\");\n});\n\nmodule(\"Application Lifecycle - Component Context\", {\n setup: prepare,\n teardown: cleanup\n});\n\ntest(\"Components with a block should have the proper content when a template is provided\", function(){\n Ember.TEMPLATES.application = compile(\"
    {{#my-component}}{{text}}{{/my-component}}
    \");\n Ember.TEMPLATES['components/my-component'] = compile(\"{{text}}-{{yield}}\");\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n 'text': 'outer'\n }));\n\n container.register('component:my-component', Ember.Component.extend({\n text: 'inner'\n }));\n });\n\n equal(Ember.$('#wrapper').text(), \"inner-outer\", \"The component is composed correctly\");\n});\n\ntest(\"Components with a block should yield the proper content without a template provided\", function(){\n Ember.TEMPLATES.application = compile(\"
    {{#my-component}}{{text}}{{/my-component}}
    \");\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n 'text': 'outer'\n }));\n\n container.register('component:my-component', Ember.Component.extend({\n text: 'inner'\n }));\n });\n\n equal(Ember.$('#wrapper').text(), \"outer\", \"The component is composed correctly\");\n});\n\ntest(\"Components without a block should have the proper content when a template is provided\", function(){\n Ember.TEMPLATES.application = compile(\"
    {{my-component}}
    \");\n Ember.TEMPLATES['components/my-component'] = compile(\"{{text}}\");\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n 'text': 'outer'\n }));\n\n container.register('component:my-component', Ember.Component.extend({\n text: 'inner'\n }));\n });\n\n equal(Ember.$('#wrapper').text(), \"inner\", \"The component is composed correctly\");\n});\n\ntest(\"Components without a block should have the proper content\", function(){\n Ember.TEMPLATES.application = compile(\"
    {{my-component}}
    \");\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n 'text': 'outer'\n }));\n\n container.register('component:my-component', Ember.Component.extend({\n didInsertElement: function() {\n this.$().html('Some text inserted by jQuery');\n }\n }));\n });\n\n equal(Ember.$('#wrapper').text(), \"Some text inserted by jQuery\", \"The component is composed correctly\");\n});\n\ntest(\"properties of a component without a template should not collide with internal structures\", function(){\n Ember.TEMPLATES.application = compile(\"
    {{my-component data=foo}}
    \");\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n 'text': 'outer',\n 'foo': 'Some text inserted by jQuery'\n }));\n\n container.register('component:my-component', Ember.Component.extend({\n didInsertElement: function() {\n this.$().html(this.get('data'));\n }\n }));\n });\n\n equal(Ember.$('#wrapper').text(), \"Some text inserted by jQuery\", \"The component is composed correctly\");\n});\n\n\ntest(\"Components trigger actions in the parents context when called from within a block\", function(){\n Ember.TEMPLATES.application = compile(\"
    {{#my-component}}Fizzbuzz{{/my-component}}
    \");\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n actions: {\n fizzbuzz: function(){\n ok(true, 'action triggered on parent');\n }\n }\n }));\n\n container.register('component:my-component', Ember.Component.extend());\n });\n\n Ember.run(function(){\n Ember.$('#fizzbuzz', \"#wrapper\").click();\n });\n});\n\ntest(\"Components trigger actions in the components context when called from within its template\", function(){\n Ember.TEMPLATES.application = compile(\"
    {{#my-component}}{{text}}{{/my-component}}
    \");\n Ember.TEMPLATES['components/my-component'] = compile(\"Fizzbuzz\");\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n actions: {\n fizzbuzz: function(){\n ok(false, 'action triggered on the wrong context');\n }\n }\n }));\n\n container.register('component:my-component', Ember.Component.extend({\n actions: {\n fizzbuzz: function(){\n ok(true, 'action triggered on component');\n }\n }\n }));\n });\n\n Ember.$('#fizzbuzz', \"#wrapper\").click();\n});\n\n})();\n//@ sourceURL=ember/~tests/component_registration_test");minispade.register('ember/~tests/helpers/helper_registration_test', "(function() {var App, container;\nvar compile = Ember.Handlebars.compile;\n\nfunction reverseHelper(value) {\n return arguments.length > 1 ? value.split('').reverse().join('') : \"--\";\n}\n\n\nmodule(\"Application Lifecycle - Helper Registration\", {\n teardown: function() {\n Ember.run(function() {\n App.destroy();\n App = null;\n Ember.TEMPLATES = {};\n });\n }\n});\n\nvar boot = function(callback) {\n Ember.run(function() {\n App = Ember.Application.create({\n name: 'App',\n rootElement: '#qunit-fixture'\n });\n\n App.deferReadiness();\n\n App.Router = Ember.Router.extend({\n location: 'none'\n });\n\n container = App.__container__;\n\n if (callback) { callback(); }\n });\n\n var router = container.lookup('router:main');\n\n Ember.run(App, 'advanceReadiness');\n Ember.run(function() {\n router.handleURL('/');\n });\n};\n\ntest(\"Unbound dashed helpers registered on the container can be late-invoked\", function() {\n\n Ember.TEMPLATES.application = compile(\"
    {{x-borf}} {{x-borf YES}}
    \");\n\n boot(function() {\n container.register('helper:x-borf', function(val) {\n return arguments.length > 1 ? val : \"BORF\";\n });\n });\n\n equal(Ember.$('#wrapper').text(), \"BORF YES\", \"The helper was invoked from the container\");\n ok(!Ember.Handlebars.helpers['x-borf'], \"Container-registered helper doesn't wind up on global helpers hash\");\n});\n\ntest(\"Bound helpers registered on the container can be late-invoked\", function() {\n\n Ember.TEMPLATES.application = compile(\"
    {{x-reverse}} {{x-reverse foo}}
    \");\n\n boot(function() {\n container.register('controller:application', Ember.Controller.extend({\n foo: \"alex\"\n }));\n container.register('helper:x-reverse', Ember.Handlebars.makeBoundHelper(reverseHelper));\n });\n\n equal(Ember.$('#wrapper').text(), \"-- xela\", \"The bound helper was invoked from the container\");\n ok(!Ember.Handlebars.helpers['x-reverse'], \"Container-registered helper doesn't wind up on global helpers hash\");\n});\n\ntest(\"Undashed helpers registered on the container can not (presently) be invoked\", function() {\n\n var realHelperMissing = Ember.Handlebars.helpers.helperMissing;\n Ember.Handlebars.helpers.helperMissing = function() {\n return \"NOHALPER\";\n };\n\n // Note: the reason we're not allowing undashed helpers is to avoid\n // a possible perf hit in hot code paths, i.e. _triageMustache.\n // We only presently perform container lookups if prop.indexOf('-') >= 0\n\n Ember.TEMPLATES.application = compile(\"
    {{omg}}|{{omg 'GRRR'}}|{{yorp}}|{{yorp 'ahh'}}
    \");\n\n boot(function() {\n container.register('helper:omg', function() {\n return \"OMG\";\n });\n container.register('helper:yorp', Ember.Handlebars.makeBoundHelper(function() {\n return \"YORP\";\n }));\n });\n\n equal(Ember.$('#wrapper').text(), \"|NOHALPER||NOHALPER\", \"The undashed helper was invoked from the container\");\n\n Ember.Handlebars.helpers.helperMissing = realHelperMissing;\n});\n\n})();\n//@ sourceURL=ember/~tests/helpers/helper_registration_test");minispade.register('ember/~tests/helpers/link_to_test', "(function() {var Router, App, AppView, templates, router, eventDispatcher, container;\nvar get = Ember.get, set = Ember.set, map = Ember.ArrayPolyfills.map;\n\nfunction bootApplication() {\n router = container.lookup('router:main');\n Ember.run(App, 'advanceReadiness');\n}\n\n// IE includes the host name\nfunction normalizeUrl(url) {\n return url.replace(/https?:\\/\\/[^\\/]+/,'');\n}\n\nfunction compile(template) {\n return Ember.Handlebars.compile(template);\n}\n\nfunction shouldNotBeActive(selector) {\n checkActive(selector, false);\n}\n\nfunction shouldBeActive(selector) {\n checkActive(selector, true);\n}\n\nfunction checkActive(selector, active) {\n var classList = Ember.$(selector, '#qunit-fixture')[0].className;\n equal(classList.indexOf('active') > -1, active, selector + \" active should be \" + active.toString());\n}\n\nvar updateCount, replaceCount;\n\nfunction sharedSetup() {\n App = Ember.Application.create({\n name: \"App\",\n rootElement: '#qunit-fixture'\n });\n\n App.deferReadiness();\n\n updateCount = replaceCount = 0;\n App.Router.reopen({\n location: Ember.NoneLocation.createWithMixins({\n setURL: function(path) {\n updateCount++;\n set(this, 'path', path);\n },\n\n replaceURL: function(path) {\n replaceCount++;\n set(this, 'path', path);\n }\n })\n });\n\n Router = App.Router;\n container = App.__container__;\n}\n\nfunction sharedTeardown() {\n Ember.run(function() { App.destroy(); });\n Ember.TEMPLATES = {};\n}\n\nmodule(\"The {{link-to}} helper\", {\n setup: function() {\n Ember.run(function() {\n\n sharedSetup();\n\n Ember.TEMPLATES.app = Ember.Handlebars.compile(\"{{outlet}}\");\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    Home

    {{#link-to 'about' id='about-link'}}About{{/link-to}}{{#link-to 'index' id='self-link'}}Self{{/link-to}}\");\n Ember.TEMPLATES.about = Ember.Handlebars.compile(\"

    About

    {{#link-to 'index' id='home-link'}}Home{{/link-to}}{{#link-to 'about' id='self-link'}}Self{{/link-to}}\");\n Ember.TEMPLATES.item = Ember.Handlebars.compile(\"

    Item

    {{name}}

    {{#link-to 'index' id='home-link'}}Home{{/link-to}}\");\n\n AppView = Ember.View.extend({\n templateName: 'app'\n });\n\n container.register('view:app', AppView);\n container.register('router:main', Router);\n });\n },\n\n teardown: sharedTeardown\n});\n\ntest(\"The {{link-to}} helper moves into the named route\", function() {\n Router.map(function(match) {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('h3:contains(Home)', '#qunit-fixture').length, 1, \"The home template was rendered\");\n equal(Ember.$('#self-link.active', '#qunit-fixture').length, 1, \"The self-link was rendered with active class\");\n equal(Ember.$('#about-link:not(.active)', '#qunit-fixture').length, 1, \"The other link was rendered without active class\");\n\n Ember.run(function() {\n Ember.$('#about-link', '#qunit-fixture').click();\n });\n\n equal(Ember.$('h3:contains(About)', '#qunit-fixture').length, 1, \"The about template was rendered\");\n equal(Ember.$('#self-link.active', '#qunit-fixture').length, 1, \"The self-link was rendered with active class\");\n equal(Ember.$('#home-link:not(.active)', '#qunit-fixture').length, 1, \"The other link was rendered without active class\");\n});\n\ntest(\"The {{link-to}} helper supports URL replacement\", function() {\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    Home

    {{#link-to 'about' id='about-link' replace=true}}About{{/link-to}}\");\n\n Router.map(function() {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(updateCount, 0, 'precond: setURL has not been called');\n equal(replaceCount, 0, 'precond: replaceURL has not been called');\n\n Ember.run(function() {\n Ember.$('#about-link', '#qunit-fixture').click();\n });\n\n equal(updateCount, 0, 'setURL should not be called');\n equal(replaceCount, 1, 'replaceURL should be called once');\n});\n\ntest(\"the {{link-to}} helper doesn't add an href when the tagName isn't 'a'\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'about' id='about-link' tagName='div'}}About{{/link-to}}\");\n\n Router.map(function() {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('#about-link').attr('href'), undefined, \"there is no href attribute\");\n});\n\n\ntest(\"the {{link-to}} applies a 'disabled' class when disabled\", function () {\n Ember.TEMPLATES.index = Ember.Handlebars.compile('{{#link-to \"about\" id=\"about-link\" disabledWhen=\"shouldDisable\"}}About{{/link-to}}');\n App.IndexController = Ember.Controller.extend({\n shouldDisable: true\n });\n\n Router.map(function() {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('#about-link.disabled', '#qunit-fixture').length, 1, \"The link is disabled when its disabledWhen is true\");\n});\n\ntest(\"the {{link-to}} doesn't apply a 'disabled' class if disabledWhen is not provided\", function () {\n Ember.TEMPLATES.index = Ember.Handlebars.compile('{{#link-to \"about\" id=\"about-link\"}}About{{/link-to}}');\n\n Router.map(function() {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n ok(!Ember.$('#about-link', '#qunit-fixture').hasClass(\"disabled\"), \"The link is not disabled if disabledWhen not provided\");\n});\n\ntest(\"the {{link-to}} helper supports a custom disabledClass\", function () {\n Ember.TEMPLATES.index = Ember.Handlebars.compile('{{#link-to \"about\" id=\"about-link\" disabledWhen=\"shouldDisable\" disabledClass=\"do-not-want\"}}About{{/link-to}}');\n App.IndexController = Ember.Controller.extend({\n shouldDisable: true\n });\n\n Router.map(function() {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('#about-link.do-not-want', '#qunit-fixture').length, 1, \"The link can apply a custom disabled class\");\n\n});\n\ntest(\"the {{link-to}} helper does not respond to clicks when disabled\", function () {\n Ember.TEMPLATES.index = Ember.Handlebars.compile('{{#link-to \"about\" id=\"about-link\" disabledWhen=\"shouldDisable\"}}About{{/link-to}}');\n App.IndexController = Ember.Controller.extend({\n shouldDisable: true\n });\n\n Router.map(function() {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n Ember.run(function() {\n Ember.$('#about-link', '#qunit-fixture').click();\n });\n\n equal(Ember.$('h3:contains(About)', '#qunit-fixture').length, 0, \"Transitioning did not occur\");\n});\n\ntest(\"The {{link-to}} helper supports a custom activeClass\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    Home

    {{#link-to 'about' id='about-link'}}About{{/link-to}}{{#link-to 'index' id='self-link' activeClass='zomg-active'}}Self{{/link-to}}\");\n\n Router.map(function() {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('h3:contains(Home)', '#qunit-fixture').length, 1, \"The home template was rendered\");\n equal(Ember.$('#self-link.zomg-active', '#qunit-fixture').length, 1, \"The self-link was rendered with active class\");\n equal(Ember.$('#about-link:not(.active)', '#qunit-fixture').length, 1, \"The other link was rendered without active class\");\n});\n\ntest(\"The {{link-to}} helper supports leaving off .index for nested routes\", function() {\n Router.map(function() {\n this.resource(\"about\", function() {\n this.route(\"item\");\n });\n });\n\n Ember.TEMPLATES.about = compile(\"

    About

    {{outlet}}\");\n Ember.TEMPLATES['about/index'] = compile(\"
    Index
    \");\n Ember.TEMPLATES['about/item'] = compile(\"
    {{#link-to 'about'}}About{{/link-to}}
    \");\n\n bootApplication();\n\n Ember.run(router, 'handleURL', '/about/item');\n\n equal(normalizeUrl(Ember.$('#item a', '#qunit-fixture').attr('href')), '/about');\n});\n\ntest(\"The {{link-to}} helper supports custom, nested, currentWhen\", function() {\n Router.map(function(match) {\n this.resource(\"index\", { path: \"/\" }, function() {\n this.route(\"about\");\n });\n\n this.route(\"item\");\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    Home

    {{outlet}}\");\n Ember.TEMPLATES['index/about'] = Ember.Handlebars.compile(\"{{#link-to 'item' id='other-link' currentWhen='index'}}ITEM{{/link-to}}\");\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/about\");\n });\n\n equal(Ember.$('#other-link.active', '#qunit-fixture').length, 1, \"The link is active since currentWhen is a parent route\");\n});\n\ntest(\"The {{link-to}} helper does not disregards currentWhen when it is given explicitly for a resource\", function() {\n Router.map(function(match) {\n this.resource(\"index\", { path: \"/\" }, function() {\n this.route(\"about\");\n });\n\n this.resource(\"items\",function(){\n this.route('item');\n });\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    Home

    {{outlet}}\");\n Ember.TEMPLATES['index/about'] = Ember.Handlebars.compile(\"{{#link-to 'items' id='other-link' currentWhen='index'}}ITEM{{/link-to}}\");\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/about\");\n });\n\n equal(Ember.$('#other-link.active', '#qunit-fixture').length, 1, \"The link is active when currentWhen is given for explicitly for a resource\");\n});\n\ntest(\"The {{link-to}} helper defaults to bubbling\", function() {\n Ember.TEMPLATES.about = Ember.Handlebars.compile(\"
    {{#link-to 'about.contact' id='about-contact'}}About{{/link-to}}
    {{outlet}}\");\n Ember.TEMPLATES['about/contact'] = Ember.Handlebars.compile(\"

    Contact

    \");\n\n Router.map(function() {\n this.resource(\"about\", function() {\n this.route(\"contact\");\n });\n });\n\n var hidden = 0;\n\n App.AboutRoute = Ember.Route.extend({\n actions: {\n hide: function() {\n hidden++;\n }\n }\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/about\");\n });\n\n Ember.run(function() {\n Ember.$('#about-contact', '#qunit-fixture').click();\n });\n\n equal(Ember.$(\"#contact\", \"#qunit-fixture\").text(), \"Contact\", \"precond - the link worked\");\n\n equal(hidden, 1, \"The link bubbles\");\n});\n\ntest(\"The {{link-to}} helper supports bubbles=false\", function() {\n Ember.TEMPLATES.about = Ember.Handlebars.compile(\"
    {{#link-to 'about.contact' id='about-contact' bubbles=false}}About{{/link-to}}
    {{outlet}}\");\n Ember.TEMPLATES['about/contact'] = Ember.Handlebars.compile(\"

    Contact

    \");\n\n Router.map(function() {\n this.resource(\"about\", function() {\n this.route(\"contact\");\n });\n });\n\n var hidden = 0;\n\n App.AboutRoute = Ember.Route.extend({\n actions: {\n hide: function() {\n hidden++;\n }\n }\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/about\");\n });\n\n Ember.run(function() {\n Ember.$('#about-contact', '#qunit-fixture').click();\n });\n\n equal(Ember.$(\"#contact\", \"#qunit-fixture\").text(), \"Contact\", \"precond - the link worked\");\n\n equal(hidden, 0, \"The link didn't bubble\");\n});\n\ntest(\"The {{link-to}} helper moves into the named route with context\", function() {\n Router.map(function(match) {\n this.route(\"about\");\n this.resource(\"item\", { path: \"/item/:id\" });\n });\n\n Ember.TEMPLATES.about = Ember.Handlebars.compile(\"

    List

      {{#each controller}}
    • {{#link-to 'item' this}}{{name}}{{/link-to}}
    • {{/each}}
    {{#link-to 'index' id='home-link'}}Home{{/link-to}}\");\n\n App.AboutRoute = Ember.Route.extend({\n model: function() {\n return Ember.A([\n { id: \"yehuda\", name: \"Yehuda Katz\" },\n { id: \"tom\", name: \"Tom Dale\" },\n { id: \"erik\", name: \"Erik Brynroflsson\" }\n ]);\n }\n });\n\n App.ItemRoute = Ember.Route.extend({\n serialize: function(object) {\n return { id: object.id };\n }\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/about\");\n });\n\n equal(Ember.$('h3:contains(List)', '#qunit-fixture').length, 1, \"The home template was rendered\");\n equal(normalizeUrl(Ember.$('#home-link').attr('href')), '/', \"The home link points back at /\");\n\n Ember.run(function() {\n Ember.$('li a:contains(Yehuda)', '#qunit-fixture').click();\n });\n\n equal(Ember.$('h3:contains(Item)', '#qunit-fixture').length, 1, \"The item template was rendered\");\n equal(Ember.$('p', '#qunit-fixture').text(), \"Yehuda Katz\", \"The name is correct\");\n\n Ember.run(function() { Ember.$('#home-link').click(); });\n Ember.run(function() { Ember.$('#about-link').click(); });\n\n equal(normalizeUrl(Ember.$('li a:contains(Yehuda)').attr('href')), \"/item/yehuda\");\n equal(normalizeUrl(Ember.$('li a:contains(Tom)').attr('href')), \"/item/tom\");\n equal(normalizeUrl(Ember.$('li a:contains(Erik)').attr('href')), \"/item/erik\");\n\n Ember.run(function() {\n Ember.$('li a:contains(Erik)', '#qunit-fixture').click();\n });\n\n equal(Ember.$('h3:contains(Item)', '#qunit-fixture').length, 1, \"The item template was rendered\");\n equal(Ember.$('p', '#qunit-fixture').text(), \"Erik Brynroflsson\", \"The name is correct\");\n});\n\ntest(\"The {{link-to}} helper binds some anchor html tag common attributes\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    Home

    {{#link-to 'index' id='self-link' title='title-attr' rel='rel-attr'}}Self{{/link-to}}\");\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n var link = Ember.$('#self-link', '#qunit-fixture');\n equal(link.attr('title'), 'title-attr', \"The self-link contains title attribute\");\n equal(link.attr('rel'), 'rel-attr', \"The self-link contains rel attribute\");\n});\n\ntest(\"The {{link-to}} helper accepts string/numeric arguments\", function() {\n Router.map(function() {\n this.route('filter', { path: '/filters/:filter' });\n this.route('post', { path: '/post/:post_id' });\n this.route('repo', { path: '/repo/:owner/:name' });\n });\n\n App.FilterController = Ember.Controller.extend({\n filter: \"unpopular\",\n repo: Ember.Object.create({owner: 'ember', name: 'ember.js'}),\n post_id: 123\n });\n Ember.TEMPLATES.filter = compile('

    {{filter}}

    {{#link-to \"filter\" \"unpopular\" id=\"link\"}}Unpopular{{/link-to}}{{#link-to \"filter\" filter id=\"path-link\"}}Unpopular{{/link-to}}{{#link-to \"post\" post_id id=\"post-path-link\"}}Post{{/link-to}}{{#link-to \"post\" 123 id=\"post-number-link\"}}Post{{/link-to}}{{#link-to \"repo\" repo id=\"repo-object-link\"}}Repo{{/link-to}}');\n\n Ember.TEMPLATES.index = compile(' ');\n\n bootApplication();\n\n Ember.run(function() { router.handleURL(\"/filters/popular\"); });\n\n equal(normalizeUrl(Ember.$('#link', '#qunit-fixture').attr('href')), \"/filters/unpopular\");\n equal(normalizeUrl(Ember.$('#path-link', '#qunit-fixture').attr('href')), \"/filters/unpopular\");\n equal(normalizeUrl(Ember.$('#post-path-link', '#qunit-fixture').attr('href')), \"/post/123\");\n equal(normalizeUrl(Ember.$('#post-number-link', '#qunit-fixture').attr('href')), \"/post/123\");\n equal(normalizeUrl(Ember.$('#repo-object-link', '#qunit-fixture').attr('href')), \"/repo/ember/ember.js\");\n});\n\ntest(\"Issue 4201 - Shorthand for route.index shouldn't throw errors about context arguments\", function() {\n expect(2);\n Router.map(function() {\n this.resource('lobby', function() {\n this.route('index', {\n path: ':lobby_id'\n });\n this.route('list');\n });\n });\n\n App.LobbyIndexRoute = Ember.Route.extend({\n model: function(params) {\n equal(params.lobby_id, 'foobar');\n return params.lobby_id;\n }\n });\n\n Ember.TEMPLATES['lobby/index'] = compile(\"{{#link-to 'lobby' 'foobar' id='lobby-link'}}Lobby{{/link-to}}\");\n Ember.TEMPLATES.index = compile(\"\");\n Ember.TEMPLATES['lobby/list'] = compile(\"{{#link-to 'lobby' 'foobar' id='lobby-link'}}Lobby{{/link-to}}\");\n bootApplication();\n Ember.run(router, 'handleURL', '/lobby/list');\n Ember.run(Ember.$('#lobby-link'), 'click');\n shouldBeActive('#lobby-link');\n\n});\n\ntest(\"The {{link-to}} helper unwraps controllers\", function() {\n expect(3);\n\n Router.map(function() {\n this.route('filter', { path: '/filters/:filter' });\n });\n\n var indexObject = { filter: 'popular' };\n\n App.FilterRoute = Ember.Route.extend({\n model: function(params) {\n return indexObject;\n },\n\n serialize: function(passedObject) {\n equal(passedObject, indexObject, \"The unwrapped object is passed\");\n return { filter: 'popular' };\n }\n });\n\n App.IndexRoute = Ember.Route.extend({\n model: function() {\n return indexObject;\n }\n });\n\n Ember.TEMPLATES.filter = compile('

    {{filter}}

    ');\n Ember.TEMPLATES.index = compile('{{#link-to \"filter\" this id=\"link\"}}Filter{{/link-to}}');\n\n bootApplication();\n\n Ember.run(function() { router.handleURL(\"/\"); });\n\n Ember.$('#link', '#qunit-fixture').trigger('click');\n});\n\ntest(\"The {{link-to}} helper doesn't change view context\", function() {\n App.IndexView = Ember.View.extend({\n elementId: 'index',\n name: 'test',\n isTrue: true\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{view.name}}-{{#link-to 'index' id='self-link'}}Link: {{view.name}}-{{#if view.isTrue}}{{view.name}}{{/if}}{{/link-to}}\");\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('#index', '#qunit-fixture').text(), 'test-Link: test-test', \"accesses correct view\");\n});\n\ntest(\"Quoteless route param performs property lookup\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'index' id='string-link'}}string{{/link-to}}{{#link-to foo id='path-link'}}path{{/link-to}}{{#link-to view.foo id='view-link'}}{{view.foo}}{{/link-to}}\");\n\n function assertEquality(href) {\n equal(normalizeUrl(Ember.$('#string-link', '#qunit-fixture').attr('href')), '/');\n equal(normalizeUrl(Ember.$('#path-link', '#qunit-fixture').attr('href')), href);\n equal(normalizeUrl(Ember.$('#view-link', '#qunit-fixture').attr('href')), href);\n }\n\n App.IndexView = Ember.View.extend({\n foo: 'index',\n elementId: 'index-view'\n });\n\n App.IndexController = Ember.Controller.extend({\n foo: 'index'\n });\n\n App.Router.map(function() {\n this.route('about');\n });\n\n bootApplication();\n\n Ember.run(router, 'handleURL', '/');\n\n assertEquality('/');\n\n var controller = container.lookup('controller:index'),\n view = Ember.View.views['index-view'];\n Ember.run(function() {\n controller.set('foo', 'about');\n view.set('foo', 'about');\n });\n\n assertEquality('/about');\n});\n\ntest(\"link-to with null/undefined dynamic parameters are put in a loading state\", function() {\n\n expect(19);\n\n var oldWarn = Ember.Logger.warn, warnCalled = false;\n Ember.Logger.warn = function() { warnCalled = true; };\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to destinationRoute routeContext loadingClass='i-am-loading' id='context-link'}}string{{/link-to}}{{#link-to secondRoute loadingClass='i-am-loading' id='static-link'}}string{{/link-to}}\");\n\n var thing = Ember.Object.create({ id: 123 });\n\n App.IndexController = Ember.Controller.extend({\n destinationRoute: null,\n routeContext: null\n });\n\n App.AboutRoute = Ember.Route.extend({\n activate: function() {\n ok(true, \"About was entered\");\n }\n });\n\n App.Router.map(function() {\n this.route('thing', { path: '/thing/:thing_id' });\n this.route('about');\n });\n\n bootApplication();\n\n Ember.run(router, 'handleURL', '/');\n\n function assertLinkStatus($link, url) {\n if (url) {\n equal(normalizeUrl($link.attr('href')), url, \"loaded link-to has expected href\");\n ok(!$link.hasClass('i-am-loading'), \"loaded linkView has no loadingClass\");\n } else {\n equal(normalizeUrl($link.attr('href')), '#', \"unloaded link-to has href='#'\");\n ok($link.hasClass('i-am-loading'), \"loading linkView has loadingClass\");\n }\n }\n\n var $contextLink = Ember.$('#context-link', '#qunit-fixture'),\n $staticLink = Ember.$('#static-link', '#qunit-fixture'),\n controller = container.lookup('controller:index');\n\n assertLinkStatus($contextLink);\n assertLinkStatus($staticLink);\n\n Ember.run(function() {\n warnCalled = false;\n $contextLink.click();\n ok(warnCalled, \"Logger.warn was called from clicking loading link\");\n });\n\n // Set the destinationRoute (context is still null).\n Ember.run(controller, 'set', 'destinationRoute', 'thing');\n assertLinkStatus($contextLink);\n\n // Set the routeContext to an id\n Ember.run(controller, 'set', 'routeContext', '456');\n assertLinkStatus($contextLink, '/thing/456');\n\n // Test that 0 isn't interpreted as falsy.\n Ember.run(controller, 'set', 'routeContext', 0);\n assertLinkStatus($contextLink, '/thing/0');\n\n // Set the routeContext to an object\n Ember.run(controller, 'set', 'routeContext', thing);\n assertLinkStatus($contextLink, '/thing/123');\n\n // Set the destinationRoute back to null.\n Ember.run(controller, 'set', 'destinationRoute', null);\n assertLinkStatus($contextLink);\n\n Ember.run(function() {\n warnCalled = false;\n $staticLink.click();\n ok(warnCalled, \"Logger.warn was called from clicking loading link\");\n });\n\n Ember.run(controller, 'set', 'secondRoute', 'about');\n assertLinkStatus($staticLink, '/about');\n\n // Click the now-active link\n Ember.run($staticLink, 'click');\n\n Ember.Logger.warn = oldWarn;\n});\n\ntest(\"The {{link-to}} helper refreshes href element when one of params changes\", function() {\n Router.map(function() {\n this.route('post', { path: '/posts/:post_id' });\n });\n\n var post = Ember.Object.create({id: '1'}),\n secondPost = Ember.Object.create({id: '2'});\n\n Ember.TEMPLATES.index = compile('{{#link-to \"post\" post id=\"post\"}}post{{/link-to}}');\n\n App.IndexController = Ember.Controller.extend();\n var indexController = container.lookup('controller:index');\n\n Ember.run(function() { indexController.set('post', post); });\n\n bootApplication();\n\n Ember.run(function() { router.handleURL(\"/\"); });\n\n equal(normalizeUrl(Ember.$('#post', '#qunit-fixture').attr('href')), '/posts/1', 'precond - Link has rendered href attr properly');\n\n Ember.run(function() { indexController.set('post', secondPost); });\n\n equal(Ember.$('#post', '#qunit-fixture').attr('href'), '/posts/2', 'href attr was updated after one of the params had been changed');\n\n Ember.run(function() { indexController.set('post', null); });\n\n equal(Ember.$('#post', '#qunit-fixture').attr('href'), '#', 'href attr becomes # when one of the arguments in nullified');\n});\n\ntest(\"The {{link-to}} helper's bound parameter functionality works as expected in conjunction with an ObjectProxy/Controller\", function() {\n Router.map(function() {\n this.route('post', { path: '/posts/:post_id' });\n });\n\n var post = Ember.Object.create({id: '1'}),\n secondPost = Ember.Object.create({id: '2'});\n\n Ember.TEMPLATES = {\n index: compile(' '),\n post: compile('{{#link-to \"post\" this id=\"self-link\"}}selflink{{/link-to}}')\n };\n\n App.PostController = Ember.ObjectController.extend();\n var postController = container.lookup('controller:post');\n\n bootApplication();\n\n Ember.run(router, 'transitionTo', 'post', post);\n\n var $link = Ember.$('#self-link', '#qunit-fixture');\n equal(normalizeUrl($link.attr('href')), '/posts/1', 'self link renders post 1');\n\n Ember.run(postController, 'set', 'content', secondPost);\n var linkView = Ember.View.views['self-link'];\n\n equal(normalizeUrl($link.attr('href')), '/posts/2', 'self link updated to post 2');\n});\n\ntest(\"{{linkTo}} is aliased\", function() {\n var originalWarn = Ember.warn;\n\n Ember.warn = function(msg) {\n equal(msg, \"The 'linkTo' view helper is deprecated in favor of 'link-to'\", 'Warning called');\n };\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    Home

    {{#linkTo 'about' id='about-link' replace=true}}About{{/linkTo}}\");\n\n Router.map(function() {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n Ember.run(function() {\n Ember.$('#about-link', '#qunit-fixture').click();\n });\n\n equal(container.lookup('controller:application').get('currentRouteName'), 'about', 'linkTo worked properly');\n\n Ember.warn = originalWarn;\n});\n\ntest(\"The {{link-to}} helper is active when a resource is active\", function() {\n Router.map(function() {\n this.resource(\"about\", function() {\n this.route(\"item\");\n });\n });\n\n Ember.TEMPLATES.about = compile(\"
    {{#link-to 'about' id='about-link'}}About{{/link-to}} {{#link-to 'about.item' id='item-link'}}Item{{/link-to}} {{outlet}}
    \");\n Ember.TEMPLATES['about/item'] = compile(\" \");\n Ember.TEMPLATES['about/index'] = compile(\" \");\n\n bootApplication();\n\n Ember.run(router, 'handleURL', '/about');\n\n equal(Ember.$('#about-link.active', '#qunit-fixture').length, 1, \"The about resource link is active\");\n equal(Ember.$('#item-link.active', '#qunit-fixture').length, 0, \"The item route link is inactive\");\n\n Ember.run(router, 'handleURL', '/about/item');\n\n equal(Ember.$('#about-link.active', '#qunit-fixture').length, 1, \"The about resource link is active\");\n equal(Ember.$('#item-link.active', '#qunit-fixture').length, 1, \"The item route link is active\");\n\n});\n\ntest(\"The {{link-to}} helper works in an #each'd array of string route names\", function() {\n Router.map(function() {\n this.route('foo');\n this.route('bar');\n this.route('rar');\n });\n\n App.IndexController = Ember.Controller.extend({\n routeNames: Ember.A(['foo', 'bar', 'rar']),\n route1: 'bar',\n route2: 'foo'\n });\n\n Ember.TEMPLATES = {\n index: compile('{{#each routeName in routeNames}}{{#link-to routeName}}{{routeName}}{{/link-to}}{{/each}}{{#each routeNames}}{{#link-to this}}{{this}}{{/link-to}}{{/each}}{{#link-to route1}}a{{/link-to}}{{#link-to route2}}b{{/link-to}}')\n };\n\n bootApplication();\n\n function linksEqual($links, expected) {\n equal($links.length, expected.length, \"Has correct number of links\");\n\n var idx;\n for (idx = 0; idx < $links.length; idx++) {\n var href = Ember.$($links[idx]).attr('href');\n // Old IE includes the whole hostname as well\n equal(href.slice(-expected[idx].length), expected[idx], \"Expected link to be '\"+expected[idx]+\"', but was '\"+href+\"'\");\n }\n }\n\n linksEqual(Ember.$('a', '#qunit-fixture'), [\"/foo\", \"/bar\", \"/rar\", \"/foo\", \"/bar\", \"/rar\", \"/bar\", \"/foo\"]);\n\n var indexController = container.lookup('controller:index');\n Ember.run(indexController, 'set', 'route1', 'rar');\n\n linksEqual(Ember.$('a', '#qunit-fixture'), [\"/foo\", \"/bar\", \"/rar\", \"/foo\", \"/bar\", \"/rar\", \"/rar\", \"/foo\"]);\n\n Ember.run(indexController.routeNames, 'shiftObject');\n\n linksEqual(Ember.$('a', '#qunit-fixture'), [\"/bar\", \"/rar\", \"/bar\", \"/rar\", \"/rar\", \"/foo\"]);\n});\n\ntest(\"The non-block form {{link-to}} helper moves into the named route\", function() {\n expect(3);\n Router.map(function(match) {\n this.route(\"contact\");\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    Home

    {{link-to 'Contact us' 'contact' id='contact-link'}}{{#link-to 'index' id='self-link'}}Self{{/link-to}}\");\n Ember.TEMPLATES.contact = Ember.Handlebars.compile(\"

    Contact

    {{link-to 'Home' 'index' id='home-link'}}{{link-to 'Self' 'contact' id='self-link'}}\");\n\n bootApplication();\n\n Ember.run(function() {\n Ember.$('#contact-link', '#qunit-fixture').click();\n });\n\n equal(Ember.$('h3:contains(Contact)', '#qunit-fixture').length, 1, \"The contact template was rendered\");\n equal(Ember.$('#self-link.active', '#qunit-fixture').length, 1, \"The self-link was rendered with active class\");\n equal(Ember.$('#home-link:not(.active)', '#qunit-fixture').length, 1, \"The other link was rendered without active class\");\n});\n\ntest(\"The non-block form {{link-to}} helper updates the link text when it is a binding\", function() {\n expect(8);\n Router.map(function(match) {\n this.route(\"contact\");\n });\n\n App.IndexController = Ember.Controller.extend({\n contactName: 'Jane'\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    Home

    {{link-to contactName 'contact' id='contact-link'}}{{#link-to 'index' id='self-link'}}Self{{/link-to}}\");\n Ember.TEMPLATES.contact = Ember.Handlebars.compile(\"

    Contact

    {{link-to 'Home' 'index' id='home-link'}}{{link-to 'Self' 'contact' id='self-link'}}\");\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n var controller = container.lookup('controller:index');\n\n equal(Ember.$('#contact-link:contains(Jane)', '#qunit-fixture').length, 1, \"The link title is correctly resolved\");\n\n Ember.run(function() {\n controller.set('contactName', 'Joe');\n });\n equal(Ember.$('#contact-link:contains(Joe)', '#qunit-fixture').length, 1, \"The link title is correctly updated when the bound property changes\");\n\n Ember.run(function() {\n controller.set('contactName', 'Robert');\n });\n equal(Ember.$('#contact-link:contains(Robert)', '#qunit-fixture').length, 1, \"The link title is correctly updated when the bound property changes a second time\");\n\n Ember.run(function() {\n Ember.$('#contact-link', '#qunit-fixture').click();\n });\n\n equal(Ember.$('h3:contains(Contact)', '#qunit-fixture').length, 1, \"The contact template was rendered\");\n equal(Ember.$('#self-link.active', '#qunit-fixture').length, 1, \"The self-link was rendered with active class\");\n equal(Ember.$('#home-link:not(.active)', '#qunit-fixture').length, 1, \"The other link was rendered without active class\");\n\n Ember.run(function() {\n Ember.$('#home-link', '#qunit-fixture').click();\n });\n\n equal(Ember.$('h3:contains(Home)', '#qunit-fixture').length, 1, \"The index template was rendered\");\n equal(Ember.$('#contact-link:contains(Robert)', '#qunit-fixture').length, 1, \"The link title is correctly updated when the route changes\");\n});\n\ntest(\"The non-block form {{link-to}} helper moves into the named route with context\", function() {\n expect(5);\n Router.map(function(match) {\n this.route(\"item\", { path: \"/item/:id\" });\n });\n\n App.IndexRoute = Ember.Route.extend({\n model: function() {\n return Ember.A([\n { id: \"yehuda\", name: \"Yehuda Katz\" },\n { id: \"tom\", name: \"Tom Dale\" },\n { id: \"erik\", name: \"Erik Brynroflsson\" }\n ]);\n }\n });\n\n App.ItemRoute = Ember.Route.extend({\n serialize: function(object) {\n return { id: object.id };\n }\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    Home

      {{#each controller}}
    • {{link-to name 'item' this}}
    • {{/each}}
    \");\n Ember.TEMPLATES.item = Ember.Handlebars.compile(\"

    Item

    {{name}}

    {{#link-to 'index' id='home-link'}}Home{{/link-to}}\");\n\n bootApplication();\n\n Ember.run(function() {\n Ember.$('li a:contains(Yehuda)', '#qunit-fixture').click();\n });\n\n equal(Ember.$('h3:contains(Item)', '#qunit-fixture').length, 1, \"The item template was rendered\");\n equal(Ember.$('p', '#qunit-fixture').text(), \"Yehuda Katz\", \"The name is correct\");\n\n Ember.run(function() { Ember.$('#home-link').click(); });\n\n equal(normalizeUrl(Ember.$('li a:contains(Yehuda)').attr('href')), \"/item/yehuda\");\n equal(normalizeUrl(Ember.$('li a:contains(Tom)').attr('href')), \"/item/tom\");\n equal(normalizeUrl(Ember.$('li a:contains(Erik)').attr('href')), \"/item/erik\");\n\n});\n\ntest(\"The non-block form {{link-to}} performs property lookup\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{link-to 'string' 'index' id='string-link'}}{{link-to path foo id='path-link'}}{{link-to view.foo view.foo id='view-link'}}\");\n\n function assertEquality(href) {\n equal(normalizeUrl(Ember.$('#string-link', '#qunit-fixture').attr('href')), '/');\n equal(normalizeUrl(Ember.$('#path-link', '#qunit-fixture').attr('href')), href);\n equal(normalizeUrl(Ember.$('#view-link', '#qunit-fixture').attr('href')), href);\n }\n\n App.IndexView = Ember.View.extend({\n foo: 'index',\n elementId: 'index-view'\n });\n\n App.IndexController = Ember.Controller.extend({\n foo: 'index'\n });\n\n App.Router.map(function() {\n this.route('about');\n });\n\n bootApplication();\n\n Ember.run(router, 'handleURL', '/');\n\n assertEquality('/');\n\n var controller = container.lookup('controller:index'),\n view = Ember.View.views['index-view'];\n Ember.run(function() {\n controller.set('foo', 'about');\n view.set('foo', 'about');\n });\n\n assertEquality('/about');\n});\n\ntest(\"The non-block form {{link-to}} protects against XSS\", function() {\n Ember.TEMPLATES.application = Ember.Handlebars.compile(\"{{link-to display 'index' id='link'}}\");\n\n App.ApplicationController = Ember.Controller.extend({\n display: 'blahzorz'\n });\n\n bootApplication();\n\n Ember.run(router, 'handleURL', '/');\n\n var controller = container.lookup('controller:application');\n\n equal(Ember.$('#link', '#qunit-fixture').text(), 'blahzorz');\n Ember.run(function() {\n controller.set('display', 'BLAMMO');\n });\n\n equal(Ember.$('#link', '#qunit-fixture').text(), 'BLAMMO');\n equal(Ember.$('b', '#qunit-fixture').length, 0);\n});\n\ntest(\"the {{link-to}} helper calls preventDefault\", function(){\n Router.map(function() {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(router, 'handleURL', '/');\n\n var event = Ember.$.Event(\"click\");\n Ember.$('#about-link', '#qunit-fixture').trigger(event);\n\n equal(event.isDefaultPrevented(), true, \"should preventDefault\");\n});\n\ntest(\"the {{link-to}} helper does not call preventDefault if `preventDefault=false` is passed as an option\", function(){\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'about' id='about-link' preventDefault=false}}About{{/link-to}}\");\n\n Router.map(function() {\n this.route(\"about\");\n });\n\n bootApplication();\n\n Ember.run(router, 'handleURL', '/');\n\n var event = Ember.$.Event(\"click\");\n Ember.$('#about-link', '#qunit-fixture').trigger(event);\n\n equal(event.isDefaultPrevented(), false, \"should not preventDefault\");\n});\n\ntest(\"the {{link-to}} helper does not throw an error if its route has exited\", function(){\n expect(0);\n\n Ember.TEMPLATES.application = Ember.Handlebars.compile(\"{{#link-to 'index' id='home-link'}}Home{{/link-to}}{{#link-to 'post' defaultPost id='default-post-link'}}Default Post{{/link-to}}{{#if currentPost}}{{#link-to 'post' id='post-link'}}Post{{/link-to}}{{/if}}\");\n\n App.ApplicationController = Ember.Controller.extend({\n needs: ['post'],\n currentPost: Ember.computed.alias('controllers.post.model')\n });\n\n App.PostController = Ember.Controller.extend({\n model: {id: 1}\n });\n\n Router.map(function() {\n this.route(\"post\", {path: 'post/:post_id'});\n });\n\n bootApplication();\n\n Ember.run(router, 'handleURL', '/');\n\n Ember.run(function() {\n Ember.$('#default-post-link', '#qunit-fixture').click();\n });\n\n Ember.run(function() {\n Ember.$('#home-link', '#qunit-fixture').click();\n });\n});\n\ntest(\"{{link-to}} active property respects changing parent route context\", function() {\n Ember.TEMPLATES.application = Ember.Handlebars.compile(\n \"{{link-to 'OMG' 'things' 'omg' id='omg-link'}} \" +\n \"{{link-to 'LOL' 'things' 'lol' id='lol-link'}} \");\n\n\n Router.map(function() {\n this.resource('things', { path: '/things/:name' }, function() {\n this.route('other');\n });\n });\n\n bootApplication();\n\n Ember.run(router, 'handleURL', '/things/omg');\n shouldBeActive('#omg-link');\n shouldNotBeActive('#lol-link');\n\n Ember.run(router, 'handleURL', '/things/omg/other');\n shouldBeActive('#omg-link');\n shouldNotBeActive('#lol-link');\n\n});\n\nif (Ember.FEATURES.isEnabled(\"query-params-new\")) {\n\n test(\"{{link-to}} populates href with default query param values even without query-params object\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: '123'\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'index' id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n equal(Ember.$('#the-link').attr('href'), \"/\", \"link has right href\");\n });\n\n test(\"{{link-to}} populates href with default query param values with empty query-params object\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: '123'\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'index' (query-params) id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n equal(Ember.$('#the-link').attr('href'), \"/\", \"link has right href\");\n });\n\n test(\"{{link-to}} populates href with supplied query param values\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: '123'\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'index' (query-params foo='456') id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n equal(Ember.$('#the-link').attr('href'), \"/?foo=456\", \"link has right href\");\n });\n\n test(\"{{link-to}} populates href with partially supplied query param values\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo', 'bar'],\n foo: '123',\n bar: 'yes'\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'index' (query-params foo='456') id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n equal(Ember.$('#the-link').attr('href'), \"/?foo=456\", \"link has right href\");\n });\n\n test(\"{{link-to}} populates href with partially supplied query param values, but omits if value is default value\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo', 'bar'],\n foo: '123',\n bar: 'yes'\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'index' (query-params foo='123') id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n equal(Ember.$('#the-link').attr('href'), \"/\", \"link has right href\");\n });\n\n test(\"{{link-to}} populates href with fully supplied query param values\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo', 'bar'],\n foo: '123',\n bar: 'yes'\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'index' (query-params foo='456' bar='NAW') id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n equal(Ember.$('#the-link').attr('href'), \"/?bar=NAW&foo=456\", \"link has right href\");\n });\n\n module(\"The {{link-to}} helper: invoking with query params\", {\n setup: function() {\n Ember.run(function() {\n sharedSetup();\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo', 'bar', 'abool'],\n foo: '123',\n bar: 'abc',\n boundThing: \"OMG\",\n abool: true\n });\n\n App.AboutController = Ember.Controller.extend({\n queryParams: ['baz', 'bat'],\n baz: 'alex',\n bat: 'borf'\n });\n\n container.register('router:main', Router);\n });\n },\n\n teardown: sharedTeardown\n });\n\n test(\"doesn't update controller QP properties on current route when invoked\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'index' id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n\n Ember.run(Ember.$('#the-link'), 'click');\n var indexController = container.lookup('controller:index');\n deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, \"controller QP properties not\");\n });\n\n test(\"doesn't update controller QP properties on current route when invoked (empty query-params obj)\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'index' (query-params) id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n\n Ember.run(Ember.$('#the-link'), 'click');\n var indexController = container.lookup('controller:index');\n deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, \"controller QP properties not\");\n });\n\n test(\"doesn't update controller QP properties on current route when invoked (inferred route)\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n\n Ember.run(Ember.$('#the-link'), 'click');\n var indexController = container.lookup('controller:index');\n deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, \"controller QP properties not\");\n });\n\n test(\"doesn't update controller QP properties on current route when invoked (empty query-params obj, inferred route)\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to (query-params) id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n\n Ember.run(Ember.$('#the-link'), 'click');\n var indexController = container.lookup('controller:index');\n deepEqual(indexController.getProperties('foo', 'bar'), { foo: '123', bar: 'abc' }, \"controller QP properties not\");\n });\n\n test(\"updates controller QP properties on current route when invoked\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'index' (query-params foo='456') id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n\n Ember.run(Ember.$('#the-link'), 'click');\n var indexController = container.lookup('controller:index');\n deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, \"controller QP properties updated\");\n });\n\n test(\"updates controller QP properties on current route when invoked (inferred route)\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to (query-params foo='456') id='the-link'}}Index{{/link-to}}\");\n bootApplication();\n\n Ember.run(Ember.$('#the-link'), 'click');\n var indexController = container.lookup('controller:index');\n deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, \"controller QP properties updated\");\n });\n\n test(\"updates controller QP properties on other route after transitioning to that route\", function() {\n Router.map(function() {\n this.route('about');\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to 'about' (query-params baz='lol') id='the-link'}}About{{/link-to}}\");\n bootApplication();\n\n equal(Ember.$('#the-link').attr('href'), '/about?baz=lol');\n Ember.run(Ember.$('#the-link'), 'click');\n var aboutController = container.lookup('controller:about');\n deepEqual(aboutController.getProperties('baz', 'bat'), { baz: 'lol', bat: 'borf' }, \"about controller QP properties updated\");\n\n equal(container.lookup('controller:application').get('currentPath'), \"about\");\n });\n\n test(\"supplied QP properties can be bound\", function() {\n var indexController = container.lookup('controller:index');\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to (query-params foo=boundThing) id='the-link'}}Index{{/link-to}}\");\n\n bootApplication();\n\n equal(Ember.$('#the-link').attr('href'), '/?foo=OMG');\n Ember.run(indexController, 'set', 'boundThing', \"ASL\");\n equal(Ember.$('#the-link').attr('href'), '/?foo=ASL');\n });\n\n test(\"supplied QP properties can be bound (booleans)\", function() {\n var indexController = container.lookup('controller:index');\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to (query-params abool=boundThing) id='the-link'}}Index{{/link-to}}\");\n\n bootApplication();\n\n equal(Ember.$('#the-link').attr('href'), '/?abool=OMG');\n Ember.run(indexController, 'set', 'boundThing', false);\n equal(Ember.$('#the-link').attr('href'), '/?abool=false');\n\n Ember.run(Ember.$('#the-link'), 'click');\n\n deepEqual(indexController.getProperties('foo', 'bar', 'abool'), { foo: '123', bar: 'abc', abool: false });\n });\n\n test(\"href updates when unsupplied controller QP props change\", function() {\n var indexController = container.lookup('controller:index');\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{#link-to (query-params foo='lol') id='the-link'}}Index{{/link-to}}\");\n\n bootApplication();\n\n equal(Ember.$('#the-link').attr('href'), '/?foo=lol');\n Ember.run(indexController, 'set', 'bar', 'BORF');\n equal(Ember.$('#the-link').attr('href'), '/?bar=BORF&foo=lol');\n Ember.run(indexController, 'set', 'foo', 'YEAH');\n equal(Ember.$('#the-link').attr('href'), '/?bar=BORF&foo=lol');\n });\n\n test(\"The {{link-to}} applies activeClass when query params are not changed\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\n \"{{#link-to (query-params foo='cat') id='cat-link'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params foo='dog') id='dog-link'}}Index{{/link-to}} \" +\n \"{{#link-to 'index' id='change-nothing'}}Index{{/link-to}}\"\n );\n\n Ember.TEMPLATES.search = Ember.Handlebars.compile(\n \"{{#link-to (query-params search='same') id='same-search'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params search='change') id='change-search'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params search='same' archive=true) id='same-search-add-archive'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params archive=true) id='only-add-archive'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params search='same' archive=true) id='both-same'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params search='different' archive=true) id='change-one'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params search='different' archive=false) id='remove-one'}}Index{{/link-to}} \" +\n \"{{#link-to id='change-nothing'}}Index{{/link-to}} \" +\n \"{{outlet}}\"\n );\n\n Ember.TEMPLATES['search/results'] = Ember.Handlebars.compile(\n \"{{#link-to (query-params sort='title') id='same-sort-child-only'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params search='same') id='same-search-parent-only'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params search='change') id='change-search-parent-only'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params search='same' sort='title') id='same-search-same-sort-child-and-parent'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params search='same' sort='author') id='same-search-different-sort-child-and-parent'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params search='change' sort='title') id='change-search-same-sort-child-and-parent'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params foo='dog') id='dog-link'}}Index{{/link-to}} \"\n );\n\n\n\n Router.map(function() {\n this.resource(\"search\", function() {\n this.route(\"results\");\n });\n });\n\n App.SearchController = Ember.Controller.extend({\n queryParams: ['search', 'archive'],\n search: '',\n archive: false\n });\n\n App.SearchResultsController = Ember.Controller.extend({\n queryParams: ['sort', 'showDetails'],\n sort: 'title',\n showDetails: true\n });\n\n bootApplication();\n\n //Basic tests\n shouldNotBeActive('#cat-link');\n shouldNotBeActive('#dog-link');\n Ember.run(router, 'handleURL', '/?foo=cat');\n shouldBeActive('#cat-link');\n shouldNotBeActive('#dog-link');\n Ember.run(router, 'handleURL', '/?foo=dog');\n shouldBeActive('#dog-link');\n shouldNotBeActive('#cat-link');\n shouldBeActive('#change-nothing');\n\n //Multiple params\n Ember.run(function() {\n router.handleURL(\"/search?search=same\");\n });\n shouldBeActive('#same-search');\n shouldNotBeActive('#change-search');\n shouldNotBeActive('#same-search-add-archive');\n shouldNotBeActive('#only-add-archive');\n shouldNotBeActive('#remove-one');\n shouldBeActive('#change-nothing');\n\n Ember.run(function() {\n router.handleURL(\"/search?search=same&archive\");\n });\n shouldBeActive('#both-same');\n shouldNotBeActive('#change-one');\n\n //Nested Controllers\n Ember.run(function() {\n router.handleURL(\"/search/results?search=same&sort=title&showDetails\");\n });\n shouldBeActive('#same-sort-child-only');\n shouldBeActive('#same-search-parent-only');\n shouldNotBeActive('#change-search-parent-only');\n shouldBeActive('#same-search-same-sort-child-and-parent');\n shouldNotBeActive('#same-search-different-sort-child-and-parent');\n shouldNotBeActive('#change-search-same-sort-child-and-parent');\n\n\n });\n\n test(\"The {{link-to}} applies active class when query-param is number\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\n \"{{#link-to (query-params page=pageNumber) id='page-link'}}Index{{/link-to}} \");\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['page'],\n page: 1,\n pageNumber: 5\n });\n\n bootApplication();\n\n shouldNotBeActive('#page-link');\n Ember.run(router, 'handleURL', '/?page=5');\n shouldBeActive('#page-link');\n\n });\n\n test(\"The {{link-to}} applies active class when query-param is array\", function() {\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\n \"{{#link-to (query-params pages=pagesArray) id='array-link'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params pages=biggerArray) id='bigger-link'}}Index{{/link-to}} \" +\n \"{{#link-to (query-params pages=emptyArray) id='empty-link'}}Index{{/link-to}} \"\n );\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['pages'],\n pages: [],\n pagesArray: [1,2],\n biggerArray: [1,2,3],\n emptyArray: []\n });\n\n bootApplication();\n\n shouldNotBeActive('#array-link');\n Ember.run(router, 'handleURL', '/?pages=%5B1%2C2%5D');\n shouldBeActive('#array-link');\n shouldNotBeActive('#bigger-link');\n shouldNotBeActive('#empty-link');\n Ember.run(router, 'handleURL', '/?pages=%5B2%2C1%5D');\n shouldNotBeActive('#array-link');\n shouldNotBeActive('#bigger-link');\n shouldNotBeActive('#empty-link');\n Ember.run(router, 'handleURL', '/?pages=%5B1%2C2%2C3%5D');\n shouldBeActive('#bigger-link');\n shouldNotBeActive('#array-link');\n shouldNotBeActive('#empty-link');\n });\n\n test(\"The {{link-to}} applies active class to parent route\", function() {\n App.Router.map(function() {\n this.resource('parent', function() {\n this.route('child');\n });\n });\n\n Ember.TEMPLATES.application = Ember.Handlebars.compile(\n \"{{#link-to 'parent' id='parent-link'}}Parent{{/link-to}} \" +\n \"{{#link-to 'parent.child' id='parent-child-link'}}Child{{/link-to}} \" +\n \"{{outlet}}\"\n );\n\n App.ParentChildController = Ember.ObjectController.extend({\n queryParams: ['foo'],\n foo: 'bar'\n });\n\n bootApplication();\n shouldNotBeActive('#parent-link');\n shouldNotBeActive('#parent-child-link');\n Ember.run(router, 'handleURL', '/parent/child?foo=dog');\n shouldBeActive('#parent-link');\n });\n}\n\nfunction basicEagerURLUpdateTest(setTagName) {\n expect(6);\n\n if (setTagName) {\n Ember.TEMPLATES.application = Ember.Handlebars.compile(\"{{outlet}}{{link-to 'Index' 'index' id='index-link'}}{{link-to 'About' 'about' id='about-link' tagName='span'}}\");\n }\n\n bootApplication();\n equal(updateCount, 0);\n Ember.run(Ember.$('#about-link'), 'click');\n\n // URL should be eagerly updated now\n equal(updateCount, 1);\n equal(router.get('location.path'), '/about');\n\n // Resolve the promise.\n Ember.run(aboutDefer, 'resolve');\n equal(router.get('location.path'), '/about');\n\n // Shouldn't have called update url again.\n equal(updateCount, 1);\n equal(router.get('location.path'), '/about');\n}\n\nvar aboutDefer;\nmodule(\"The {{link-to}} helper: eager URL updating\", {\n setup: function() {\n Ember.run(function() {\n sharedSetup();\n\n container.register('router:main', Router);\n\n Router.map(function() {\n this.route('about');\n });\n\n App.AboutRoute = Ember.Route.extend({\n model: function() {\n aboutDefer = Ember.RSVP.defer();\n return aboutDefer.promise;\n }\n });\n\n Ember.TEMPLATES.application = Ember.Handlebars.compile(\"{{outlet}}{{link-to 'Index' 'index' id='index-link'}}{{link-to 'About' 'about' id='about-link'}}\");\n });\n },\n\n teardown: function() {\n sharedTeardown();\n aboutDefer = null;\n }\n});\n\ntest(\"invoking a link-to with a slow promise eager updates url\", function() {\n basicEagerURLUpdateTest(false);\n});\n\ntest(\"when link-to eagerly updates url, the path it provides does NOT include the rootURL\", function() {\n expect(2);\n\n // HistoryLocation is the only Location class that will cause rootURL to be\n // prepended to link-to href's right now\n var HistoryTestLocation = Ember.HistoryLocation.extend({\n // Don't actually touch the URL\n replaceState: function(path) {},\n pushState: function(path) {},\n\n setURL: function(path) {\n set(this, 'path', path);\n },\n\n replaceURL: function(path) {\n set(this, 'path', path);\n }\n });\n\n container.register('location:historyTest', HistoryTestLocation);\n\n Router.reopen({\n location: 'historyTest',\n rootURL: '/app/'\n });\n\n bootApplication();\n\n // href should have rootURL prepended\n equal(Ember.$('#about-link').attr('href'), '/app/about');\n\n Ember.run(Ember.$('#about-link'), 'click');\n\n // Actual path provided to Location class should NOT have rootURL\n equal(router.get('location.path'), '/about');\n});\n\ntest(\"non `a` tags also eagerly update URL\", function() {\n basicEagerURLUpdateTest(true);\n});\n\ntest(\"invoking a link-to with a promise that rejects on the run loop doesn't update url\", function() {\n App.AboutRoute = Ember.Route.extend({\n model: function() {\n return Ember.RSVP.reject();\n }\n });\n\n bootApplication();\n Ember.run(Ember.$('#about-link'), 'click');\n\n // Shouldn't have called update url.\n equal(updateCount, 0);\n equal(router.get('location.path'), '', 'url was not updated');\n});\n\ntest(\"invoking a link-to whose transition gets aborted in will transition doesn't update the url\", function() {\n App.IndexRoute = Ember.Route.extend({\n actions: {\n willTransition: function(transition) {\n ok(true, \"aborting transition\");\n transition.abort();\n }\n }\n });\n\n bootApplication();\n Ember.run(Ember.$('#about-link'), 'click');\n\n // Shouldn't have called update url.\n equal(updateCount, 0);\n equal(router.get('location.path'), '', 'url was not updated');\n});\n\n\n})();\n//@ sourceURL=ember/~tests/helpers/link_to_test");minispade.register('ember/~tests/homepage_example_test', "(function() {var App, $fixture;\n\nfunction setupExample() {\n // setup templates\n Ember.TEMPLATES.application = Ember.Handlebars.compile(\"{{outlet}}\");\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    People

      {{#each model}}
    • Hello, {{fullName}}!
    • {{/each}}
    \");\n\n\n App.Person = Ember.Object.extend({\n firstName: null,\n lastName: null,\n\n fullName: Ember.computed('firstName', 'lastName', function() {\n return this.get('firstName') + \" \" + this.get('lastName');\n })\n });\n\n App.IndexRoute = Ember.Route.extend({\n model: function() {\n var people = Ember.A([\n App.Person.create({\n firstName: \"Tom\",\n lastName: \"Dale\"\n }),\n App.Person.create({\n firstName: \"Yehuda\",\n lastName: \"Katz\"\n })\n ]);\n return people;\n }\n });\n}\n\nmodule(\"Homepage Example\", {\n setup: function() {\n Ember.run(function() {\n App = Ember.Application.create({\n name: \"App\",\n rootElement: '#qunit-fixture'\n });\n App.deferReadiness();\n\n App.Router.reopen({\n location: 'none'\n });\n\n App.LoadingRoute = Ember.Route.extend();\n });\n\n $fixture = Ember.$('#qunit-fixture');\n\n\n setupExample();\n\n },\n\n teardown: function() {\n Ember.run(function() {\n App.destroy();\n App = null;\n\n Ember.TEMPLATES = {};\n });\n }\n});\n\n\ntest(\"The example renders correctly\", function() {\n Ember.run(App, 'advanceReadiness');\n\n equal($fixture.find('h1:contains(People)').length, 1);\n equal($fixture.find('li').length, 2);\n equal($fixture.find('li:nth-of-type(1)').text(), 'Hello, Tom Dale!');\n equal($fixture.find('li:nth-of-type(2)').text(), 'Hello, Yehuda Katz!');\n});\n\n})();\n//@ sourceURL=ember/~tests/homepage_example_test");minispade.register('ember/~tests/location_test', "(function() {var App;\n\nmodule('AutoLocation', {\n setup: function() {\n Ember.AutoLocation._location = {\n href: 'http://test.com/',\n pathname: '/rootdir/subdir',\n hash: '',\n search: '',\n replace: function () {\n ok(false, 'location.replace should not be called');\n }\n };\n\n Ember.run(function() {\n App = Ember.Application.create({\n name: 'App',\n rootElement: '#qunit-fixture'\n });\n App.Router.reopen({\n location: 'none',\n rootURL: '/rootdir/'\n });\n App.deferReadiness();\n });\n },\n\n teardown: function() {\n Ember.run(function() {\n App.destroy();\n App = null;\n\n Ember.TEMPLATES = {};\n });\n }\n});\n\ntest('has the rootURL from the main router', function() {\n Ember.run(App, 'advanceReadiness');\n\n var location = App.__container__.lookup('location:auto');\n equal(Ember.get(location, 'rootURL'), '/rootdir/');\n});\n\n})();\n//@ sourceURL=ember/~tests/location_test");minispade.register('ember/~tests/routing/basic_test', "(function() {var Router, App, AppView, templates, router, container;\nvar get = Ember.get,\n set = Ember.set,\n compile = Ember.Handlebars.compile,\n forEach = Ember.EnumerableUtils.forEach;\n\nfunction bootApplication() {\n router = container.lookup('router:main');\n Ember.run(App, 'advanceReadiness');\n}\n\nfunction handleURL(path) {\n return Ember.run(function() {\n return router.handleURL(path).then(function(value) {\n ok(true, 'url: `' + path + '` was handled');\n return value;\n }, function(reason) {\n ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason));\n throw reason;\n });\n });\n}\n\nfunction handleURLAborts(path) {\n Ember.run(function() {\n router.handleURL(path).then(function(value) {\n ok(false, 'url: `' + path + '` was NOT to be handled');\n }, function(reason) {\n ok(reason && reason.message === \"TransitionAborted\", 'url: `' + path + '` was to be aborted');\n });\n });\n}\n\nfunction handleURLRejectsWith(path, expectedReason) {\n Ember.run(function() {\n router.handleURL(path).then(function(value) {\n ok(false, 'expected handleURLing: `' + path + '` to fail');\n }, function(reason) {\n equal(expectedReason, reason);\n });\n });\n}\n\nmodule(\"Basic Routing\", {\n setup: function() {\n Ember.run(function() {\n App = Ember.Application.create({\n name: \"App\",\n rootElement: '#qunit-fixture'\n });\n\n App.deferReadiness();\n\n App.Router.reopen({\n location: 'none'\n });\n\n Router = App.Router;\n\n App.LoadingRoute = Ember.Route.extend({\n });\n\n container = App.__container__;\n\n Ember.TEMPLATES.application = compile(\"{{outlet}}\");\n Ember.TEMPLATES.home = compile(\"

    Hours

    \");\n Ember.TEMPLATES.homepage = compile(\"

    Megatroll

    {{home}}

    \");\n Ember.TEMPLATES.camelot = compile('

    Is a silly place

    ');\n });\n },\n\n teardown: function() {\n Ember.run(function() {\n App.destroy();\n App = null;\n\n Ember.TEMPLATES = {};\n });\n }\n});\n\ntest(\"warn on URLs not included in the route set\", function () {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n\n bootApplication();\n\n expectAssertion(function(){\n Ember.run(function(){\n router.handleURL(\"/what-is-this-i-dont-even\");\n });\n }, \"The URL '/what-is-this-i-dont-even' did not match any routes in your application\");\n});\n\ntest(\"The Homepage\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeRoute = Ember.Route.extend({\n });\n\n var currentPath;\n\n App.ApplicationController = Ember.Controller.extend({\n currentPathDidChange: Ember.observer('currentPath', function() {\n currentPath = get(this, 'currentPath');\n })\n });\n\n bootApplication();\n\n equal(currentPath, 'home');\n equal(Ember.$('h3:contains(Hours)', '#qunit-fixture').length, 1, \"The home template was rendered\");\n});\n\ntest(\"The Home page and the Camelot page with multiple Router.map calls\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n Router.map(function() {\n this.route(\"camelot\", {path: \"/camelot\"});\n });\n\n App.HomeRoute = Ember.Route.extend({\n });\n\n App.CamelotRoute = Ember.Route.extend({\n });\n\n var currentPath;\n\n App.ApplicationController = Ember.Controller.extend({\n currentPathDidChange: Ember.observer('currentPath', function() {\n currentPath = get(this, 'currentPath');\n })\n });\n\n App.CamelotController = Ember.Controller.extend({\n currentPathDidChange: Ember.observer('currentPath', function() {\n currentPath = get(this, 'currentPath');\n })\n });\n\n bootApplication();\n\n handleURL(\"/camelot\");\n\n equal(currentPath, 'camelot');\n equal(Ember.$('h3:contains(silly)', '#qunit-fixture').length, 1, \"The camelot template was rendered\");\n\n handleURL(\"/\");\n\n equal(currentPath, 'home');\n equal(Ember.$('h3:contains(Hours)', '#qunit-fixture').length, 1, \"The home template was rendered\");\n});\n\ntest(\"The Homepage register as activeView\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n this.route(\"homepage\");\n });\n\n App.HomeRoute = Ember.Route.extend({\n });\n\n App.HomepageRoute = Ember.Route.extend({\n });\n\n bootApplication();\n\n ok(router._lookupActiveView('home'), '`home` active view is connected');\n\n handleURL('/homepage');\n\n ok(router._lookupActiveView('homepage'), '`homepage` active view is connected');\n equal(router._lookupActiveView('home'), undefined, '`home` active view is disconnected');\n});\n\ntest(\"The Homepage with explicit template name in renderTemplate\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeRoute = Ember.Route.extend({\n renderTemplate: function() {\n this.render('homepage');\n }\n });\n\n bootApplication();\n\n equal(Ember.$('h3:contains(Megatroll)', '#qunit-fixture').length, 1, \"The homepage template was rendered\");\n});\n\ntest(\"An alternate template will pull in an alternate controller\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeRoute = Ember.Route.extend({\n renderTemplate: function() {\n this.render('homepage');\n }\n });\n\n App.HomepageController = Ember.Controller.extend({\n home: \"Comes from homepage\"\n });\n\n bootApplication();\n\n equal(Ember.$('h3:contains(Megatroll) + p:contains(Comes from homepage)', '#qunit-fixture').length, 1, \"The homepage template was rendered\");\n});\n\ntest(\"The template will pull in an alternate controller via key/value\", function() {\n Router.map(function() {\n this.route(\"homepage\", { path: \"/\" });\n });\n\n App.HomepageRoute = Ember.Route.extend({\n renderTemplate: function() {\n this.render({controller: 'home'});\n }\n });\n\n App.HomeController = Ember.Controller.extend({\n home: \"Comes from home.\"\n });\n\n bootApplication();\n\n equal(Ember.$('h3:contains(Megatroll) + p:contains(Comes from home.)', '#qunit-fixture').length, 1, \"The homepage template was rendered from data from the HomeController\");\n});\n\ntest(\"The Homepage with explicit template name in renderTemplate and controller\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeController = Ember.Controller.extend({\n home: \"YES I AM HOME\"\n });\n\n App.HomeRoute = Ember.Route.extend({\n renderTemplate: function() {\n this.render('homepage');\n }\n });\n\n bootApplication();\n\n equal(Ember.$('h3:contains(Megatroll) + p:contains(YES I AM HOME)', '#qunit-fixture').length, 1, \"The homepage template was rendered\");\n});\n\nif(Ember.FEATURES.isEnabled(\"ember-routing-add-model-option\")) {\ntest(\"Model passed via renderTemplate model is set as controller's content\", function(){\n Ember.TEMPLATES['bio'] = compile(\"

    {{name}}

    \");\n\n App.BioController = Ember.ObjectController.extend();\n\n Router.map(function(){\n this.route('home', { path: '/'});\n });\n\n App.HomeRoute = Ember.Route.extend({\n renderTemplate: function(){\n this.render('bio', {\n model: {name: 'emberjs'}\n });\n }\n });\n\n bootApplication();\n\n equal(Ember.$('p:contains(emberjs)', '#qunit-fixture').length, 1, \"Passed model was set as controllers content\");\n});\n}\n\ntest(\"Renders correct view with slash notation\", function() {\n Ember.TEMPLATES['home/page'] = compile(\"

    {{view.name}}

    \");\n\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeRoute = Ember.Route.extend({\n renderTemplate: function() {\n this.render('home/page');\n }\n });\n\n App.HomePageView = Ember.View.extend({\n name: \"Home/Page\"\n });\n\n bootApplication();\n\n equal(Ember.$('p:contains(Home/Page)', '#qunit-fixture').length, 1, \"The homepage template was rendered\");\n});\n\ntest(\"Renders the view given in the view option\", function() {\n Ember.TEMPLATES['home'] = compile(\"

    {{view.name}}

    \");\n\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeRoute = Ember.Route.extend({\n renderTemplate: function() {\n this.render({view: 'homePage'});\n }\n });\n\n App.HomePageView = Ember.View.extend({\n name: \"Home/Page\"\n });\n\n bootApplication();\n\n equal(Ember.$('p:contains(Home/Page)', '#qunit-fixture').length, 1, \"The homepage view was rendered\");\n});\n\ntest('render does not replace templateName if user provided', function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n Ember.TEMPLATES.the_real_home_template = Ember.Handlebars.compile(\n \"

    THIS IS THE REAL HOME

    \"\n );\n\n App.HomeView = Ember.View.extend({\n templateName: 'the_real_home_template'\n });\n App.HomeController = Ember.Controller.extend();\n App.HomeRoute = Ember.Route.extend();\n\n bootApplication();\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"THIS IS THE REAL HOME\", \"The homepage template was rendered\");\n});\n\ntest('render does not replace template if user provided', function () {\n Router.map(function () {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeView = Ember.View.extend({\n template: Ember.Handlebars.compile(\"

    THIS IS THE REAL HOME

    \")\n });\n App.HomeController = Ember.Controller.extend();\n App.HomeRoute = Ember.Route.extend();\n\n bootApplication();\n\n Ember.run(function () {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"THIS IS THE REAL HOME\", \"The homepage template was rendered\");\n});\n\ntest('render uses templateName from route', function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n Ember.TEMPLATES.the_real_home_template = Ember.Handlebars.compile(\n \"

    THIS IS THE REAL HOME

    \"\n );\n\n App.HomeController = Ember.Controller.extend();\n App.HomeRoute = Ember.Route.extend({\n templateName: 'the_real_home_template'\n });\n\n bootApplication();\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"THIS IS THE REAL HOME\", \"The homepage template was rendered\");\n});\n\ntest('defining templateName allows other templates to be rendered', function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n Ember.TEMPLATES.alert = Ember.Handlebars.compile(\n \"
    Invader!
    \"\n );\n Ember.TEMPLATES.the_real_home_template = Ember.Handlebars.compile(\n \"

    THIS IS THE REAL HOME

    {{outlet alert}}\"\n );\n\n App.HomeController = Ember.Controller.extend();\n App.HomeRoute = Ember.Route.extend({\n templateName: 'the_real_home_template',\n actions: {\n showAlert: function(){\n this.render('alert', {\n into: 'home',\n outlet: 'alert'\n });\n }\n }\n });\n\n bootApplication();\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"THIS IS THE REAL HOME\", \"The homepage template was rendered\");\n\n Ember.run(function(){\n router.send('showAlert');\n });\n\n equal(Ember.$('.alert-box', '#qunit-fixture').text(), \"Invader!\", \"Template for alert was render into outlet\");\n\n});\n\ntest('Specifying a name to render should have precedence over everything else', function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeController = Ember.Controller.extend();\n App.HomeRoute = Ember.Route.extend({\n templateName: 'home',\n controllerName: 'home',\n viewName: 'home',\n\n renderTemplate: function() {\n this.render('homepage');\n }\n });\n\n App.HomeView = Ember.View.extend({\n template: Ember.Handlebars.compile(\"

    This should not be rendered

    {{home}}

    \")\n });\n\n App.HomepageController = Ember.ObjectController.extend({\n content: {\n home: 'Tinytroll'\n }\n });\n App.HomepageView = Ember.View.extend({\n layout: Ember.Handlebars.compile(\n \"Outer{{yield}}troll\"\n ),\n templateName: 'homepage'\n });\n\n bootApplication();\n\n equal(Ember.$('h3', '#qunit-fixture').text(), \"Megatroll\", \"The homepage template was rendered\");\n equal(Ember.$('p', '#qunit-fixture').text(), \"Tinytroll\", \"The homepage controller was used\");\n equal(Ember.$('span', '#qunit-fixture').text(), \"Outertroll\", \"The homepage view was used\");\n});\n\ntest(\"The Homepage with a `setupController` hook\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeRoute = Ember.Route.extend({\n setupController: function(controller) {\n set(controller, 'hours', Ember.A([\n \"Monday through Friday: 9am to 5pm\",\n \"Saturday: Noon to Midnight\",\n \"Sunday: Noon to 6pm\"\n ]));\n }\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"
      {{#each entry in hours}}
    • {{entry}}
    • {{/each}}
    \"\n );\n\n bootApplication();\n\n equal(Ember.$('ul li', '#qunit-fixture').eq(2).text(), \"Sunday: Noon to 6pm\", \"The template was rendered with the hours context\");\n});\n\ntest(\"The route controller is still set when overriding the setupController hook\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeRoute = Ember.Route.extend({\n setupController: function(controller) {\n // no-op\n // importantly, we are not calling this._super here\n }\n });\n\n container.register('controller:home', Ember.Controller.extend());\n\n bootApplication();\n\n deepEqual(container.lookup('route:home').controller, container.lookup('controller:home'), \"route controller is the home controller\");\n});\n\ntest(\"The route controller can be specified via controllerName\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"

    {{myValue}}

    \"\n );\n\n App.HomeRoute = Ember.Route.extend({\n controllerName: 'myController'\n });\n\n container.register('controller:myController', Ember.Controller.extend({\n myValue: \"foo\"\n }));\n\n bootApplication();\n\n deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), \"route controller is set by controllerName\");\n equal(Ember.$('p', '#qunit-fixture').text(), \"foo\", \"The homepage template was rendered with data from the custom controller\");\n});\n\ntest(\"The route controller specified via controllerName is used in render\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n Ember.TEMPLATES.alternative_home = Ember.Handlebars.compile(\n \"

    alternative home: {{myValue}}

    \"\n );\n\n App.HomeRoute = Ember.Route.extend({\n controllerName: 'myController',\n renderTemplate: function() {\n this.render(\"alternative_home\");\n }\n });\n\n container.register('controller:myController', Ember.Controller.extend({\n myValue: \"foo\"\n }));\n\n bootApplication();\n\n deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), \"route controller is set by controllerName\");\n equal(Ember.$('p', '#qunit-fixture').text(), \"alternative home: foo\", \"The homepage template was rendered with data from the custom controller\");\n});\n\ntest(\"The Homepage with a `setupController` hook modifying other controllers\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeRoute = Ember.Route.extend({\n setupController: function(controller) {\n set(this.controllerFor('home'), 'hours', Ember.A([\n \"Monday through Friday: 9am to 5pm\",\n \"Saturday: Noon to Midnight\",\n \"Sunday: Noon to 6pm\"\n ]));\n }\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"
      {{#each entry in hours}}
    • {{entry}}
    • {{/each}}
    \"\n );\n\n bootApplication();\n\n equal(Ember.$('ul li', '#qunit-fixture').eq(2).text(), \"Sunday: Noon to 6pm\", \"The template was rendered with the hours context\");\n});\n\ntest(\"The Homepage with a computed context that does not get overridden\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeController = Ember.ArrayController.extend({\n content: Ember.computed(function() {\n return Ember.A([\n \"Monday through Friday: 9am to 5pm\",\n \"Saturday: Noon to Midnight\",\n \"Sunday: Noon to 6pm\"\n ]);\n })\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"
      {{#each}}
    • {{this}}
    • {{/each}}
    \"\n );\n\n bootApplication();\n\n equal(Ember.$('ul li', '#qunit-fixture').eq(2).text(), \"Sunday: Noon to 6pm\", \"The template was rendered with the context intact\");\n});\n\ntest(\"The Homepage getting its controller context via model\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeRoute = Ember.Route.extend({\n model: function() {\n return Ember.A([\n \"Monday through Friday: 9am to 5pm\",\n \"Saturday: Noon to Midnight\",\n \"Sunday: Noon to 6pm\"\n ]);\n },\n\n setupController: function(controller, model) {\n equal(this.controllerFor('home'), controller);\n\n set(this.controllerFor('home'), 'hours', model);\n }\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"
      {{#each entry in hours}}
    • {{entry}}
    • {{/each}}
    \"\n );\n\n bootApplication();\n\n equal(Ember.$('ul li', '#qunit-fixture').eq(2).text(), \"Sunday: Noon to 6pm\", \"The template was rendered with the hours context\");\n});\n\ntest(\"The Specials Page getting its controller context by deserializing the params hash\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n this.resource(\"special\", { path: \"/specials/:menu_item_id\" });\n });\n\n App.SpecialRoute = Ember.Route.extend({\n model: function(params) {\n return Ember.Object.create({\n menuItemId: params.menu_item_id\n });\n },\n\n setupController: function(controller, model) {\n set(controller, 'content', model);\n }\n });\n\n Ember.TEMPLATES.special = Ember.Handlebars.compile(\n \"

    {{content.menuItemId}}

    \"\n );\n\n bootApplication();\n\n container.register('controller:special', Ember.Controller.extend());\n\n handleURL(\"/specials/1\");\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"1\", \"The model was used to render the template\");\n});\n\ntest(\"The Specials Page defaults to looking models up via `find`\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n this.resource(\"special\", { path: \"/specials/:menu_item_id\" });\n });\n\n App.MenuItem = Ember.Object.extend();\n App.MenuItem.reopenClass({\n find: function(id) {\n return App.MenuItem.create({\n id: id\n });\n }\n });\n\n App.SpecialRoute = Ember.Route.extend({\n setupController: function(controller, model) {\n set(controller, 'content', model);\n }\n });\n\n Ember.TEMPLATES.special = Ember.Handlebars.compile(\n \"

    {{content.id}}

    \"\n );\n\n bootApplication();\n\n container.register('controller:special', Ember.Controller.extend());\n\n handleURL(\"/specials/1\");\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"1\", \"The model was used to render the template\");\n});\n\ntest(\"The Special Page returning a promise puts the app into a loading state until the promise is resolved\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n this.resource(\"special\", { path: \"/specials/:menu_item_id\" });\n });\n\n var menuItem;\n\n App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);\n App.MenuItem.reopenClass({\n find: function(id) {\n menuItem = App.MenuItem.create({\n id: id\n });\n\n return menuItem;\n }\n });\n\n App.LoadingRoute = Ember.Route.extend({\n\n });\n\n App.SpecialRoute = Ember.Route.extend({\n setupController: function(controller, model) {\n set(controller, 'content', model);\n }\n });\n\n Ember.TEMPLATES.special = Ember.Handlebars.compile(\n \"

    {{content.id}}

    \"\n );\n\n Ember.TEMPLATES.loading = Ember.Handlebars.compile(\n \"

    LOADING!

    \"\n );\n\n bootApplication();\n\n container.register('controller:special', Ember.Controller.extend());\n\n handleURL(\"/specials/1\");\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"LOADING!\", \"The app is in the loading state\");\n\n Ember.run(function() {\n menuItem.resolve(menuItem);\n });\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"1\", \"The app is now in the specials state\");\n});\n\ntest(\"The loading state doesn't get entered for promises that resolve on the same run loop\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n this.resource(\"special\", { path: \"/specials/:menu_item_id\" });\n });\n\n App.MenuItem = Ember.Object.extend();\n App.MenuItem.reopenClass({\n find: function(id) {\n return { id: id };\n }\n });\n\n App.LoadingRoute = Ember.Route.extend({\n enter: function() {\n ok(false, \"LoadingRoute shouldn't have been entered.\");\n }\n });\n\n App.SpecialRoute = Ember.Route.extend({\n setupController: function(controller, model) {\n set(controller, 'content', model);\n }\n });\n\n Ember.TEMPLATES.special = Ember.Handlebars.compile(\n \"

    {{content.id}}

    \"\n );\n\n Ember.TEMPLATES.loading = Ember.Handlebars.compile(\n \"

    LOADING!

    \"\n );\n\n bootApplication();\n\n container.register('controller:special', Ember.Controller.extend());\n\n handleURL(\"/specials/1\");\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"1\", \"The app is now in the specials state\");\n});\n\n/*\nasyncTest(\"The Special page returning an error fires the error hook on SpecialRoute\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n this.resource(\"special\", { path: \"/specials/:menu_item_id\" });\n });\n\n var menuItem;\n\n App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);\n App.MenuItem.reopenClass({\n find: function(id) {\n menuItem = App.MenuItem.create({ id: id });\n Ember.run.later(function() { menuItem.resolve(menuItem); }, 1);\n return menuItem;\n }\n });\n\n App.SpecialRoute = Ember.Route.extend({\n setup: function() {\n throw 'Setup error';\n },\n actions: {\n error: function(reason) {\n equal(reason, 'Setup error');\n QUnit.start();\n }\n }\n });\n\n bootApplication();\n\n handleURLRejectsWith('/specials/1', 'Setup error');\n});\n*/\n\ntest(\"The Special page returning an error invokes SpecialRoute's error handler\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n this.resource(\"special\", { path: \"/specials/:menu_item_id\" });\n });\n\n var menuItem;\n\n App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);\n App.MenuItem.reopenClass({\n find: function(id) {\n menuItem = App.MenuItem.create({ id: id });\n return menuItem;\n }\n });\n\n App.SpecialRoute = Ember.Route.extend({\n setup: function() {\n throw 'Setup error';\n },\n actions: {\n error: function(reason) {\n equal(reason, 'Setup error', 'SpecialRoute#error received the error thrown from setup');\n }\n }\n });\n\n bootApplication();\n\n handleURLRejectsWith('/specials/1', 'Setup error');\n\n Ember.run(menuItem, menuItem.resolve, menuItem);\n});\n\nfunction testOverridableErrorHandler(handlersName) {\n\n expect(2);\n\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n this.resource(\"special\", { path: \"/specials/:menu_item_id\" });\n });\n\n var menuItem;\n\n App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);\n App.MenuItem.reopenClass({\n find: function(id) {\n menuItem = App.MenuItem.create({ id: id });\n return menuItem;\n }\n });\n\n var attrs = {};\n attrs[handlersName] = {\n error: function(reason) {\n equal(reason, 'Setup error', \"error was correctly passed to custom ApplicationRoute handler\");\n }\n };\n\n App.ApplicationRoute = Ember.Route.extend(attrs);\n\n App.SpecialRoute = Ember.Route.extend({\n setup: function() {\n throw 'Setup error';\n }\n });\n\n bootApplication();\n\n handleURLRejectsWith(\"/specials/1\", \"Setup error\");\n\n Ember.run(menuItem, 'resolve', menuItem);\n}\n\ntest(\"ApplicationRoute's default error handler can be overridden\", function() {\n testOverridableErrorHandler('actions');\n});\n\ntest(\"ApplicationRoute's default error handler can be overridden (with DEPRECATED `events`)\", function() {\n testOverridableErrorHandler('events');\n});\n\nasyncTest(\"Moving from one page to another triggers the correct callbacks\", function() {\n expect(3);\n\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n this.resource(\"special\", { path: \"/specials/:menu_item_id\" });\n });\n\n App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);\n\n App.SpecialRoute = Ember.Route.extend({\n setupController: function(controller, model) {\n set(controller, 'content', model);\n }\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"

    Home

    \"\n );\n\n Ember.TEMPLATES.special = Ember.Handlebars.compile(\n \"

    {{content.id}}

    \"\n );\n\n bootApplication();\n\n container.register('controller:special', Ember.Controller.extend());\n\n var transition = handleURL('/');\n\n Ember.run(function() {\n transition.then(function() {\n equal(Ember.$('h3', '#qunit-fixture').text(), \"Home\", \"The app is now in the initial state\");\n\n var promiseContext = App.MenuItem.create({ id: 1 });\n Ember.run.later(function() {\n promiseContext.resolve(promiseContext);\n }, 1);\n\n return router.transitionTo('special', promiseContext);\n }).then(function(result) {\n deepEqual(router.location.path, '/specials/1');\n QUnit.start();\n });\n });\n});\n\nasyncTest(\"Nested callbacks are not exited when moving to siblings\", function() {\n Router.map(function() {\n this.resource(\"root\", { path: \"/\" }, function() {\n this.resource(\"special\", { path: \"/specials/:menu_item_id\" });\n });\n });\n\n var currentPath;\n\n App.ApplicationController = Ember.Controller.extend({\n currentPathDidChange: Ember.observer('currentPath', function() {\n currentPath = get(this, 'currentPath');\n })\n });\n\n var menuItem;\n\n App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);\n App.MenuItem.reopenClass({\n find: function(id) {\n menuItem = App.MenuItem.create({ id: id });\n return menuItem;\n }\n });\n\n App.LoadingRoute = Ember.Route.extend({\n\n });\n\n App.RootRoute = Ember.Route.extend({\n model: function() {\n rootModel++;\n return this._super.apply(this, arguments);\n },\n\n serialize: function() {\n rootSerialize++;\n return this._super.apply(this, arguments);\n },\n\n setupController: function() {\n rootSetup++;\n },\n\n renderTemplate: function() {\n rootRender++;\n }\n });\n\n App.HomeRoute = Ember.Route.extend({\n\n });\n\n App.SpecialRoute = Ember.Route.extend({\n setupController: function(controller, model) {\n set(controller, 'content', model);\n }\n });\n\n Ember.TEMPLATES['root/index'] = Ember.Handlebars.compile(\n \"

    Home

    \"\n );\n\n Ember.TEMPLATES.special = Ember.Handlebars.compile(\n \"

    {{content.id}}

    \"\n );\n\n Ember.TEMPLATES.loading = Ember.Handlebars.compile(\n \"

    LOADING!

    \"\n );\n\n var rootSetup = 0, rootRender = 0, rootModel = 0, rootSerialize = 0;\n\n bootApplication();\n\n container.register('controller:special', Ember.Controller.extend());\n\n equal(Ember.$('h3', '#qunit-fixture').text(), \"Home\", \"The app is now in the initial state\");\n equal(rootSetup, 1, \"The root setup was triggered\");\n equal(rootRender, 1, \"The root render was triggered\");\n equal(rootSerialize, 0, \"The root serialize was not called\");\n equal(rootModel, 1, \"The root model was called\");\n\n router = container.lookup('router:main');\n\n Ember.run(function() {\n var menuItem = App.MenuItem.create({ id: 1 });\n Ember.run.later(function() { menuItem.resolve(menuItem); }, 1);\n\n router.transitionTo('special', menuItem).then(function(result) {\n equal(rootSetup, 1, \"The root setup was not triggered again\");\n equal(rootRender, 1, \"The root render was not triggered again\");\n equal(rootSerialize, 0, \"The root serialize was not called\");\n\n // TODO: Should this be changed?\n equal(rootModel, 1, \"The root model was called again\");\n\n deepEqual(router.location.path, '/specials/1');\n equal(currentPath, 'root.special');\n\n QUnit.start();\n });\n });\n});\n\nasyncTest(\"Events are triggered on the controller if a matching action name is implemented\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n var model = { name: \"Tom Dale\" };\n var stateIsNotCalled = true;\n\n App.HomeRoute = Ember.Route.extend({\n model: function() {\n return model;\n },\n\n actions: {\n showStuff: function(obj) {\n stateIsNotCalled = false;\n }\n }\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"{{name}}\"\n );\n\n var controller = Ember.Controller.extend({\n actions: {\n showStuff: function(context) {\n ok (stateIsNotCalled, \"an event on the state is not triggered\");\n deepEqual(context, { name: \"Tom Dale\" }, \"an event with context is passed\");\n QUnit.start();\n }\n }\n });\n\n container.register('controller:home', controller);\n\n bootApplication();\n\n var actionId = Ember.$(\"#qunit-fixture a\").data(\"ember-action\");\n var action = Ember.Handlebars.ActionHelper.registeredActions[actionId];\n var event = new Ember.$.Event(\"click\");\n action.handler(event);\n});\n\nasyncTest(\"Events are triggered on the current state when defined in `actions` object\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n var model = { name: \"Tom Dale\" };\n\n App.HomeRoute = Ember.Route.extend({\n model: function() {\n return model;\n },\n\n actions: {\n showStuff: function(obj) {\n ok(this instanceof App.HomeRoute, \"the handler is an App.HomeRoute\");\n // Using Ember.copy removes any private Ember vars which older IE would be confused by\n deepEqual(Ember.copy(obj, true), { name: \"Tom Dale\" }, \"the context is correct\");\n QUnit.start();\n }\n }\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"{{name}}\"\n );\n\n bootApplication();\n\n var actionId = Ember.$(\"#qunit-fixture a\").data(\"ember-action\");\n var action = Ember.Handlebars.ActionHelper.registeredActions[actionId];\n var event = new Ember.$.Event(\"click\");\n action.handler(event);\n});\n\nasyncTest(\"Events defined in `actions` object are triggered on the current state when routes are nested\", function() {\n Router.map(function() {\n this.resource(\"root\", { path: \"/\" }, function() {\n this.route(\"index\", { path: \"/\" });\n });\n });\n\n var model = { name: \"Tom Dale\" };\n\n App.RootRoute = Ember.Route.extend({\n actions: {\n showStuff: function(obj) {\n ok(this instanceof App.RootRoute, \"the handler is an App.HomeRoute\");\n // Using Ember.copy removes any private Ember vars which older IE would be confused by\n deepEqual(Ember.copy(obj, true), { name: \"Tom Dale\" }, \"the context is correct\");\n QUnit.start();\n }\n }\n });\n\n App.RootIndexRoute = Ember.Route.extend({\n model: function() {\n return model;\n }\n });\n\n Ember.TEMPLATES['root/index'] = Ember.Handlebars.compile(\n \"{{name}}\"\n );\n\n bootApplication();\n\n var actionId = Ember.$(\"#qunit-fixture a\").data(\"ember-action\");\n var action = Ember.Handlebars.ActionHelper.registeredActions[actionId];\n var event = new Ember.$.Event(\"click\");\n action.handler(event);\n});\n\nasyncTest(\"Events are triggered on the current state when defined in `events` object (DEPRECATED)\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n var model = { name: \"Tom Dale\" };\n\n App.HomeRoute = Ember.Route.extend({\n model: function() {\n return model;\n },\n\n events: {\n showStuff: function(obj) {\n ok(this instanceof App.HomeRoute, \"the handler is an App.HomeRoute\");\n // Using Ember.copy removes any private Ember vars which older IE would be confused by\n deepEqual(Ember.copy(obj, true), { name: \"Tom Dale\" }, \"the context is correct\");\n QUnit.start();\n }\n }\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"{{name}}\"\n );\n\n expectDeprecation(/Action handlers contained in an `events` object are deprecated/);\n bootApplication();\n\n var actionId = Ember.$(\"#qunit-fixture a\").data(\"ember-action\");\n var action = Ember.Handlebars.ActionHelper.registeredActions[actionId];\n var event = new Ember.$.Event(\"click\");\n action.handler(event);\n});\n\nasyncTest(\"Events defined in `events` object are triggered on the current state when routes are nested (DEPRECATED)\", function() {\n Router.map(function() {\n this.resource(\"root\", { path: \"/\" }, function() {\n this.route(\"index\", { path: \"/\" });\n });\n });\n\n var model = { name: \"Tom Dale\" };\n\n App.RootRoute = Ember.Route.extend({\n events: {\n showStuff: function(obj) {\n ok(this instanceof App.RootRoute, \"the handler is an App.HomeRoute\");\n // Using Ember.copy removes any private Ember vars which older IE would be confused by\n deepEqual(Ember.copy(obj, true), { name: \"Tom Dale\" }, \"the context is correct\");\n QUnit.start();\n }\n }\n });\n\n App.RootIndexRoute = Ember.Route.extend({\n model: function() {\n return model;\n }\n });\n\n Ember.TEMPLATES['root/index'] = Ember.Handlebars.compile(\n \"{{name}}\"\n );\n\n expectDeprecation(/Action handlers contained in an `events` object are deprecated/);\n bootApplication();\n\n var actionId = Ember.$(\"#qunit-fixture a\").data(\"ember-action\");\n var action = Ember.Handlebars.ActionHelper.registeredActions[actionId];\n var event = new Ember.$.Event(\"click\");\n action.handler(event);\n});\n\ntest(\"Events can be handled by inherited event handlers\", function() {\n\n expect(4);\n\n App.SuperRoute = Ember.Route.extend({\n actions: {\n foo: function() {\n ok(true, 'foo');\n },\n bar: function(msg) {\n equal(msg, \"HELLO\");\n }\n }\n });\n\n App.RouteMixin = Ember.Mixin.create({\n actions: {\n bar: function(msg) {\n equal(msg, \"HELLO\");\n this._super(msg);\n }\n }\n });\n\n App.IndexRoute = App.SuperRoute.extend(App.RouteMixin, {\n actions: {\n baz: function() {\n ok(true, 'baz');\n }\n }\n });\n\n bootApplication();\n\n router.send(\"foo\");\n router.send(\"bar\", \"HELLO\");\n router.send(\"baz\");\n});\n\nif (Ember.FEATURES.isEnabled('ember-routing-drop-deprecated-action-style')) {\n asyncTest(\"Actions are not triggered on the controller if a matching action name is implemented as a method\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n var model = { name: \"Tom Dale\" };\n var stateIsNotCalled = true;\n\n App.HomeRoute = Ember.Route.extend({\n model: function() {\n return model;\n },\n\n actions: {\n showStuff: function(context) {\n ok (stateIsNotCalled, \"an event on the state is not triggered\");\n deepEqual(context, { name: \"Tom Dale\" }, \"an event with context is passed\");\n QUnit.start();\n }\n }\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"{{name}}\"\n );\n\n var controller = Ember.Controller.extend({\n showStuff: function(context) {\n stateIsNotCalled = false;\n ok (stateIsNotCalled, \"an event on the state is not triggered\");\n }\n });\n\n container.register('controller:home', controller);\n\n bootApplication();\n\n var actionId = Ember.$(\"#qunit-fixture a\").data(\"ember-action\");\n var action = Ember.Handlebars.ActionHelper.registeredActions[actionId];\n var event = new Ember.$.Event(\"click\");\n action.handler(event);\n });\n} else {\n asyncTest(\"Events are triggered on the controller if a matching action name is implemented as a method (DEPRECATED)\", function() {\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n var model = { name: \"Tom Dale\" };\n var stateIsNotCalled = true;\n\n App.HomeRoute = Ember.Route.extend({\n model: function() {\n return model;\n },\n\n events: {\n showStuff: function(obj) {\n stateIsNotCalled = false;\n ok (stateIsNotCalled, \"an event on the state is not triggered\");\n }\n }\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"{{name}}\"\n );\n\n var controller = Ember.Controller.extend({\n showStuff: function(context) {\n ok (stateIsNotCalled, \"an event on the state is not triggered\");\n deepEqual(context, { name: \"Tom Dale\" }, \"an event with context is passed\");\n QUnit.start();\n }\n });\n\n container.register('controller:home', controller);\n\n expectDeprecation(/Action handlers contained in an `events` object are deprecated/);\n bootApplication();\n\n var actionId = Ember.$(\"#qunit-fixture a\").data(\"ember-action\");\n var action = Ember.Handlebars.ActionHelper.registeredActions[actionId];\n var event = new Ember.$.Event(\"click\");\n action.handler(event);\n });\n}\n\nasyncTest(\"actions can be triggered with multiple arguments\", function() {\n Router.map(function() {\n this.resource(\"root\", { path: \"/\" }, function() {\n this.route(\"index\", { path: \"/\" });\n });\n });\n\n var model1 = { name: \"Tilde\" },\n model2 = { name: \"Tom Dale\" };\n\n App.RootRoute = Ember.Route.extend({\n actions: {\n showStuff: function(obj1, obj2) {\n ok(this instanceof App.RootRoute, \"the handler is an App.HomeRoute\");\n // Using Ember.copy removes any private Ember vars which older IE would be confused by\n deepEqual(Ember.copy(obj1, true), { name: \"Tilde\" }, \"the first context is correct\");\n deepEqual(Ember.copy(obj2, true), { name: \"Tom Dale\" }, \"the second context is correct\");\n QUnit.start();\n }\n }\n });\n\n App.RootIndexController = Ember.Controller.extend({\n model1: model1,\n model2: model2\n });\n\n Ember.TEMPLATES['root/index'] = Ember.Handlebars.compile(\n \"{{model1.name}}\"\n );\n\n bootApplication();\n\n var actionId = Ember.$(\"#qunit-fixture a\").data(\"ember-action\");\n var action = Ember.Handlebars.ActionHelper.registeredActions[actionId];\n var event = new Ember.$.Event(\"click\");\n action.handler(event);\n});\n\ntest(\"transitioning multiple times in a single run loop only sets the URL once\", function() {\n Router.map(function() {\n this.route(\"root\", { path: \"/\" });\n this.route(\"foo\");\n this.route(\"bar\");\n });\n\n bootApplication();\n\n var urlSetCount = 0;\n\n router.get('location').setURL = function(path) {\n urlSetCount++;\n set(this, 'path', path);\n };\n\n equal(urlSetCount, 0);\n\n Ember.run(function() {\n router.transitionTo(\"foo\");\n router.transitionTo(\"bar\");\n });\n\n equal(urlSetCount, 1);\n equal(router.get('location').getURL(), \"/bar\");\n});\n\ntest('navigating away triggers a url property change', function() {\n\n expect(3);\n\n Router.map(function() {\n this.route('root', { path: '/' });\n this.route('foo', { path: '/foo' });\n this.route('bar', { path: '/bar' });\n });\n\n bootApplication();\n\n Ember.run(function() {\n Ember.addObserver(router, 'url', function() {\n ok(true, \"url change event was fired\");\n });\n });\n\n forEach(['foo', 'bar', '/foo'], function(destination) {\n Ember.run(router, 'transitionTo', destination);\n });\n});\n\ntest(\"using replaceWith calls location.replaceURL if available\", function() {\n var setCount = 0,\n replaceCount = 0;\n\n Router.reopen({\n location: Ember.NoneLocation.createWithMixins({\n setURL: function(path) {\n setCount++;\n set(this, 'path', path);\n },\n\n replaceURL: function(path) {\n replaceCount++;\n set(this, 'path', path);\n }\n })\n });\n\n Router.map(function() {\n this.route(\"root\", { path: \"/\" });\n this.route(\"foo\");\n });\n\n bootApplication();\n\n equal(setCount, 0);\n equal(replaceCount, 0);\n\n Ember.run(function() {\n router.replaceWith(\"foo\");\n });\n\n equal(setCount, 0, 'should not call setURL');\n equal(replaceCount, 1, 'should call replaceURL once');\n equal(router.get('location').getURL(), \"/foo\");\n});\n\ntest(\"using replaceWith calls setURL if location.replaceURL is not defined\", function() {\n var setCount = 0;\n\n Router.reopen({\n location: Ember.NoneLocation.createWithMixins({\n setURL: function(path) {\n setCount++;\n set(this, 'path', path);\n }\n })\n });\n\n Router.map(function() {\n this.route(\"root\", { path: \"/\" });\n this.route(\"foo\");\n });\n\n bootApplication();\n\n equal(setCount, 0);\n\n Ember.run(function() {\n router.replaceWith(\"foo\");\n });\n\n equal(setCount, 1, 'should call setURL once');\n equal(router.get('location').getURL(), \"/foo\");\n});\n\ntest(\"Route inherits model from parent route\", function() {\n expect(9);\n\n Router.map(function() {\n this.resource(\"the_post\", { path: \"/posts/:post_id\" }, function() {\n this.route(\"comments\");\n\n this.resource(\"shares\", { path: \"/shares/:share_id\"}, function() {\n this.route(\"share\");\n });\n });\n });\n\n var post1 = {}, post2 = {}, post3 = {}, currentPost;\n var share1 = {}, share2 = {}, share3 = {}, currentShare;\n\n var posts = {\n 1: post1,\n 2: post2,\n 3: post3\n };\n var shares = {\n 1: share1,\n 2: share2,\n 3: share3\n };\n\n App.ThePostRoute = Ember.Route.extend({\n model: function(params) {\n return posts[params.post_id];\n }\n });\n\n App.ThePostCommentsRoute = Ember.Route.extend({\n afterModel: function(post, transition) {\n var parent_model = this.modelFor('thePost');\n\n equal(post, parent_model);\n }\n });\n\n App.SharesRoute = Ember.Route.extend({\n model: function(params) {\n return shares[params.share_id];\n }\n });\n\n App.SharesShareRoute = Ember.Route.extend({\n afterModel: function(share, transition) {\n var parent_model = this.modelFor('shares');\n\n equal(share, parent_model);\n }\n });\n\n bootApplication();\n\n currentPost = post1;\n handleURL(\"/posts/1/comments\");\n handleURL(\"/posts/1/shares/1\");\n\n currentPost = post2;\n handleURL(\"/posts/2/comments\");\n handleURL(\"/posts/2/shares/2\");\n\n currentPost = post3;\n handleURL(\"/posts/3/comments\");\n handleURL(\"/posts/3/shares/3\");\n});\n\ntest(\"Resource does not inherit model from parent resource\", function() {\n expect(6);\n\n Router.map(function() {\n this.resource(\"the_post\", { path: \"/posts/:post_id\" }, function() {\n this.resource(\"comments\", function() {\n });\n });\n });\n\n var post1 = {}, post2 = {}, post3 = {}, currentPost;\n\n var posts = {\n 1: post1,\n 2: post2,\n 3: post3\n };\n\n App.ThePostRoute = Ember.Route.extend({\n model: function(params) {\n return posts[params.post_id];\n }\n });\n\n App.CommentsRoute = Ember.Route.extend({\n afterModel: function(post, transition) {\n var parent_model = this.modelFor('thePost');\n\n notEqual(post, parent_model);\n }\n });\n\n bootApplication();\n\n currentPost = post1;\n handleURL(\"/posts/1/comments\");\n\n currentPost = post2;\n handleURL(\"/posts/2/comments\");\n\n currentPost = post3;\n handleURL(\"/posts/3/comments\");\n});\n\ntest(\"It is possible to get the model from a parent route\", function() {\n expect(9);\n\n Router.map(function() {\n this.resource(\"the_post\", { path: \"/posts/:post_id\" }, function() {\n this.resource(\"comments\");\n });\n });\n\n var post1 = {}, post2 = {}, post3 = {}, currentPost;\n\n var posts = {\n 1: post1,\n 2: post2,\n 3: post3\n };\n\n App.ThePostRoute = Ember.Route.extend({\n model: function(params) {\n return posts[params.post_id];\n }\n });\n\n App.CommentsRoute = Ember.Route.extend({\n model: function() {\n // Allow both underscore / camelCase format.\n equal(this.modelFor('thePost'), currentPost);\n equal(this.modelFor('the_post'), currentPost);\n }\n });\n\n bootApplication();\n\n currentPost = post1;\n handleURL(\"/posts/1/comments\");\n\n currentPost = post2;\n handleURL(\"/posts/2/comments\");\n\n currentPost = post3;\n handleURL(\"/posts/3/comments\");\n});\n\ntest(\"A redirection hook is provided\", function() {\n Router.map(function() {\n this.route(\"choose\", { path: \"/\" });\n this.route(\"home\");\n });\n\n var chooseFollowed = 0, destination;\n\n App.ChooseRoute = Ember.Route.extend({\n redirect: function() {\n if (destination) {\n this.transitionTo(destination);\n }\n },\n\n setupController: function() {\n chooseFollowed++;\n }\n });\n\n destination = 'home';\n\n bootApplication();\n\n equal(chooseFollowed, 0, \"The choose route wasn't entered since a transition occurred\");\n equal(Ember.$(\"h3:contains(Hours)\", \"#qunit-fixture\").length, 1, \"The home template was rendered\");\n equal(router.container.lookup('controller:application').get('currentPath'), 'home');\n});\n\ntest(\"Redirecting from the middle of a route aborts the remainder of the routes\", function() {\n expect(3);\n\n Router.map(function() {\n this.route(\"home\");\n this.resource(\"foo\", function() {\n this.resource(\"bar\", function() {\n this.route(\"baz\");\n });\n });\n });\n\n App.BarRoute = Ember.Route.extend({\n redirect: function() {\n this.transitionTo(\"home\");\n },\n setupController: function() {\n ok(false, \"Should transition before setupController\");\n }\n });\n\n App.BarBazRoute = Ember.Route.extend({\n enter: function() {\n ok(false, \"Should abort transition getting to next route\");\n }\n });\n\n bootApplication();\n\n handleURLAborts(\"/foo/bar/baz\");\n\n equal(router.container.lookup('controller:application').get('currentPath'), 'home');\n equal(router.get('location').getURL(), \"/home\");\n});\n\ntest(\"Redirecting to the current target in the middle of a route does not abort initial routing\", function() {\n expect(5);\n\n Router.map(function() {\n this.route(\"home\");\n this.resource(\"foo\", function() {\n this.resource(\"bar\", function() {\n this.route(\"baz\");\n });\n });\n });\n\n var successCount = 0;\n App.BarRoute = Ember.Route.extend({\n redirect: function() {\n this.transitionTo(\"bar.baz\").then(function() {\n successCount++;\n });\n },\n\n setupController: function() {\n ok(true, \"Should still invoke bar's setupController\");\n }\n });\n\n App.BarBazRoute = Ember.Route.extend({\n setupController: function() {\n ok(true, \"Should still invoke bar.baz's setupController\");\n }\n });\n\n bootApplication();\n\n handleURL(\"/foo/bar/baz\");\n\n equal(router.container.lookup('controller:application').get('currentPath'), 'foo.bar.baz');\n equal(successCount, 1, 'transitionTo success handler was called once');\n\n});\n\ntest(\"Redirecting to the current target with a different context aborts the remainder of the routes\", function() {\n expect(4);\n\n Router.map(function() {\n this.route(\"home\");\n this.resource(\"foo\", function() {\n this.resource(\"bar\", { path: \"bar/:id\" }, function() {\n this.route(\"baz\");\n });\n });\n });\n\n var model = { id: 2 };\n\n var count = 0;\n\n App.BarRoute = Ember.Route.extend({\n afterModel: function(context) {\n if (count++ > 10) {\n ok(false, 'infinite loop');\n } else {\n this.transitionTo(\"bar.baz\", model);\n }\n },\n\n serialize: function(params) {\n return params;\n }\n });\n\n App.BarBazRoute = Ember.Route.extend({\n setupController: function() {\n ok(true, \"Should still invoke setupController\");\n }\n });\n\n bootApplication();\n\n handleURLAborts(\"/foo/bar/1/baz\");\n\n equal(router.container.lookup('controller:application').get('currentPath'), 'foo.bar.baz');\n equal(router.get('location').getURL(), \"/foo/bar/2/baz\");\n});\n\ntest(\"Transitioning from a parent event does not prevent currentPath from being set\", function() {\n Router.map(function() {\n this.resource(\"foo\", function() {\n this.resource(\"bar\", function() {\n this.route(\"baz\");\n });\n this.route(\"qux\");\n });\n });\n\n App.FooRoute = Ember.Route.extend({\n actions: {\n goToQux: function() {\n this.transitionTo('foo.qux');\n }\n }\n });\n\n bootApplication();\n\n var applicationController = router.container.lookup('controller:application');\n\n handleURL(\"/foo/bar/baz\");\n\n equal(applicationController.get('currentPath'), 'foo.bar.baz');\n\n Ember.run(function() {\n router.send(\"goToQux\");\n });\n\n equal(applicationController.get('currentPath'), 'foo.qux');\n equal(router.get('location').getURL(), \"/foo/qux\");\n});\n\ntest(\"Generated names can be customized when providing routes with dot notation\", function() {\n expect(4);\n\n Ember.TEMPLATES.index = compile(\"
    Index
    \");\n Ember.TEMPLATES.application = compile(\"

    Home

    {{outlet}}
    \");\n Ember.TEMPLATES.foo = compile(\"
    {{outlet}}
    \");\n Ember.TEMPLATES.bar = compile(\"
    {{outlet}}
    \");\n Ember.TEMPLATES['bar/baz'] = compile(\"

    {{name}}Bottom!

    \");\n\n Router.map(function() {\n this.resource(\"foo\", { path: \"/top\" }, function() {\n this.resource(\"bar\", { path: \"/middle\" }, function() {\n this.route(\"baz\", { path: \"/bottom\" });\n });\n });\n });\n\n App.FooRoute = Ember.Route.extend({\n renderTemplate: function() {\n ok(true, \"FooBarRoute was called\");\n return this._super.apply(this, arguments);\n }\n });\n\n App.BarBazRoute = Ember.Route.extend({\n renderTemplate: function() {\n ok(true, \"BarBazRoute was called\");\n return this._super.apply(this, arguments);\n }\n });\n\n App.BarController = Ember.Controller.extend({\n name: \"Bar\"\n });\n\n App.BarBazController = Ember.Controller.extend({\n name: \"BarBaz\"\n });\n\n bootApplication();\n\n handleURL(\"/top/middle/bottom\");\n\n equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').text(), \"BarBazBottom!\", \"The templates were rendered into their appropriate parents\");\n});\n\ntest(\"Child routes render into their parent route's template by default\", function() {\n Ember.TEMPLATES.index = compile(\"
    Index
    \");\n Ember.TEMPLATES.application = compile(\"

    Home

    {{outlet}}
    \");\n Ember.TEMPLATES.top = compile(\"
    {{outlet}}
    \");\n Ember.TEMPLATES.middle = compile(\"
    {{outlet}}
    \");\n Ember.TEMPLATES['middle/bottom'] = compile(\"

    Bottom!

    \");\n\n Router.map(function() {\n this.resource(\"top\", function() {\n this.resource(\"middle\", function() {\n this.route(\"bottom\");\n });\n });\n });\n\n bootApplication();\n\n handleURL(\"/top/middle/bottom\");\n\n equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').text(), \"Bottom!\", \"The templates were rendered into their appropriate parents\");\n});\n\ntest(\"Child routes render into specified template\", function() {\n Ember.TEMPLATES.index = compile(\"
    Index
    \");\n Ember.TEMPLATES.application = compile(\"

    Home

    {{outlet}}
    \");\n Ember.TEMPLATES.top = compile(\"
    {{outlet}}
    \");\n Ember.TEMPLATES.middle = compile(\"
    {{outlet}}
    \");\n Ember.TEMPLATES['middle/bottom'] = compile(\"

    Bottom!

    \");\n\n Router.map(function() {\n this.resource(\"top\", function() {\n this.resource(\"middle\", function() {\n this.route(\"bottom\");\n });\n });\n });\n\n App.MiddleBottomRoute = Ember.Route.extend({\n renderTemplate: function() {\n this.render('middle/bottom', { into: 'top' });\n }\n });\n\n bootApplication();\n\n handleURL(\"/top/middle/bottom\");\n\n equal(Ember.$('.main .middle .bottom p', '#qunit-fixture').length, 0, \"should not render into the middle template\");\n equal(Ember.$('.main .middle > p', '#qunit-fixture').text(), \"Bottom!\", \"The template was rendered into the top template\");\n});\n\ntest(\"Rendering into specified template with slash notation\", function() {\n Ember.TEMPLATES['person/profile'] = compile(\"profile {{outlet}}\");\n Ember.TEMPLATES['person/details'] = compile(\"details!\");\n\n Router.map(function() {\n this.resource(\"home\", { path: '/' });\n });\n\n App.HomeRoute = Ember.Route.extend({\n renderTemplate: function() {\n this.render('person/profile');\n this.render('person/details', { into: 'person/profile' });\n }\n });\n\n bootApplication();\n\n equal(Ember.$('#qunit-fixture:contains(profile details!)').length, 1, \"The templates were rendered\");\n});\n\n\ntest(\"Parent route context change\", function() {\n var editCount = 0,\n editedPostIds = Ember.A();\n\n Ember.TEMPLATES.application = compile(\"{{outlet}}\");\n Ember.TEMPLATES.posts = compile(\"{{outlet}}\");\n Ember.TEMPLATES.post = compile(\"{{outlet}}\");\n Ember.TEMPLATES['post/index'] = compile(\"showing\");\n Ember.TEMPLATES['post/edit'] = compile(\"editing\");\n\n Router.map(function() {\n this.resource(\"posts\", function() {\n this.resource(\"post\", { path: \"/:postId\" }, function() {\n this.route(\"edit\");\n });\n });\n });\n\n App.PostsRoute = Ember.Route.extend({\n actions: {\n showPost: function(context) {\n this.transitionTo('post', context);\n }\n }\n });\n\n App.PostRoute = Ember.Route.extend({\n model: function(params) {\n return {id: params.postId};\n },\n\n actions: {\n editPost: function(context) {\n this.transitionTo('post.edit');\n }\n }\n });\n\n App.PostEditRoute = Ember.Route.extend({\n model: function(params) {\n var postId = this.modelFor(\"post\").id;\n editedPostIds.push(postId);\n return null;\n },\n setup: function() {\n this._super.apply(this, arguments);\n editCount++;\n }\n });\n\n bootApplication();\n\n handleURL(\"/posts/1\");\n\n Ember.run(function() {\n router.send('editPost');\n });\n\n Ember.run(function() {\n router.send('showPost', {id: '2'});\n });\n\n Ember.run(function() {\n router.send('editPost');\n });\n\n equal(editCount, 2, 'set up the edit route twice without failure');\n deepEqual(editedPostIds, ['1', '2'], 'modelFor posts.post returns the right context');\n});\n\ntest(\"Router accounts for rootURL on page load when using history location\", function() {\n var rootURL = window.location.pathname + '/app',\n postsTemplateRendered = false,\n setHistory,\n HistoryTestLocation;\n\n setHistory = function(obj, path) {\n obj.set('history', { state: { path: path } });\n };\n\n // Create new implementation that extends HistoryLocation\n // and set current location to rootURL + '/posts'\n HistoryTestLocation = Ember.HistoryLocation.extend({\n initState: function() {\n var path = rootURL + '/posts';\n\n setHistory(this, path);\n this.set('location', {\n pathname: path\n });\n },\n\n replaceState: function(path) {\n setHistory(this, path);\n },\n\n pushState: function(path) {\n setHistory(this, path);\n }\n });\n\n\n container.register('location:historyTest', HistoryTestLocation);\n\n Router.reopen({\n location: 'historyTest',\n rootURL: rootURL\n });\n\n Router.map(function() {\n this.resource(\"posts\", { path: '/posts' });\n });\n\n App.PostsRoute = Ember.Route.extend({\n model: function() {},\n renderTemplate: function() {\n postsTemplateRendered = true;\n }\n });\n\n bootApplication();\n\n ok(postsTemplateRendered, \"Posts route successfully stripped from rootURL\");\n});\n\ntest(\"The rootURL is passed properly to the location implementation\", function() {\n expect(1);\n var rootURL = \"/blahzorz\",\n HistoryTestLocation;\n\n HistoryTestLocation = Ember.HistoryLocation.extend({\n rootURL: 'this is not the URL you are looking for',\n initState: function() {\n equal(this.get('rootURL'), rootURL);\n }\n });\n\n container.register('location:history-test', HistoryTestLocation);\n\n Router.reopen({\n location: 'history-test',\n rootURL: rootURL,\n // if we transition in this test we will receive failures\n // if the tests are run from a static file\n _doTransition: function(){}\n });\n\n bootApplication();\n});\n\n\ntest(\"Only use route rendered into main outlet for default into property on child\", function() {\n Ember.TEMPLATES.application = compile(\"{{outlet menu}}{{outlet}}\");\n Ember.TEMPLATES.posts = compile(\"{{outlet}}\");\n Ember.TEMPLATES['posts/index'] = compile(\"postsIndex\");\n Ember.TEMPLATES['posts/menu'] = compile(\"postsMenu\");\n\n Router.map(function() {\n this.resource(\"posts\", function() {});\n });\n\n App.PostsMenuView = Ember.View.extend({\n tagName: 'div',\n templateName: 'posts/menu',\n classNames: ['posts-menu']\n });\n\n App.PostsIndexView = Ember.View.extend({\n tagName: 'p',\n classNames: ['posts-index']\n });\n\n App.PostsRoute = Ember.Route.extend({\n renderTemplate: function() {\n this.render();\n this.render('postsMenu', {\n into: 'application',\n outlet: 'menu'\n });\n }\n });\n\n bootApplication();\n\n handleURL(\"/posts\");\n\n equal(Ember.$('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 1, \"The posts/menu template was rendered\");\n equal(Ember.$('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, \"The posts/index template was rendered\");\n});\n\ntest(\"Generating a URL should not affect currentModel\", function() {\n Router.map(function() {\n this.route(\"post\", { path: \"/posts/:post_id\" });\n });\n\n var posts = {\n 1: { id: 1 },\n 2: { id: 2 }\n };\n\n App.PostRoute = Ember.Route.extend({\n model: function(params) {\n return posts[params.post_id];\n }\n });\n\n bootApplication();\n\n handleURL(\"/posts/1\");\n\n var route = container.lookup('route:post');\n equal(route.modelFor('post'), posts[1]);\n\n var url = router.generate('post', posts[2]);\n equal(url, \"/posts/2\");\n\n equal(route.modelFor('post'), posts[1]);\n});\n\n\ntest(\"Generated route should be an instance of App.Route if provided\", function() {\n var generatedRoute;\n\n Router.map(function() {\n this.route('posts');\n });\n\n App.Route = Ember.Route.extend();\n\n bootApplication();\n\n handleURL(\"/posts\");\n\n generatedRoute = container.lookup('route:posts');\n\n ok(generatedRoute instanceof App.Route, 'should extend the correct route');\n\n});\n\ntest(\"Nested index route is not overriden by parent's implicit index route\", function() {\n Router.map(function() {\n this.resource('posts', function() {\n this.route('index', { path: ':category' } );\n });\n });\n\n App.Route = Ember.Route.extend({\n serialize: function(model) {\n return { category: model.category };\n }\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.transitionTo('posts', { category: 'emberjs' });\n });\n\n deepEqual(router.location.path, '/posts/emberjs');\n});\n\ntest(\"Application template does not duplicate when re-rendered\", function() {\n Ember.TEMPLATES.application = compile(\"

    I Render Once

    {{outlet}}\");\n\n Router.map(function() {\n this.route('posts');\n });\n\n App.ApplicationRoute = Ember.Route.extend({\n model: function() {\n return Ember.A();\n }\n });\n\n bootApplication();\n\n // should cause application template to re-render\n handleURL('/posts');\n\n equal(Ember.$('h3:contains(I Render Once)').size(), 1);\n});\n\ntest(\"Child routes should render inside the application template if the application template causes a redirect\", function() {\n Ember.TEMPLATES.application = compile(\"

    App

    {{outlet}}\");\n Ember.TEMPLATES.posts = compile(\"posts\");\n\n Router.map(function() {\n this.route('posts');\n this.route('photos');\n });\n\n App.ApplicationRoute = Ember.Route.extend({\n afterModel: function() {\n this.transitionTo('posts');\n }\n });\n\n bootApplication();\n\n equal(Ember.$('#qunit-fixture > div').text(), \"App posts\");\n});\n\ntest(\"The template is not re-rendered when the route's context changes\", function() {\n Router.map(function() {\n this.route(\"page\", { path: \"/page/:name\" });\n });\n\n App.PageRoute = Ember.Route.extend({\n model: function(params) {\n return Ember.Object.create({name: params.name});\n }\n });\n\n var insertionCount = 0;\n App.PageView = Ember.View.extend({\n didInsertElement: function() {\n insertionCount += 1;\n }\n });\n\n Ember.TEMPLATES.page = Ember.Handlebars.compile(\n \"

    {{name}}

    \"\n );\n\n bootApplication();\n\n handleURL(\"/page/first\");\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"first\");\n equal(insertionCount, 1);\n\n handleURL(\"/page/second\");\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"second\");\n equal(insertionCount, 1, \"view should have inserted only once\");\n\n Ember.run(function() {\n router.transitionTo('page', Ember.Object.create({name: 'third'}));\n });\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"third\");\n equal(insertionCount, 1, \"view should still have inserted only once\");\n});\n\n\ntest(\"The template is not re-rendered when two routes present the exact same template, view, & controller\", function() {\n Router.map(function() {\n this.route(\"first\");\n this.route(\"second\");\n this.route(\"third\");\n this.route(\"fourth\");\n });\n\n App.SharedRoute = Ember.Route.extend({\n viewName: 'shared',\n setupController: function(controller) {\n this.controllerFor('shared').set('message', \"This is the \" + this.routeName + \" message\");\n },\n\n renderTemplate: function(controller, context) {\n this.render({ controller: 'shared' });\n }\n });\n\n App.FirstRoute = App.SharedRoute.extend();\n App.SecondRoute = App.SharedRoute.extend();\n App.ThirdRoute = App.SharedRoute.extend();\n App.FourthRoute = App.SharedRoute.extend({\n viewName: 'fourth'\n });\n\n App.SharedController = Ember.Controller.extend();\n\n var insertionCount = 0;\n App.SharedView = Ember.View.extend({\n templateName: 'shared',\n didInsertElement: function() {\n insertionCount += 1;\n }\n });\n\n // Extending, in essence, creates a different view\n App.FourthView = App.SharedView.extend();\n\n Ember.TEMPLATES.shared = Ember.Handlebars.compile(\n \"

    {{message}}

    \"\n );\n\n bootApplication();\n\n handleURL(\"/first\");\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"This is the first message\");\n equal(insertionCount, 1, 'expected one assertion');\n\n // Transition by URL\n handleURL(\"/second\");\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"This is the second message\");\n equal(insertionCount, 1, \"view should have inserted only once\");\n\n // Then transition directly by route name\n Ember.run(function() {\n router.transitionTo('third').then(function(value){\n ok(true, 'expected transition');\n }, function(reason) {\n ok(false, 'unexpected transition failure: ', QUnit.jsDump.parse(reason));\n });\n });\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"This is the third message\");\n equal(insertionCount, 1, \"view should still have inserted only once\");\n\n // Lastly transition to a different view, with the same controller and template\n handleURL(\"/fourth\");\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"This is the fourth message\");\n equal(insertionCount, 2, \"view should have inserted a second time\");\n});\n\ntest(\"ApplicationRoute with model does not proxy the currentPath\", function() {\n var model = {};\n var currentPath;\n\n App.ApplicationRoute = Ember.Route.extend({\n model: function () { return model; }\n });\n\n App.ApplicationController = Ember.ObjectController.extend({\n currentPathDidChange: Ember.observer('currentPath', function() {\n currentPath = get(this, 'currentPath');\n })\n });\n\n bootApplication();\n\n equal(currentPath, 'index', 'currentPath is index');\n equal('currentPath' in model, false, 'should have defined currentPath on controller');\n});\n\ntest(\"Promises encountered on app load put app into loading state until resolved\", function() {\n\n expect(2);\n\n var deferred = Ember.RSVP.defer();\n\n App.IndexRoute = Ember.Route.extend({\n model: function() {\n return deferred.promise;\n }\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"

    INDEX

    \");\n Ember.TEMPLATES.loading = Ember.Handlebars.compile(\"

    LOADING

    \");\n\n bootApplication();\n\n equal(Ember.$('p', '#qunit-fixture').text(), \"LOADING\", \"The loading state is displaying.\");\n Ember.run(deferred.resolve);\n equal(Ember.$('p', '#qunit-fixture').text(), \"INDEX\", \"The index route is display.\");\n});\n\ntest(\"Route should tear down multiple outlets\", function() {\n Ember.TEMPLATES.application = compile(\"{{outlet menu}}{{outlet}}{{outlet footer}}\");\n Ember.TEMPLATES.posts = compile(\"{{outlet}}\");\n Ember.TEMPLATES.users = compile(\"users\");\n Ember.TEMPLATES['posts/index'] = compile(\"postsIndex\");\n Ember.TEMPLATES['posts/menu'] = compile(\"postsMenu\");\n Ember.TEMPLATES['posts/footer'] = compile(\"postsFooter\");\n\n Router.map(function() {\n this.resource(\"posts\", function() {});\n this.resource(\"users\", function() {});\n });\n\n App.PostsMenuView = Ember.View.extend({\n tagName: 'div',\n templateName: 'posts/menu',\n classNames: ['posts-menu']\n });\n\n App.PostsIndexView = Ember.View.extend({\n tagName: 'p',\n classNames: ['posts-index']\n });\n\n App.PostsFooterView = Ember.View.extend({\n tagName: 'div',\n templateName: 'posts/footer',\n classNames: ['posts-footer']\n });\n\n App.PostsRoute = Ember.Route.extend({\n renderTemplate: function() {\n this.render('postsMenu', {\n into: 'application',\n outlet: 'menu'\n });\n\n this.render();\n\n this.render('postsFooter', {\n into: 'application',\n outlet: 'footer'\n });\n }\n });\n\n bootApplication();\n\n handleURL('/posts');\n\n equal(Ember.$('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 1, \"The posts/menu template was rendered\");\n equal(Ember.$('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, \"The posts/index template was rendered\");\n equal(Ember.$('div.posts-footer:contains(postsFooter)', '#qunit-fixture').length, 1, \"The posts/footer template was rendered\");\n\n handleURL('/users');\n\n equal(Ember.$('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 0, \"The posts/menu template was removed\");\n equal(Ember.$('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, \"The posts/index template was removed\");\n equal(Ember.$('div.posts-footer:contains(postsFooter)', '#qunit-fixture').length, 0, \"The posts/footer template was removed\");\n\n});\n\n\ntest(\"Route supports clearing outlet explicitly\", function() {\n Ember.TEMPLATES.application = compile(\"{{outlet}}{{outlet modal}}\");\n Ember.TEMPLATES.posts = compile(\"{{outlet}}\");\n Ember.TEMPLATES.users = compile(\"users\");\n Ember.TEMPLATES['posts/index'] = compile(\"postsIndex {{outlet}}\");\n Ember.TEMPLATES['posts/modal'] = compile(\"postsModal\");\n Ember.TEMPLATES['posts/extra'] = compile(\"postsExtra\");\n\n Router.map(function() {\n this.resource(\"posts\", function() {});\n this.resource(\"users\", function() {});\n });\n\n App.PostsIndexView = Ember.View.extend({\n classNames: ['posts-index']\n });\n\n App.PostsModalView = Ember.View.extend({\n templateName: 'posts/modal',\n classNames: ['posts-modal']\n });\n\n App.PostsExtraView = Ember.View.extend({\n templateName: 'posts/extra',\n classNames: ['posts-extra']\n });\n\n App.PostsRoute = Ember.Route.extend({\n actions: {\n showModal: function() {\n this.render('postsModal', {\n into: 'application',\n outlet: 'modal'\n });\n },\n hideModal: function() {\n this.disconnectOutlet({outlet: 'modal', parentView: 'application'});\n }\n }\n });\n\n App.PostsIndexRoute = Ember.Route.extend({\n actions: {\n showExtra: function() {\n this.render('postsExtra', {\n into: 'posts/index'\n });\n },\n hideExtra: function() {\n this.disconnectOutlet({parentView: 'posts/index'});\n }\n }\n });\n\n bootApplication();\n\n handleURL('/posts');\n\n equal(Ember.$('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, \"The posts/index template was rendered\");\n Ember.run(function() {\n router.send('showModal');\n });\n equal(Ember.$('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 1, \"The posts/modal template was rendered\");\n Ember.run(function() {\n router.send('showExtra');\n });\n equal(Ember.$('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 1, \"The posts/extra template was rendered\");\n Ember.run(function() {\n router.send('hideModal');\n });\n equal(Ember.$('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, \"The posts/modal template was removed\");\n Ember.run(function() {\n router.send('hideExtra');\n });\n equal(Ember.$('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 0, \"The posts/extra template was removed\");\n\n handleURL('/users');\n\n equal(Ember.$('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, \"The posts/index template was removed\");\n equal(Ember.$('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, \"The posts/modal template was removed\");\n equal(Ember.$('div.posts-extra:contains(postsExtra)', '#qunit-fixture').length, 0, \"The posts/extra template was removed\");\n});\n\ntest(\"Route supports clearing outlet using string parameter\", function() {\n Ember.TEMPLATES.application = compile(\"{{outlet}}{{outlet modal}}\");\n Ember.TEMPLATES.posts = compile(\"{{outlet}}\");\n Ember.TEMPLATES.users = compile(\"users\");\n Ember.TEMPLATES['posts/index'] = compile(\"postsIndex {{outlet}}\");\n Ember.TEMPLATES['posts/modal'] = compile(\"postsModal\");\n\n Router.map(function() {\n this.resource(\"posts\", function() {});\n this.resource(\"users\", function() {});\n });\n\n App.PostsIndexView = Ember.View.extend({\n classNames: ['posts-index']\n });\n\n App.PostsModalView = Ember.View.extend({\n templateName: 'posts/modal',\n classNames: ['posts-modal']\n });\n\n App.PostsRoute = Ember.Route.extend({\n actions: {\n showModal: function() {\n this.render('postsModal', {\n into: 'application',\n outlet: 'modal'\n });\n },\n hideModal: function() {\n this.disconnectOutlet('modal');\n }\n }\n });\n\n bootApplication();\n\n handleURL('/posts');\n\n equal(Ember.$('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, \"The posts/index template was rendered\");\n Ember.run(function() {\n router.send('showModal');\n });\n equal(Ember.$('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 1, \"The posts/modal template was rendered\");\n Ember.run(function() {\n router.send('hideModal');\n });\n equal(Ember.$('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, \"The posts/modal template was removed\");\n\n handleURL('/users');\n\n equal(Ember.$('div.posts-index:contains(postsIndex)', '#qunit-fixture').length, 0, \"The posts/index template was removed\");\n equal(Ember.$('div.posts-modal:contains(postsModal)', '#qunit-fixture').length, 0, \"The posts/modal template was removed\");\n});\n\ntest(\"Route silently fails when cleaning an outlet from an inactive view\", function() {\n expect(1); // handleURL\n\n Ember.TEMPLATES.application = compile(\"{{outlet}}\");\n Ember.TEMPLATES.posts = compile(\"{{outlet modal}}\");\n Ember.TEMPLATES.modal = compile(\"A Yo.\");\n\n Router.map(function() {\n this.route(\"posts\");\n });\n\n App.PostsRoute = Ember.Route.extend({\n actions: {\n hideSelf: function() {\n this.disconnectOutlet({outlet: 'main', parentView: 'application'});\n },\n showModal: function() {\n this.render('modal', {into: 'posts', outlet: 'modal'});\n },\n hideModal: function() {\n this.disconnectOutlet({outlet: 'modal', parentView: 'posts'});\n }\n }\n });\n\n bootApplication();\n\n handleURL('/posts');\n\n Ember.run(function() { router.send('showModal'); });\n Ember.run(function() { router.send('hideSelf'); });\n Ember.run(function() { router.send('hideModal'); });\n});\n\ntest(\"Aborting/redirecting the transition in `willTransition` prevents LoadingRoute from being entered\", function() {\n expect(8);\n\n Router.map(function() {\n this.route(\"nork\");\n this.route(\"about\");\n });\n\n var redirect = false;\n\n App.IndexRoute = Ember.Route.extend({\n actions: {\n willTransition: function(transition) {\n ok(true, \"willTransition was called\");\n if (redirect) {\n // router.js won't refire `willTransition` for this redirect\n this.transitionTo('about');\n } else {\n transition.abort();\n }\n }\n }\n });\n\n var deferred = null;\n\n App.LoadingRoute = Ember.Route.extend({\n activate: function() {\n ok(deferred, \"LoadingRoute should be entered at this time\");\n },\n deactivate: function() {\n ok(true, \"LoadingRoute was exited\");\n }\n });\n\n App.NorkRoute = Ember.Route.extend({\n activate: function() {\n ok(true, \"NorkRoute was entered\");\n }\n });\n\n App.AboutRoute = Ember.Route.extend({\n activate: function() {\n ok(true, \"AboutRoute was entered\");\n },\n model: function() {\n if (deferred) { return deferred.promise; }\n }\n });\n\n bootApplication();\n\n // Attempted transitions out of index should abort.\n Ember.run(router, 'transitionTo', 'nork');\n Ember.run(router, 'handleURL', '/nork');\n\n // Attempted transitions out of index should redirect to about\n redirect = true;\n Ember.run(router, 'transitionTo', 'nork');\n Ember.run(router, 'transitionTo', 'index');\n\n // Redirected transitions out of index to a route with a\n // promise model should pause the transition and\n // activate LoadingRoute\n deferred = Ember.RSVP.defer();\n Ember.run(router, 'transitionTo', 'nork');\n Ember.run(deferred.resolve);\n});\n\ntest(\"`didTransition` event fires on the router\", function() {\n expect(3);\n\n Router.map(function(){\n this.route(\"nork\");\n });\n\n router = container.lookup('router:main');\n\n router.one('didTransition', function(){\n ok(true, 'didTransition fired on initial routing');\n });\n\n bootApplication();\n\n router.one('didTransition', function(){\n ok(true, 'didTransition fired on the router');\n equal(router.get('url'), \"/nork\", 'The url property is updated by the time didTransition fires');\n });\n\n Ember.run(router, 'transitionTo', 'nork');\n});\ntest(\"`didTransition` can be reopened\", function() {\n expect(1);\n\n Router.map(function(){\n this.route(\"nork\");\n });\n\n Router.reopen({\n didTransition: function(){\n this._super.apply(this, arguments);\n ok(true, 'reopened didTransition was called');\n }\n });\n\n bootApplication();\n});\n\ntest(\"Actions can be handled by inherited action handlers\", function() {\n\n expect(4);\n\n App.SuperRoute = Ember.Route.extend({\n actions: {\n foo: function() {\n ok(true, 'foo');\n },\n bar: function(msg) {\n equal(msg, \"HELLO\");\n }\n }\n });\n\n App.RouteMixin = Ember.Mixin.create({\n actions: {\n bar: function(msg) {\n equal(msg, \"HELLO\");\n this._super(msg);\n }\n }\n });\n\n App.IndexRoute = App.SuperRoute.extend(App.RouteMixin, {\n actions: {\n baz: function() {\n ok(true, 'baz');\n }\n }\n });\n\n bootApplication();\n\n router.send(\"foo\");\n router.send(\"bar\", \"HELLO\");\n router.send(\"baz\");\n});\n\ntest(\"currentRouteName is a property installed on ApplicationController that can be used in transitionTo\", function() {\n\n expect(24);\n\n Router.map(function() {\n this.resource(\"be\", function() {\n this.resource(\"excellent\", function() {\n this.resource(\"to\", function() {\n this.resource(\"each\", function() {\n this.route(\"other\");\n });\n });\n });\n });\n });\n\n bootApplication();\n\n var appController = router.container.lookup('controller:application');\n\n function transitionAndCheck(path, expectedPath, expectedRouteName) {\n if (path) { Ember.run(router, 'transitionTo', path); }\n equal(appController.get('currentPath'), expectedPath);\n equal(appController.get('currentRouteName'), expectedRouteName);\n }\n\n transitionAndCheck(null, 'index', 'index');\n transitionAndCheck('/be', 'be.index', 'be.index');\n transitionAndCheck('/be/excellent', 'be.excellent.index', 'excellent.index');\n transitionAndCheck('/be/excellent/to', 'be.excellent.to.index', 'to.index');\n transitionAndCheck('/be/excellent/to/each', 'be.excellent.to.each.index', 'each.index');\n transitionAndCheck('/be/excellent/to/each/other', 'be.excellent.to.each.other', 'each.other');\n\n transitionAndCheck('index', 'index', 'index');\n transitionAndCheck('be', 'be.index', 'be.index');\n transitionAndCheck('excellent', 'be.excellent.index', 'excellent.index');\n transitionAndCheck('to.index', 'be.excellent.to.index', 'to.index');\n transitionAndCheck('each', 'be.excellent.to.each.index', 'each.index');\n transitionAndCheck('each.other', 'be.excellent.to.each.other', 'each.other');\n});\n\ntest(\"Route model hook finds the same model as a manual find\", function() {\n var Post;\n App.Post = Ember.Object.extend();\n App.Post.reopenClass({\n find: function() {\n Post = this;\n return {};\n }\n });\n\n Router.map(function() {\n this.route('post', { path: '/post/:post_id' });\n });\n\n bootApplication();\n\n handleURL('/post/1');\n\n equal(App.Post, Post);\n});\n\ntest(\"Can register an implementation via Ember.Location.registerImplementation (DEPRECATED)\", function(){\n var TestLocation = Ember.NoneLocation.extend({\n implementation: 'test'\n });\n\n expectDeprecation(/Using the Ember.Location.registerImplementation is no longer supported/);\n\n Ember.Location.registerImplementation('test', TestLocation);\n\n Router.reopen({\n location: 'test'\n });\n\n bootApplication();\n\n equal(router.get('location.implementation'), 'test', 'custom location implementation can be registered with registerImplementation');\n});\n\ntest(\"Ember.Location.registerImplementation is deprecated\", function(){\n var TestLocation = Ember.NoneLocation.extend({\n implementation: 'test'\n });\n\n expectDeprecation(function(){\n Ember.Location.registerImplementation('test', TestLocation);\n }, \"Using the Ember.Location.registerImplementation is no longer supported. Register your custom location implementation with the container instead.\");\n});\n\ntest(\"Routes can refresh themselves causing their model hooks to be re-run\", function() {\n Router.map(function() {\n this.resource('parent', { path: '/parent/:parent_id' }, function() {\n this.route('child');\n });\n });\n\n var appcount = 0;\n App.ApplicationRoute = Ember.Route.extend({\n model: function() {\n ++appcount;\n }\n });\n\n var parentcount = 0;\n App.ParentRoute = Ember.Route.extend({\n model: function(params) {\n equal(params.parent_id, '123');\n ++parentcount;\n },\n actions: {\n refreshParent: function() {\n this.refresh();\n }\n }\n });\n\n var childcount = 0;\n App.ParentChildRoute = Ember.Route.extend({\n model: function() {\n ++childcount;\n }\n });\n\n bootApplication();\n\n equal(appcount, 1);\n equal(parentcount, 0);\n equal(childcount, 0);\n\n Ember.run(router, 'transitionTo', 'parent.child', '123');\n\n equal(appcount, 1);\n equal(parentcount, 1);\n equal(childcount, 1);\n\n Ember.run(router, 'send', 'refreshParent');\n\n equal(appcount, 1);\n equal(parentcount, 2);\n equal(childcount, 2);\n});\n\ntest(\"Specifying non-existent controller name in route#render throws\", function() {\n expect(1);\n\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n });\n\n App.HomeRoute = Ember.Route.extend({\n renderTemplate: function() {\n try {\n this.render('homepage', { controller: 'stefanpenneristhemanforme' });\n } catch(e) {\n equal(e.message, \"You passed `controller: 'stefanpenneristhemanforme'` into the `render` method, but no such controller could be found.\");\n }\n }\n });\n\n bootApplication();\n});\n\ntest(\"Redirecting with null model doesn't error out\", function() {\n Router.map(function() {\n this.route(\"home\", { path: '/' });\n this.route(\"about\", { path: '/about/:hurhurhur' });\n });\n\n App.HomeRoute = Ember.Route.extend({\n beforeModel: function() {\n this.transitionTo('about', null);\n }\n });\n\n App.AboutRoute = Ember.Route.extend({\n serialize: function(model) {\n if (model === null) {\n return { hurhurhur: 'TreeklesMcGeekles' };\n }\n }\n });\n\n bootApplication();\n\n equal(router.get('location.path'), \"/about/TreeklesMcGeekles\");\n});\n\ntest(\"rejecting the model hooks promise with a non-error prints the `message` property\", function() {\n var rejectedMessage = 'OMG!! SOOOOOO BAD!!!!',\n rejectedStack = 'Yeah, buddy: stack gets printed too.',\n originalLoggerError = Ember.Logger.error;\n\n Router.map(function() {\n this.route(\"yippie\", { path: \"/\" });\n });\n\n Ember.Logger.error = function(initialMessage, errorMessage, errorStack) {\n equal(initialMessage, 'Error while loading route: yippie', 'a message with the current route name is printed');\n equal(errorMessage, rejectedMessage, \"the rejected reason's message property is logged\");\n equal(errorStack, rejectedStack, \"the rejected reason's stack property is logged\");\n };\n\n App.YippieRoute = Ember.Route.extend({\n model: function(){\n return Ember.RSVP.reject({message: rejectedMessage, stack: rejectedStack});\n }\n });\n\n bootApplication();\n\n Ember.Logger.error = originalLoggerError;\n});\n\ntest(\"rejecting the model hooks promise with no reason still logs error\", function() {\n var originalLoggerError = Ember.Logger.error;\n\n Router.map(function() {\n this.route(\"wowzers\", { path: \"/\" });\n });\n\n Ember.Logger.error = function(initialMessage) {\n equal(initialMessage, 'Error while loading route: wowzers', 'a message with the current route name is printed');\n };\n\n App.WowzersRoute = Ember.Route.extend({\n model: function(){\n return Ember.RSVP.reject();\n }\n });\n\n bootApplication();\n\n Ember.Logger.error = originalLoggerError;\n});\n\ntest(\"rejecting the model hooks promise with a string shows a good error\", function() {\n var originalLoggerError = Ember.Logger.error,\n rejectedMessage = \"Supercalifragilisticexpialidocious\";\n\n Router.map(function() {\n this.route(\"yondo\", { path: \"/\" });\n });\n\n Ember.Logger.error = function(initialMessage, errorMessage) {\n equal(initialMessage, 'Error while loading route: yondo', 'a message with the current route name is printed');\n equal(errorMessage, rejectedMessage, \"the rejected reason's message property is logged\");\n };\n\n App.YondoRoute = Ember.Route.extend({\n model: function(){\n return Ember.RSVP.reject(rejectedMessage);\n }\n });\n\n bootApplication();\n\n Ember.Logger.error = originalLoggerError;\n});\n\n})();\n//@ sourceURL=ember/~tests/routing/basic_test");minispade.register('ember/~tests/routing/query_params_test', "(function() {var Router, App, AppView, templates, router, container;\nvar get = Ember.get,\n set = Ember.set,\n compile = Ember.Handlebars.compile,\n forEach = Ember.EnumerableUtils.forEach;\n\nfunction bootApplication() {\n router = container.lookup('router:main');\n Ember.run(App, 'advanceReadiness');\n}\n\nfunction handleURL(path) {\n return Ember.run(function() {\n return router.handleURL(path).then(function(value) {\n ok(true, 'url: `' + path + '` was handled');\n return value;\n }, function(reason) {\n ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason));\n throw reason;\n });\n });\n}\n\nfunction handleURLAborts(path) {\n Ember.run(function() {\n router.handleURL(path).then(function(value) {\n ok(false, 'url: `' + path + '` was NOT to be handled');\n }, function(reason) {\n ok(reason && reason.message === \"TransitionAborted\", 'url: `' + path + '` was to be aborted');\n });\n });\n}\n\nfunction handleURLRejectsWith(path, expectedReason) {\n Ember.run(function() {\n router.handleURL(path).then(function(value) {\n ok(false, 'expected handleURLing: `' + path + '` to fail');\n }, function(reason) {\n equal(expectedReason, reason);\n });\n });\n}\n\nvar startingURL = '', expectedReplaceURL, expectedPushURL;\n\nvar TestLocation = Ember.NoneLocation.extend({\n initState: function() {\n this.set('path', startingURL);\n },\n\n setURL: function(path) {\n if (expectedPushURL) {\n equal(path, expectedPushURL, \"an expected pushState occurred\");\n expectedPushURL = null;\n }\n this.set('path', path);\n },\n\n replaceURL: function(path) {\n if (expectedReplaceURL) {\n equal(path, expectedReplaceURL, \"an expected replaceState occurred\");\n expectedReplaceURL = null;\n }\n this.set('path', path);\n }\n});\n\nif (Ember.FEATURES.isEnabled(\"query-params-new\")) {\n\n module(\"Routing w/ Query Params\", {\n setup: function() {\n Ember.run(function() {\n App = Ember.Application.create({\n name: \"App\",\n rootElement: '#qunit-fixture'\n });\n\n App.deferReadiness();\n\n container = App.__container__;\n container.register('location:test', TestLocation);\n\n startingURL = expectedReplaceURL = expectedPushURL = '';\n\n App.Router.reopen({\n location: 'test'\n });\n\n Router = App.Router;\n\n App.LoadingRoute = Ember.Route.extend({\n });\n\n Ember.TEMPLATES.application = compile(\"{{outlet}}\");\n Ember.TEMPLATES.home = compile(\"

    Hours

    \");\n });\n },\n\n teardown: function() {\n Ember.run(function() {\n App.destroy();\n App = null;\n\n Ember.TEMPLATES = {};\n });\n }\n });\n\n test(\"Single query params can be set\", function() {\n Router.map(function() {\n this.route(\"home\", { path: '/' });\n });\n\n App.HomeController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: \"123\"\n });\n\n bootApplication();\n\n var controller = container.lookup('controller:home');\n\n Ember.run(controller, 'set', 'foo', '456');\n\n equal(router.get('location.path'), \"/?foo=456\");\n\n Ember.run(controller, 'set', 'foo', '987');\n equal(router.get('location.path'), \"/?foo=987\");\n });\n\n test(\"Query params can map to different url keys with colon syntax.\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo:other_key'],\n foo: \"FOO\"\n });\n\n bootApplication();\n equal(router.get('location.path'), \"\");\n\n var controller = container.lookup('controller:index');\n Ember.run(controller, 'set', 'foo', 'LEX');\n\n equal(router.get('location.path'), \"/?other_key=LEX\");\n Ember.run(controller, 'set', 'foo', 'WOO');\n equal(router.get('location.path'), \"/?other_key=WOO\");\n\n Ember.run(router, 'transitionTo', '/?other_key=NAW');\n equal(controller.get('foo'), \"NAW\");\n });\n\n test(\"No replaceURL occurs on startup because default values don't show up in URL\", function() {\n expect(0);\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: \"123\"\n });\n\n expectedReplaceURL = \"/?foo=123\";\n\n bootApplication();\n });\n\n test(\"model hooks receives query params\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['omg'],\n omg: 'lol'\n });\n\n App.IndexRoute = Ember.Route.extend({\n model: function(params) {\n deepEqual(params, { omg: 'lol' });\n }\n });\n\n bootApplication();\n\n equal(router.get('location.path'), \"\");\n });\n\n test(\"controllers won't be eagerly instantiated by internal query params logic\", function() {\n expect(10);\n Router.map(function() {\n this.resource('cats', function() {\n this.route('index', { path: '/' });\n });\n this.route(\"home\", { path: '/' });\n this.route(\"about\");\n });\n\n Ember.TEMPLATES.home = compile(\"

    {{link-to 'About' 'about' (query-params lol='wat') id='link-to-about'}}

    \");\n Ember.TEMPLATES.about = compile(\"

    {{link-to 'Home' 'home' (query-params foo='naw')}}

    \");\n Ember.TEMPLATES['cats/index'] = compile(\"

    {{link-to 'Cats' 'cats' (query-params name='domino') id='cats-link'}}

    \");\n\n var homeShouldBeCreated = false,\n aboutShouldBeCreated = false,\n catsIndexShouldBeCreated = false;\n\n App.HomeRoute = Ember.Route.extend({\n setup: function() {\n homeShouldBeCreated = true;\n this._super.apply(this, arguments);\n }\n });\n\n App.HomeController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: \"123\",\n init: function() {\n this._super();\n ok (homeShouldBeCreated, \"HomeController should be created at this time\");\n }\n });\n\n App.AboutRoute = Ember.Route.extend({\n setup: function() {\n aboutShouldBeCreated = true;\n this._super.apply(this, arguments);\n }\n });\n\n App.AboutController = Ember.Controller.extend({\n queryParams: ['lol'],\n lol: \"haha\",\n init: function() {\n this._super();\n ok (aboutShouldBeCreated, \"AboutController should be created at this time\");\n }\n });\n\n App.CatsIndexRoute = Ember.Route.extend({\n model: function(){\n return [];\n },\n setup: function() {\n catsIndexShouldBeCreated = true;\n this._super.apply(this, arguments);\n },\n setupController: function(controller, context) {\n controller.set('model', context);\n }\n });\n\n App.CatsIndexController = Ember.Controller.extend({\n queryParams: ['breed', 'name' ],\n breed: 'Golden',\n name: null,\n init: function() {\n this._super();\n ok (catsIndexShouldBeCreated, \"CatsIndexController should be created at this time\");\n }\n });\n\n bootApplication();\n\n equal(router.get('location.path'), \"\", 'url is correct');\n var controller = container.lookup('controller:home');\n Ember.run(controller, 'set', 'foo', '456');\n equal(router.get('location.path'), \"/?foo=456\", 'url is correct');\n equal(Ember.$('#link-to-about').attr('href'), \"/about?lol=wat\", \"link to about is correct\");\n\n Ember.run(router, 'transitionTo', 'about');\n equal(router.get('location.path'), \"/about\", 'url is correct');\n\n Ember.run(router, 'transitionTo', 'cats');\n\n equal(router.get('location.path'), \"/cats\", 'url is correct');\n equal(Ember.$('#cats-link').attr('href'), \"/cats?name=domino\", \"link to cats is correct\");\n Ember.run(Ember.$('#cats-link'), 'click');\n equal(router.get('location.path'), \"/cats?name=domino\", 'url is correct');\n });\n\n test(\"model hooks receives query params (overridden by incoming url value)\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['omg'],\n omg: 'lol'\n });\n\n App.IndexRoute = Ember.Route.extend({\n model: function(params) {\n deepEqual(params, { omg: 'yes' });\n }\n });\n\n startingURL = \"/?omg=yes\";\n bootApplication();\n\n equal(router.get('location.path'), \"/?omg=yes\");\n });\n\n test(\"Route#paramsFor fetches query params\", function() {\n expect(1);\n\n Router.map(function() {\n this.route('index', { path: '/:something' });\n });\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: 'fooapp'\n });\n\n App.IndexRoute = Ember.Route.extend({\n model: function(params, transition) {\n deepEqual(this.paramsFor('index'), { something: 'omg', foo: 'fooapp' }, \"could retrieve params for index\");\n }\n });\n\n startingURL = \"/omg\";\n bootApplication();\n });\n\n test(\"model hook can query prefix-less application params\", function() {\n App.ApplicationController = Ember.Controller.extend({\n queryParams: ['appomg'],\n appomg: 'applol'\n });\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['omg'],\n omg: 'lol'\n });\n\n App.ApplicationRoute = Ember.Route.extend({\n model: function(params) {\n deepEqual(params, { appomg: 'applol' });\n }\n });\n\n App.IndexRoute = Ember.Route.extend({\n model: function(params) {\n deepEqual(params, { omg: 'lol' });\n deepEqual(this.paramsFor('application'), { appomg: 'applol' });\n }\n });\n\n bootApplication();\n\n equal(router.get('location.path'), \"\");\n });\n\n test(\"model hook can query prefix-less application params (overridden by incoming url value)\", function() {\n App.ApplicationController = Ember.Controller.extend({\n queryParams: ['appomg'],\n appomg: 'applol'\n });\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['omg'],\n omg: 'lol'\n });\n\n App.ApplicationRoute = Ember.Route.extend({\n model: function(params) {\n deepEqual(params, { appomg: 'appyes' });\n }\n });\n\n App.IndexRoute = Ember.Route.extend({\n model: function(params) {\n deepEqual(params, { omg: 'yes' });\n deepEqual(this.paramsFor('application'), { appomg: 'appyes' });\n }\n });\n\n startingURL = \"/?appomg=appyes&omg=yes\";\n bootApplication();\n\n equal(router.get('location.path'), \"/?appomg=appyes&omg=yes\");\n });\n\n test(\"can opt into full transition by setting refreshModel in route queryParams\", function() {\n expect(6);\n App.ApplicationController = Ember.Controller.extend({\n queryParams: ['appomg'],\n appomg: 'applol'\n });\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['omg'],\n omg: 'lol'\n });\n\n var appModelCount = 0;\n App.ApplicationRoute = Ember.Route.extend({\n model: function(params) {\n appModelCount++;\n }\n });\n\n var indexModelCount = 0;\n App.IndexRoute = Ember.Route.extend({\n queryParams: {\n omg: {\n refreshModel: true\n }\n },\n model: function(params) {\n indexModelCount++;\n\n if (indexModelCount === 1) {\n deepEqual(params, { omg: 'lol' });\n } else if (indexModelCount === 2) {\n deepEqual(params, { omg: 'lex' });\n }\n }\n });\n\n bootApplication();\n\n equal(appModelCount, 1);\n equal(indexModelCount, 1);\n\n var indexController = container.lookup('controller:index');\n Ember.run(indexController, 'set', 'omg', 'lex');\n\n equal(appModelCount, 1);\n equal(indexModelCount, 2);\n });\n\n test(\"Use Ember.get to retrieve query params 'refreshModel' configuration\", function() {\n expect(6);\n App.ApplicationController = Ember.Controller.extend({\n queryParams: ['appomg'],\n appomg: 'applol'\n });\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['omg'],\n omg: 'lol'\n });\n\n var appModelCount = 0;\n App.ApplicationRoute = Ember.Route.extend({\n model: function(params) {\n appModelCount++;\n }\n });\n\n var indexModelCount = 0;\n App.IndexRoute = Ember.Route.extend({\n queryParams: Ember.Object.create({\n unknownProperty: function(keyName) {\n return {refreshModel: true};\n }\n }),\n model: function(params) {\n indexModelCount++;\n\n if (indexModelCount === 1) {\n deepEqual(params, { omg: 'lol' });\n } else if (indexModelCount === 2) {\n deepEqual(params, { omg: 'lex' });\n }\n }\n });\n\n bootApplication();\n\n equal(appModelCount, 1);\n equal(indexModelCount, 1);\n\n var indexController = container.lookup('controller:index');\n Ember.run(indexController, 'set', 'omg', 'lex');\n\n equal(appModelCount, 1);\n equal(indexModelCount, 2);\n });\n\n test(\"can use refreshModel even w URL changes that remove QPs from address bar\", function() {\n expect(4);\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['omg'],\n omg: 'lol'\n });\n\n var indexModelCount = 0;\n App.IndexRoute = Ember.Route.extend({\n queryParams: {\n omg: {\n refreshModel: true\n }\n },\n model: function(params) {\n indexModelCount++;\n\n var data;\n if (indexModelCount === 1) {\n data = 'foo';\n } else if (indexModelCount === 2) {\n data = 'lol';\n }\n\n deepEqual(params, { omg: data }, \"index#model receives right data\");\n }\n });\n\n startingURL = '/?omg=foo';\n bootApplication();\n handleURL('/');\n\n var indexController = container.lookup('controller:index');\n equal(indexController.get('omg'), 'lol');\n });\n\n\n test(\"can opt into a replace query by specifying replace:true in the Router config hash\", function() {\n expect(2);\n App.ApplicationController = Ember.Controller.extend({\n queryParams: ['alex'],\n alex: 'matchneer'\n });\n\n App.ApplicationRoute = Ember.Route.extend({\n queryParams: {\n alex: {\n replace: true\n }\n }\n });\n\n bootApplication();\n\n equal(router.get('location.path'), \"\");\n\n var appController = container.lookup('controller:application');\n expectedReplaceURL = \"/?alex=wallace\";\n Ember.run(appController, 'set', 'alex', 'wallace');\n });\n\n test(\"Use Ember.get to retrieve query params 'replace' configuration\", function() {\n expect(2);\n App.ApplicationController = Ember.Controller.extend({\n queryParams: ['alex'],\n alex: 'matchneer'\n });\n\n App.ApplicationRoute = Ember.Route.extend({\n queryParams: Ember.Object.create({\n unknownProperty: function(keyName) {\n // We are simulating all qps requiring refress\n return { replace: true };\n }\n })\n });\n\n bootApplication();\n\n equal(router.get('location.path'), \"\");\n\n var appController = container.lookup('controller:application');\n expectedReplaceURL = \"/?alex=wallace\";\n Ember.run(appController, 'set', 'alex', 'wallace');\n });\n\n test(\"can override incoming QP values in setupController\", function() {\n expect(3);\n\n App.Router.map(function() {\n this.route('about');\n });\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['omg'],\n omg: 'lol'\n });\n\n App.IndexRoute = Ember.Route.extend({\n setupController: function(controller) {\n ok(true, \"setupController called\");\n controller.set('omg', 'OVERRIDE');\n },\n actions: {\n queryParamsDidChange: function() {\n ok(false, \"queryParamsDidChange shouldn't fire\");\n }\n }\n });\n\n startingURL = \"/about\";\n bootApplication();\n equal(router.get('location.path'), \"/about\");\n Ember.run(router, 'transitionTo', 'index');\n equal(router.get('location.path'), \"/?omg=OVERRIDE\");\n });\n\n test(\"URL transitions that remove QPs still register as QP changes\", function() {\n expect(2);\n\n App.IndexController = Ember.Controller.extend({\n queryParams: ['omg'],\n omg: 'lol'\n });\n\n startingURL = \"/?omg=borf\";\n bootApplication();\n\n var indexController = container.lookup('controller:index');\n equal(indexController.get('omg'), 'borf');\n Ember.run(router, 'transitionTo', '/');\n equal(indexController.get('omg'), 'lol');\n });\n\n test(\"Subresource naming style is supported\", function() {\n\n Router.map(function() {\n this.resource('abc.def', { path: '/abcdef' }, function() {\n this.route('zoo');\n });\n });\n\n Ember.TEMPLATES.application = compile(\"{{link-to 'A' 'abc.def' (query-params foo='123') id='one'}}{{link-to 'B' 'abc.def.zoo' (query-params foo='123' bar='456') id='two'}}{{outlet}}\");\n\n App.AbcDefController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: 'lol'\n });\n\n App.AbcDefZooController = Ember.Controller.extend({\n queryParams: ['bar'],\n bar: 'haha'\n });\n\n bootApplication();\n equal(router.get('location.path'), \"\");\n equal(Ember.$('#one').attr('href'), \"/abcdef?foo=123\");\n equal(Ember.$('#two').attr('href'), \"/abcdef/zoo?bar=456&foo=123\");\n\n Ember.run(Ember.$('#one'), 'click');\n equal(router.get('location.path'), \"/abcdef?foo=123\");\n Ember.run(Ember.$('#two'), 'click');\n equal(router.get('location.path'), \"/abcdef/zoo?bar=456&foo=123\");\n });\n\n test(\"transitionTo supports query params\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: 'lol'\n });\n\n bootApplication();\n\n equal(router.get('location.path'), \"\");\n\n Ember.run(router, 'transitionTo', { queryParams: { foo: \"borf\" } });\n equal(router.get('location.path'), \"/?foo=borf\", \"shorthand supported\");\n Ember.run(router, 'transitionTo', { queryParams: { 'index:foo': \"blaf\" } });\n equal(router.get('location.path'), \"/?foo=blaf\", \"longform supported\");\n Ember.run(router, 'transitionTo', { queryParams: { 'index:foo': false } });\n equal(router.get('location.path'), \"/?foo=false\", \"longform supported (bool)\");\n Ember.run(router, 'transitionTo', { queryParams: { foo: false } });\n equal(router.get('location.path'), \"/?foo=false\", \"shorhand supported (bool)\");\n });\n\n test(\"transitionTo supports query params (multiple)\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo', 'bar'],\n foo: 'lol',\n bar: 'wat'\n });\n\n bootApplication();\n\n equal(router.get('location.path'), \"\");\n\n Ember.run(router, 'transitionTo', { queryParams: { foo: \"borf\" } });\n equal(router.get('location.path'), \"/?foo=borf\", \"shorthand supported\");\n Ember.run(router, 'transitionTo', { queryParams: { 'index:foo': \"blaf\" } });\n equal(router.get('location.path'), \"/?foo=blaf\", \"longform supported\");\n Ember.run(router, 'transitionTo', { queryParams: { 'index:foo': false } });\n equal(router.get('location.path'), \"/?foo=false\", \"longform supported (bool)\");\n Ember.run(router, 'transitionTo', { queryParams: { foo: false } });\n equal(router.get('location.path'), \"/?foo=false\", \"shorhand supported (bool)\");\n });\n\n test(\"setting controller QP to empty string doesn't generate null in URL\", function() {\n expect(1);\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: \"123\"\n });\n\n bootApplication();\n var controller = container.lookup('controller:index');\n\n expectedPushURL = \"/?foo=\";\n Ember.run(controller, 'set', 'foo', '');\n });\n\n test(\"A default boolean value deserializes QPs as booleans rather than strings\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: false\n });\n\n App.IndexRoute = Ember.Route.extend({\n model: function(params) {\n equal(params.foo, true, \"model hook received foo as boolean true\");\n }\n });\n\n startingURL = \"/?foo=true\";\n bootApplication();\n\n var controller = container.lookup('controller:index');\n equal(controller.get('foo'), true);\n\n handleURL('/?foo=false');\n equal(controller.get('foo'), false);\n });\n\n test(\"Query param without value are empty string\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: ''\n });\n\n startingURL = \"/?foo=\";\n bootApplication();\n\n var controller = container.lookup('controller:index');\n equal(controller.get('foo'), \"\");\n });\n\n test(\"Array query params can be set\", function() {\n Router.map(function() {\n this.route(\"home\", { path: '/' });\n });\n\n App.HomeController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: []\n });\n\n bootApplication();\n\n var controller = container.lookup('controller:home');\n\n Ember.run(controller, 'set', 'foo', [1,2]);\n\n equal(router.get('location.path'), \"/?foo=%5B1%2C2%5D\");\n\n Ember.run(controller, 'set', 'foo', [3,4]);\n equal(router.get('location.path'), \"/?foo=%5B3%2C4%5D\");\n });\n\n test(\"(de)serialization: arrays\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: [1]\n });\n\n bootApplication();\n\n equal(router.get('location.path'), \"\");\n\n Ember.run(router, 'transitionTo', { queryParams: { foo: [2,3] } });\n equal(router.get('location.path'), \"/?foo=%5B2%2C3%5D\", \"shorthand supported\");\n Ember.run(router, 'transitionTo', { queryParams: { 'index:foo': [4,5] } });\n equal(router.get('location.path'), \"/?foo=%5B4%2C5%5D\", \"longform supported\");\n Ember.run(router, 'transitionTo', { queryParams: { foo: [] } });\n equal(router.get('location.path'), \"/?foo=%5B%5D\", \"longform supported\");\n });\n\n test(\"Url with array query param sets controller property to array\", function() {\n App.IndexController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: ''\n });\n\n startingURL = \"/?foo[]=1&foo[]=2&foo[]=3\";\n bootApplication();\n\n var controller = container.lookup('controller:index');\n deepEqual(controller.get('foo'), [\"1\",\"2\",\"3\"]);\n });\n\n test(\"Array query params can be pushed/popped\", function() {\n Router.map(function() {\n this.route(\"home\", { path: '/' });\n });\n\n App.HomeController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: Ember.A([])\n });\n\n bootApplication();\n\n equal(router.get('location.path'), \"\");\n\n var controller = container.lookup('controller:home');\n\n Ember.run(controller.foo, 'pushObject', 1);\n equal(router.get('location.path'), \"/?foo=%5B1%5D\");\n Ember.run(controller.foo, 'pushObject', 2);\n equal(router.get('location.path'), \"/?foo=%5B1%2C2%5D\");\n Ember.run(controller.foo, 'popObject');\n equal(router.get('location.path'), \"/?foo=%5B1%5D\");\n Ember.run(controller.foo, 'unshiftObject', 'lol');\n equal(router.get('location.path'), \"/?foo=%5B%22lol%22%2C1%5D\");\n });\n\n test(\"Overwriting with array with same content shouldn't refire update\", function() {\n expect(3);\n var modelCount = 0;\n\n Router.map(function() {\n this.route(\"home\", { path: '/' });\n });\n\n App.HomeRoute = Ember.Route.extend({\n model: function() {\n modelCount++;\n }\n });\n\n App.HomeController = Ember.Controller.extend({\n queryParams: ['foo'],\n foo: Ember.A([1])\n });\n\n bootApplication();\n\n equal(modelCount, 1);\n var controller = container.lookup('controller:home');\n Ember.run(controller, 'set', Ember.A([1]));\n equal(modelCount, 1);\n equal(router.get('location.path'), \"\");\n });\n\n test(\"Defaulting to params hash as the model should not result in that params object being watched\", function() {\n expect(1);\n\n Router.map(function() {\n this.route('other');\n });\n\n // This causes the params hash, which is returned as a route's\n // model if no other model could be resolved given the provided\n // params (and no custom model hook was defined), to be watched,\n // unless we return a copy of the params hash.\n App.ApplicationController = Ember.ObjectController.extend({\n queryParams: ['woot']\n });\n\n App.OtherRoute = Ember.Route.extend({\n model: function(p, trans) {\n var m = Ember.meta(trans.params.application);\n ok(!m.watching.woot, \"A meta object isn't constructed for this params POJO\");\n }\n });\n\n bootApplication();\n\n Ember.run(router, 'transitionTo', 'other');\n });\n}\n\n})();\n//@ sourceURL=ember/~tests/routing/query_params_test");minispade.register('ember/~tests/routing/substates_test', "(function() {var Router, App, AppView, templates, router, container, counter;\nvar get = Ember.get, set = Ember.set, compile = Ember.Handlebars.compile;\n\nfunction step(expectedValue, description) {\n equal(counter, expectedValue, \"Step \" + expectedValue + \": \" + description);\n counter++;\n}\n\nfunction bootApplication(startingURL) {\n\n for (var name in templates) {\n Ember.TEMPLATES[name] = compile(templates[name]);\n }\n\n if (startingURL) {\n Ember.NoneLocation.reopen({\n path: startingURL\n });\n }\n\n startingURL = startingURL || '';\n router = container.lookup('router:main');\n Ember.run(App, 'advanceReadiness');\n}\n\nfunction handleURL(path) {\n return Ember.run(function() {\n return router.handleURL(path).then(function(value) {\n ok(true, 'url: `' + path + '` was handled');\n return value;\n }, function(reason) {\n ok(false, 'failed to visit:`' + path + '` reason: `' + QUnit.jsDump.parse(reason));\n throw reason;\n });\n });\n}\n\nmodule(\"Loading/Error Substates\", {\n setup: function() {\n counter = 1;\n\n Ember.run(function() {\n App = Ember.Application.create({\n name: \"App\",\n rootElement: '#qunit-fixture'\n });\n\n App.deferReadiness();\n\n App.Router.reopen({\n location: 'none'\n });\n\n Router = App.Router;\n\n container = App.__container__;\n\n templates = {\n application: '
    {{outlet}}
    ',\n index: 'INDEX',\n loading: 'LOADING',\n bro: 'BRO',\n sis: 'SIS'\n };\n });\n },\n\n teardown: function() {\n Ember.run(function() {\n App.destroy();\n App = null;\n\n Ember.TEMPLATES = {};\n });\n\n Ember.NoneLocation.reopen({\n path: ''\n });\n }\n});\n\ntest(\"Slow promise from a child route of application enters nested loading state\", function() {\n\n var broModel = {}, broDeferred = Ember.RSVP.defer();\n\n Router.map(function() {\n this.route('bro');\n });\n\n App.ApplicationRoute = Ember.Route.extend({\n setupController: function() {\n step(2, \"ApplicationRoute#setup\");\n }\n });\n\n App.BroRoute = Ember.Route.extend({\n model: function() {\n step(1, \"BroRoute#model\");\n return broDeferred.promise;\n }\n });\n\n bootApplication('/bro');\n\n equal(Ember.$('#app', '#qunit-fixture').text(), \"LOADING\", \"The Loading template is nested in application template's outlet\");\n\n Ember.run(broDeferred, 'resolve', broModel);\n\n equal(Ember.$('#app', '#qunit-fixture').text(), \"BRO\", \"bro template has loaded and replaced loading template\");\n});\n\ntest(\"Slow promises waterfall on startup\", function() {\n\n expect(7);\n\n var grandmaDeferred = Ember.RSVP.defer(),\n sallyDeferred = Ember.RSVP.defer();\n\n Router.map(function() {\n this.resource('grandma', function() {\n this.resource('mom', function() {\n this.route('sally');\n });\n });\n });\n\n templates.grandma = \"GRANDMA {{outlet}}\";\n templates.mom = \"MOM {{outlet}}\";\n templates['mom/loading'] = \"MOMLOADING\";\n templates['mom/sally'] = \"SALLY\";\n\n App.GrandmaRoute = Ember.Route.extend({\n model: function() {\n step(1, \"GrandmaRoute#model\");\n return grandmaDeferred.promise;\n }\n });\n\n App.MomRoute = Ember.Route.extend({\n model: function() {\n step(2, \"Mom#model\");\n return {};\n }\n });\n\n App.MomSallyRoute = Ember.Route.extend({\n model: function() {\n step(3, \"SallyRoute#model\");\n return sallyDeferred.promise;\n },\n setupController: function() {\n step(4, \"SallyRoute#setupController\");\n }\n });\n\n bootApplication('/grandma/mom/sally');\n\n equal(Ember.$('#app', '#qunit-fixture').text(), \"LOADING\", \"The Loading template is nested in application template's outlet\");\n\n Ember.run(grandmaDeferred, 'resolve', {});\n equal(Ember.$('#app', '#qunit-fixture').text(), \"GRANDMA MOM MOMLOADING\", \"Mom's child loading route is displayed due to sally's slow promise\");\n\n Ember.run(sallyDeferred, 'resolve', {});\n equal(Ember.$('#app', '#qunit-fixture').text(), \"GRANDMA MOM SALLY\", \"Sally template displayed\");\n});\n\ntest(\"ApplicationRoute#currentPath reflects loading state path\", function() {\n\n expect(4);\n\n var momDeferred = Ember.RSVP.defer();\n\n Router.map(function() {\n this.resource('grandma', function() {\n this.route('mom');\n });\n });\n\n templates.grandma = \"GRANDMA {{outlet}}\";\n templates['grandma/loading'] = \"GRANDMALOADING\";\n templates['grandma/mom'] = \"MOM\";\n\n App.GrandmaMomRoute = Ember.Route.extend({\n model: function() {\n return momDeferred.promise;\n }\n });\n\n bootApplication('/grandma/mom');\n\n equal(Ember.$('#app', '#qunit-fixture').text(), \"GRANDMA GRANDMALOADING\");\n\n var appController = container.lookup('controller:application');\n equal(appController.get('currentPath'), \"grandma.loading\", \"currentPath reflects loading state\");\n\n Ember.run(momDeferred, 'resolve', {});\n equal(Ember.$('#app', '#qunit-fixture').text(), \"GRANDMA MOM\");\n equal(appController.get('currentPath'), \"grandma.mom\", \"currentPath reflects final state\");\n});\n\ntest(\"Slow promises returned from ApplicationRoute#model don't enter LoadingRoute\", function() {\n\n expect(2);\n\n var appDeferred = Ember.RSVP.defer();\n\n App.ApplicationRoute = Ember.Route.extend({\n model: function() {\n return appDeferred.promise;\n }\n });\n\n App.LoadingRoute = Ember.Route.extend({\n setupController: function() {\n ok(false, \"shouldn't get here\");\n }\n });\n\n bootApplication();\n\n equal(Ember.$('#app', '#qunit-fixture').text(), \"\", \"nothing has been rendered yet\");\n\n Ember.run(appDeferred, 'resolve', {});\n equal(Ember.$('#app', '#qunit-fixture').text(), \"INDEX\");\n});\n\ntest(\"Don't enter loading route unless either route or template defined\", function() {\n\n delete templates.loading;\n\n expect(2);\n\n var indexDeferred = Ember.RSVP.defer();\n\n App.ApplicationController = Ember.Controller.extend();\n\n App.IndexRoute = Ember.Route.extend({\n model: function() {\n return indexDeferred.promise;\n }\n });\n\n bootApplication();\n\n var appController = container.lookup('controller:application');\n ok(appController.get('currentPath') !== \"loading\", \"loading state not entered\");\n\n Ember.run(indexDeferred, 'resolve', {});\n equal(Ember.$('#app', '#qunit-fixture').text(), \"INDEX\");\n});\n\ntest(\"Enter loading route if only LoadingRoute defined\", function() {\n\n delete templates.loading;\n\n expect(4);\n\n var indexDeferred = Ember.RSVP.defer();\n\n App.IndexRoute = Ember.Route.extend({\n model: function() {\n step(1, \"IndexRoute#model\");\n return indexDeferred.promise;\n }\n });\n\n App.LoadingRoute = Ember.Route.extend({\n setupController: function() {\n step(2, \"LoadingRoute#setupController\");\n }\n });\n\n bootApplication();\n\n var appController = container.lookup('controller:application');\n equal(appController.get('currentPath'), \"loading\", \"loading state entered\");\n\n Ember.run(indexDeferred, 'resolve', {});\n equal(Ember.$('#app', '#qunit-fixture').text(), \"INDEX\");\n});\n\ntest(\"Enter child loading state of pivot route\", function() {\n\n expect(4);\n\n var deferred = Ember.RSVP.defer();\n\n Router.map(function() {\n this.resource('grandma', function() {\n this.resource('mom', function() {\n this.route('sally');\n });\n this.route('smells');\n });\n });\n\n templates['grandma/loading'] = \"GMONEYLOADING\";\n\n App.ApplicationController = Ember.Controller.extend();\n\n App.MomSallyRoute = Ember.Route.extend({\n setupController: function() {\n step(1, \"SallyRoute#setupController\");\n }\n });\n\n App.GrandmaSmellsRoute = Ember.Route.extend({\n model: function() {\n return deferred.promise;\n }\n });\n\n bootApplication('/grandma/mom/sally');\n\n var appController = container.lookup('controller:application');\n equal(appController.get('currentPath'), \"grandma.mom.sally\", \"Initial route fully loaded\");\n\n Ember.run(router, 'transitionTo', 'grandma.smells');\n equal(appController.get('currentPath'), \"grandma.loading\", \"in pivot route's child loading state\");\n\n Ember.run(deferred, 'resolve', {});\n\n equal(appController.get('currentPath'), \"grandma.smells\", \"Finished transition\");\n});\n\ntest(\"Loading actions bubble to root, but don't enter substates above pivot\", function() {\n\n expect(6);\n\n delete templates.loading;\n\n var sallyDeferred = Ember.RSVP.defer(),\n smellsDeferred = Ember.RSVP.defer();\n\n var shouldBubbleToApplication = true;\n\n Router.map(function() {\n this.resource('grandma', function() {\n this.resource('mom', function() {\n this.route('sally');\n });\n this.route('smells');\n });\n });\n\n App.ApplicationController = Ember.Controller.extend();\n\n App.ApplicationRoute = Ember.Route.extend({\n actions: {\n loading: function(transition, route) {\n ok(true, \"loading action received on ApplicationRoute\");\n }\n }\n });\n\n App.MomSallyRoute = Ember.Route.extend({\n model: function() {\n return sallyDeferred.promise;\n }\n });\n\n App.GrandmaSmellsRoute = Ember.Route.extend({\n model: function() {\n return smellsDeferred.promise;\n }\n });\n\n bootApplication('/grandma/mom/sally');\n\n var appController = container.lookup('controller:application');\n ok(!appController.get('currentPath'), \"Initial route fully loaded\");\n Ember.run(sallyDeferred, 'resolve', {});\n\n equal(appController.get('currentPath'), \"grandma.mom.sally\", \"transition completed\");\n\n Ember.run(router, 'transitionTo', 'grandma.smells');\n equal(appController.get('currentPath'), \"grandma.mom.sally\", \"still in initial state because the only loading state is above the pivot route\");\n\n Ember.run(smellsDeferred, 'resolve', {});\n\n equal(appController.get('currentPath'), \"grandma.smells\", \"Finished transition\");\n});\n\ntest(\"Default error event moves into nested route\", function() {\n\n expect(5);\n\n templates['grandma'] = \"GRANDMA {{outlet}}\";\n templates['grandma/error'] = \"ERROR: {{msg}}\";\n\n Router.map(function() {\n this.resource('grandma', function() {\n this.resource('mom', function() {\n this.route('sally');\n });\n });\n });\n\n App.ApplicationController = Ember.Controller.extend();\n\n App.MomSallyRoute = Ember.Route.extend({\n model: function() {\n step(1, \"MomSallyRoute#model\");\n\n return Ember.RSVP.reject({\n msg: \"did it broke?\"\n });\n },\n actions: {\n error: function() {\n step(2, \"MomSallyRoute#actions.error\");\n return true;\n }\n }\n });\n\n bootApplication('/grandma/mom/sally');\n\n step(3, \"App finished booting\");\n\n equal(Ember.$('#app', '#qunit-fixture').text(), \"GRANDMA ERROR: did it broke?\", \"error bubbles\");\n\n var appController = container.lookup('controller:application');\n equal(appController.get('currentPath'), 'grandma.error', \"Initial route fully loaded\");\n});\n\nif (Ember.FEATURES.isEnabled(\"ember-routing-named-substates\")) {\n\n test(\"Slow promises returned from ApplicationRoute#model enter ApplicationLoadingRoute if present\", function() {\n\n expect(2);\n\n var appDeferred = Ember.RSVP.defer();\n\n App.ApplicationRoute = Ember.Route.extend({\n model: function() {\n return appDeferred.promise;\n }\n });\n\n var loadingRouteEntered = false;\n App.ApplicationLoadingRoute = Ember.Route.extend({\n setupController: function() {\n loadingRouteEntered = true;\n }\n });\n\n bootApplication();\n\n ok(loadingRouteEntered, \"ApplicationLoadingRoute was entered\");\n\n Ember.run(appDeferred, 'resolve', {});\n equal(Ember.$('#app', '#qunit-fixture').text(), \"INDEX\");\n });\n\n test(\"Slow promises returned from ApplicationRoute#model enter application_loading if template present\", function() {\n\n expect(3);\n\n templates['application_loading'] = 'TOPLEVEL LOADING';\n\n var appDeferred = Ember.RSVP.defer();\n\n App.ApplicationRoute = Ember.Route.extend({\n model: function() {\n return appDeferred.promise;\n }\n });\n\n var loadingRouteEntered = false;\n App.ApplicationLoadingRoute = Ember.Route.extend({\n setupController: function() {\n loadingRouteEntered = true;\n }\n });\n\n App.ApplicationLoadingView = Ember.View.extend({\n elementId: 'toplevel-loading'\n });\n\n bootApplication();\n\n equal(Ember.$('#qunit-fixture > #toplevel-loading').text(), \"TOPLEVEL LOADING\");\n\n Ember.run(appDeferred, 'resolve', {});\n\n equal(Ember.$('#toplevel-loading', '#qunit-fixture').length, 0, 'top-level loading View has been entirely removed from DOM');\n equal(Ember.$('#app', '#qunit-fixture').text(), \"INDEX\");\n });\n\n test(\"Default error event moves into nested route, prioritizing more specifically named error route\", function() {\n\n expect(5);\n\n templates['grandma'] = \"GRANDMA {{outlet}}\";\n templates['grandma/error'] = \"ERROR: {{msg}}\";\n templates['grandma/mom_error'] = \"MOM ERROR: {{msg}}\";\n\n Router.map(function() {\n this.resource('grandma', function() {\n this.resource('mom', function() {\n this.route('sally');\n });\n });\n });\n\n App.ApplicationController = Ember.Controller.extend();\n\n App.MomSallyRoute = Ember.Route.extend({\n model: function() {\n step(1, \"MomSallyRoute#model\");\n\n return Ember.RSVP.reject({\n msg: \"did it broke?\"\n });\n },\n actions: {\n error: function() {\n step(2, \"MomSallyRoute#actions.error\");\n return true;\n }\n }\n });\n\n bootApplication('/grandma/mom/sally');\n\n step(3, \"App finished booting\");\n\n equal(Ember.$('#app', '#qunit-fixture').text(), \"GRANDMA MOM ERROR: did it broke?\", \"the more specifically-named mom error substate was entered over the other error route\");\n\n var appController = container.lookup('controller:application');\n equal(appController.get('currentPath'), 'grandma.mom_error', \"Initial route fully loaded\");\n });\n\n test(\"Prioritized substate entry works with preserved-namespace nested resources\", function() {\n\n expect(2);\n\n templates['foo/bar_loading'] = \"FOOBAR LOADING\";\n templates['foo/bar/index'] = \"YAY\";\n\n Router.map(function() {\n this.resource('foo', function() {\n this.resource('foo.bar', { path: '/bar' }, function() {\n });\n });\n });\n\n App.ApplicationController = Ember.Controller.extend();\n\n var deferred = Ember.RSVP.defer();\n App.FooBarRoute = Ember.Route.extend({\n model: function() {\n return deferred.promise;\n }\n });\n\n bootApplication('/foo/bar');\n\n equal(Ember.$('#app', '#qunit-fixture').text(), \"FOOBAR LOADING\", \"foo.bar_loading was entered (as opposed to something like foo/foo/bar_loading)\");\n\n Ember.run(deferred, 'resolve');\n\n equal(Ember.$('#app', '#qunit-fixture').text(), \"YAY\");\n });\n\n test(\"Rejected promises returned from ApplicationRoute transition into top-level application_error\", function() {\n\n expect(2);\n\n templates['application_error'] = '

    TOPLEVEL ERROR: {{msg}}

    ';\n\n var reject = true;\n App.ApplicationRoute = Ember.Route.extend({\n model: function() {\n if (reject) {\n return Ember.RSVP.reject({ msg: \"BAD NEWS BEARS\" });\n } else {\n return {};\n }\n }\n });\n\n bootApplication();\n\n equal(Ember.$('#toplevel-error', '#qunit-fixture').text(), \"TOPLEVEL ERROR: BAD NEWS BEARS\");\n\n reject = false;\n Ember.run(router, 'transitionTo', 'index');\n\n equal(Ember.$('#app', '#qunit-fixture').text(), \"INDEX\");\n });\n}\n\n})();\n//@ sourceURL=ember/~tests/routing/substates_test");minispade.register('ember/~tests/states_removal_test', "(function() {/*globals EmberDev */\n\nmodule(\"ember-states removal\");\n\ntest(\"errors occur when attempting to use Ember.StateManager or Ember.State\", function() {\n if (EmberDev && EmberDev.runningProdBuild){\n ok(true, 'Ember.State & Ember.StateManager are not added to production builds');\n return;\n }\n\n raises(function() {\n Ember.StateManager.extend();\n }, /has been moved into a plugin/);\n\n raises(function() {\n Ember.State.extend();\n }, /has been moved into a plugin/);\n\n raises(function() {\n Ember.StateManager.create();\n }, /has been moved into a plugin/);\n\n raises(function() {\n Ember.State.create();\n }, /has been moved into a plugin/);\n});\n\n})();\n//@ sourceURL=ember/~tests/states_removal_test");