var JSHINTRC = { "predef": [ "define", "console", "Ember", "DS", "Handlebars", "Metamorph", "RSVP", "require", "requireModule", "equal", "notEqual", "notStrictEqual", "test", "asyncTest", "testBoth", "testWithDefault", "raises", "throws", "deepEqual", "start", "stop", "ok", "strictEqual", "module", "expect", "minispade" ], "node" : false, "browser" : true, "boss" : true, "curly": false, "debug": false, "devel": false, "eqeqeq": true, "evil": true, "forin": false, "immed": false, "laxbreak": false, "newcap": true, "noarg": true, "noempty": false, "nonew": false, "nomen": false, "onevar": false, "plusplus": false, "regexp": false, "undef": true, "sub": true, "strict": false, "white": false, "eqnull": true } ; minispade.register('container/~tests/container_test', "(function() {var passedOptions;\nvar Container = requireModule('container');\n\nvar setProperties = function(object, properties) {\n for (var key in properties) {\n if (properties.hasOwnProperty(key)) {\n object[key] = properties[key];\n }\n }\n};\n\nmodule(\"Container\");\n\nfunction factory() {\n var Klass = function(options) {\n setProperties(this, options);\n };\n\n Klass.prototype.destroy = function() {\n this.isDestroyed = true;\n };\n\n Klass.create = function(options) {\n passedOptions = options;\n return new Klass(options);\n };\n\n return Klass;\n}\n\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"A factory type 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.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\ntest(\"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 deepEqual(passedOptions, {\n store: store,\n container: container,\n _debugContainerKey: 'controller:post'\n });\n});\n\ntest(\"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\ntest(\"A non-singleton factory 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\ntest(\"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\ntest(\"A failed lookup returns undefined\", function() {\n var container = new Container();\n\n equal(container.lookup(\"doesnot:exist\"), undefined);\n});\n\ntest(\"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\ntest(\"The container can take a hook to resolve factories lazily\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.resolve = 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\ntest(\"The container respect the resolver hook for `has`\", function() {\n var container = new Container();\n var PostController = factory();\n\n container.resolve = 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\ntest(\"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.resolve = 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})();\n//@ sourceURL=container/~tests/container_test");minispade.register('container/~tests/sub_container_test', "(function() {var passedOptions;\nvar Container = requireModule('container');\n\nvar setProperties = function(object, properties) {\n for (var key in properties) {\n if (properties.hasOwnProperty(key)) {\n object[key] = properties[key];\n }\n }\n};\n\nvar container;\n\nmodule(\"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\nfunction factory() {\n var Klass = function(options) {\n setProperties(this, options);\n };\n\n Klass.prototype.destroy = function() {\n this.isDestroyed = true;\n };\n\n Klass.create = function(options) {\n passedOptions = options;\n return new Klass(options);\n };\n\n return Klass;\n}\n\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"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/sub_container_test");minispade.register('ember-application/~tests/system/application_test', "(function() {var view;\nvar application;\nvar set = Ember.set, get = Ember.get;\nvar trim = Ember.$.trim;\n\nmodule(\"Ember.Application\", {\n setup: function() {\n Ember.$(\"#qunit-fixture\").html(\"
Bye bros
\");\n }\n });\n\n metamorphView = Ember._MetamorphView.create({\n render: function(buffer) {\n buffer.push(\"BYE
\")\n }));\n });\n\n // IE likes to add newlines\n equal(view.$().text().replace(/\\s+/g, ''), 'HIBYE');\n});\n\ntest(\"outlet should allow controllers to fill in slots in prerender state\", function() {\n var controller = Ember.Object.create({\n view: Ember.View.create({\n template: compile(\"BYE
\")\n })\n });\n\n var template = \"BYE
\")\n }));\n });\n\n // IE likes to add newlines\n equal(view.$().text().replace(/\\s+/g, ''), 'HIBYE');\n});\n\ntest(\"outlet should support an optional name\", function() {\n var controller = Ember.Object.create();\n\n var template = \"BYE
\")\n }));\n });\n\n // IE likes to add newlines\n equal(view.$().text().replace(/\\s+/g, ''), 'HIBYE');\n});\n\n})();\n//@ sourceURL=ember-old-router/~tests/helpers/outlet_test");minispade.register('ember-old-router/~tests/location_test', "(function() {var locationObject;\n\nmodule(\"Ember.Location, hash implementation\", {\n setup: function() {\n locationObject = Ember.Location.create({\n implementation: 'hash'\n });\n locationObject.setURL(\"/\");\n\n // make sure the onhashchange event fires\n stop();\n // There are weird issues in FF 3.6 if we pass start itself as the parameter\n setTimeout(function(){ start(); }, 1);\n },\n\n teardown: function() {\n window.location.hash = \"\";\n Ember.run(function(){\n locationObject.destroy();\n });\n }\n});\n\ntest(\"it is possible to get the current URL\", function() {\n equal(locationObject.getURL(), \"/\", \"the initial URL is '/'\");\n equal(window.location.hash, \"#/\", \"the initial hash is '#/'\");\n});\n\ntest(\"it is possible to set the current URL\", function() {\n locationObject.setURL(\"/foo\");\n equal(locationObject.getURL(), \"/foo\", \"the updated URL is '/'\");\n equal(window.location.hash, \"#/foo\", \"the updated hash is '#/foo'\");\n});\n\ntest(\"if the hash changes, the onUpdateURL callback is invoked\", function() {\n stop();\n\n locationObject.onUpdateURL(function(url) {\n start();\n\n equal(url, '/foo/bar', \"the callback is invoked with the URL\");\n });\n\n window.location.hash = \"#/foo/bar\";\n});\n\ntest(\"if the URL is set, it doesn't trigger the hashchange event\", function() {\n stop();\n\n var count = 0;\n\n setTimeout(function() {\n start();\n equal(count, 0, \"The update callback was not called\");\n }, 100);\n\n locationObject.onUpdateURL(function(url) {\n count++;\n });\n\n locationObject.setURL('/avoid/triggering');\n});\n\nmodule(\"Ember.Location, history implementation\", {\n setup: function() {\n\n var setHistory = function(obj, path) {\n obj.set('history', { state: { path: path } });\n };\n\n Ember.HistoryLocation.reopen({\n initState: function() {\n setHistory(this, window.location.pathname);\n },\n\n replaceState: function(path) {\n setHistory(this, path);\n },\n\n pushState: function(path) {\n setHistory(this, path);\n }\n });\n\n locationObject = Ember.Location.create({\n implementation: 'history'\n });\n\n stop();\n setTimeout(start, 1);\n },\n\n teardown: function() {\n Ember.run(function() {\n locationObject.destroy();\n });\n }\n});\n\ntest(\"it sets the initial state\", function() {\n equal(locationObject.getState().path, window.location.pathname, \"the initial state is set\");\n});\n\ntest(\"it is possible to get the current URL\", function() {\n equal(locationObject.getURL(), window.location.pathname, \"current URL is set\");\n});\n\ntest(\"it is possible to set the current URL\", function() {\n var setPath;\n\n locationObject.pushState = function(path) {\n setPath = path;\n };\n\n locationObject.setURL(\"/foo\");\n equal(setPath, \"/foo\", \"the updated URL is '/foo'\");\n});\n\ntest(\"if the URL is set, it doesn't trigger the popstate event\", function() {\n expect(1);\n\n stop();\n var count = 0;\n locationObject.pushState = function(data, title, path) {};\n\n setTimeout(function() {\n start();\n equal(count, 0, \"The update callback was not called\");\n }, 100);\n\n locationObject.onUpdateURL(function(url) {\n count++;\n });\n\n locationObject.setURL('/avoid/triggering');\n});\n\ntest(\"if history is used, it triggers the popstate event\", function() {\n expect(1);\n\n stop();\n var count = 0;\n\n setTimeout(function() {\n start();\n equal(count, 1, \"The update callback was not called\");\n }, 300);\n\n locationObject.onUpdateURL(function(url) {\n count++;\n });\n\n window.history.back();\n});\n\ntest(\"doesn't push a state if path has not changed\", function() {\n expect(1);\n stop();\n\n var count = 0;\n locationObject.pushState = function() {\n count++;\n };\n\n setTimeout(function() {\n start();\n equal(count, 0, \"pushState should not have been called\");\n }, 100);\n\n locationObject.setURL(window.location.pathname);\n});\n\ntest(\"it calls pushState if state.path is different than given path\", function() {\n expect(1);\n stop();\n\n var count = 0;\n\n locationObject.pushState = function() {\n count++;\n };\n\n setTimeout(function() {\n start();\n equal(count, 1, \"pushState should have been called\");\n }, 100);\n\n locationObject.setURL('/test');\n});\n\ntest(\"it handles an empty path as root\", function() {\n equal(locationObject.formatURL(''), '/', \"The formatted url is '/'\");\n});\n\ntest(\"formatURL properly appends to rootURL\", function() {\n locationObject.set('rootURL', '/test');\n equal(locationObject.formatURL('/foo'), '/test/foo', \"The formatted url is '/test/foo'\");\n});\n\ntest(\"it prepends rootURL to path\", function() {\n var setPath;\n\n locationObject.pushState = function(path) {\n setPath = path;\n };\n\n locationObject.set('rootURL', '/test');\n locationObject.setURL(\"/foo\");\n\n equal(setPath, '/test/foo', \"The updated url is '/test/foot'\");\n});\n\n})();\n//@ sourceURL=ember-old-router/~tests/location_test");minispade.register('ember-old-router/~tests/render_test', "(function() {var router;\n\nmodule(\"Rendering in the router\", {\n teardown: function() {\n Ember.run(function() {\n var view = router.get('applicationController.view') ||\n router.get('appController.view');\n if (view) { view.destroy(); }\n router.destroy();\n });\n }\n});\n\ntest(\"By default, `render` renders into the application's outlet\", function() {\n expect(1);\n\n router = Ember.Router.extend({\n applicationController: Ember.Controller.extend({\n viewDidChange: Ember.observer(function() {\n equal(this.get('view.templateName'), 'posts');\n }, 'view')\n }).create(),\n\n namespace: {},\n\n root: Ember.Route.extend({\n template: 'application',\n\n posts: Ember.Route.extend({\n template: 'posts'\n })\n })\n }).create();\n\n var postsRoute = router.get('states.root.states.posts');\n\n Ember.run(function() {\n postsRoute.render();\n });\n});\n\ntest(\"If a view class for a given template exists, use it and update it with the relevant templateName\", function() {\n expect(2);\n\n var PostView = Ember.Object.extend();\n\n router = Ember.Router.extend({\n applicationController: Ember.Controller.extend({\n viewDidChange: Ember.observer(function() {\n ok(this.get('view') instanceof PostView, \"The view is an instance of PostView\");\n equal(this.get('view.templateName'), 'post');\n }, 'view')\n }).create(),\n\n namespace: {\n PostView: PostView\n },\n\n root: Ember.Route.extend({\n template: 'application',\n\n posts: Ember.Route.extend({\n template: 'post'\n })\n })\n }).create();\n\n var postsRoute = router.get('states.root.states.posts');\n\n Ember.run(function() {\n postsRoute.render();\n });\n});\n\ntest(\"The default template to render into is `application`\", function() {\n expect(1);\n\n router = Ember.Router.extend({\n applicationController: Ember.Controller.extend({\n viewDidChange: Ember.observer(function() {\n equal(this.get('view.templateName'), 'posts');\n }, 'view')\n }).create(),\n\n namespace: {},\n\n root: Ember.Route.extend({\n posts: Ember.Route.extend({\n template: 'posts'\n })\n })\n }).create();\n\n var postsRoute = router.get('states.root.states.posts');\n\n Ember.run(function() {\n postsRoute.render();\n });\n});\n\ntest(\"You can override the template to render and the template to render into\", function() {\n expect(1);\n\n router = Ember.Router.extend({\n appController: Ember.Controller.extend({\n viewDidChange: Ember.observer(function() {\n equal(this.get('view.templateName'), 'other');\n }, 'view')\n }).create(),\n\n namespace: {},\n\n root: Ember.Route.extend({\n posts: Ember.Route.extend({\n template: 'posts'\n })\n })\n }).create();\n\n var postsRoute = router.get('states.root.states.posts');\n\n Ember.run(function() {\n postsRoute.render({ into: 'app', template: 'other' });\n });\n});\n\ntest(\"By default, the route's class name is used to infer its template name\", function() {\n var PostsRoute = Ember.Route.extend();\n PostsRoute.toString = function() { return \"App.PostsRoute\"; };\n\n var ApplicationRoute = Ember.Route.extend({\n posts: PostsRoute\n });\n ApplicationRoute.toString = function() { return \"App.ApplicationRoute\"; };\n\n router = Ember.Router.extend({\n applicationController: Ember.Controller.extend({\n viewDidChange: Ember.observer(function() {\n equal(this.get('view.templateName'), 'posts');\n }, 'view')\n }).create(),\n\n namespace: {},\n\n root: Ember.Route.extend({\n posts: PostsRoute\n })\n }).create();\n\n Ember.run(function() {\n router.get('states.root.states.posts').render();\n });\n});\n\n})();\n//@ sourceURL=ember-old-router/~tests/render_test");minispade.register('ember-old-router/~tests/routable_test', "(function() {var originalLookup = Ember.lookup, lookup, TestApp;\n\nmodule(\"Ember.Routable\");\n\ntest(\"it should have its updateRoute method called when it is entered\", function() {\n var locationStub = { };\n\n expect(2);\n\n var state = Ember.Route.create({\n route: 'foo',\n updateRoute: function(manager, location) {\n ok(true, \"updateRoute was called\");\n strictEqual(location, locationStub);\n }\n });\n\n var router = Ember.Router.create({\n location: locationStub,\n root: Ember.Route.create({\n ready: function(manager) {\n manager.transitionTo('initial');\n },\n\n initial: state\n })\n });\n\n router.send('ready');\n});\n\ntest(\"a RouteMatcher matches routes\", function() {\n var match;\n\n var matcher = Ember._RouteMatcher.create({\n route: \"foo\"\n });\n\n match = matcher.match('foo');\n equal(match.remaining, \"\");\n equal(match.hash, null);\n\n match = matcher.match('foo/bar');\n equal(match.remaining, \"/bar\");\n equal(match.hash, null);\n\n match = matcher.match('bar');\n equal(match, undefined);\n});\n\ntest(\"a RouteMatcher matches routes with dynamic segments\", function() {\n var match;\n\n var matcher = Ember._RouteMatcher.create({\n route: \"foo/:id/:name/:ok_tom\"\n });\n\n match = matcher.match('foo/bar/baz/sigh');\n equal(match.remaining, \"\");\n deepEqual(match.hash, {\"id\": \"bar\", \"name\": \"baz\", \"ok_tom\": \"sigh\"});\n\n match = matcher.match('foo/bar/baz/common/bro');\n equal(match.remaining, \"/bro\");\n deepEqual(match.hash, {\"id\": \"bar\", \"name\": \"baz\", \"ok_tom\": \"common\"});\n\n match = matcher.match('foo/bar');\n equal(match, undefined);\n});\n\ntest(\"a RouteMatcher matches routes with dynamic segments (the last being globbed)\", function() {\n var match;\n\n var matcher = Ember._RouteMatcher.create({\n route: \"foo/:id/:name/*ok_tom\"\n });\n\n match = matcher.match('foo/bar/baz/common/bro');\n equal(match.remaining, \"\");\n deepEqual(match.hash, {\"id\": \"bar\", \"name\": \"baz\", \"ok_tom\": \"common/bro\"});\n\n match = matcher.match('foo/bar');\n equal(match, undefined);\n});\n\ntest(\"a RouteMatcher generates routes with dynamic segments\", function() {\n var url;\n\n var matcher = Ember._RouteMatcher.create({\n route: \"foo/:id/:first_name\"\n });\n\n url = matcher.generate({ id: 1, first_name: \"Yehuda\" });\n equal(url, \"foo/1/Yehuda\");\n});\n\ntest(\"a RouteMatcher generates routes with dynamic segments (with glob)\", function() {\n var url;\n\n var matcher = Ember._RouteMatcher.create({\n route: \"foo/:id/*first_name\"\n });\n\n url = matcher.generate({ id: 1, first_name: \"Yehuda/test\" });\n equal(url, \"foo/1/Yehuda/test\");\n});\n\ntest(\"route repeatedly descends into a nested hierarchy\", function() {\n var state = Ember.Route.create({\n fooChild: Ember.Route.create({\n route: 'foo',\n\n barChild: Ember.Route.create({\n route: 'bar',\n\n bazChild: Ember.Route.create({\n route: 'baz'\n })\n })\n })\n });\n\n var router = Ember.Router.create({\n location: 'none',\n root: state\n });\n\n router.route(\"/foo/bar/baz\");\n\n equal(router.get('currentState.path'), 'root.fooChild.barChild.bazChild');\n});\n\ntest(\"when you descend into a state, the route is set\", function() {\n var state = Ember.Route.create({\n ready: function(manager) {\n manager.transitionTo('fooChild.barChild.bazChild');\n },\n\n fooChild: Ember.Route.create({\n route: 'foo',\n\n barChild: Ember.Route.create({\n route: 'bar',\n\n bazChild: Ember.Route.create({\n route: 'baz'\n })\n })\n })\n });\n\n var count = 0;\n\n var router = Ember.Router.create({\n root: state,\n location: {\n setURL: function(url) {\n if (count === 0) {\n equal(url, '/foo/bar/baz', \"The current URL should be passed in\");\n count++;\n } else {\n ok(false, \"Should not get here\");\n }\n }\n }\n });\n\n router.send('ready');\n});\n\ntest(\"when you descend into a state, the route is set even when child states (not routes) are present\", function() {\n var state = Ember.Route.create({\n ready: function(manager) {\n manager.transitionTo('fooChild.barChild.bazChild');\n },\n\n fooChild: Ember.Route.create({\n route: 'foo',\n\n barChild: Ember.Route.create({\n route: 'bar',\n\n bazChild: Ember.Route.create({\n route: 'baz',\n\n basicState: Ember.State.create()\n })\n })\n })\n });\n\n var count = 0;\n\n var router = Ember.Router.create({\n root: state,\n location: {\n setURL: function(url) {\n if (count === 0) {\n equal(url, '/foo/bar/baz', \"The current URL should be passed in\");\n count++;\n } else {\n ok(false, \"Should not get here\");\n }\n }\n }\n });\n\n router.send('ready');\n});\n\nvar router;\nvar Post = {\n find: function(id) {\n return { isPerson: true, id: parseInt(id, 10) };\n }\n};\n\nvar setURL;\nvar locationMock = {\n setURL: function(url) {\n setURL = url;\n }\n};\n\nmodule(\"Routing Serialization and Deserialization\", {\n setup: function() {\n router = Ember.Router.create({\n location: locationMock,\n root: Ember.Route.create({\n ready: function(manager, post) {\n manager.transitionTo('post.show', { post: post });\n },\n\n showIndex: function(manager) {\n manager.transitionTo('post.index');\n },\n\n post: Ember.Route.create({\n route: '/posts',\n\n index: Ember.Route.create({\n route: '/',\n\n showPost: function(manager, post) {\n manager.transitionTo('post.show', { post: post });\n }\n }),\n\n show: Ember.Route.create({\n route: \"/:post_id\",\n\n connectOutlets: function(manager, context) {\n equal(context.post.id, 2, \"should be the same value regardless of entry point\");\n },\n\n deserialize: function(manager, params) {\n return { post: Post.find(params['post_id']) };\n },\n\n serialize: function(manager, hash) {\n return { post_id: hash.post.id };\n },\n\n showIndex: function(manager) {\n manager.transitionTo('index');\n }\n })\n })\n })\n });\n }\n});\n\ntest(\"should invoke the deserialize method on a state when it is entered via a URL\", function() {\n expect(1);\n\n router.route('/posts/2');\n});\n\ntest(\"should invoke the serialize method on a state when it is entered programmatically (initially deep)\", function() {\n expect(3);\n\n router.send('ready', Post.find(2));\n equal(setURL, '/posts/2', \"The post is serialized\");\n\n router.send('showIndex');\n equal(setURL, '/posts');\n});\n\ntest(\"should invoke the serialize method on a state when it is entered programmatically (initially shallow)\", function() {\n expect(3);\n\n router.send('showIndex');\n equal(setURL, '/posts', \"The post is serialized\");\n\n router.send('showPost', Post.find(2));\n equal(setURL, '/posts/2');\n});\n\nvar url, firstPost, firstUser;\n\nmodule(\"default serialize and deserialize with modelType\", {\n setup: function() {\n Ember.BOOTED = false;\n\n Ember.lookup = lookup = {};\n\n lookup.TestApp = TestApp = Ember.Namespace.create();\n TestApp.Post = Ember.Object.extend();\n TestApp.Post.find = function(id) {\n if (id === \"1\") { return firstPost; }\n };\n TestApp.Post.toString();\n\n TestApp.User = Ember.Object.extend();\n TestApp.User.find = function(id) {\n if (id === \"1\") { return firstUser; }\n };\n TestApp.User.toString();\n\n firstPost = TestApp.Post.create({ id: 1 });\n firstUser = TestApp.User.create({ id: 1 });\n\n router = Ember.Router.create({\n location: {\n setURL: function(passedURL) {\n url = passedURL;\n }\n },\n\n root: Ember.Route.extend({\n post: Ember.Route.extend({\n route: '/posts/:post_id',\n modelType: 'TestApp.Post',\n\n connectOutlets: function(router, post) {\n equal(post, firstPost, \"the post should have deserialized correctly\");\n }\n }),\n\n user: Ember.Route.extend({\n route: '/users/:user_id',\n modelType: TestApp.User,\n\n connectOutlets: function(router, user) {\n equal(user, firstUser, \"the post should have deserialized correctly\");\n }\n })\n })\n });\n\n Ember.BOOTED = true;\n },\n\n teardown: function() {\n Ember.lookup = originalLookup;\n }\n});\n\ntest(\"should use a specified String `modelType` in the default `serialize`\", function() {\n window.billy = true;\n router.transitionTo('post', firstPost);\n window.billy = false;\n equal(url, \"/posts/1\");\n});\n\ntest(\"should use a specified String `modelType` in the default `deserialize`\", function() {\n expect(1);\n\n router.route(\"/posts/1\");\n});\n\ntest(\"should use a specified class `modelType` in the default `serialize`\", function() {\n router.transitionTo('user', firstUser);\n equal(url, \"/users/1\");\n});\n\ntest(\"should use a specified class `modelType` in the default `deserialize`\", function() {\n expect(1);\n\n router.route(\"/users/1\");\n});\n\nvar postSuccessCallback, postFailureCallback,\n userSuccessCallback, userFailureCallback,\n connectedUser, connectedPost, connectedChild, connectedOther,\n isLoading, userLoaded;\n\nmodule(\"modelType with promise\", {\n setup: function() {\n Ember.BOOTED = false;\n Ember.lookup = lookup = {};\n lookup.TestApp = TestApp = Ember.Namespace.create();\n\n TestApp.User = Ember.Object.extend({\n then: function(success, failure) {\n userLoaded = true;\n userSuccessCallback = success;\n userFailureCallback = failure;\n }\n });\n TestApp.User.find = function(id) {\n if (id === \"1\") {\n return firstUser;\n }\n };\n TestApp.User.toString();\n\n TestApp.Post = Ember.Object.extend({\n then: function(success, failure) {\n postSuccessCallback = success;\n postFailureCallback = failure;\n }\n });\n TestApp.Post.find = function(id) {\n // Simulate dependency on user\n if (!userLoaded) { return; }\n if (id === \"1\") { return firstPost; }\n };\n TestApp.Post.toString();\n\n firstUser = TestApp.User.create({ id: 1 });\n firstPost = TestApp.Post.create({ id: 1 });\n\n router = Ember.Router.create({\n location: {\n setURL: function(passedURL) {\n url = passedURL;\n }\n },\n\n root: Ember.Route.extend({\n users: Ember.Route.extend({\n route: '/users',\n\n user: Ember.Route.extend({\n route: '/:user_id',\n modelType: 'TestApp.User',\n\n connectOutlets: function(router, obj) {\n connectedUser = obj;\n },\n\n posts: Ember.Route.extend({\n route: '/posts',\n\n post: Ember.Route.extend({\n route: '/:post_id',\n modelType: 'TestApp.Post',\n\n connectOutlets: function(router, obj) {\n connectedPost = obj;\n },\n\n show: Ember.Route.extend({\n route: '/',\n\n connectOutlets: function(router) {\n connectedChild = true;\n }\n })\n })\n })\n })\n }),\n\n other: Ember.Route.extend({\n route: '/other',\n\n connectOutlets: function() {\n connectedOther = true;\n }\n }),\n\n loading: Ember.State.extend({\n setup: function() {\n isLoading = true;\n },\n\n exit: function() {\n isLoading = false;\n }\n })\n })\n });\n },\n\n teardown: function() {\n postSuccessCallback = postFailureCallback = undefined;\n userSuccessCallback = userFailureCallback = undefined;\n connectedUser = connectedPost = connectedChild = connectedOther = undefined;\n isLoading = userLoaded = undefined;\n Ember.lookup = originalLookup;\n }\n});\n\ntest(\"should handle promise success\", function() {\n ok(!isLoading, 'precond - should not start loading');\n\n Ember.run(function() {\n router.route('/users/1/posts/1');\n });\n\n ok(!connectedUser, 'precond - should not connect user immediately');\n ok(!connectedPost, 'precond - should not connect post immediately');\n ok(!connectedChild, 'precond - should not connect child immediately');\n ok(isLoading, 'should be loading');\n\n Ember.run(function() {\n userSuccessCallback('loadedUser');\n });\n\n ok(!connectedUser, 'should not connect user until all promises are loaded');\n ok(!connectedPost, 'should not connect post until all promises are loaded');\n ok(!connectedChild, 'should not connect child until all promises are loaded');\n ok(isLoading, 'should still be loading');\n\n Ember.run(function() {\n postSuccessCallback('loadedPost');\n });\n\n equal(connectedUser, 'loadedUser', 'should connect user after success callback');\n equal(connectedPost, 'loadedPost', 'should connect post after success callback');\n ok(connectedChild, \"should connect child's outlets after success callback\");\n ok(!isLoading, 'should not be loading');\n});\n\ntest(\"should handle early promise failure\", function() {\n router.route('/users/1/posts/1');\n\n ok(userFailureCallback, 'precond - has failureCallback');\n\n raises(function() {\n userFailureCallback('failedUser');\n }, \"Unable to load record.\", \"should throw exception on failure\");\n\n ok(!connectedUser, 'should not connect user after early failure');\n ok(!connectedPost, 'should not connect post after early failure');\n ok(!connectedChild, 'should not connect child after early failure');\n});\n\ntest(\"should handle late promise failure\", function() {\n router.route('/users/1/posts/1');\n\n userSuccessCallback('loadedUser');\n\n ok(postFailureCallback, 'precond - has failureCallback');\n\n raises(function() {\n postFailureCallback('failedPost');\n }, \"Unable to load record.\", \"should throw exception on failure\");\n\n ok(!connectedUser, 'should not connect user after late failure');\n ok(!connectedPost, 'should not connect post after late failure');\n ok(!connectedChild, 'should not connect child after late failure');\n});\n\ntest(\"should stop promises if new route is targeted\", function() {\n router.route('/users/1/posts/1');\n\n userSuccessCallback('loadedUser');\n\n ok(!connectedOther, 'precond - has not yet connected other');\n\n Ember.run(function() {\n router.route('/other');\n });\n\n ok(connectedOther, 'should connect other');\n\n postSuccessCallback('loadedPost');\n\n ok(!connectedUser, 'should not connect user after reroute');\n ok(!connectedPost, 'should not connect post after reroute');\n ok(!connectedChild, 'should not connect child after reroute');\n});\n\ntest(\"should stop promises if transitionTo is called\", function() {\n router.route('/users/1/posts/1');\n\n userSuccessCallback('loadedUser');\n\n ok(!connectedOther, 'precond - has not yet connected other');\n\n Ember.run(function() {\n router.transitionTo('other');\n });\n\n ok(connectedOther, 'should connect other');\n\n postSuccessCallback('loadedPost');\n\n ok(!connectedUser, 'should not connect user after reroute');\n ok(!connectedPost, 'should not connect post after reroute');\n ok(!connectedChild, 'should not connect child after reroute');\n});\n\nmodule(\"default serialize and deserialize without modelType\", {\n setup: function() {\n Ember.lookup = lookup = {};\n lookup.TestApp = TestApp = Ember.Namespace.create();\n TestApp.Post = Ember.Object.extend();\n TestApp.Post.find = function(id) {\n if (id === \"1\") { return firstPost; }\n };\n\n firstPost = TestApp.Post.create({ id: 1 });\n\n router = Ember.Router.create({\n namespace: TestApp,\n\n location: {\n setURL: function(passedURL) {\n url = passedURL;\n }\n },\n\n root: Ember.Route.extend({\n post: Ember.Route.extend({\n route: '/posts/:post_id',\n\n connectOutlets: function(router, post) {\n equal(post, firstPost, \"the post should have deserialized correctly\");\n }\n })\n })\n });\n },\n\n teardown: function() {\n Ember.lookup = originalLookup;\n }\n});\n\n\n\ntest(\"should use a specified String `modelType` in the default `serialize`\", function() {\n router.transitionTo('post', firstPost);\n equal(url, \"/posts/1\");\n});\n\ntest(\"should use a specified String `modelType` in the default `deserialize`\", function() {\n expect(1);\n\n router.route(\"/posts/1\");\n});\n\nmodule(\"redirectsTo\");\n\ntest(\"if a leaf state has a redirectsTo, it automatically transitions into that state\", function() {\n var router = Ember.Router.create({\n location: 'none',\n root: Ember.Route.create({\n\n index: Ember.Route.create({\n route: '/',\n redirectsTo: 'someOtherState'\n }),\n\n someOtherState: Ember.Route.create({\n route: '/other'\n })\n })\n });\n\n Ember.run(function() {\n router.route(\"/\");\n });\n\n equal(router.get('currentState.path'), \"root.someOtherState\");\n});\n\ntest(\"you cannot define connectOutlets AND redirectsTo\", function() {\n raises(function() {\n Ember.Router.create({\n location: 'none',\n root: Ember.Route.create({\n index: Ember.Route.create({\n route: '/',\n redirectsTo: 'someOtherState',\n connectOutlets: function() {}\n })\n })\n });\n });\n});\n\ntest(\"you cannot have a redirectsTo in a non-leaf state\", function () {\n raises(function() {\n Ember.Router.create({\n location: 'none',\n root: Ember.Route.create({\n redirectsTo: 'someOtherState',\n\n index: Ember.Route.create()\n })\n });\n });\n});\n\nmodule(\"urlFor\");\n\nvar formatURLArgument = null;\nvar locationStub = {\n formatURL: function(url) {\n formatURLArgument = url;\n return url;\n },\n setURL: Ember.K\n};\nvar expectURL = function(url) {\n equal(formatURLArgument, url, \"should invoke formatURL with URL \"+url);\n};\n\ntest(\"urlFor returns an absolute route\", function() {\n expect(2);\n\n var router = Ember.Router.create({\n location: locationStub,\n root: Ember.Route.create({\n dashboard: Ember.Route.create({\n route: '/dashboard'\n })\n })\n });\n\n var url = router.urlFor('root.dashboard');\n equal(url, '/dashboard');\n expectURL('/dashboard');\n});\n\ntest(\"urlFor raises an error when route property is not defined\", function() {\n var router = Ember.Router.create({\n location: locationStub,\n root: Ember.Route.create({\n dashboard: Ember.Route.create({}) // state without route property\n })\n });\n\n raises(function (){\n router.urlFor('root.dashboard');\n });\n});\n\ntest(\"urlFor supports dynamic segments\", function() {\n var router = Ember.Router.create({\n location: locationStub,\n\n root: Ember.Route.create({\n dashboard: Ember.Route.create({\n route: '/dashboard',\n\n posts: Ember.Route.create({\n route: '/posts/:post_id'\n })\n })\n })\n });\n\n var url = router.urlFor('root.dashboard.posts', { post_id: 1 });\n equal(url, \"/dashboard/posts/1\");\n expectURL('/dashboard/posts/1');\n});\n\ntest(\"urlFor supports using the current information for dynamic segments\", function() {\n var router = Ember.Router.create({\n location: locationStub,\n namespace: {\n Post: {\n toString: function() { return \"Post\"; },\n find: function() { return { id: 1 }; }\n }\n },\n\n root: Ember.Route.create({\n dashboard: Ember.Route.create({\n route: '/dashboard',\n\n posts: Ember.Route.create({\n route: '/posts/:post_id',\n\n index: Ember.Route.create({\n route: '/'\n }),\n\n manage: Ember.Route.create({\n route: '/manage'\n })\n })\n })\n })\n });\n\n Ember.run(function() {\n router.route('/dashboard/posts/1');\n });\n\n var url = router.urlFor('root.dashboard.posts.manage');\n equal(url, '/dashboard/posts/1/manage');\n expectURL('/dashboard/posts/1/manage');\n});\n\ntest(\"urlFor supports merging the current information for dynamic segments\", function() {\n var router = Ember.Router.create({\n location: locationStub,\n namespace: {\n Post: {\n toString: function() { return \"Post\"; },\n find: function() { return { id: 1 }; }\n },\n\n Widget: {\n toString: function() { return \"Widget\"; },\n find: function() { return { id: 2 }; }\n }\n },\n\n root: Ember.Route.create({\n dashboard: Ember.Route.create({\n route: '/dashboard',\n\n posts: Ember.Route.create({\n route: '/posts/:post_id',\n\n index: Ember.Route.create({\n route: '/'\n }),\n\n manage: Ember.Route.create({\n route: '/manage/:widget_id'\n })\n })\n })\n })\n });\n\n Ember.run(function() {\n router.route('/dashboard/posts/1');\n });\n\n var url = router.urlFor('root.dashboard.posts.manage', { widget_id: 2 });\n equal(url, '/dashboard/posts/1/manage/2');\n expectURL('/dashboard/posts/1/manage/2');\n});\n\n\ntest(\"urlForEvent supports nested routes that have different contexts but share property names\", function() {\n var router = Ember.Router.create({\n location: locationStub,\n\n root: Ember.Route.create({\n goToComments: Ember.Route.transitionTo('root.dashboard.posts.comments'),\n\n dashboard: Ember.Route.create({\n route: '/dashboard',\n\n posts: Ember.Route.create({\n route: '/posts/:id',\n comments: Ember.Route.create({\n route: '/comments/:id'\n })\n })\n })\n })\n });\n\n var url = router.urlForEvent('goToComments', { id: 1 }, {id: 5});\n equal(url, \"/dashboard/posts/1/comments/5\");\n expectURL('/dashboard/posts/1/comments/5');\n});\n\n\ntest(\"navigateAway is called if the URL changes\", function() {\n var navigated = 0;\n\n var router = Ember.Router.create({\n location: locationStub,\n root: Ember.Route.create({\n index: Ember.Route.create({\n route: '/',\n\n navigateAway: function(router) {\n navigated++;\n }\n }),\n\n show: Ember.Route.create({\n route: '/show'\n })\n })\n });\n\n Ember.run(function() {\n router.route('/');\n });\n\n equal(router.get('currentState.path'), 'root.index', \"The current state is root.index\");\n\n Ember.run(function() {\n router.route('/show');\n });\n\n equal(router.get('currentState.path'), 'root.show', \"The current state is root.index\");\n equal(navigated, 1, \"The navigateAway method was called\");\n});\n\n})();\n//@ sourceURL=ember-old-router/~tests/routable_test");minispade.register('ember-old-router/~tests/router_test', "(function() {module(\"router.urlForEvent\");\n\nvar namespace = {\n \"Component\": {\n toString: function() { return \"Component\"; },\n find: function() { return { id: 1 }; }\n }\n};\n\nvar location = {\n formatURL: function(url) {\n return '#!#' + url;\n },\n\n setURL: function(url) {\n this.url = url;\n }\n};\n\nvar get = Ember.get;\n\ntest(\"router.urlForEvent looks in the current state's eventTransitions hash\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n index: Ember.Route.create({\n route: '/',\n\n showDashboard: function(router) {\n router.transitionTo('dashboard');\n },\n\n eventTransitions: {\n showDashboard: 'dashboard'\n }\n }),\n\n dashboard: Ember.Route.create({\n route: '/dashboard'\n })\n })\n });\n\n Ember.run(function() {\n router.route('/');\n });\n\n equal(router.get('currentState.path'), \"root.index\", \"precond - the router is in root.index\");\n\n var url = router.urlForEvent('showDashboard');\n equal(url, \"#!#/dashboard\");\n});\n\ntest(\"router.urlForEvent looks in the eventTransitions hashes of the current state's ancestors\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n eventTransitions: {\n showDashboard: 'dashboard'\n },\n\n index: Ember.Route.create({\n route: '/'\n }),\n\n dashboard: Ember.Route.create({\n route: '/dashboard'\n })\n })\n });\n\n Ember.run(function() {\n router.route('/');\n });\n\n equal(router.get('currentState.path'), \"root.index\", \"precond - the router is in root.index\");\n\n var url = router.urlForEvent('showDashboard');\n equal(url, \"#!#/dashboard\");\n});\n\ntest(\"router.urlForEvent works with a context\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n index: Ember.Route.create({\n route: '/',\n\n showDashboard: function(router) {\n router.transitionTo('dashboard');\n },\n\n eventTransitions: {\n showDashboard: 'dashboard'\n }\n }),\n\n dashboard: Ember.Route.create({\n route: '/dashboard/:component_id'\n })\n })\n });\n\n Ember.run(function() {\n router.route('/');\n });\n\n equal(router.get('currentState.path'), \"root.index\", \"precond - the router is in root.index\");\n\n var url = router.urlForEvent('showDashboard', { id: 1 });\n equal(url, \"#!#/dashboard/1\");\n});\n\ntest(\"router.urlForEvent works with multiple contexts\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n index: Ember.Route.create({\n route: '/',\n\n showDashboard: function(router) {\n router.transitionTo('dashboard');\n },\n\n eventTransitions: {\n showComment: 'post.comment'\n }\n }),\n\n post: Ember.Route.create({\n route: '/post/:post_id',\n\n comment: Ember.Route.create({\n route: '/comment/:comment_id'\n })\n })\n })\n });\n\n Ember.run(function() {\n router.route('/');\n });\n\n equal(router.get('currentState.path'), \"root.index\", \"precond - the router is in root.index\");\n\n var url = router.urlForEvent('showComment', { post_id: 1 }, { comment_id: 2 });\n equal(url, \"#!#/post/1/comment/2\");\n});\n\ntest(\"router.urlForEvent works with changing context in the current state\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n index: Ember.Route.create({\n route: '/'\n }),\n\n showDashboard: function(router) {\n router.transitionTo('dashboard');\n },\n\n eventTransitions: {\n showDashboard: 'dashboard'\n },\n\n dashboard: Ember.Route.create({\n route: '/dashboard/:component_id'\n })\n })\n });\n\n Ember.run(function() {\n router.route('/dashboard/1');\n });\n\n equal(router.get('currentState.path'), \"root.dashboard\", \"precond - the router is in root.dashboard\");\n\n var url = router.urlForEvent('showDashboard', { id: 2 });\n equal(url, \"#!#/dashboard/2\");\n});\n\n\ntest(\"router.urlForEvent works for nested routes with a context\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n index: Ember.Route.create({\n route: '/',\n\n showDashboardActivity: function(router) {\n router.transitionTo('dashboard.activity');\n },\n\n eventTransitions: {\n showDashboardActivity: 'dashboard.activity'\n }\n }),\n\n dashboard: Ember.Route.create({\n route: '/dashboard/:component_id',\n\n activity: Ember.Route.create({\n route: '/activity'\n })\n })\n })\n });\n\n Ember.run(function() {\n router.route('/');\n });\n\n equal(router.get('currentState.path'), \"root.index\", \"precond - the router is in root.index\");\n\n var url = router.urlForEvent('showDashboardActivity', { id: 1 });\n equal(url, \"#!#/dashboard/1/activity\");\n});\n\n\ntest(\"router.urlForEvent works with Ember.State.transitionTo\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n index: Ember.Route.create({\n route: '/',\n\n showDashboard: Ember.Route.transitionTo('dashboard')\n }),\n\n dashboard: Ember.Route.create({\n route: '/dashboard/:component_id'\n })\n })\n });\n\n Ember.run(function() {\n router.route('/');\n });\n\n equal(router.get('currentState.path'), \"root.index\", \"precond - the router is in root.index\");\n\n var url = router.urlForEvent('showDashboard', { id: 1 });\n equal(url, \"#!#/dashboard/1\");\n});\n\ntest(\"rerouting doesn't exit all the way out\", function() {\n var exited = 0;\n\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n index: Ember.Route.create({\n route: '/',\n showDashboard: Ember.Route.transitionTo('dashboard.index')\n }),\n\n dashboard: Ember.Route.create({\n route: '/dashboard',\n\n exit: function() {\n exited++;\n },\n\n index: Ember.Route.create({\n route: '/',\n showComponent: Ember.Route.transitionTo('component')\n }),\n\n component: Ember.Route.create({\n route: '/:component_id',\n showIndex: Ember.Route.transitionTo('index')\n })\n })\n })\n });\n\n Ember.run(function() {\n router.route('/');\n });\n\n equal(router.get('currentState.path'), \"root.index\", \"precond - the router is in root.index\");\n\n Ember.run(function() {\n router.send('showDashboard');\n });\n\n equal(router.get('currentState.path'), \"root.dashboard.index\", \"precond - the router is in root.dashboard.index\");\n equal(exited, 0, \"the dashboard hasn't been exited yet\");\n\n Ember.run(function() {\n router.send('showComponent', { id: 1 });\n });\n\n equal(router.get('currentState.path'), \"root.dashboard.component\", \"precond - the router is in root.index\");\n equal(exited, 0, \"moving around shouldn't gratuitously exit states\");\n\n Ember.run(function() {\n router.route('/dashboard');\n });\n\n equal(router.get('currentState.path'), \"root.dashboard.index\", \"the router is in root.dashboard.index\");\n equal(exited, 0, \"moving around shouldn't gratuitously exit states\");\n\n Ember.run(function() {\n router.route('/');\n });\n\n equal(router.get('currentState.path'), \"root.index\", \"the router is in root.dashboard.index\");\n equal(exited, 1, \"now, the exit was called\");\n\n Ember.run(function() {\n router.route('/dashboard/1');\n });\n\n exited = 0;\n equal(router.get('currentState.path'), \"root.dashboard.component\", \"the router is in root.dashboard.index\");\n equal(exited, 0, \"exit wasn't called now\");\n});\n\ntest(\"should be able to unroute out of a state with context\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n components: Ember.Route.create({\n route: '/components',\n\n show: Ember.Route.create({\n route: '/:component_id',\n\n index: Ember.Route.create({\n route: '/'\n }),\n\n edit: Ember.Route.create({\n route: '/edit'\n })\n })\n })\n })\n });\n\n router.route('/components/1/edit');\n equal(get(router, 'currentState.path'), 'root.components.show.edit', \"should go to the correct state\");\n\n router.route('/components/1');\n equal(get(router, 'currentState.path'), 'root.components.show.index', \"should go to the correct state\");\n});\n\ntest(\"should be able to route with initialState\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n initialState: 'stateOne',\n\n stateOne: Ember.Route.create({\n route: '/state_one'\n }),\n\n stateTwo: Ember.Route.create({\n route: '/state_two'\n })\n })\n });\n\n equal(get(router, 'currentState.path'), 'root.stateOne', \"should be in stateOne\");\n\n router.route('/state_two');\n\n equal(get(router, 'currentState.path'), 'root.stateTwo', \"should be in stateTwo\");\n});\n\ntest(\"should be able to route with rootURL\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n rootURL: '/test',\n root: Ember.Route.create({\n stateOne: Ember.Route.create({\n route: '/one'\n }),\n\n stateTwo: Ember.Route.create({\n route: '/two'\n })\n })\n });\n\n router.route('/test/two');\n\n equal(get(router, 'currentState.path'), 'root.stateTwo', \"should be in stateTwo\");\n});\n\ntest(\"should update route for redirections\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n index: Ember.Route.create({\n route: '/',\n redirectsTo: 'login'\n }),\n\n login: Ember.Route.create({\n route: '/login'\n })\n })\n });\n\n Ember.run(function() {\n router.route('/');\n });\n\n equal(location.url, '/login');\n});\n\ntest(\"respects initialState if leafRoute with child states\", function() {\n var router = Ember.Router.create({\n location: location,\n namespace: namespace,\n root: Ember.Route.create({\n foo: Ember.Route.create({\n route: '/foo',\n\n initialState: 'bar',\n\n bar: Ember.State.create()\n })\n })\n });\n\n Ember.run(function() {\n router.route('/foo');\n });\n\n equal(location.url, '/foo');\n equal(router.get('currentState.name'), 'bar');\n});\n\n})();\n//@ sourceURL=ember-old-router/~tests/router_test");minispade.register('ember-old-router/~tests/view_test', "(function() {var set = Ember.set, get = Ember.get, view;\n\nmodule(\"Ember.View - Old Router Functionality\", {\n setup: function() {\n Ember.TEMPLATES = {};\n },\n teardown: function() {\n Ember.run(function() {\n view.destroy();\n });\n }\n});\n\ntest(\"should load named templates from View.templates\", function() {\n\n\n view = Ember.View.create({\n templates: {\n testTemplate: function() {\n return \"BYE
\")\n }));\n });\n\n // Replace whitespace for older IE\n equal(view.$().text().replace(/\\s+/,''), 'HIBYE');\n});\n\ntest(\"outlet should support connectOutlet in slots in prerender state\", function() {\n var template = \"BYE
\")\n }));\n\n appendView(view);\n\n equal(view.$().text(), 'HIBYE');\n});\n\ntest(\"outlet should support an optional name\", function() {\n var template = \"BYE
\")\n }));\n });\n\n // Replace whitespace for older IE\n equal(view.$().text().replace(/\\s+/,''), 'HIBYE');\n});\n\ntest(\"Outlets bind to the current view, not the current concrete view\", function() {\n var parentTemplate = \"BYE
\")\n }));\n });\n\n // Replace whitespace for older IE\n equal(view.$().text().replace(/\\s+/,''), 'HIBYE');\n\n Ember.run(function() {\n view.disconnectOutlet('main');\n });\n\n // Replace whitespace for older IE\n equal(view.$().text().replace(/\\s+/,''), 'HI');\n});\n\ntest(\"Outlets bind to the current template's view, not inner contexts\", function() {\n var parentTemplate = \"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\ntest(\"{{render}} helper should render given template with a supplied model\", function() {\n var template = \"{{title}}
\");\n\n var postController = container.lookup('controller:post');\n\n appendView(view);\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 deepEqual(postController.get('model'), { title: \"Rails is unagi\" });\n});\n\ntest(\"{{render}} helper should render with given controller\", function() {\n var template = '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\ntest(\"{{render}} helper should render a template only once\", function() {\n var template = \"BYE
\");\n\n raises(function() {\n appendView(view);\n }, 'should raise an exception');\n});\n\ntest(\"{{render}} helper should link child controllers to the parent controller\", function() {\n var parentTriggered = 0;\n\n var template = 'BYE
\");\n\n appendView(view);\n\n Ember.run(function() {\n view.connectOutlet('main', Ember.View.create({\n controller: controller.create(),\n template: compile(\"1{{render home}}
\")\n }));\n });\n\n equal(view.$().text(), 'HI1BYE');\n\n Ember.run(function() {\n view.connectOutlet('main', Ember.View.create({\n controller: controller.create(),\n template: compile(\"2{{render home}}
\")\n }));\n });\n\n equal(view.$().text(), 'HI2BYE');\n});\n\ntest(\"{{render}} works with dot notation\", function() {\n var template = '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\ntest(\"{{render}} works with slash notation\", function() {\n var template = '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})();\n//@ sourceURL=ember-routing/~tests/helpers/render_test");minispade.register('ember-routing/~tests/system/controller_for_test', "(function() {var buildContainer = function(namespace) {\n var container = new Ember.Container();\n\n container.set = Ember.set;\n container.resolver = resolverFor(namespace);\n container.optionsForType('view', { singleton: false });\n container.register('application', 'main', namespace, { instantiate: false });\n\n return container;\n};\n\nfunction resolverFor(namespace) {\n return function(fullName) {\n var nameParts = fullName.split(\":\"),\n type = nameParts[0], name = nameParts[1];\n\n var className = Ember.String.classify(name) + Ember.String.classify(type);\n var factory = Ember.get(namespace, className);\n\n if (factory) { return factory; }\n };\n}\n\nvar container, appController;\n\nmodule(\"Ember.controllerFor\", {\n setup: function() {\n var namespace = Ember.Namespace.create();\n container = buildContainer(namespace);\n container.register('controller', 'app', Ember.Controller.extend());\n appController = container.lookup('controller:app');\n },\n teardown: function() {\n Ember.run(function () {\n if (container) {\n container.destroy();\n }\n });\n }\n});\n\ntest(\"controllerFor should lookup for registered controllers\", function() {\n var controller = Ember.controllerFor(container, 'app');\n\n equal(appController, controller, 'should find app controller');\n});\n\ntest(\"controllerFor should create Ember.Controller\", function() {\n var controller = Ember.controllerFor(container, 'home');\n\n ok(controller instanceof Ember.Controller, 'should create controller');\n});\n\ntest(\"controllerFor should create Ember.ObjectController\", function() {\n var context = {};\n var controller = Ember.controllerFor(container, 'home', context);\n\n ok(controller instanceof Ember.ObjectController, 'should create controller');\n equal(controller.get('content'), context, 'should set content');\n});\n\ntest(\"controllerFor should create Ember.ArrayController\", function() {\n var context = Ember.A();\n var controller = Ember.controllerFor(container, 'home', context);\n\n ok(controller instanceof Ember.ArrayController, 'should create controller');\n equal(controller.get('content'), context, 'should set content');\n});\n\n})();\n//@ sourceURL=ember-routing/~tests/system/controller_for_test");minispade.register('ember-runtime/~tests/controllers/array_controller_test', "(function() {minispade.require('ember-runtime/~tests/suites/mutable_array');\n\nmodule(\"ember-runtime/controllers/array_controller_test\");\n\nEmber.MutableArrayTests.extend({\n\n name: 'Ember.ArrayController',\n\n newObject: function(ary) {\n var ret = ary ? ary.slice() : this.newFixture(3);\n return Ember.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\ntest(\"defaults it's `content` to an empty array\", function () {\n var Controller = Ember.ArrayController.extend();\n deepEqual(Controller.create().get(\"content\"), [], \"`ArrayController` defaults it's content to an empty array\");\n});\n\n})();\n//@ sourceURL=ember-runtime/~tests/controllers/array_controller_test");minispade.register('ember-runtime/~tests/controllers/item_controller_class_test', "(function() {var lannisters, arrayController, controllerClass, otherControllerClass, container, itemControllerCount,\n tywin, jaime, cersei, tyrion,\n get = Ember.get;\n\nmodule(\"Ember.ArrayController - itemController\", {\n setup: function() {\n container = new Ember.Container();\n\n tywin = Ember.Object.create({ name: 'Tywin' });\n jaime = Ember.Object.create({ name: 'Jaime' });\n cersei = Ember.Object.create({ name: 'Cersei' });\n tyrion = Ember.Object.create({ name: 'Tyrion' });\n lannisters = Ember.A([ tywin, jaime, cersei ]);\n\n itemControllerCount = 0;\n controllerClass = Ember.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 = Ember.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 Ember.run(function() {\n container.destroy();\n });\n }\n});\n\nfunction createUnwrappedArrayController() {\n arrayController = Ember.ArrayController.create({\n container: container,\n content: lannisters\n });\n}\n\nfunction createArrayController() {\n arrayController = Ember.ArrayController.create({\n container: container,\n itemController: 'Item',\n content: lannisters\n });\n}\n\nfunction createDynamicArrayController() {\n arrayController = Ember.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\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"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 subContainers = get(arrayController, 'subContainers'),\n jaimeContainer = subContainers[1],\n cerseiContainer = subContainers[2];\n\n equal(!!jaimeContainer.isDestroyed, false, \"precond - nobody is destroyed yet\");\n equal(!!!!cerseiContainer.isDestroyed, false, \"precond - nobody is destroyed yet\");\n\n Ember.run(function() {\n arrayController.set('content', Ember.A());\n });\n\n equal(!!jaimeContainer.isDestroyed, true, \"old subcontainers are destroyed\");\n equal(!!cerseiContainer.isDestroyed, true, \"old subcontainers are destroyed\");\n});\n\n\ntest(\"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\ntest(\"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 subContainers = get(arrayController, 'subContainers'),\n jaimeContainer = subContainers[1],\n cerseiContainer = subContainers[2];\n\n equal(!!cerseiContainer.isDestroyed, false, \"precond - nobody is destroyed yet\");\n equal(!!jaimeContainer.isDestroyed, false, \"precond - nobody is destroyed yet\");\n\n Ember.run(function() {\n arrayController.removeObject(cerseiController);\n });\n\n equal(!!cerseiContainer.isDestroyed, true, \"Removed objects' containers are cleaned up\");\n equal(!!jaimeContainer.isDestroyed, false, \"Retained objects' containers are not cleaned up\");\n});\n\ntest(\"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 Ember.run(function() {\n arrayController.removeObject(cerseiController);\n });\n equal(arrayController.get('length'), 2, \"can remove wrapper objects\");\n});\n\ntest(\"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 jaimeContainer = subContainers[1],\n cerseiContainer = subContainers[2];\n\n equal(!!jaimeContainer.isDestroyed, false, \"precond - nobody is destroyed yet\");\n equal(!!cerseiContainer.isDestroyed, false, \"precond - nobody is destroyed yet\");\n\n Ember.run(function() {\n lannisters.removeObject(cersei); // if only it were that easy\n });\n\n equal(!!jaimeContainer.isDestroyed, false, \"Retained objects' containers are not cleaned up\");\n equal(!!cerseiContainer.isDestroyed, true, \"Removed objects' containers are cleaned up\");\n});\n\ntest(\"`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\ntest(\"when `idx` is out of range, `lookupItemController` is not called\", function() {\n arrayController = Ember.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\ntest(\"if `lookupItemController` returns a string, it must be resolvable by the container\", function() {\n arrayController = Ember.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\ntest(\"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 Ember.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})();\n//@ sourceURL=ember-runtime/~tests/controllers/item_controller_class_test");minispade.register('ember-runtime/~tests/controllers/object_controller_tests', "(function() {module(\"Ember.ObjectController\");\n\n\ntest(\"should be able to set the target property of an ObjectController\", function() {\n var controller = Ember.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\n})();\n//@ sourceURL=ember-runtime/~tests/controllers/object_controller_tests");minispade.register('ember-runtime/~tests/core/compare_test', "(function() {/*globals module ok equals same test MyApp */\n\n// test parsing of query string\nvar v = [];\nmodule(\"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] = Ember.Object.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\ntest(\"ordering should work\", function() {\n for (var j=0; j < v.length; j++) {\n equal(Ember.compare(v[j],v[j]), 0, j +' should equal itself');\n for (var i=j+1; i < v.length; i++) {\n equal(Ember.compare(v[j],v[i]), -1, 'v[' + j + '] (' + Ember.typeOf(v[j]) + ') should be smaller than v[' + i + '] (' + Ember.typeOf(v[i]) + ')' );\n }\n\n }\n});\n\n\n})();\n//@ sourceURL=ember-runtime/~tests/core/compare_test");minispade.register('ember-runtime/~tests/core/copy_test', "(function() {module(\"Ember Copy Method\");\n\ntest(\"Ember.copy null\", function() {\n var obj = {field: null};\n equal(Ember.copy(obj, true).field, null, \"null should still be null\");\n});\n\n\n})();\n//@ sourceURL=ember-runtime/~tests/core/copy_test");minispade.register('ember-runtime/~tests/core/error_test', "(function() {module(\"Ember Error Throwing\");\n\ntest(\"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\n})();\n//@ sourceURL=ember-runtime/~tests/core/error_test");minispade.register('ember-runtime/~tests/core/inspect_test', "(function() {module(\"Ember.inspect\");\n\nvar inspect = Ember.inspect;\n\ntest(\"strings\", function() {\n equal(inspect(\"foo\"), \"foo\");\n});\n\ntest(\"numbers\", function() {\n equal(inspect(2.6), \"2.6\");\n});\n\ntest(\"null\", function() {\n equal(inspect(null), \"null\");\n});\n\ntest(\"undefined\", function() {\n equal(inspect(undefined), \"undefined\");\n});\n\ntest(\"true\", function() {\n equal(inspect(true), \"true\");\n});\n\ntest(\"false\", function() {\n equal(inspect(false), \"false\");\n});\n\ntest(\"object\", function() {\n equal(inspect({}), \"{}\");\n equal(inspect({ foo: 'bar' }), \"{foo: bar}\");\n equal(inspect({ foo: Ember.K }), \"{foo: function() { ... }}\");\n});\n\ntest(\"array\", function() {\n // this could be better, but let's not let this method get\n // out of control unless we want to go all the way, a la\n // JSDump\n equal(inspect([1,2,3]), \"{0: 1, 1: 2, 2: 3}\");\n});\n\n})();\n//@ sourceURL=ember-runtime/~tests/core/inspect_test");minispade.register('ember-runtime/~tests/core/isArray_test', "(function() {module(\"Ember Type Checking\");\n\nvar global = this;\n\ntest(\"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( Ember.isArray(numarray), true, \"[1,2,3]\" );\n equal( Ember.isArray(number), false, \"23\" );\n equal( Ember.isArray(strarray), true, '[\"Hello\", \"Hi\"]' );\n equal( Ember.isArray(string), false, '\"Hello\"' );\n equal( Ember.isArray(object), false, \"{}\" );\n equal( Ember.isArray(length), true, \"{length: 12}\" );\n equal( Ember.isArray(global), false, \"global\" );\n equal( Ember.isArray(fn), false, \"function() {}\" );\n});\n\n})();\n//@ sourceURL=ember-runtime/~tests/core/isArray_test");minispade.register('ember-runtime/~tests/core/isEmpty_test', "(function() {module(\"Ember.isEmpty\");\n\ntest(\"Ember.isEmpty\", function() {\n var string = \"string\", fn = function() {},\n object = {length: 0},\n arrayProxy = Ember.ArrayProxy.create({ content: Ember.A([]) });\n\n equal(true, Ember.isEmpty(null), \"for null\");\n equal(true, Ember.isEmpty(undefined), \"for undefined\");\n equal(true, Ember.isEmpty(\"\"), \"for an empty String\");\n equal(false, Ember.isEmpty(true), \"for true\");\n equal(false, Ember.isEmpty(false), \"for false\");\n equal(false, Ember.isEmpty(string), \"for a String\");\n equal(false, Ember.isEmpty(fn), \"for a Function\");\n equal(false, Ember.isEmpty(0), \"for 0\");\n equal(true, Ember.isEmpty([]), \"for an empty Array\");\n equal(false, Ember.isEmpty({}), \"for an empty Object\");\n equal(true, Ember.isEmpty(object), \"for an Object that has zero 'length'\");\n equal(true, Ember.isEmpty(arrayProxy), \"for an ArrayProxy that has empty content\");\n});\n\n})();\n//@ sourceURL=ember-runtime/~tests/core/isEmpty_test");minispade.register('ember-runtime/~tests/core/isEqual_test', "(function() {// ========================================================================\n// Ember.isEqual Tests\n// ========================================================================\n/*globals module test */\n\nmodule(\"isEqual\");\n\ntest(\"undefined and null\", function() {\n ok( Ember.isEqual(undefined, undefined), \"undefined is equal to undefined\" );\n ok( !Ember.isEqual(undefined, null), \"undefined is not equal to null\" );\n ok( Ember.isEqual(null, null), \"null is equal to null\" );\n ok( !Ember.isEqual(null, undefined), \"null is not equal to undefined\" );\n});\n\ntest(\"strings should be equal\",function(){\n\tok( !Ember.isEqual(\"Hello\", \"Hi\"), \"different Strings are unequal\" );\n\tok( Ember.isEqual(\"Hello\", \"Hello\"), \"same Strings are equal\" );\n});\n\ntest(\"numericals should be equal\",function(){\n ok( Ember.isEqual(24, 24), \"same numbers are equal\" );\n\tok( !Ember.isEqual(24, 21), \"different numbers are inequal\" );\n});\n\ntest(\"array should be equal\",function(){\n\t// NOTE: We don't test for array contents -- that would be too expensive.\n\tok( !Ember.isEqual( [1,2], [1,2] ), 'two array instances with the same values should not be equal' );\n\tok( !Ember.isEqual( [1,2], [1] ), 'two array instances with different values should not be equal' );\n});\n\ntest(\"first object implements isEqual should use it\", function() {\n ok(Ember.isEqual({ isEqual: function() { return true; } }, null), 'should return true always');\n\n var obj = { isEqual: function() { return false; } };\n equal(Ember.isEqual(obj, obj), false, 'should return false because isEqual returns false');\n});\n\n\n\n})();\n//@ sourceURL=ember-runtime/~tests/core/isEqual_test");minispade.register('ember-runtime/~tests/core/isNone_test', "(function() {module(\"Ember.isNone\");\n\ntest(\"Ember.isNone\", function() {\n var string = \"string\", fn = function() {};\n\n equal(true, Ember.isNone(null), \"for null\");\n equal(true, Ember.isNone(undefined), \"for undefined\");\n equal(false, Ember.isNone(\"\"), \"for an empty String\");\n equal(false, Ember.isNone(true), \"for true\");\n equal(false, Ember.isNone(false), \"for false\");\n equal(false, Ember.isNone(string), \"for a String\");\n equal(false, Ember.isNone(fn), \"for a Function\");\n equal(false, Ember.isNone(0), \"for 0\");\n equal(false, Ember.isNone([]), \"for an empty Array\");\n equal(false, Ember.isNone({}), \"for an empty Object\");\n});\n\n})();\n//@ sourceURL=ember-runtime/~tests/core/isNone_test");minispade.register('ember-runtime/~tests/core/keys_test', "(function() {// ========================================================================\n// Ember.keys Tests\n// ========================================================================\n/*globals module test */\n\nmodule(\"Fetch Keys \");\n\ntest(\"should get a key array for a specified object \",function(){\n\tvar object1 = {};\n\n\tobject1.names = \"Rahul\";\n\tobject1.age = \"23\";\n\tobject1.place = \"Mangalore\";\n\n\tvar object2 = [];\n\tobject2 = Ember.keys(object1);\n\tdeepEqual(object2,['names','age','place']);\n});\n\n\n\n})();\n//@ sourceURL=ember-runtime/~tests/core/keys_test");minispade.register('ember-runtime/~tests/core/type_test', "(function() {module(\"Ember Type Checking\");\n\ntest(\"Ember.typeOf\", function() {\n\tvar a = null,\n arr = [1,2,3],\n obj = {},\n object = Ember.Object.create({ method: function() {} });\n\n equal(Ember.typeOf(undefined), 'undefined', \"item of type undefined\");\n equal(Ember.typeOf(a), 'null', \"item of type null\");\n\tequal(Ember.typeOf(arr), 'array', \"item of type array\");\n\tequal(Ember.typeOf(obj), 'object', \"item of type object\");\n\tequal(Ember.typeOf(object), 'instance', \"item of type instance\");\n\tequal(Ember.typeOf(object.method), 'function', \"item of type function\") ;\n\tequal(Ember.typeOf(Ember.Object), 'class', \"item of type class\");\n equal(Ember.typeOf(new Error()), 'error', \"item of type error\");\n});\n\n\n})();\n//@ sourceURL=ember-runtime/~tests/core/type_test");minispade.register('ember-runtime/~tests/ext/function_test', "(function() {/*globals testBoth */\nminispade.require('ember-runtime/~tests/props_helper');\n\nmodule('Function.prototype.observes() helper');\n\ntestBoth('global observer helper takes multiple params', 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\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\n})();\n//@ sourceURL=ember-runtime/~tests/ext/function_test");minispade.register('ember-runtime/~tests/ext/mixin_test', "(function() {module('system/mixin/binding_test');\n\ntest('Defining a property ending in Binding should setup binding when applied', function() {\n\n var MyMixin = Ember.Mixin.create({\n fooBinding: 'bar.baz'\n });\n\n var obj = { bar: { baz: 'BIFF' } };\n\n Ember.run(function(){\n MyMixin.apply(obj);\n });\n\n ok(Ember.get(obj, 'fooBinding') instanceof Ember.Binding, 'should be a binding object');\n equal(Ember.get(obj, 'foo'), 'BIFF', 'binding should be created and synced');\n\n});\n\ntest('Defining a property ending in Binding should apply to prototype children', function() {\n var MyMixin, obj, obj2;\n\n Ember.run(function(){\n MyMixin = Ember.Mixin.create({\n fooBinding: 'bar.baz'\n });\n });\n\n obj = { bar: { baz: 'BIFF' } };\n\n Ember.run(function(){\n MyMixin.apply(obj);\n });\n\n\n obj2 = Ember.create(obj);\n Ember.run(function(){\n Ember.set(Ember.get(obj2, 'bar'), 'baz', 'BARG');\n });\n\n\n ok(Ember.get(obj2, 'fooBinding') instanceof Ember.Binding, 'should be a binding object');\n equal(Ember.get(obj2, 'foo'), 'BARG', 'binding should be created and synced');\n\n});\n\n})();\n//@ sourceURL=ember-runtime/~tests/ext/mixin_test");minispade.register('ember-runtime/~tests/legacy_1x/mixins/observable/chained_test', "(function() {/*\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 Ember.addObserver()\n*/\n\nvar get = Ember.get, set = Ember.set;\n\nmodule(\"Ember.Observable - Observing with @each\");\n\ntest(\"chained observers on enumerable properties are triggered when the observed property of any item changes\", function() {\n var family = Ember.Object.create({ momma: null });\n var momma = Ember.Object.create({ children: [] });\n\n var child1 = Ember.Object.create({ name: \"Bartholomew\" });\n var child2 = Ember.Object.create({ name: \"Agnes\" });\n var child3 = Ember.Object.create({ name: \"Dan\" });\n var child4 = Ember.Object.create({ name: \"Nancy\" });\n\n set(family, 'momma', momma);\n set(momma, 'children', Ember.A([child1, child2, child3]));\n\n var observerFiredCount = 0;\n Ember.addObserver(family, 'momma.children.@each.name', this, function() {\n observerFiredCount++;\n });\n\n observerFiredCount = 0;\n Ember.run(function() { get(momma, 'children').setEach('name', 'Juan'); });\n equal(observerFiredCount, 3, \"observer fired after changing child names\");\n\n observerFiredCount = 0;\n Ember.run(function() { get(momma, 'children').pushObject(child4); });\n equal(observerFiredCount, 1, \"observer fired after adding a new item\");\n\n observerFiredCount = 0;\n Ember.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 Ember.run(function() { set(child1, 'name', \"Hanna\"); });\n equal(observerFiredCount, 0, \"observer did not fire after removing changing property on a removed object\");\n});\n\n\n})();\n//@ sourceURL=ember-runtime/~tests/legacy_1x/mixins/observable/chained_test");minispade.register('ember-runtime/~tests/legacy_1x/mixins/observable/observable_test', "(function() {/*global Namespace:true DepObj:true*/\n\nvar get = Ember.get, set = Ember.set;\nvar forEach = Ember.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() -> Ember.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\nvar object, ObjectC, ObjectD, objectA, objectB ;\n\nvar ObservableObject = Ember.Object.extend(Ember.Observable);\nvar originalLookup = Ember.lookup, lookup;\n\n// ..........................................................\n// GET()\n//\n\nmodule(\"object.get()\", {\n\n setup: function() {\n object = ObservableObject.createWithMixins(Ember.Observable, {\n\n normal: 'value',\n numberVal: 24,\n toggleVal: true,\n\n computed: Ember.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\ntest(\"should get normal properties\", function() {\n equal(object.get('normal'), 'value') ;\n});\n\ntest(\"should call computed properties and return their result\", function() {\n equal(object.get(\"computed\"), \"value\") ;\n});\n\ntest(\"should return the function for a non-computed property\", function() {\n var value = object.get(\"method\") ;\n equal(Ember.typeOf(value), 'function') ;\n});\n\ntest(\"should return null when property value is null\", function() {\n equal(object.get(\"nullProperty\"), null) ;\n});\n\ntest(\"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//\nmodule(\"Ember.get()\", {\n setup: function() {\n objectA = ObservableObject.createWithMixins({\n\n normal: 'value',\n numberVal: 24,\n toggleVal: true,\n\n computed: Ember.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\ntest(\"should get normal properties on Ember.Observable\", function() {\n equal(Ember.get(objectA, 'normal'), 'value') ;\n});\n\ntest(\"should call computed properties on Ember.Observable and return their result\", function() {\n equal(Ember.get(objectA, \"computed\"), \"value\") ;\n});\n\ntest(\"should return the function for a non-computed property on Ember.Observable\", function() {\n var value = Ember.get(objectA, \"method\") ;\n equal(Ember.typeOf(value), 'function') ;\n});\n\ntest(\"should return null when property value is null on Ember.Observable\", function() {\n equal(Ember.get(objectA, \"nullProperty\"), null) ;\n});\n\ntest(\"should call unknownProperty when value is undefined on Ember.Observable\", function() {\n equal(Ember.get(object, \"unknown\"), \"unknown\") ;\n equal(object.lastUnknownProperty, \"unknown\") ;\n});\n\ntest(\"should get normal properties on standard objects\", function() {\n equal(Ember.get(objectB, 'normal'), 'value');\n});\n\ntest(\"should return null when property is null on standard objects\", function() {\n equal(Ember.get(objectB, 'nullProperty'), null);\n});\n\n/*\ntest(\"raise if the provided object is null\", function() {\n raises(function() {\n Ember.get(null, 'key');\n });\n});\n*/\n\ntest(\"raise if the provided object is undefined\", function() {\n raises(function() {\n Ember.get(undefined, 'key');\n });\n});\n\ntest(\"should work when object is Ember (used in Ember.get)\", function() {\n equal(Ember.get('Ember.RunLoop'), Ember.RunLoop, 'Ember.get');\n equal(Ember.get(Ember, 'RunLoop'), Ember.RunLoop, 'Ember.get(Ember, RunLoop)');\n});\n\nmodule(\"Ember.get() with paths\", {\n setup: function() {\n lookup = Ember.lookup = {};\n },\n\n teardown: function() {\n Ember.lookup = originalLookup;\n }\n});\n\ntest(\"should return a property at a given path relative to the lookup\", function() {\n lookup.Foo = ObservableObject.create({\n Bar: ObservableObject.createWithMixins({\n Baz: Ember.computed(function() { return \"blargh\"; }).volatile()\n })\n });\n\n equal(Ember.get('Foo.Bar.Baz'), \"blargh\");\n});\n\ntest(\"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: Ember.computed(function() { return \"blargh\"; }).volatile()\n })\n });\n\n equal(Ember.get(foo, 'bar.baz'), \"blargh\");\n});\n\ntest(\"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(Ember.get('Foo.Bar.Baz'), \"blargh\");\n});\n\ntest(\"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(Ember.get(foo, 'bar.baz'), \"blargh\");\n});\n\n// ..........................................................\n// SET()\n//\n\nmodule(\"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: Ember.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\ntest(\"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\ntest(\"should call computed properties passing value and return this\", function() {\n var ret = object.set(\"computed\", \"changed\") ;\n equal(object._computed, \"changed\") ;\n\n // DISABLED: this is no longer true with accessors\n //equal(Ember.typeOf(object.computed), 'function') ;\n\n equal(ret, object) ;\n});\n\ntest(\"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\ntest(\"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(Ember.typeOf(object.method) !== 'function') ;\n equal(ret, object) ;\n});\n\ntest(\"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\ntest(\"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\nmodule(\"Computed properties\", {\n setup: function() {\n lookup = Ember.lookup = {};\n\n object = ObservableObject.createWithMixins({\n\n // REGULAR\n\n computedCalls: [],\n computed: Ember.computed(function(key, value) {\n this.computedCalls.push(value);\n return 'computed';\n }).volatile(),\n\n computedCachedCalls: [],\n computedCached: Ember.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: Ember.computed(function(key, value) {\n this.dependentCalls.push(value);\n return 'dependent';\n }).property('changer').volatile(),\n\n dependentFrontCalls: [],\n dependentFront: Ember.computed('changer', function(key, value) {\n this.dependentFrontCalls.push(value);\n return 'dependentFront';\n }).volatile(),\n\n dependentCachedCalls: [],\n dependentCached: Ember.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: Ember.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: Ember.computed(function(key, value) {\n return this.nestedIncCallCount++;\n }).property('inc'),\n\n // two computed properties that depend on a third property\n state: 'on',\n isOn: Ember.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: Ember.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\ntest(\"getting values should call function return value\", function() {\n\n // get each property twice. Verify return.\n var keys = Ember.String.w('computed computedCached dependent dependentFront dependentCached');\n\n forEach(keys, function(key) {\n equal(object.get(key), key, Ember.String.fmt('Try #1: object.get(%@) should run function', [key]));\n equal(object.get(key), key, Ember.String.fmt('Try #2: object.get(%@) should run function', [key]));\n });\n\n // verify each call count. cached should only be called once\n forEach(Ember.String.w('computedCalls dependentFrontCalls dependentCalls'), function(key) {\n equal(object[key].length, 2, Ember.String.fmt('non-cached property %@ should be called 2x', [key]));\n });\n\n forEach(Ember.String.w('computedCachedCalls dependentCachedCalls'), function(key) {\n equal(object[key].length, 1, Ember.String.fmt('non-cached property %@ should be called 1x', [key]));\n });\n\n});\n\ntest(\"setting values should call function return value\", function() {\n\n // get each property twice. Verify return.\n var keys = Ember.String.w('computed dependent dependentFront computedCached dependentCached');\n var values = Ember.String.w('value1 value2');\n\n forEach(keys, function(key) {\n\n equal(object.set(key, values[0]), object, Ember.String.fmt('Try #1: object.set(%@, %@) should run function', [key, values[0]]));\n\n equal(object.set(key, values[1]), object, Ember.String.fmt('Try #2: object.set(%@, %@) should run function', [key, values[1]]));\n\n equal(object.set(key, values[1]), object, Ember.String.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, Ember.String.fmt('set(%@) should be called the right amount of times', [key]));\n for(idx=0;idx<2;idx++) {\n equal(calls[idx], values[idx], Ember.String.fmt('call #%@ to set(%@) should have passed value %@', [idx+1, key, values[idx]]));\n }\n });\n\n});\n\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"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\ntest(\"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.\ntest(\"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\ntest('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\ntest(\"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: Ember.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\ntest(\"nested dependent keys should propagate after they update\", function() {\n var bindObj;\n Ember.run(function () {\n lookup.DepObj = ObservableObject.createWithMixins({\n restaurant: ObservableObject.create({\n menu: ObservableObject.create({\n price: 5\n })\n }),\n\n price: Ember.computed(function() {\n return this.get('restaurant.menu.price');\n }).property('restaurant.menu.price').volatile()\n });\n\n bindObj = ObservableObject.createWithMixins({\n priceBinding: \"DepObj.price\"\n });\n });\n\n equal(bindObj.get('price'), 5, \"precond - binding propagates\");\n\n Ember.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 Ember.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\ntest(\"cacheable nested dependent keys should clear after their dependencies update\", function() {\n ok(true);\n\n var DepObj;\n\n Ember.run(function(){\n lookup.DepObj = DepObj = ObservableObject.createWithMixins({\n restaurant: ObservableObject.create({\n menu: ObservableObject.create({\n price: 5\n })\n }),\n\n price: Ember.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 Ember.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 Ember.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 Ember.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 Ember.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\nmodule(\"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; idxBye!
\");\n }\n });\n\n Ember.run(function() {\n Ember.$(\"#qunit-fixture\").empty();\n rootView.appendTo(\"#qunit-fixture\");\n });\n\n equal(Ember.$(\"#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\ntest(\"when a virtual view's child views change, the parent's childViews should reflect\", function() {\n rootView = Ember.View.create({\n elementId: 'root-view',\n\n render: function(buffer) {\n buffer.push(\"Bye!
\");\n }\n });\n\n Ember.run(function() {\n Ember.$(\"#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 Ember.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/views/view/virtual_views_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;\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\nmodule(\"The {{linkTo}} helper\", {\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 Ember.TEMPLATES.app = Ember.Handlebars.compile(\"{{outlet}}\");\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{name}}
{{#linkTo index id='home-link'}}Home{{/linkTo}}\");\n\n AppView = Ember.View.extend({\n templateName: 'app'\n });\n\n container = App.__container__;\n\n container.register('view', 'app');\n container.register('router', 'main', Router);\n });\n },\n\n teardown: function() {\n Ember.run(function() { App.destroy(); });\n }\n});\n\ntest(\"The {{linkTo}} 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 {{linkTo}} helper supports URL replacement\", function() {\n var setCount = 0,\n replaceCount = 0;\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{filter}}
{{#linkTo filter \"unpopular\" id=\"link\"}}Unpopular{{/linkTo}}');\n Ember.TEMPLATES.index = compile('');\n\n bootApplication();\n\n Ember.run(function() { router.handleURL(\"/filters/popular\"); });\n\n equal(Ember.$('#link', '#qunit-fixture').attr('href'), \"/filters/unpopular\");\n});\n\ntest(\"The {{linkTo}} helper doesn't change view context\", function() {\n App.IndexView = Ember.View.extend({\n elementId: 'index',\n name: 'test'\n });\n\n Ember.TEMPLATES.index = Ember.Handlebars.compile(\"{{view.name}}-{{#linkTo index id='self-link'}}Link: {{view.name}}{{/linkTo}}\");\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('#index', '#qunit-fixture').text(), 'test-Link: test', \"accesses correct view\");\n});\n\n})();\n//@ sourceURL=ember/~tests/helpers/link_to_test");minispade.register('ember/~tests/routing/basic_test', "(function() {var Router, App, AppView, templates, router, container, originalTemplates;\nvar get = Ember.get, set = Ember.set;\n\nfunction bootApplication() {\n router = container.lookup('router:main');\n Ember.run(App, 'advanceReadiness');\n}\n\nfunction compile(string) {\n return Ember.Handlebars.compile(string);\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 originalTemplates = Ember.$.extend({}, Ember.TEMPLATES);\n Ember.TEMPLATES.application = compile(\"{{outlet}}\");\n Ember.TEMPLATES.home = compile(\"{{home}}
\");\n });\n },\n\n teardown: function() {\n Ember.run(function() {\n App.destroy();\n App = null;\n\n Ember.TEMPLATES = originalTemplates;\n });\n }\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(function() {\n currentPath = get(this, 'currentPath');\n }, 'currentPath')\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\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 Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n ok(router._lookupActiveView('home'), '`home` active view is connected');\n\n Ember.run(function() {\n router.handleURL(\"/homepage\");\n });\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 Ember.run(function() {\n router.handleURL(\"/\");\n });\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 Ember.run(function() {\n router.handleURL(\"/\");\n });\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 Ember.run(function() {\n router.handleURL(\"/\");\n });\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 Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('h3:contains(Megatroll) + p:contains(YES I AM HOME)', '#qunit-fixture').length, 1, \"The homepage template was rendered\");\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 Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('p:contains(Home/Page)', '#qunit-fixture').length, 1, \"The homepage template 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 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(\"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 \"{{content.menuItemId}}
\"\n );\n\n bootApplication();\n\n container.register('controller', 'special', Ember.Controller.extend());\n\n Ember.run(function() {\n router.handleURL(\"/specials/1\");\n });\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.find = function(id) {\n return Ember.Object.create({\n id: id\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 Ember.run(function() {\n router.handleURL(\"/specials/1\");\n });\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 stop();\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.find = function(id) {\n menuItem = App.MenuItem.create({ id: id });\n return menuItem;\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 Ember.run(function() {\n router.handleURL(\"/specials/1\");\n });\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 setTimeout(function() {\n equal(Ember.$('p', '#qunit-fixture').text(), \"1\", \"The app is now in the specials state\");\n start();\n }, 100);\n});\n\ntest(\"The Special page returning an error puts the app into the failure state\", function() {\n stop();\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.find = function(id) {\n menuItem = App.MenuItem.create({ id: id });\n return menuItem;\n };\n\n App.SpecialRoute = Ember.Route.extend({\n setup: function() {\n throw 'Setup error';\n }\n });\n\n App.FailureRoute = Ember.Route.extend({\n });\n\n Ember.TEMPLATES.failure = Ember.Handlebars.compile(\n \"FAILURE!
\"\n );\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/specials/1\");\n menuItem.resolve(menuItem);\n });\n\n setTimeout(function() {\n equal(Ember.$('p', '#qunit-fixture').text(), \"FAILURE!\", \"The app is now in the failure state\");\n start();\n }, 100);\n});\n\ntest(\"The Special page returning an error puts the app into a default failure state if none provided\", function() {\n stop();\n\n Router.map(function() {\n this.route(\"home\", { path: \"/\" });\n this.resource(\"special\", { path: \"/specials/:menu_item_id\" });\n });\n\n var lastFailure;\n Router.reopenClass({\n defaultFailureHandler: {\n setup: function(error) {\n lastFailure = error;\n }\n }\n });\n\n var menuItem;\n\n App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);\n App.MenuItem.find = function(id) {\n menuItem = App.MenuItem.create({ id: id });\n return menuItem;\n };\n\n App.SpecialRoute = Ember.Route.extend({\n setup: function() {\n throw 'Setup error';\n }\n });\n\n bootApplication();\n\n Ember.run(function() {\n router.handleURL(\"/specials/1\");\n menuItem.resolve(menuItem);\n });\n\n setTimeout(function() {\n equal(lastFailure, 'Setup error');\n start();\n }, 100);\n});\n\ntest(\"Moving from one page to another triggers the correct callbacks\", 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.find = function(id) {\n menuItem = App.MenuItem.create({ id: id });\n return menuItem;\n };\n\n App.LoadingRoute = Ember.Route.extend({\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.home = 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 Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(Ember.$('h3', '#qunit-fixture').text(), \"Home\", \"The app is now in the initial state\");\n\n Ember.run(function() {\n router.transitionTo('special', App.MenuItem.create({ id: 1 }));\n });\n\n deepEqual(router.location.path, '/specials/1');\n});\n\ntest(\"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(function() {\n currentPath = get(this, 'currentPath');\n }, 'currentPath')\n });\n\n var menuItem;\n\n App.MenuItem = Ember.Object.extend(Ember.DeferredMixin);\n App.MenuItem.find = function(id) {\n menuItem = App.MenuItem.create({ id: id });\n return menuItem;\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 \"{{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 Ember.run(function() {\n bootApplication();\n });\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 router.transitionTo('special', App.MenuItem.create({ id: 1 }));\n });\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\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 events: {\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 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 start();\n }\n });\n\n container.register('controller', 'home', controller);\n\n bootApplication();\n\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\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\", 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 start();\n }\n }\n });\n\n Ember.TEMPLATES.home = Ember.Handlebars.compile(\n \"{{name}}\"\n );\n\n bootApplication();\n\n container.register('controller', 'home', Ember.Controller.extend());\n\n //var controller = router._container.controller.home = Ember.Controller.create();\n //controller.target = router;\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\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 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 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 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(\"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 events: {\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 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 Ember.run(function() {\n router.handleURL(\"/\");\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 var urlPropertyChangeCount = 0;\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 urlPropertyChangeCount++;\n });\n });\n\n equal(urlPropertyChangeCount, 0);\n\n Ember.run(function() {\n router.handleURL(\"/\");\n });\n\n equal(urlPropertyChangeCount, 2);\n\n Ember.run(function() {\n // Trigger the callback that would otherwise be triggered\n // when a user clicks the back or forward button.\n router.router.transitionTo('foo');\n router.router.transitionTo('bar');\n });\n\n equal(urlPropertyChangeCount, 4, 'triggered url property change');\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 Ember.run(function() {\n router.handleURL(\"/\");\n });\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 Ember.run(function() {\n router.handleURL(\"/\");\n });\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(\"It is possible to get the model from a parent route\", function() {\n expect(3);\n\n Router.map(function() {\n this.resource(\"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.PostRoute = 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 equal(this.modelFor('post'), currentPost);\n }\n });\n\n bootApplication();\n\n Ember.run(function() {\n currentPost = post1;\n router.handleURL(\"/posts/1/comments\");\n });\n\n Ember.run(function() {\n currentPost = post2;\n router.handleURL(\"/posts/2/comments\");\n });\n\n Ember.run(function() {\n currentPost = post3;\n router.handleURL(\"/posts/3/comments\");\n });\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(2);\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 Ember.run(function() {\n router.handleURL(\"/foo/bar/baz\");\n });\n\n equal(router.container.lookup('controller:application').get('currentPath'), 'home');\n equal(router.get('location').getURL(), \"/home\");\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 events: {\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 Ember.run(function() {\n router.handleURL(\"/foo/bar/baz\");\n });\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(3);\n\n Ember.TEMPLATES.index = 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 Ember.run(function() {\n router.handleURL(\"/top/middle/bottom\");\n });\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(\"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 Ember.run(function() {\n router.handleURL(\"/top/middle/bottom\");\n });\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(\"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 Ember.run(function() {\n router.handleURL(\"/top/middle/bottom\");\n });\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 Ember.run(function() {\n router.handleURL(\"/\");\n });\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 events: {\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 events: {\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 Ember.run(function() {\n router.handleURL(\"/posts/1\");\n });\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(\"Calling controllerFor for a non-route controller returns a controller\", function() {\n var controller;\n\n App.ApplicationRoute = Ember.Route.extend({\n setupController: function() {\n controller = this.controllerFor('nonDefinedRoute', {});\n }\n });\n\n bootApplication();\n\n ok(controller instanceof Ember.ObjectController, \"controller was able to be retrieved\");\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 Ember.Location.registerImplementation('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 // clean after test\n delete Ember.Location.implementations['historyTest'];\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: 'section',\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 Ember.run(function() {\n router.handleURL(\"/posts\");\n });\n\n equal(Ember.$('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 1, \"The posts/menu template was rendered\");\n equal(Ember.$('section.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 Ember.run(function() {\n router.handleURL(\"/posts/1\");\n });\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})();\n//@ sourceURL=ember/~tests/routing/basic_test");