(function() {
/*!
* @overview Ember - JavaScript Application Framework
* @copyright Copyright 2011-2017 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
* @version 2.17.0-beta.6
*/
var enifed, requireModule, Ember;
var mainContext = this; // Used in ember-environment/lib/global.js
(function() {
var isNode = typeof window === 'undefined' &&
typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
if (!isNode) {
Ember = this.Ember = this.Ember || {};
}
if (typeof Ember === 'undefined') { Ember = {}; }
if (typeof Ember.__loader === 'undefined') {
var registry = {};
var seen = {};
enifed = function(name, deps, callback) {
var value = { };
if (!callback) {
value.deps = [];
value.callback = deps;
} else {
value.deps = deps;
value.callback = callback;
}
registry[name] = value;
};
requireModule = function(name) {
return internalRequire(name, null);
};
// setup `require` module
requireModule['default'] = requireModule;
requireModule.has = function registryHas(moduleName) {
return !!registry[moduleName] || !!registry[moduleName + '/index'];
};
function missingModule(name, referrerName) {
if (referrerName) {
throw new Error('Could not find module ' + name + ' required by: ' + referrerName);
} else {
throw new Error('Could not find module ' + name);
}
}
function internalRequire(_name, referrerName) {
var name = _name;
var mod = registry[name];
if (!mod) {
name = name + '/index';
mod = registry[name];
}
var exports = seen[name];
if (exports !== undefined) {
return exports;
}
exports = seen[name] = {};
if (!mod) {
missingModule(_name, referrerName);
}
var deps = mod.deps;
var callback = mod.callback;
var reified = new Array(deps.length);
for (var i = 0; i < deps.length; i++) {
if (deps[i] === 'exports') {
reified[i] = exports;
} else if (deps[i] === 'require') {
reified[i] = requireModule;
} else {
reified[i] = internalRequire(deps[i], name);
}
}
callback.apply(this, reified);
return exports;
}
requireModule._eak_seen = registry;
Ember.__loader = {
define: enifed,
require: requireModule,
registry: registry
};
} else {
enifed = Ember.__loader.define;
requireModule = Ember.__loader.require;
}
})();
QUnit.module('ESLint | alias.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'alias.js should pass ESLint\n\n');
});
QUnit.module('ESLint | binding.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'binding.js should pass ESLint\n\n');
});
QUnit.module('ESLint | cache.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'cache.js should pass ESLint\n\n');
});
QUnit.module('ESLint | chains.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'chains.js should pass ESLint\n\n');
});
QUnit.module('ESLint | computed.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'computed.js should pass ESLint\n\n');
});
QUnit.module('ESLint | container.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'container.js should pass ESLint\n\n');
});
enifed('container/tests/container_test', ['ember-babel', 'ember-utils', 'ember-metal', 'ember/features', 'container', 'internal-test-helpers'], function (_emberBabel, _emberUtils, _emberMetal, _features, _container, _internalTestHelpers) {
'use strict';
QUnit.module('Container');
QUnit.test('A registered factory returns the same instance each time', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
var postController = container.lookup('controller:post');
ok(postController instanceof PostController, 'The lookup is an instance of the factory');
equal(postController, container.lookup('controller:post'));
});
QUnit.test('uses create time injections if factory has no extend', function () {
var registry = new _container.Registry();
var container = registry.container();
var AppleController = (0, _internalTestHelpers.factory)();
var PostController = (0, _internalTestHelpers.factory)();
PostController.extend = undefined; // remove extend
registry.register('controller:apple', AppleController);
registry.register('controller:post', PostController);
registry.injection('controller:post', 'apple', 'controller:apple');
var postController = container.lookup('controller:post');
ok(postController.apple instanceof AppleController, 'instance receives an apple of instance AppleController');
});
QUnit.test('A registered factory returns a fresh instance if singleton: false is passed as an option', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
var postController1 = container.lookup('controller:post');
var postController2 = container.lookup('controller:post', { singleton: false });
var postController3 = container.lookup('controller:post', { singleton: false });
var postController4 = container.lookup('controller:post');
equal(postController1.toString(), postController4.toString(), 'Singleton factories looked up normally return the same value');
notEqual(postController1.toString(), postController2.toString(), 'Singleton factories are not equal to factories looked up with singleton: false');
notEqual(postController2.toString(), postController3.toString(), 'Two factories looked up with singleton: false are not equal');
notEqual(postController3.toString(), postController4.toString(), 'A singleton factory looked up after a factory called with singleton: false is not equal');
ok(postController1 instanceof PostController, 'All instances are instances of the registered factory');
ok(postController2 instanceof PostController, 'All instances are instances of the registered factory');
ok(postController3 instanceof PostController, 'All instances are instances of the registered factory');
ok(postController4 instanceof PostController, 'All instances are instances of the registered factory');
});
QUnit.test('A factory type with a registered injection\'s instances receive that injection', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
var Store = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
registry.register('store:main', Store);
registry.typeInjection('controller', 'store', 'store:main');
var postController = container.lookup('controller:post');
var store = container.lookup('store:main');
equal(postController.store, store);
});
QUnit.test('An individual factory with a registered injection receives the injection', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
var Store = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
registry.register('store:main', Store);
registry.injection('controller:post', 'store', 'store:main');
var postController = container.lookup('controller:post');
var store = container.lookup('store:main');
equal(postController.store, store, 'has the correct store injected');
});
QUnit.test('A factory with both type and individual injections', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
var Store = (0, _internalTestHelpers.factory)();
var Router = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
registry.register('store:main', Store);
registry.register('router:main', Router);
registry.injection('controller:post', 'store', 'store:main');
registry.typeInjection('controller', 'router', 'router:main');
var postController = container.lookup('controller:post');
var store = container.lookup('store:main');
var router = container.lookup('router:main');
equal(postController.store, store);
equal(postController.router, router);
});
QUnit.test('A non-singleton instance is never cached', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostView = (0, _internalTestHelpers.factory)();
registry.register('view:post', PostView, { singleton: false });
var postView1 = container.lookup('view:post');
var postView2 = container.lookup('view:post');
ok(postView1 !== postView2, 'Non-singletons are not cached');
});
QUnit.test('A non-instantiated property is not instantiated', function () {
var registry = new _container.Registry();
var container = registry.container();
var template = function () {};
registry.register('template:foo', template, { instantiate: false });
equal(container.lookup('template:foo'), template);
});
QUnit.test('A failed lookup returns undefined', function () {
var registry = new _container.Registry();
var container = registry.container();
equal(container.lookup('doesnot:exist'), undefined);
});
QUnit.test('An invalid factory throws an error', function () {
var registry = new _container.Registry();
var container = registry.container();
registry.register('controller:foo', {});
throws(function () {
container.lookup('controller:foo');
}, /Failed to create an instance of \'controller:foo\'/);
});
QUnit.test('Injecting a failed lookup raises an error', function () {
var registry = new _container.Registry();
var container = registry.container();
var fooInstance = {};
var fooFactory = {};
var Foo = {
create: function (args) {
return fooInstance;
},
extend: function (args) {
return fooFactory;
}
};
registry.register('model:foo', Foo);
registry.injection('model:foo', 'store', 'store:main');
throws(function () {
container.lookup('model:foo');
});
});
QUnit.test('Injecting a falsy value does not raise an error', function () {
var registry = new _container.Registry();
var container = registry.container();
var ApplicationController = (0, _internalTestHelpers.factory)();
registry.register('controller:application', ApplicationController);
registry.register('user:current', null, { instantiate: false });
registry.injection('controller:application', 'currentUser', 'user:current');
strictEqual(container.lookup('controller:application').currentUser, null);
});
QUnit.test('The container returns same value each time even if the value is falsy', function () {
var registry = new _container.Registry();
var container = registry.container();
registry.register('falsy:value', null, { instantiate: false });
strictEqual(container.lookup('falsy:value'), container.lookup('falsy:value'));
});
QUnit.test('Destroying the container destroys any cached singletons', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
var PostView = (0, _internalTestHelpers.factory)();
var template = function () {};
registry.register('controller:post', PostController);
registry.register('view:post', PostView, { singleton: false });
registry.register('template:post', template, { instantiate: false });
registry.injection('controller:post', 'postView', 'view:post');
var postController = container.lookup('controller:post');
var postView = postController.postView;
ok(postView instanceof PostView, 'The non-singleton was injected');
container.destroy();
ok(postController.isDestroyed, 'Singletons are destroyed');
ok(!postView.isDestroyed, 'Non-singletons are not destroyed');
});
QUnit.test('The container can use a registry hook to resolve factories lazily', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
registry.resolver = {
resolve: function (fullName) {
if (fullName === 'controller:post') {
return PostController;
}
}
};
var postController = container.lookup('controller:post');
ok(postController instanceof PostController, 'The correct factory was provided');
});
QUnit.test('The container normalizes names before resolving', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
registry.normalizeFullName = function (fullName) {
return 'controller:post';
};
registry.register('controller:post', PostController);
var postController = container.lookup('controller:normalized');
ok(postController instanceof PostController, 'Normalizes the name before resolving');
});
QUnit.test('The container normalizes names when looking factory up', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
registry.normalizeFullName = function (fullName) {
return 'controller:post';
};
registry.register('controller:post', PostController);
var fact = container.factoryFor('controller:normalized');
var factInstance = fact.create();
ok(factInstance instanceof PostController, 'Normalizes the name');
});
QUnit.test('Options can be registered that should be applied to a given factory', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostView = (0, _internalTestHelpers.factory)();
registry.resolver = {
resolve: function (fullName) {
if (fullName === 'view:post') {
return PostView;
}
}
};
registry.options('view:post', { instantiate: true, singleton: false });
var postView1 = container.lookup('view:post');
var postView2 = container.lookup('view:post');
ok(postView1 instanceof PostView, 'The correct factory was provided');
ok(postView2 instanceof PostView, 'The correct factory was provided');
ok(postView1 !== postView2, 'The two lookups are different');
});
QUnit.test('Options can be registered that should be applied to all factories for a given type', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostView = (0, _internalTestHelpers.factory)();
registry.resolver = {
resolve: function (fullName) {
if (fullName === 'view:post') {
return PostView;
}
}
};
registry.optionsForType('view', { singleton: false });
var postView1 = container.lookup('view:post');
var postView2 = container.lookup('view:post');
ok(postView1 instanceof PostView, 'The correct factory was provided');
ok(postView2 instanceof PostView, 'The correct factory was provided');
ok(postView1 !== postView2, 'The two lookups are different');
});
QUnit.test('An injected non-singleton instance is never cached', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostView = (0, _internalTestHelpers.factory)();
var PostViewHelper = (0, _internalTestHelpers.factory)();
registry.register('view:post', PostView, { singleton: false });
registry.register('view_helper:post', PostViewHelper, { singleton: false });
registry.injection('view:post', 'viewHelper', 'view_helper:post');
var postView1 = container.lookup('view:post');
var postView2 = container.lookup('view:post');
ok(postView1.viewHelper !== postView2.viewHelper, 'Injected non-singletons are not cached');
});
QUnit.test('Factory resolves are cached', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
var resolveWasCalled = [];
registry.resolve = function (fullName) {
resolveWasCalled.push(fullName);
return PostController;
};
deepEqual(resolveWasCalled, []);
container.factoryFor('controller:post');
deepEqual(resolveWasCalled, ['controller:post']);
container.factoryFor('controller:post');
deepEqual(resolveWasCalled, ['controller:post']);
});
QUnit.test('factory for non extendables (MODEL) resolves are cached', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
var resolveWasCalled = [];
registry.resolve = function (fullName) {
resolveWasCalled.push(fullName);
return PostController;
};
deepEqual(resolveWasCalled, []);
container.factoryFor('model:post');
deepEqual(resolveWasCalled, ['model:post']);
container.factoryFor('model:post');
deepEqual(resolveWasCalled, ['model:post']);
});
QUnit.test('factory for non extendables resolves are cached', function () {
var registry = new _container.Registry();
var container = registry.container();
var PostController = {};
var resolveWasCalled = [];
registry.resolve = function (fullName) {
resolveWasCalled.push(fullName);
return PostController;
};
deepEqual(resolveWasCalled, []);
container.factoryFor('foo:post');
deepEqual(resolveWasCalled, ['foo:post']);
container.factoryFor('foo:post');
deepEqual(resolveWasCalled, ['foo:post']);
});
QUnit.test('A factory\'s lazy injections are validated when first instantiated', function () {
var registry = new _container.Registry();
var container = registry.container();
var Apple = (0, _internalTestHelpers.factory)();
var Orange = (0, _internalTestHelpers.factory)();
Apple.reopenClass({
_lazyInjections: function () {
return ['orange:main', 'banana:main'];
}
});
registry.register('apple:main', Apple);
registry.register('orange:main', Orange);
throws(function () {
container.lookup('apple:main');
}, /Attempting to inject an unknown injection: 'banana:main'/);
});
QUnit.test('Lazy injection validations are cached', function () {
expect(1);
var registry = new _container.Registry();
var container = registry.container();
var Apple = (0, _internalTestHelpers.factory)();
var Orange = (0, _internalTestHelpers.factory)();
Apple.reopenClass({
_lazyInjections: function () {
ok(true, 'should call lazy injection method');
return ['orange:main'];
}
});
registry.register('apple:main', Apple);
registry.register('orange:main', Orange);
container.lookup('apple:main');
container.lookup('apple:main');
});
QUnit.test('An object with its owner pre-set should be returned from ownerInjection', function () {
var owner = {};
var registry = new _container.Registry();
var container = registry.container({ owner: owner });
var result = container.ownerInjection();
equal(result[_emberUtils.OWNER], owner, 'owner is properly included');
});
QUnit.test('lookup passes options through to expandlocallookup', function (assert) {
var registry = new _container.Registry();
var container = registry.container();
var PostController = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
registry.expandLocalLookup = function (fullName, options) {
assert.ok(true, 'expandLocalLookup was called');
assert.equal(fullName, 'foo:bar');
assert.deepEqual(options, { source: 'baz:qux' });
return 'controller:post';
};
var PostControllerLookupResult = container.lookup('foo:bar', { source: 'baz:qux' });
assert.ok(PostControllerLookupResult instanceof PostController);
});
QUnit.test('#factoryFor class is registered class', function (assert) {
var registry = new _container.Registry();
var container = registry.container();
var Component = (0, _internalTestHelpers.factory)();
registry.register('component:foo-bar', Component);
var factoryManager = container.factoryFor('component:foo-bar');
assert.deepEqual(factoryManager.class, Component, 'No double extend');
});
QUnit.test('#factoryFor must supply a fullname', function (assert) {
var registry = new _container.Registry();
var container = registry.container();
assert.throws(function () {
container.factoryFor('chad-bar');
}, /Invalid Fullname, expected: 'type:name' got: chad-bar/);
});
QUnit.test('#factoryFor returns a factory manager', function (assert) {
var registry = new _container.Registry();
var container = registry.container();
var Component = (0, _internalTestHelpers.factory)();
registry.register('component:foo-bar', Component);
var factoryManager = container.factoryFor('component:foo-bar');
assert.ok(factoryManager.create);
assert.ok(factoryManager.class);
});
QUnit.test('#factoryFor returns a cached factory manager for the same type', function (assert) {
var registry = new _container.Registry();
var container = registry.container();
var Component = (0, _internalTestHelpers.factory)();
registry.register('component:foo-bar', Component);
registry.register('component:baz-bar', Component);
var factoryManager1 = container.factoryFor('component:foo-bar');
var factoryManager2 = container.factoryFor('component:foo-bar');
var factoryManager3 = container.factoryFor('component:baz-bar');
assert.equal(factoryManager1, factoryManager2, 'cache hit');
assert.notEqual(factoryManager1, factoryManager3, 'cache miss');
});
QUnit.test('#factoryFor class returns the factory function', function (assert) {
var registry = new _container.Registry();
var container = registry.container();
var Component = (0, _internalTestHelpers.factory)();
registry.register('component:foo-bar', Component);
var factoryManager = container.factoryFor('component:foo-bar');
assert.deepEqual(factoryManager.class, Component, 'No double extend');
});
QUnit.test('#factoryFor instance have a common parent', function (assert) {
var registry = new _container.Registry();
var container = registry.container();
var Component = (0, _internalTestHelpers.factory)();
registry.register('component:foo-bar', Component);
var factoryManager1 = container.factoryFor('component:foo-bar');
var factoryManager2 = container.factoryFor('component:foo-bar');
var instance1 = factoryManager1.create({ foo: 'foo' });
var instance2 = factoryManager2.create({ bar: 'bar' });
assert.deepEqual(instance1.constructor, instance2.constructor);
});
QUnit.test('can properly reset cache', function (assert) {
var registry = new _container.Registry();
var container = registry.container();
var Component = (0, _internalTestHelpers.factory)();
registry.register('component:foo-bar', Component);
var factory1 = container.factoryFor('component:foo-bar');
var factory2 = container.factoryFor('component:foo-bar');
var instance1 = container.lookup('component:foo-bar');
var instance2 = container.lookup('component:foo-bar');
assert.equal(instance1, instance2);
assert.equal(factory1, factory2);
container.reset();
var factory3 = container.factoryFor('component:foo-bar');
var instance3 = container.lookup('component:foo-bar');
assert.notEqual(instance1, instance3);
assert.notEqual(factory1, factory3);
});
QUnit.test('#factoryFor created instances come with instance injections', function (assert) {
var registry = new _container.Registry();
var container = registry.container();
var Component = (0, _internalTestHelpers.factory)();
var Ajax = (0, _internalTestHelpers.factory)();
registry.register('component:foo-bar', Component);
registry.register('util:ajax', Ajax);
registry.injection('component:foo-bar', 'ajax', 'util:ajax');
var componentFactory = container.factoryFor('component:foo-bar');
var component = componentFactory.create();
assert.ok(component.ajax);
assert.ok(component.ajax instanceof Ajax);
});
QUnit.test('#factoryFor options passed to create clobber injections', function (assert) {
var registry = new _container.Registry();
var container = registry.container();
var Component = (0, _internalTestHelpers.factory)();
var Ajax = (0, _internalTestHelpers.factory)();
registry.register('component:foo-bar', Component);
registry.register('util:ajax', Ajax);
registry.injection('component:foo-bar', 'ajax', 'util:ajax');
var componentFactory = container.factoryFor('component:foo-bar');
var instrance = componentFactory.create({ ajax: 'fetch' });
assert.equal(instrance.ajax, 'fetch');
});
QUnit.test('#factoryFor does not add properties to the object being instantiated when _initFactory is present', function (assert) {
var owner = {};
var registry = new _container.Registry();
var container = registry.container();
var factory = void 0;
var Component = function () {
function Component() {
(0, _emberBabel.classCallCheck)(this, Component);
}
Component._initFactory = function _initFactory(_factory) {
factory = _factory;
};
Component.create = function create(options) {
var instance = new this();
(0, _emberUtils.assign)(instance, options);
return instance;
};
return Component;
}();
registry.register('component:foo-bar', Component);
var componentFactory = container.factoryFor('component:foo-bar');
var instance = componentFactory.create();
// note: _guid and isDestroyed are being set in the `factory` constructor
// not via registry/container shenanigans
assert.deepEqual(Object.keys(instance), []);
});
// this is skipped until templates and the glimmer environment do not require `OWNER` to be
// passed in as constructor args
QUnit.skip('#factoryFor does not add properties to the object being instantiated', function (assert) {
var owner = {};
var registry = new _container.Registry();
var container = registry.container();
var factory = void 0;
var Component = function () {
function Component() {
(0, _emberBabel.classCallCheck)(this, Component);
}
Component.create = function create(options) {
var instance = new this();
(0, _emberUtils.assign)(instance, options);
return instance;
};
return Component;
}();
registry.register('component:foo-bar', Component);
var componentFactory = container.factoryFor('component:foo-bar');
var instance = componentFactory.create();
// note: _guid and isDestroyed are being set in the `factory` constructor
// not via registry/container shenanigans
assert.deepEqual(Object.keys(instance), []);
});
if (_features.EMBER_MODULE_UNIFICATION) {
QUnit.module('Container module unification');
QUnit.test('The container can pass a source to factoryFor', function (assert) {
var PrivateComponent = (0, _internalTestHelpers.factory)();
var lookup = 'component:my-input';
var expectedSource = 'template:routes/application';
var registry = new _container.Registry();
var resolveCount = 0;
registry.resolve = function (fullName, _ref) {
var source = _ref.source;
resolveCount++;
if (fullName === lookup && source === expectedSource) {
return PrivateComponent;
}
};
var container = registry.container();
assert.strictEqual(container.factoryFor(lookup, { source: expectedSource }).class, PrivateComponent, 'The correct factory was provided');
assert.strictEqual(container.factoryFor(lookup, { source: expectedSource }).class, PrivateComponent, 'The correct factory was provided again');
assert.equal(resolveCount, 1, 'resolve called only once and a cached factory was returned the second time');
});
QUnit.test('The container can pass a source to lookup', function (assert) {
var PrivateComponent = (0, _internalTestHelpers.factory)();
var lookup = 'component:my-input';
var expectedSource = 'template:routes/application';
var registry = new _container.Registry();
registry.resolve = function (fullName, _ref2) {
var source = _ref2.source;
if (fullName === lookup && source === expectedSource) {
return PrivateComponent;
}
};
var container = registry.container();
var result = container.lookup(lookup, { source: expectedSource });
assert.ok(result instanceof PrivateComponent, 'The correct factory was provided');
assert.ok(container.cache['template:routes/application:component:my-input'] instanceof PrivateComponent, 'The correct factory was stored in the cache with the correct key which includes the source.');
});
}
});
QUnit.module('ESLint | container/tests/container_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'container/tests/container_test.js should pass ESLint\n\n');
});
enifed('container/tests/owner_test', ['ember-utils'], function (_emberUtils) {
'use strict';
QUnit.module('Owner', {});
QUnit.test('An owner can be set with `setOwner` and retrieved with `getOwner`', function () {
var owner = {};
var obj = {};
strictEqual((0, _emberUtils.getOwner)(obj), undefined, 'owner has not been set');
(0, _emberUtils.setOwner)(obj, owner);
strictEqual((0, _emberUtils.getOwner)(obj), owner, 'owner has been set');
strictEqual(obj[_emberUtils.OWNER], owner, 'owner has been set to the OWNER symbol');
});
});
QUnit.module('ESLint | container/tests/owner_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'container/tests/owner_test.js should pass ESLint\n\n');
});
enifed('container/tests/registry_test', ['container', 'internal-test-helpers', 'ember/features'], function (_container, _internalTestHelpers, _features) {
'use strict';
QUnit.module('Registry');
QUnit.test('A registered factory is returned from resolve', function () {
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
var PostControllerFactory = registry.resolve('controller:post');
ok(PostControllerFactory, 'factory is returned');
ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController');
});
QUnit.test('The registered factory returned from resolve is the same factory each time', function () {
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
deepEqual(registry.resolve('controller:post'), registry.resolve('controller:post'), 'The return of resolve is always the same');
});
QUnit.test('The registered value returned from resolve is the same value each time even if the value is falsy', function () {
var registry = new _container.Registry();
registry.register('falsy:value', null, { instantiate: false });
strictEqual(registry.resolve('falsy:value'), registry.resolve('falsy:value'), 'The return of resolve is always the same');
});
QUnit.test('The value returned from resolver is the same value as the original value even if the value is falsy', function () {
var resolver = {
resolve: function (fullName) {
if (fullName === 'falsy:value') {
return null;
}
}
};
var registry = new _container.Registry({ resolver: resolver });
strictEqual(registry.resolve('falsy:value'), null);
});
QUnit.test('A registered factory returns true for `has` if an item is registered', function () {
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
equal(registry.has('controller:post'), true, 'The `has` method returned true for registered factories');
equal(registry.has('controller:posts'), false, 'The `has` method returned false for unregistered factories');
});
QUnit.test('Throw exception when trying to inject `type:thing` on all type(s)', function () {
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
throws(function () {
registry.typeInjection('controller', 'injected', 'controller:post');
}, /Cannot inject a 'controller:post' on other controller\(s\)\./);
});
QUnit.test('The registry can take a hook to resolve factories lazily', function () {
var PostController = (0, _internalTestHelpers.factory)();
var resolver = {
resolve: function (fullName) {
if (fullName === 'controller:post') {
return PostController;
}
}
};
var registry = new _container.Registry({ resolver: resolver });
strictEqual(registry.resolve('controller:post'), PostController, 'The correct factory was provided');
});
QUnit.test('The registry respects the resolver hook for `has`', function () {
var PostController = (0, _internalTestHelpers.factory)();
var resolver = {
resolve: function (fullName) {
if (fullName === 'controller:post') {
return PostController;
}
}
};
var registry = new _container.Registry({ resolver: resolver });
ok(registry.has('controller:post'), 'the `has` method uses the resolver hook');
});
QUnit.test('The registry normalizes names when resolving', function () {
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
registry.normalizeFullName = function (fullName) {
return 'controller:post';
};
registry.register('controller:post', PostController);
var type = registry.resolve('controller:normalized');
strictEqual(type, PostController, 'Normalizes the name when resolving');
});
QUnit.test('The registry normalizes names when checking if the factory is registered', function () {
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
registry.normalizeFullName = function (fullName) {
return fullName === 'controller:normalized' ? 'controller:post' : fullName;
};
registry.register('controller:post', PostController);
var isPresent = registry.has('controller:normalized');
equal(isPresent, true, 'Normalizes the name when checking if the factory or instance is present');
});
QUnit.test('validateFullName throws an error if name is incorrect', function () {
expect(2);
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
registry.normalize = function (fullName) {
return 'controller:post';
};
registry.register('controller:post', PostController);
throws(function () {
registry.validateFullName('post');
}, /TypeError: Invalid Fullname, expected: 'type:name' got: post/);
throws(function () {
registry.validateFullName('route:http://foo.bar.com/baz');
}, /TypeError: Invalid Fullname, expected: 'type:name' got: route:http:\/\/foo.bar.com\/baz/);
});
QUnit.test('The registry normalizes names when injecting', function () {
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
var user = { name: 'Stef' };
registry.normalize = function (fullName) {
return 'controller:post';
};
registry.register('controller:post', PostController);
registry.register('user:post', user, { instantiate: false });
registry.injection('controller:post', 'user', 'controller:normalized');
deepEqual(registry.resolve('controller:post'), user, 'Normalizes the name when injecting');
});
QUnit.test('cannot register an `undefined` factory', function () {
var registry = new _container.Registry();
throws(function () {
registry.register('controller:apple', undefined);
}, '');
});
QUnit.test('can re-register a factory', function () {
var registry = new _container.Registry();
var FirstApple = (0, _internalTestHelpers.factory)('first');
var SecondApple = (0, _internalTestHelpers.factory)('second');
registry.register('controller:apple', FirstApple);
registry.register('controller:apple', SecondApple);
ok(registry.resolve('controller:apple').create() instanceof SecondApple);
});
QUnit.test('cannot re-register a factory if it has been resolved', function () {
var registry = new _container.Registry();
var FirstApple = (0, _internalTestHelpers.factory)('first');
var SecondApple = (0, _internalTestHelpers.factory)('second');
registry.register('controller:apple', FirstApple);
strictEqual(registry.resolve('controller:apple'), FirstApple);
throws(function () {
registry.register('controller:apple', SecondApple);
}, /Cannot re-register: 'controller:apple', as it has already been resolved\./);
strictEqual(registry.resolve('controller:apple'), FirstApple);
});
QUnit.test('registry.has should not accidentally cause injections on that factory to be run. (Mitigate merely on observing)', function () {
expect(1);
var registry = new _container.Registry();
var FirstApple = (0, _internalTestHelpers.factory)('first');
var SecondApple = (0, _internalTestHelpers.factory)('second');
SecondApple.extend = function (a, b, c) {
ok(false, 'should not extend or touch the injected model, merely to inspect existence of another');
};
registry.register('controller:apple', FirstApple);
registry.register('controller:second-apple', SecondApple);
registry.injection('controller:apple', 'badApple', 'controller:second-apple');
ok(registry.has('controller:apple'));
});
QUnit.test('registry.has should not error for invalid fullNames)', function () {
expect(1);
var registry = new _container.Registry();
ok(!registry.has('foo:bar:baz'));
});
QUnit.test('once resolved, always return the same result', function () {
expect(1);
var registry = new _container.Registry();
registry.resolver = {
resolve: function () {
return 'bar';
}
};
var Bar = registry.resolve('models:bar');
registry.resolver = {
resolve: function () {
return 'not bar';
}
};
equal(registry.resolve('models:bar'), Bar);
});
QUnit.test('factory resolves are cached', function () {
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
var resolveWasCalled = [];
registry.resolver = {
resolve: function (fullName) {
resolveWasCalled.push(fullName);
return PostController;
}
};
deepEqual(resolveWasCalled, []);
registry.resolve('controller:post');
deepEqual(resolveWasCalled, ['controller:post']);
registry.resolve('controller:post');
deepEqual(resolveWasCalled, ['controller:post']);
});
QUnit.test('factory for non extendables (MODEL) resolves are cached', function () {
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
var resolveWasCalled = [];
registry.resolver = {
resolve: function (fullName) {
resolveWasCalled.push(fullName);
return PostController;
}
};
deepEqual(resolveWasCalled, []);
registry.resolve('model:post');
deepEqual(resolveWasCalled, ['model:post']);
registry.resolve('model:post');
deepEqual(resolveWasCalled, ['model:post']);
});
QUnit.test('factory for non extendables resolves are cached', function () {
var registry = new _container.Registry();
var PostController = {};
var resolveWasCalled = [];
registry.resolver = {
resolve: function (fullName) {
resolveWasCalled.push(fullName);
return PostController;
}
};
deepEqual(resolveWasCalled, []);
registry.resolve('foo:post');
deepEqual(resolveWasCalled, ['foo:post']);
registry.resolve('foo:post');
deepEqual(resolveWasCalled, ['foo:post']);
});
QUnit.test('registry.container creates a container', function () {
var registry = new _container.Registry();
var PostController = (0, _internalTestHelpers.factory)();
registry.register('controller:post', PostController);
var container = registry.container();
var postController = container.lookup('controller:post');
ok(postController instanceof PostController, 'The lookup is an instance of the registered factory');
});
QUnit.test('`describe` will be handled by the resolver, then by the fallback registry, if available', function () {
var fallback = {
describe: function (fullName) {
return fullName + '-fallback';
}
};
var resolver = {
lookupDescription: function (fullName) {
return fullName + '-resolver';
}
};
var registry = new _container.Registry({ fallback: fallback, resolver: resolver });
equal(registry.describe('controller:post'), 'controller:post-resolver', '`describe` handled by the resolver first.');
registry.resolver = null;
equal(registry.describe('controller:post'), 'controller:post-fallback', '`describe` handled by fallback registry next.');
registry.fallback = null;
equal(registry.describe('controller:post'), 'controller:post', '`describe` by default returns argument.');
});
QUnit.test('`normalizeFullName` will be handled by the resolver, then by the fallback registry, if available', function () {
var fallback = {
normalizeFullName: function (fullName) {
return fullName + '-fallback';
}
};
var resolver = {
normalize: function (fullName) {
return fullName + '-resolver';
}
};
var registry = new _container.Registry({ fallback: fallback, resolver: resolver });
equal(registry.normalizeFullName('controller:post'), 'controller:post-resolver', '`normalizeFullName` handled by the resolver first.');
registry.resolver = null;
equal(registry.normalizeFullName('controller:post'), 'controller:post-fallback', '`normalizeFullName` handled by fallback registry next.');
registry.fallback = null;
equal(registry.normalizeFullName('controller:post'), 'controller:post', '`normalizeFullName` by default returns argument.');
});
QUnit.test('`makeToString` will be handled by the resolver, then by the fallback registry, if available', function () {
var fallback = {
makeToString: function (fullName) {
return fullName + '-fallback';
}
};
var resolver = {
makeToString: function (fullName) {
return fullName + '-resolver';
}
};
var registry = new _container.Registry({ fallback: fallback, resolver: resolver });
equal(registry.makeToString('controller:post'), 'controller:post-resolver', '`makeToString` handled by the resolver first.');
registry.resolver = null;
equal(registry.makeToString('controller:post'), 'controller:post-fallback', '`makeToString` handled by fallback registry next.');
registry.fallback = null;
equal(registry.makeToString('controller:post'), 'controller:post', '`makeToString` by default returns argument.');
});
QUnit.test('`resolve` can be handled by a fallback registry', function () {
var fallback = new _container.Registry();
var registry = new _container.Registry({ fallback: fallback });
var PostController = (0, _internalTestHelpers.factory)();
fallback.register('controller:post', PostController);
var PostControllerFactory = registry.resolve('controller:post');
ok(PostControllerFactory, 'factory is returned');
ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController');
});
QUnit.test('`has` can be handled by a fallback registry', function () {
var fallback = new _container.Registry();
var registry = new _container.Registry({ fallback: fallback });
var PostController = (0, _internalTestHelpers.factory)();
fallback.register('controller:post', PostController);
equal(registry.has('controller:post'), true, 'Fallback registry is checked for registration');
});
QUnit.test('`getInjections` includes injections from a fallback registry', function () {
var fallback = new _container.Registry();
var registry = new _container.Registry({ fallback: fallback });
equal(registry.getInjections('model:user').length, 0, 'No injections in the primary registry');
fallback.injection('model:user', 'post', 'model:post');
equal(registry.getInjections('model:user').length, 1, 'Injections from the fallback registry are merged');
});
QUnit.test('`getTypeInjections` includes type injections from a fallback registry', function () {
var fallback = new _container.Registry();
var registry = new _container.Registry({ fallback: fallback });
equal(registry.getTypeInjections('model').length, 0, 'No injections in the primary registry');
fallback.injection('model', 'source', 'source:main');
equal(registry.getTypeInjections('model').length, 1, 'Injections from the fallback registry are merged');
});
QUnit.test('`knownForType` contains keys for each item of a given type', function () {
var registry = new _container.Registry();
registry.register('foo:bar-baz', 'baz');
registry.register('foo:qux-fez', 'fez');
var found = registry.knownForType('foo');
deepEqual(found, {
'foo:bar-baz': true,
'foo:qux-fez': true
});
});
QUnit.test('`knownForType` includes fallback registry results', function () {
var fallback = new _container.Registry();
var registry = new _container.Registry({ fallback: fallback });
registry.register('foo:bar-baz', 'baz');
registry.register('foo:qux-fez', 'fez');
fallback.register('foo:zurp-zorp', 'zorp');
var found = registry.knownForType('foo');
deepEqual(found, {
'foo:bar-baz': true,
'foo:qux-fez': true,
'foo:zurp-zorp': true
});
});
QUnit.test('`knownForType` is called on the resolver if present', function () {
expect(3);
var resolver = {
knownForType: function (type) {
ok(true, 'knownForType called on the resolver');
equal(type, 'foo', 'the type was passed through');
return { 'foo:yorp': true };
}
};
var registry = new _container.Registry({
resolver: resolver
});
registry.register('foo:bar-baz', 'baz');
var found = registry.knownForType('foo');
deepEqual(found, {
'foo:yorp': true,
'foo:bar-baz': true
});
});
QUnit.test('A registry can be created with a deprecated `resolver` function instead of an object', function () {
expect(2);
var registry = void 0;
expectDeprecation(function () {
registry = new _container.Registry({
resolver: function (fullName) {
return fullName + '-resolved';
}
});
}, 'Passing a `resolver` function into a Registry is deprecated. Please pass in a Resolver object with a `resolve` method.');
equal(registry.resolve('foo:bar'), 'foo:bar-resolved', '`resolve` still calls the deprecated function');
});
QUnit.test('resolver.expandLocalLookup is not required', function (assert) {
assert.expect(1);
var registry = new _container.Registry({
resolver: {}
});
var result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
});
assert.equal(result, null);
});
QUnit.test('expandLocalLookup is called on the resolver if present', function (assert) {
assert.expect(4);
var resolver = {
expandLocalLookup: function (targetFullName, sourceFullName) {
assert.ok(true, 'expandLocalLookup is called on the resolver');
assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through');
assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through');
return 'foo:qux/bar';
}
};
var registry = new _container.Registry({
resolver: resolver
});
var result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
});
assert.equal(result, 'foo:qux/bar');
});
QUnit.test('`expandLocalLookup` is handled by the resolver, then by the fallback registry, if available', function (assert) {
assert.expect(9);
var fallbackResolver = {
expandLocalLookup: function (targetFullName, sourceFullName) {
assert.ok(true, 'expandLocalLookup is called on the fallback resolver');
assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through');
assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through');
return 'foo:qux/bar-fallback';
}
};
var resolver = {
expandLocalLookup: function (targetFullName, sourceFullName) {
assert.ok(true, 'expandLocalLookup is called on the resolver');
assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through');
assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through');
return 'foo:qux/bar-resolver';
}
};
var fallbackRegistry = new _container.Registry({
resolver: fallbackResolver
});
var registry = new _container.Registry({
fallback: fallbackRegistry,
resolver: resolver
});
var result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
});
assert.equal(result, 'foo:qux/bar-resolver', 'handled by the resolver');
registry.resolver = null;
result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
});
assert.equal(result, 'foo:qux/bar-fallback', 'handled by the fallback registry');
registry.fallback = null;
result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
});
assert.equal(result, null, 'null is returned by default when no resolver or fallback registry is present');
});
QUnit.test('resolver.expandLocalLookup result is cached', function (assert) {
assert.expect(3);
var result = void 0;
var resolver = {
expandLocalLookup: function (targetFullName, sourceFullName) {
assert.ok(true, 'expandLocalLookup is called on the resolver');
return 'foo:qux/bar';
}
};
var registry = new _container.Registry({
resolver: resolver
});
result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
});
assert.equal(result, 'foo:qux/bar');
result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
});
assert.equal(result, 'foo:qux/bar');
});
QUnit.test('resolver.expandLocalLookup cache is busted when any unregister is called', function (assert) {
assert.expect(4);
var result = void 0;
var resolver = {
expandLocalLookup: function (targetFullName, sourceFullName) {
assert.ok(true, 'expandLocalLookup is called on the resolver');
return 'foo:qux/bar';
}
};
var registry = new _container.Registry({
resolver: resolver
});
result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
});
assert.equal(result, 'foo:qux/bar');
registry.unregister('foo:bar');
result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
});
assert.equal(result, 'foo:qux/bar');
});
QUnit.test('resolve calls expandLocallookup when it receives options.source', function (assert) {
assert.expect(3);
var resolver = {
resolve: function () {},
expandLocalLookup: function (targetFullName, sourceFullName) {
assert.ok(true, 'expandLocalLookup is called on the resolver');
assert.equal(targetFullName, 'foo:bar', 'the targetFullName was passed through');
assert.equal(sourceFullName, 'baz:qux', 'the sourceFullName was passed through');
return 'foo:qux/bar';
}
};
var registry = new _container.Registry({
resolver: resolver
});
registry.resolve('foo:bar', {
source: 'baz:qux'
});
});
QUnit.test('has uses expandLocalLookup', function (assert) {
assert.expect(5);
var resolvedFullNames = [];
var result = void 0;
var resolver = {
resolve: function (name) {
if (_features.EMBER_MODULE_UNIFICATION && name === 'foo:baz') {
return;
}
resolvedFullNames.push(name);
return 'yippie!';
},
expandLocalLookup: function (targetFullName, sourceFullName) {
assert.ok(true, 'expandLocalLookup is called on the resolver');
if (targetFullName === 'foo:bar') {
return 'foo:qux/bar';
} else {
return null;
}
}
};
var registry = new _container.Registry({
resolver: resolver
});
result = registry.has('foo:bar', {
source: 'baz:qux'
});
assert.ok(result, 'found foo:bar/qux');
result = registry.has('foo:baz', {
source: 'baz:qux'
});
assert.ok(!result, 'foo:baz/qux not found');
assert.deepEqual(['foo:qux/bar'], resolvedFullNames);
});
QUnit.module('Registry privatize');
QUnit.test('valid format', function (assert) {
var privatized = (0, _container.privatize)(['secret:factory']);
var matched = privatized.match(/^([^:]+):([^:]+)-(\d+)$/);
assert.ok(matched, 'privatized format was recognized');
assert.equal(matched[1], 'secret');
assert.equal(matched[2], 'factory');
assert.ok(/^\d+$/.test(matched[3]));
});
if (_features.EMBER_MODULE_UNIFICATION) {
QUnit.module('Registry module unification');
QUnit.test('The registry can pass a source to the resolver', function (assert) {
var PrivateComponent = (0, _internalTestHelpers.factory)();
var lookup = 'component:my-input';
var source = 'template:routes/application';
var resolveCount = 0;
var resolver = {
resolve: function (fullName, src) {
resolveCount++;
if (fullName === lookup && src === source) {
return PrivateComponent;
}
}
};
var registry = new _container.Registry({ resolver: resolver });
registry.normalize = function (name) {
return name;
};
assert.strictEqual(registry.resolve(lookup, { source: source }), PrivateComponent, 'The correct factory was provided');
assert.strictEqual(registry.resolve(lookup, { source: source }), PrivateComponent, 'The correct factory was provided again');
assert.equal(resolveCount, 1, 'resolve called only once and a cached factory was returned the second time');
});
}
});
QUnit.module('ESLint | container/tests/registry_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'container/tests/registry_test.js should pass ESLint\n\n');
});
QUnit.module('ESLint | core.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'core.js should pass ESLint\n\n');
});
QUnit.module('ESLint | dependent_keys.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'dependent_keys.js should pass ESLint\n\n');
});
QUnit.module('ESLint | deprecate_property.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'deprecate_property.js should pass ESLint\n\n');
});
QUnit.module('ESLint | descriptor.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'descriptor.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/index.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/index.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/initializers/dom-templates.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/initializers/dom-templates.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/system/application-instance.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/system/application-instance.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/system/application.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/system/application.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/system/engine-instance.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/system/engine-instance.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/system/engine-parent.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/system/engine-parent.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/system/engine.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/system/engine.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/system/resolver.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/system/resolver.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/application_instance_test', ['ember-babel', 'ember-application/system/engine', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-metal', 'ember-views', 'container', 'internal-test-helpers', 'ember-runtime'], function (_emberBabel, _engine, _application, _applicationInstance, _emberMetal, _emberViews, _container, _internalTestHelpers, _emberRuntime) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['-bucket-cache:main'], ['-bucket-cache:main']);
var application = void 0,
appInstance = void 0;
QUnit.module('Ember.ApplicationInstance', {
setup: function () {
(0, _emberViews.jQuery)('#qunit-fixture').html('
HI
HI
');
application = (0, _emberMetal.run)(function () {
return _application.default.create({ rootElement: '#one', router: null });
});
},
teardown: function () {
(0, _emberViews.jQuery)('#qunit-fixture').empty();
if (appInstance) {
(0, _emberMetal.run)(appInstance, 'destroy');
}
if (application) {
(0, _emberMetal.run)(application, 'destroy');
}
}
});
QUnit.test('an application instance can be created based upon an application', function () {
appInstance = (0, _emberMetal.run)(function () {
return appInstance = _applicationInstance.default.create({ application: application });
});
ok(appInstance, 'instance should be created');
equal(appInstance.application, application, 'application should be set to parent');
});
QUnit.test('properties (and aliases) are correctly assigned for accessing the container and registry', function () {
expect(6);
appInstance = (0, _emberMetal.run)(function () {
return _applicationInstance.default.create({ application: application });
});
ok(appInstance, 'instance should be created');
ok(appInstance.__container__, '#__container__ is accessible');
ok(appInstance.__registry__, '#__registry__ is accessible');
// stub with a no-op to keep deprecation test simple
appInstance.__container__.lookup = function () {
ok(true, '#loookup alias is called correctly');
};
ok(typeof appInstance.registry.register === 'function', '#registry.register is available as a function');
appInstance.__registry__.register = function () {
ok(true, '#register alias is called correctly');
};
expectDeprecation(function () {
appInstance.registry.register();
}, /Using `ApplicationInstance.registry.register` is deprecated. Please use `ApplicationInstance.register` instead./);
});
QUnit.test('customEvents added to the application before setupEventDispatcher', function (assert) {
assert.expect(1);
appInstance = (0, _emberMetal.run)(function () {
return _applicationInstance.default.create({ application: application });
});
appInstance.setupRegistry();
application.customEvents = {
awesome: 'sauce'
};
var eventDispatcher = appInstance.lookup('event_dispatcher:main');
eventDispatcher.setup = function (events) {
assert.equal(events.awesome, 'sauce');
};
appInstance.setupEventDispatcher();
});
QUnit.test('customEvents added to the application before setupEventDispatcher', function (assert) {
assert.expect(1);
(0, _emberMetal.run)(function () {
return appInstance = _applicationInstance.default.create({ application: application });
});
appInstance.setupRegistry();
application.customEvents = {
awesome: 'sauce'
};
var eventDispatcher = appInstance.lookup('event_dispatcher:main');
eventDispatcher.setup = function (events) {
assert.equal(events.awesome, 'sauce');
};
appInstance.setupEventDispatcher();
});
QUnit.test('customEvents added to the application instance before setupEventDispatcher', function (assert) {
assert.expect(1);
appInstance = (0, _emberMetal.run)(function () {
return _applicationInstance.default.create({ application: application });
});
appInstance.setupRegistry();
appInstance.customEvents = {
awesome: 'sauce'
};
var eventDispatcher = appInstance.lookup('event_dispatcher:main');
eventDispatcher.setup = function (events) {
assert.equal(events.awesome, 'sauce');
};
appInstance.setupEventDispatcher();
});
QUnit.test('unregistering a factory clears all cached instances of that factory', function (assert) {
assert.expect(5);
appInstance = (0, _emberMetal.run)(function () {
return _applicationInstance.default.create({ application: application });
});
var PostController1 = (0, _internalTestHelpers.factory)();
var PostController2 = (0, _internalTestHelpers.factory)();
appInstance.register('controller:post', PostController1);
var postController1 = appInstance.lookup('controller:post');
var postController1Factory = appInstance.factoryFor('controller:post');
assert.ok(postController1 instanceof PostController1, 'precond - lookup creates instance');
assert.equal(PostController1, postController1Factory.class, 'precond - factoryFor().class matches');
appInstance.unregister('controller:post');
appInstance.register('controller:post', PostController2);
var postController2 = appInstance.lookup('controller:post');
var postController2Factory = appInstance.factoryFor('controller:post');
assert.ok(postController2 instanceof PostController2, 'lookup creates instance');
assert.equal(PostController2, postController2Factory.class, 'factoryFor().class matches');
assert.notStrictEqual(postController1, postController2, 'lookup creates a brand new instance, because the previous one was reset');
});
QUnit.test('can build and boot a registered engine', function (assert) {
assert.expect(11);
var ChatEngine = _engine.default.extend();
var chatEngineInstance = void 0;
application.register('engine:chat', ChatEngine);
(0, _emberMetal.run)(function () {
appInstance = _applicationInstance.default.create({ application: application });
appInstance.setupRegistry();
chatEngineInstance = appInstance.buildChildEngineInstance('chat');
});
return chatEngineInstance.boot().then(function () {
assert.ok(true, 'boot successful');
var registrations = ['route:basic', 'service:-routing', 'service:-glimmer-environment'];
registrations.forEach(function (key) {
assert.strictEqual(chatEngineInstance.resolveRegistration(key), appInstance.resolveRegistration(key), 'Engine and parent app share registrations for \'' + key + '\'');
});
var singletons = ['router:main', (0, _container.privatize)(_templateObject), '-view-registry:main', '-environment:main', 'service:-document', 'event_dispatcher:main'];
var env = appInstance.lookup('-environment:main');
singletons.push(env.isInteractive ? 'renderer:-dom' : 'renderer:-inert');
singletons.forEach(function (key) {
assert.strictEqual(chatEngineInstance.lookup(key), appInstance.lookup(key), 'Engine and parent app share singleton \'' + key + '\'');
});
});
});
QUnit.test('can build a registry via Ember.ApplicationInstance.setupRegistry() -- simulates ember-test-helpers', function (assert) {
var namespace = _emberRuntime.Object.create({
Resolver: { create: function () {} }
});
var registry = _application.default.buildRegistry(namespace);
_applicationInstance.default.setupRegistry(registry);
assert.equal(registry.resolve('service:-document'), document);
});
});
QUnit.module('ESLint | ember-application/tests/system/application_instance_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/application_instance_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/application_test', ['ember-babel', 'ember', 'ember-environment', 'ember-metal', 'ember-debug', 'ember-application/system/application', 'ember-routing', 'ember-views', 'ember-runtime', 'ember-template-compiler', 'ember-glimmer', 'container', 'ember-application/tests/test-helpers/registry-check', 'ember-utils', 'internal-test-helpers'], function (_emberBabel, _ember, _emberEnvironment, _emberMetal, _emberDebug, _application, _emberRouting, _emberViews, _emberRuntime, _emberTemplateCompiler, _emberGlimmer, _container, _registryCheck, _emberUtils, _internalTestHelpers) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['-bucket-cache:main'], ['-bucket-cache:main']),
_templateObject2 = (0, _emberBabel.taggedTemplateLiteralLoose)(['template:components/-default'], ['template:components/-default']);
var secondApp = void 0;
(0, _internalTestHelpers.moduleFor)('Ember.Application, autobooting multiple apps', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
(0, _emberViews.jQuery)('#qunit-fixture').html('\n
\n
HI
\n
\n
HI
\n ');
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.call(this));
}
_class.prototype.createSecondApplication = function createSecondApplication(options) {
var myOptions = (0, _emberUtils.assign)(this.applicationOptions, options);
return this.secondApp = _application.default.create(myOptions);
};
_class.prototype.teardown = function teardown() {
var _this2 = this;
_ApplicationTestCase.prototype.teardown.call(this);
if (this.secondApp) {
this.runTask(function () {
return _this2.secondApp.destroy();
});
}
};
_class.prototype['@test you can make a new application in a non-overlapping element'] = function (assert) {
var _this3 = this;
var app = this.runTask(function () {
return _this3.createSecondApplication({
rootElement: '#two'
});
});
this.runTask(function () {
return app.destroy();
});
assert.ok(true, 'should not raise');
};
_class.prototype['@test you cannot make a new application that is a parent of an existing application'] = function () {
var _this4 = this;
expectAssertion(function () {
_this4.runTask(function () {
return _this4.createSecondApplication({
rootElement: _this4.applicationOptions.rootElement
});
});
});
};
_class.prototype['@test you cannot make a new application that is a descendant of an existing application'] = function () {
var _this5 = this;
expectAssertion(function () {
_this5.runTask(function () {
return _this5.createSecondApplication({
rootElement: '#one-child'
});
});
});
};
_class.prototype['@test you cannot make a new application that is a duplicate of an existing application'] = function () {
var _this6 = this;
expectAssertion(function () {
_this6.runTask(function () {
return _this6.createSecondApplication({
rootElement: '#one'
});
});
});
};
_class.prototype['@test you cannot make two default applications without a rootElement error'] = function () {
var _this7 = this;
expectAssertion(function () {
_this7.runTask(function () {
return _this7.createSecondApplication();
});
});
};
(0, _emberBabel.createClass)(_class, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_ApplicationTestCase.prototype.applicationOptions, {
rootElement: '#one',
router: null,
autoboot: true
});
}
}]);
return _class;
}(_internalTestHelpers.ApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Ember.Application', function (_ApplicationTestCase2) {
(0, _emberBabel.inherits)(_class2, _ApplicationTestCase2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase2.apply(this, arguments));
}
_class2.prototype['@test includes deprecated access to `application.registry`'] = function testIncludesDeprecatedAccessToApplicationRegistry(assert) {
var _this9 = this;
assert.expect(3);
assert.ok(typeof this.application.registry.register === 'function', '#registry.register is available as a function');
this.application.__registry__.register = function () {
assert.ok(true, '#register alias is called correctly');
};
expectDeprecation(function () {
_this9.application.registry.register();
}, /Using `Application.registry.register` is deprecated. Please use `Application.register` instead./);
};
_class2.prototype['@test builds a registry'] = function (assert) {
var application = this.application;
assert.strictEqual(application.resolveRegistration('application:main'), application, 'application:main is registered');
assert.deepEqual(application.registeredOptionsForType('component'), { singleton: false }, 'optionsForType \'component\'');
assert.deepEqual(application.registeredOptionsForType('view'), { singleton: false }, 'optionsForType \'view\'');
(0, _registryCheck.verifyRegistration)(application, 'controller:basic');
(0, _registryCheck.verifyRegistration)(application, '-view-registry:main');
(0, _registryCheck.verifyInjection)(application, 'view', '_viewRegistry', '-view-registry:main');
(0, _registryCheck.verifyInjection)(application, 'route', '_topLevelViewTemplate', 'template:-outlet');
(0, _registryCheck.verifyRegistration)(application, 'route:basic');
(0, _registryCheck.verifyRegistration)(application, 'event_dispatcher:main');
(0, _registryCheck.verifyInjection)(application, 'router:main', 'namespace', 'application:main');
(0, _registryCheck.verifyInjection)(application, 'view:-outlet', 'namespace', 'application:main');
(0, _registryCheck.verifyRegistration)(application, 'location:auto');
(0, _registryCheck.verifyRegistration)(application, 'location:hash');
(0, _registryCheck.verifyRegistration)(application, 'location:history');
(0, _registryCheck.verifyRegistration)(application, 'location:none');
(0, _registryCheck.verifyInjection)(application, 'controller', 'target', 'router:main');
(0, _registryCheck.verifyInjection)(application, 'controller', 'namespace', 'application:main');
(0, _registryCheck.verifyRegistration)(application, (0, _container.privatize)(_templateObject));
(0, _registryCheck.verifyInjection)(application, 'router', '_bucketCache', (0, _container.privatize)(_templateObject));
(0, _registryCheck.verifyInjection)(application, 'route', '_bucketCache', (0, _container.privatize)(_templateObject));
(0, _registryCheck.verifyInjection)(application, 'route', 'router', 'router:main');
(0, _registryCheck.verifyRegistration)(application, 'component:-text-field');
(0, _registryCheck.verifyRegistration)(application, 'component:-text-area');
(0, _registryCheck.verifyRegistration)(application, 'component:-checkbox');
(0, _registryCheck.verifyRegistration)(application, 'component:link-to');
(0, _registryCheck.verifyRegistration)(application, 'service:-routing');
(0, _registryCheck.verifyInjection)(application, 'service:-routing', 'router', 'router:main');
// DEBUGGING
(0, _registryCheck.verifyRegistration)(application, 'resolver-for-debugging:main');
(0, _registryCheck.verifyInjection)(application, 'container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main');
(0, _registryCheck.verifyInjection)(application, 'data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main');
(0, _registryCheck.verifyRegistration)(application, 'container-debug-adapter:main');
(0, _registryCheck.verifyRegistration)(application, 'component-lookup:main');
(0, _registryCheck.verifyRegistration)(application, 'service:-glimmer-environment');
(0, _registryCheck.verifyRegistration)(application, 'service:-dom-changes');
(0, _registryCheck.verifyRegistration)(application, 'service:-dom-tree-construction');
(0, _registryCheck.verifyInjection)(application, 'service:-glimmer-environment', 'appendOperations', 'service:-dom-tree-construction');
(0, _registryCheck.verifyInjection)(application, 'service:-glimmer-environment', 'updateOperations', 'service:-dom-changes');
(0, _registryCheck.verifyInjection)(application, 'renderer', 'env', 'service:-glimmer-environment');
(0, _registryCheck.verifyRegistration)(application, 'view:-outlet');
(0, _registryCheck.verifyRegistration)(application, 'renderer:-dom');
(0, _registryCheck.verifyRegistration)(application, 'renderer:-inert');
(0, _registryCheck.verifyRegistration)(application, (0, _container.privatize)(_templateObject2));
(0, _registryCheck.verifyRegistration)(application, 'template:-outlet');
(0, _registryCheck.verifyInjection)(application, 'view:-outlet', 'template', 'template:-outlet');
(0, _registryCheck.verifyInjection)(application, 'template', 'env', 'service:-glimmer-environment');
assert.deepEqual(application.registeredOptionsForType('helper'), { instantiate: false }, 'optionsForType \'helper\'');
};
return _class2;
}(_internalTestHelpers.ApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Ember.Application, default resolver with autoboot', function (_DefaultResolverAppli) {
(0, _emberBabel.inherits)(_class3, _DefaultResolverAppli);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
var _this10 = (0, _emberBabel.possibleConstructorReturn)(this, _DefaultResolverAppli.call(this));
_this10.originalLookup = _emberEnvironment.context.lookup;
return _this10;
}
_class3.prototype.teardown = function teardown() {
_emberEnvironment.context.lookup = this.originalLookup;
_DefaultResolverAppli.prototype.teardown.call(this);
(0, _emberGlimmer.setTemplates)({});
};
_class3.prototype['@test acts like a namespace'] = function (assert) {
var _this11 = this;
var lookup = _emberEnvironment.context.lookup = {};
lookup.TestApp = this.runTask(function () {
return _this11.createApplication();
});
(0, _emberRuntime.setNamespaceSearchDisabled)(false);
var Foo = this.application.Foo = _emberRuntime.Object.extend();
assert.equal(Foo.toString(), 'TestApp.Foo', 'Classes pick up their parent namespace');
};
_class3.prototype['@test can specify custom router'] = function (assert) {
var _this12 = this;
var MyRouter = _emberRouting.Router.extend();
this.runTask(function () {
_this12.createApplication();
_this12.application.Router = MyRouter;
});
assert.ok(this.application.__deprecatedInstance__.lookup('router:main') instanceof MyRouter, 'application resolved the correct router');
};
_class3.prototype['@test Minimal Application initialized with just an application template'] = function (assert) {
var _this13 = this;
this.$().html('');
this.runTask(function () {
return _this13.createApplication();
});
assert.equal(this.$().text().trim(), 'Hello World');
};
(0, _emberBabel.createClass)(_class3, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_DefaultResolverAppli.prototype.applicationOptions, {
autoboot: true
});
}
}]);
return _class3;
}(_internalTestHelpers.DefaultResolverApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Ember.Application, autobooting', function (_AutobootApplicationT) {
(0, _emberBabel.inherits)(_class4, _AutobootApplicationT);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
var _this14 = (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT.call(this));
_this14.originalLogVersion = _emberEnvironment.ENV.LOG_VERSION;
_this14.originalDebug = (0, _emberDebug.getDebugFunction)('debug');
_this14.originalWarn = (0, _emberDebug.getDebugFunction)('warn');
return _this14;
}
_class4.prototype.teardown = function teardown() {
(0, _emberDebug.setDebugFunction)('warn', this.originalWarn);
(0, _emberDebug.setDebugFunction)('debug', this.originalDebug);
_emberEnvironment.ENV.LOG_VERSION = this.originalLogVersion;
_AutobootApplicationT.prototype.teardown.call(this);
};
_class4.prototype['@test initialized application goes to initial route'] = function (assert) {
var _this15 = this;
this.runTask(function () {
_this15.createApplication();
_this15.addTemplate('application', '{{outlet}}');
_this15.addTemplate('index', '
Hi from index
');
});
assert.equal(this.$('h1').text(), 'Hi from index');
};
_class4.prototype['@test ready hook is called before routing begins'] = function (assert) {
var _this16 = this;
assert.expect(2);
this.runTask(function () {
function registerRoute(application, name, callback) {
var route = _emberRouting.Route.extend({
activate: callback
});
application.register('route:' + name, route);
}
var MyApplication = _application.default.extend({
ready: function () {
registerRoute(this, 'index', function () {
assert.ok(true, 'last-minute route is activated');
});
}
});
var app = _this16.createApplication({}, MyApplication);
registerRoute(app, 'application', function () {
return ok(true, 'normal route is activated');
});
});
};
_class4.prototype['@test initialize application via initialize call'] = function (assert) {
var _this17 = this;
this.runTask(function () {
return _this17.createApplication();
});
// This is not a public way to access the container; we just
// need to make some assertions about the created router
var router = this.applicationInstance.lookup('router:main');
assert.equal(router instanceof _emberRouting.Router, true, 'Router was set from initialize call');
assert.equal(router.location instanceof _emberRouting.NoneLocation, true, 'Location was set from location implementation name');
};
_class4.prototype['@test initialize application with stateManager via initialize call from Router class'] = function (assert) {
var _this18 = this;
this.runTask(function () {
_this18.createApplication();
_this18.addTemplate('application', '
Hello!
');
});
// This is not a public way to access the container; we just
// need to make some assertions about the created router
var router = this.application.__deprecatedInstance__.lookup('router:main');
assert.equal(router instanceof _emberRouting.Router, true, 'Router was set from initialize call');
assert.equal(this.$('h1').text(), 'Hello!');
};
_class4.prototype['@test Application Controller backs the appplication template'] = function (assert) {
var _this19 = this;
this.runTask(function () {
_this19.createApplication();
_this19.addTemplate('application', '
{{greeting}}
');
_this19.add('controller:application', _emberRuntime.Controller.extend({
greeting: 'Hello!'
}));
});
assert.equal(this.$('h1').text(), 'Hello!');
};
_class4.prototype['@test enable log of libraries with an ENV var'] = function (assert) {
var _this20 = this;
if (EmberDev && EmberDev.runningProdBuild) {
assert.ok(true, 'Logging does not occur in production builds');
return;
}
var messages = [];
_emberEnvironment.ENV.LOG_VERSION = true;
(0, _emberDebug.setDebugFunction)('debug', function (message) {
return messages.push(message);
});
_emberMetal.libraries.register('my-lib', '2.0.0a');
this.runTask(function () {
return _this20.createApplication();
});
assert.equal(messages[1], 'Ember : ' + _ember.VERSION);
assert.equal(messages[2], 'jQuery : ' + (0, _emberViews.jQuery)().jquery);
assert.equal(messages[3], 'my-lib : ' + '2.0.0a');
_emberMetal.libraries.deRegister('my-lib');
};
_class4.prototype['@test disable log of version of libraries with an ENV var'] = function (assert) {
var _this21 = this;
var logged = false;
_emberEnvironment.ENV.LOG_VERSION = false;
(0, _emberDebug.setDebugFunction)('debug', function () {
return logged = true;
});
this.runTask(function () {
return _this21.createApplication();
});
assert.ok(!logged, 'library version logging skipped');
};
_class4.prototype['@test can resolve custom router'] = function (assert) {
var _this22 = this;
var CustomRouter = _emberRouting.Router.extend();
this.runTask(function () {
_this22.createApplication();
_this22.add('router:main', CustomRouter);
});
assert.ok(this.application.__deprecatedInstance__.lookup('router:main') instanceof CustomRouter, 'application resolved the correct router');
};
_class4.prototype['@test does not leak itself in onLoad._loaded'] = function (assert) {
var _this23 = this;
assert.equal(_emberRuntime._loaded.application, undefined);
this.runTask(function () {
return _this23.createApplication();
});
assert.equal(_emberRuntime._loaded.application, this.application);
this.runTask(function () {
return _this23.application.destroy();
});
assert.equal(_emberRuntime._loaded.application, undefined);
};
_class4.prototype['@test can build a registry via Ember.Application.buildRegistry() --- simulates ember-test-helpers'] = function (assert) {
var namespace = _emberRuntime.Object.create({
Resolver: { create: function () {} }
});
var registry = _application.default.buildRegistry(namespace);
assert.equal(registry.resolve('application:main'), namespace);
};
return _class4;
}(_internalTestHelpers.AutobootApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Ember.Application#buildRegistry', function (_AbstractTestCase) {
(0, _emberBabel.inherits)(_class5, _AbstractTestCase);
function _class5() {
(0, _emberBabel.classCallCheck)(this, _class5);
return (0, _emberBabel.possibleConstructorReturn)(this, _AbstractTestCase.apply(this, arguments));
}
_class5.prototype['@test can build a registry via Ember.Application.buildRegistry() --- simulates ember-test-helpers'] = function (assert) {
var namespace = _emberRuntime.Object.create({
Resolver: {
create: function () {}
}
});
var registry = _application.default.buildRegistry(namespace);
assert.equal(registry.resolve('application:main'), namespace);
};
return _class5;
}(_internalTestHelpers.AbstractTestCase));
});
QUnit.module('ESLint | ember-application/tests/system/application_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/application_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/bootstrap-test', ['ember-babel', 'ember-utils', 'ember-views', 'internal-test-helpers'], function (_emberBabel, _emberUtils, _emberViews, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Ember.Application with default resolver and autoboot', function (_DefaultResolverAppli) {
(0, _emberBabel.inherits)(_class, _DefaultResolverAppli);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
(0, _emberViews.jQuery)('#qunit-fixture').html('\n \n\n \n \n ');
return (0, _emberBabel.possibleConstructorReturn)(this, _DefaultResolverAppli.call(this));
}
_class.prototype['@test templates in script tags are extracted at application creation'] = function testTemplatesInScriptTagsAreExtractedAtApplicationCreation(assert) {
var _this2 = this;
this.runTask(function () {
return _this2.createApplication();
});
assert.equal(this.$('#app').text(), 'Hello World!');
};
(0, _emberBabel.createClass)(_class, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_DefaultResolverAppli.prototype.applicationOptions, {
autoboot: true,
rootElement: '#app'
});
}
}]);
return _class;
}(_internalTestHelpers.DefaultResolverApplicationTestCase));
});
QUnit.module('ESLint | ember-application/tests/system/bootstrap-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/bootstrap-test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/dependency_injection/custom_resolver_test', ['ember-babel', 'ember-application/system/resolver', 'ember-utils', 'internal-test-helpers'], function (_emberBabel, _resolver, _emberUtils, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Ember.Application with extended default resolver and autoboot', function (_DefaultResolverAppli) {
(0, _emberBabel.inherits)(_class, _DefaultResolverAppli);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _DefaultResolverAppli.apply(this, arguments));
}
_class.prototype['@test a resolver can be supplied to application'] = function (assert) {
var _this2 = this;
this.runTask(function () {
return _this2.createApplication();
});
assert.equal(this.$('h1').text(), 'Fallback');
};
(0, _emberBabel.createClass)(_class, [{
key: 'applicationOptions',
get: function () {
var applicationTemplate = this.compile('
Fallback
');
var Resolver = _resolver.default.extend({
resolveTemplate: function (resolvable) {
if (resolvable.fullNameWithoutType === 'application') {
return applicationTemplate;
} else {
return this._super(resolvable);
}
}
});
return (0, _emberUtils.assign)(_DefaultResolverAppli.prototype.applicationOptions, {
Resolver: Resolver,
autoboot: true
});
}
}]);
return _class;
}(_internalTestHelpers.DefaultResolverApplicationTestCase));
});
QUnit.module('ESLint | ember-application/tests/system/dependency_injection/custom_resolver_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/dependency_injection/custom_resolver_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/dependency_injection/default_resolver_test', ['ember-babel', 'internal-test-helpers', 'ember-environment', 'ember-runtime', 'ember-routing', 'ember-glimmer', 'ember-debug'], function (_emberBabel, _internalTestHelpers, _emberEnvironment, _emberRuntime, _emberRouting, _emberGlimmer, _emberDebug) {
'use strict';
/* globals EmberDev */
(0, _internalTestHelpers.moduleFor)('Ember.Application Dependency Injection - Integration - default resolver', function (_DefaultResolverAppli) {
(0, _emberBabel.inherits)(_class, _DefaultResolverAppli);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _DefaultResolverAppli.apply(this, arguments));
}
_class.prototype.beforeEach = function beforeEach() {
var _this2 = this;
this.runTask(function () {
return _this2.createApplication();
});
return this.visit('/');
};
_class.prototype['@test the default resolver looks up templates in Ember.TEMPLATES'] = function (assert) {
var fooTemplate = this.addTemplate('foo', 'foo template');
var fooBarTemplate = this.addTemplate('fooBar', 'fooBar template');
var fooBarBazTemplate = this.addTemplate('fooBar/baz', 'fooBar/baz template');
assert.equal(this.applicationInstance.factoryFor('template:foo').class, fooTemplate, 'resolves template:foo');
assert.equal(this.applicationInstance.factoryFor('template:fooBar').class, fooBarTemplate, 'resolves template:foo_bar');
assert.equal(this.applicationInstance.factoryFor('template:fooBar.baz').class, fooBarBazTemplate, 'resolves template:foo_bar.baz');
};
_class.prototype['@test the default resolver looks up basic name as no prefix'] = function (assert) {
var instance = this.applicationInstance.lookup('controller:basic');
assert.ok(_emberRuntime.Controller.detect(instance), 'locator looks up correct controller');
};
_class.prototype['@test the default resolver looks up arbitrary types on the namespace'] = function (assert) {
var Class = this.application.FooManager = _emberRuntime.Object.extend();
var resolvedClass = this.application.resolveRegistration('manager:foo');
assert.equal(Class, resolvedClass, 'looks up FooManager on application');
};
_class.prototype['@test the default resolver resolves models on the namespace'] = function (assert) {
var Class = this.application.Post = _emberRuntime.Object.extend();
var factoryClass = this.applicationInstance.factoryFor('model:post').class;
assert.equal(Class, factoryClass, 'looks up Post model on application');
};
_class.prototype['@test the default resolver resolves *:main on the namespace'] = function (assert) {
var Class = this.application.FooBar = _emberRuntime.Object.extend();
var factoryClass = this.applicationInstance.factoryFor('foo-bar:main').class;
assert.equal(Class, factoryClass, 'looks up FooBar type without name on application');
};
_class.prototype['@test the default resolver resolves container-registered helpers'] = function (assert) {
var shorthandHelper = (0, _emberGlimmer.helper)(function () {});
var helper = _emberGlimmer.Helper.extend();
this.application.register('helper:shorthand', shorthandHelper);
this.application.register('helper:complete', helper);
var lookedUpShorthandHelper = this.applicationInstance.factoryFor('helper:shorthand').class;
assert.ok(lookedUpShorthandHelper.isHelperFactory, 'shorthand helper isHelper');
var lookedUpHelper = this.applicationInstance.factoryFor('helper:complete').class;
assert.ok(lookedUpHelper.isHelperFactory, 'complete helper is factory');
assert.ok(helper.detect(lookedUpHelper), 'looked up complete helper');
};
_class.prototype['@test the default resolver resolves container-registered helpers via lookupFor'] = function (assert) {
var shorthandHelper = (0, _emberGlimmer.helper)(function () {});
var helper = _emberGlimmer.Helper.extend();
this.application.register('helper:shorthand', shorthandHelper);
this.application.register('helper:complete', helper);
var lookedUpShorthandHelper = this.applicationInstance.factoryFor('helper:shorthand').class;
assert.ok(lookedUpShorthandHelper.isHelperFactory, 'shorthand helper isHelper');
var lookedUpHelper = this.applicationInstance.factoryFor('helper:complete').class;
assert.ok(lookedUpHelper.isHelperFactory, 'complete helper is factory');
assert.ok(helper.detect(lookedUpHelper), 'looked up complete helper');
};
_class.prototype['@test the default resolver resolves helpers on the namespace'] = function (assert) {
var ShorthandHelper = (0, _emberGlimmer.helper)(function () {});
var CompleteHelper = _emberGlimmer.Helper.extend();
this.application.ShorthandHelper = ShorthandHelper;
this.application.CompleteHelper = CompleteHelper;
var resolvedShorthand = this.application.resolveRegistration('helper:shorthand');
var resolvedComplete = this.application.resolveRegistration('helper:complete');
assert.equal(resolvedShorthand, ShorthandHelper, 'resolve fetches the shorthand helper factory');
assert.equal(resolvedComplete, CompleteHelper, 'resolve fetches the complete helper factory');
};
_class.prototype['@test the default resolver resolves to the same instance, no matter the notation '] = function (assert) {
this.application.NestedPostController = _emberRuntime.Controller.extend({});
assert.equal(this.applicationInstance.lookup('controller:nested-post'), this.applicationInstance.lookup('controller:nested_post'), 'looks up NestedPost controller on application');
};
_class.prototype['@test the default resolver throws an error if the fullName to resolve is invalid'] = function (assert) {
var _this3 = this;
assert.throws(function () {
_this3.applicationInstance.resolveRegistration(undefined);
}, TypeError, /Invalid fullName/);
assert.throws(function () {
_this3.applicationInstance.resolveRegistration(null);
}, TypeError, /Invalid fullName/);
assert.throws(function () {
_this3.applicationInstance.resolveRegistration('');
}, TypeError, /Invalid fullName/);
assert.throws(function () {
_this3.applicationInstance.resolveRegistration('');
}, TypeError, /Invalid fullName/);
assert.throws(function () {
_this3.applicationInstance.resolveRegistration(':');
}, TypeError, /Invalid fullName/);
assert.throws(function () {
_this3.applicationInstance.resolveRegistration('model');
}, TypeError, /Invalid fullName/);
assert.throws(function () {
_this3.applicationInstance.resolveRegistration('model:');
}, TypeError, /Invalid fullName/);
assert.throws(function () {
_this3.applicationInstance.resolveRegistration(':type');
}, TypeError, /Invalid fullName/);
};
_class.prototype['@test lookup description'] = function (assert) {
this.application.toString = function () {
return 'App';
};
assert.equal(this.privateRegistry.describe('controller:foo'), 'App.FooController', 'Type gets appended at the end');
assert.equal(this.privateRegistry.describe('controller:foo.bar'), 'App.FooBarController', 'dots are removed');
assert.equal(this.privateRegistry.describe('model:foo'), 'App.Foo', 'models don\'t get appended at the end');
};
_class.prototype['@test assertion for routes without isRouteFactory property'] = function (assert) {
var _this4 = this;
this.application.FooRoute = _emberGlimmer.Component.extend();
expectAssertion(function () {
_this4.privateRegistry.resolve('route:foo');
}, /to resolve to an Ember.Route/, 'Should assert');
};
_class.prototype['@test no assertion for routes that extend from Ember.Route'] = function (assert) {
assert.expect(0);
this.application.FooRoute = _emberRouting.Route.extend();
this.privateRegistry.resolve('route:foo');
};
_class.prototype['@test deprecation warning for service factories without isServiceFactory property'] = function (assert) {
var _this5 = this;
expectAssertion(function () {
_this5.application.FooService = _emberRuntime.Object.extend();
_this5.privateRegistry.resolve('service:foo');
}, /Expected service:foo to resolve to an Ember.Service but instead it was \.FooService\./);
};
_class.prototype['@test no deprecation warning for service factories that extend from Ember.Service'] = function (assert) {
assert.expect(0);
this.application.FooService = _emberRuntime.Service.extend();
this.privateRegistry.resolve('service:foo');
};
_class.prototype['@test deprecation warning for component factories without isComponentFactory property'] = function (assert) {
var _this6 = this;
expectAssertion(function () {
_this6.application.FooComponent = _emberRuntime.Object.extend();
_this6.privateRegistry.resolve('component:foo');
}, /Expected component:foo to resolve to an Ember\.Component but instead it was \.FooComponent\./);
};
_class.prototype['@test no deprecation warning for component factories that extend from Ember.Component'] = function (assert) {
expectNoDeprecation();
this.application.FooView = _emberGlimmer.Component.extend();
this.privateRegistry.resolve('component:foo');
};
_class.prototype['@test knownForType returns each item for a given type found'] = function (assert) {
this.application.FooBarHelper = 'foo';
this.application.BazQuxHelper = 'bar';
var found = this.privateRegistry.resolver.knownForType('helper');
assert.deepEqual(found, {
'helper:foo-bar': true,
'helper:baz-qux': true
});
};
_class.prototype['@test knownForType is not required to be present on the resolver'] = function (assert) {
delete this.privateRegistry.resolver.knownForType;
this.privateRegistry.resolver.knownForType('helper', function () {});
assert.ok(true, 'does not error');
};
(0, _emberBabel.createClass)(_class, [{
key: 'privateRegistry',
get: function () {
return this.application.__registry__;
}
}]);
return _class;
}(_internalTestHelpers.DefaultResolverApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Ember.Application Dependency Injection - Integration - default resolver w/ other namespace', function (_DefaultResolverAppli2) {
(0, _emberBabel.inherits)(_class2, _DefaultResolverAppli2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _DefaultResolverAppli2.apply(this, arguments));
}
_class2.prototype.beforeEach = function beforeEach() {
var _this8 = this;
this.UserInterface = _emberEnvironment.context.lookup.UserInterface = _emberRuntime.Namespace.create();
this.runTask(function () {
return _this8.createApplication();
});
return this.visit('/');
};
_class2.prototype.teardown = function teardown() {
var UserInterfaceNamespace = _emberRuntime.Namespace.NAMESPACES_BY_ID['UserInterface'];
if (UserInterfaceNamespace) {
this.runTask(function () {
UserInterfaceNamespace.destroy();
});
}
_DefaultResolverAppli2.prototype.teardown.call(this);
};
_class2.prototype['@test the default resolver can look things up in other namespaces'] = function (assert) {
this.UserInterface.NavigationController = _emberRuntime.Controller.extend();
var nav = this.applicationInstance.lookup('controller:userInterface/navigation');
assert.ok(nav instanceof this.UserInterface.NavigationController, 'the result should be an instance of the specified class');
};
return _class2;
}(_internalTestHelpers.DefaultResolverApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Ember.Application Dependency Injection - Integration - default resolver', function (_DefaultResolverAppli3) {
(0, _emberBabel.inherits)(_class3, _DefaultResolverAppli3);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
var _this9 = (0, _emberBabel.possibleConstructorReturn)(this, _DefaultResolverAppli3.call(this));
_this9._originalLookup = _emberEnvironment.context.lookup;
_this9._originalInfo = (0, _emberDebug.getDebugFunction)('info');
return _this9;
}
_class3.prototype.beforeEach = function beforeEach() {
var _this10 = this;
this.runTask(function () {
return _this10.createApplication();
});
return this.visit('/');
};
_class3.prototype.teardown = function teardown() {
(0, _emberDebug.setDebugFunction)('info', this._originalInfo);
_emberEnvironment.context.lookup = this._originalLookup;
_DefaultResolverAppli3.prototype.teardown.call(this);
};
_class3.prototype['@test the default resolver logs hits if \'LOG_RESOLVER\' is set'] = function (assert) {
if (EmberDev && EmberDev.runningProdBuild) {
assert.ok(true, 'Logging does not occur in production builds');
return;
}
assert.expect(3);
this.application.LOG_RESOLVER = true;
this.application.ScoobyDoo = _emberRuntime.Object.extend();
this.application.toString = function () {
return 'App';
};
(0, _emberDebug.setDebugFunction)('info', function (symbol, name, padding, lookupDescription) {
assert.equal(symbol, '[✓]', 'proper symbol is printed when a module is found');
assert.equal(name, 'doo:scooby', 'proper lookup value is logged');
assert.equal(lookupDescription, 'App.ScoobyDoo');
});
this.applicationInstance.resolveRegistration('doo:scooby');
};
_class3.prototype['@test the default resolver logs misses if \'LOG_RESOLVER\' is set'] = function (assert) {
if (EmberDev && EmberDev.runningProdBuild) {
assert.ok(true, 'Logging does not occur in production builds');
return;
}
assert.expect(3);
this.application.LOG_RESOLVER = true;
this.application.toString = function () {
return 'App';
};
(0, _emberDebug.setDebugFunction)('info', function (symbol, name, padding, lookupDescription) {
assert.equal(symbol, '[ ]', 'proper symbol is printed when a module is not found');
assert.equal(name, 'doo:scooby', 'proper lookup value is logged');
assert.equal(lookupDescription, 'App.ScoobyDoo');
});
this.applicationInstance.resolveRegistration('doo:scooby');
};
_class3.prototype['@test doesn\'t log without LOG_RESOLVER'] = function (assert) {
if (EmberDev && EmberDev.runningProdBuild) {
assert.ok(true, 'Logging does not occur in production builds');
return;
}
var infoCount = 0;
this.application.ScoobyDoo = _emberRuntime.Object.extend();
(0, _emberDebug.setDebugFunction)('info', function (symbol, name) {
return infoCount = infoCount + 1;
});
this.applicationInstance.resolveRegistration('doo:scooby');
this.applicationInstance.resolveRegistration('doo:scrappy');
assert.equal(infoCount, 0, 'Logger.info should not be called if LOG_RESOLVER is not set');
};
return _class3;
}(_internalTestHelpers.DefaultResolverApplicationTestCase));
});
QUnit.module('ESLint | ember-application/tests/system/dependency_injection/default_resolver_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/dependency_injection/default_resolver_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/dependency_injection/normalization_test', ['ember-metal', 'ember-application/system/application'], function (_emberMetal, _application) {
'use strict';
var application = void 0,
registry = void 0;
QUnit.module('Ember.Application Dependency Injection – normalization', {
setup: function () {
application = (0, _emberMetal.run)(_application.default, 'create');
registry = application.__registry__;
},
teardown: function () {
(0, _emberMetal.run)(application, 'destroy');
}
});
QUnit.test('normalization', function () {
ok(registry.normalize, 'registry#normalize is present');
equal(registry.normalize('foo:bar'), 'foo:bar');
equal(registry.normalize('controller:posts'), 'controller:posts');
equal(registry.normalize('controller:posts_index'), 'controller:postsIndex');
equal(registry.normalize('controller:posts.index'), 'controller:postsIndex');
equal(registry.normalize('controller:posts-index'), 'controller:postsIndex');
equal(registry.normalize('controller:posts.post.index'), 'controller:postsPostIndex');
equal(registry.normalize('controller:posts_post.index'), 'controller:postsPostIndex');
equal(registry.normalize('controller:posts.post_index'), 'controller:postsPostIndex');
equal(registry.normalize('controller:posts.post-index'), 'controller:postsPostIndex');
equal(registry.normalize('controller:postsIndex'), 'controller:postsIndex');
equal(registry.normalize('controller:blogPosts.index'), 'controller:blogPostsIndex');
equal(registry.normalize('controller:blog/posts.index'), 'controller:blog/postsIndex');
equal(registry.normalize('controller:blog/posts-index'), 'controller:blog/postsIndex');
equal(registry.normalize('controller:blog/posts.post.index'), 'controller:blog/postsPostIndex');
equal(registry.normalize('controller:blog/posts_post.index'), 'controller:blog/postsPostIndex');
equal(registry.normalize('controller:blog/posts_post-index'), 'controller:blog/postsPostIndex');
equal(registry.normalize('template:blog/posts_index'), 'template:blog/posts_index');
});
QUnit.test('normalization is indempotent', function () {
var examples = ['controller:posts', 'controller:posts.post.index', 'controller:blog/posts.post_index', 'template:foo_bar'];
examples.forEach(function (example) {
equal(registry.normalize(registry.normalize(example)), registry.normalize(example));
});
});
});
QUnit.module('ESLint | ember-application/tests/system/dependency_injection/normalization_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/dependency_injection/normalization_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/dependency_injection/to_string_test', ['ember-babel', 'ember-utils', 'ember-runtime', 'ember-application', 'internal-test-helpers'], function (_emberBabel, _emberUtils, _emberRuntime, _emberApplication, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Ember.Application Dependency Injection - DefaultResolver#toString', function (_DefaultResolverAppli) {
(0, _emberBabel.inherits)(_class, _DefaultResolverAppli);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _DefaultResolverAppli.call(this));
_this.runTask(function () {
return _this.createApplication();
});
_this.application.Post = _emberRuntime.Object.extend();
return _this;
}
_class.prototype.beforeEach = function beforeEach() {
return this.visit('/');
};
_class.prototype['@test factories'] = function testFactories(assert) {
var PostFactory = this.applicationInstance.factoryFor('model:post').class;
assert.equal(PostFactory.toString(), '.Post', 'expecting the model to be post');
};
_class.prototype['@test instances'] = function testInstances(assert) {
var post = this.applicationInstance.lookup('model:post');
var guid = (0, _emberUtils.guidFor)(post);
assert.equal(post.toString(), '<.Post:' + guid + '>', 'expecting the model to be post');
};
return _class;
}(_internalTestHelpers.DefaultResolverApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Ember.Application Dependency Injection - Resolver#toString', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class2, _ApplicationTestCase);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.apply(this, arguments));
}
_class2.prototype.beforeEach = function beforeEach() {
return this.visit('/');
};
_class2.prototype['@test toString called on a resolver'] = function testToStringCalledOnAResolver(assert) {
this.add('model:peter', _emberRuntime.Object.extend());
var peter = this.applicationInstance.lookup('model:peter');
var guid = (0, _emberUtils.guidFor)(peter);
assert.equal(peter.toString(), '', 'expecting the supermodel to be peter');
};
(0, _emberBabel.createClass)(_class2, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_ApplicationTestCase.prototype.applicationOptions, {
Resolver: function (_ModuleBasedTestResol) {
(0, _emberBabel.inherits)(Resolver, _ModuleBasedTestResol);
function Resolver() {
(0, _emberBabel.classCallCheck)(this, Resolver);
return (0, _emberBabel.possibleConstructorReturn)(this, _ModuleBasedTestResol.apply(this, arguments));
}
Resolver.prototype.makeToString = function makeToString(_, fullName) {
return fullName;
};
return Resolver;
}(_internalTestHelpers.ModuleBasedTestResolver)
});
}
}]);
return _class2;
}(_internalTestHelpers.ApplicationTestCase));
});
QUnit.module('ESLint | ember-application/tests/system/dependency_injection/to_string_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/dependency_injection/to_string_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/dependency_injection_test', ['ember-environment', 'ember-metal', 'ember-runtime', 'ember-application/system/application'], function (_emberEnvironment, _emberMetal, _emberRuntime, _application) {
'use strict';
var EmberApplication = _application.default;
var originalLookup = _emberEnvironment.context.lookup;
var registry = void 0,
locator = void 0,
application = void 0;
QUnit.module('Ember.Application Dependency Injection', {
setup: function () {
application = (0, _emberMetal.run)(EmberApplication, 'create');
application.Person = _emberRuntime.Object.extend({});
application.Orange = _emberRuntime.Object.extend({});
application.Email = _emberRuntime.Object.extend({});
application.User = _emberRuntime.Object.extend({});
application.PostIndexController = _emberRuntime.Object.extend({});
application.register('model:person', application.Person, { singleton: false });
application.register('model:user', application.User, { singleton: false });
application.register('fruit:favorite', application.Orange);
application.register('communication:main', application.Email, { singleton: false });
application.register('controller:postIndex', application.PostIndexController, { singleton: true });
registry = application.__registry__;
locator = application.__container__;
_emberEnvironment.context.lookup = {};
},
teardown: function () {
(0, _emberMetal.run)(application, 'destroy');
application = locator = null;
_emberEnvironment.context.lookup = originalLookup;
}
});
QUnit.test('container lookup is normalized', function () {
var dotNotationController = locator.lookup('controller:post.index');
var camelCaseController = locator.lookup('controller:postIndex');
ok(dotNotationController instanceof application.PostIndexController);
ok(camelCaseController instanceof application.PostIndexController);
equal(dotNotationController, camelCaseController);
});
QUnit.test('registered entities can be looked up later', function () {
equal(registry.resolve('model:person'), application.Person);
equal(registry.resolve('model:user'), application.User);
equal(registry.resolve('fruit:favorite'), application.Orange);
equal(registry.resolve('communication:main'), application.Email);
equal(registry.resolve('controller:postIndex'), application.PostIndexController);
equal(locator.lookup('fruit:favorite'), locator.lookup('fruit:favorite'), 'singleton lookup worked');
ok(locator.lookup('model:user') !== locator.lookup('model:user'), 'non-singleton lookup worked');
});
QUnit.test('injections', function () {
application.inject('model', 'fruit', 'fruit:favorite');
application.inject('model:user', 'communication', 'communication:main');
var user = locator.lookup('model:user');
var person = locator.lookup('model:person');
var fruit = locator.lookup('fruit:favorite');
equal(user.get('fruit'), fruit);
equal(person.get('fruit'), fruit);
ok(application.Email.detectInstance(user.get('communication')));
});
});
QUnit.module('ESLint | ember-application/tests/system/dependency_injection_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/dependency_injection_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/engine_initializers_test', ['ember-metal', 'ember-application/system/engine'], function (_emberMetal, _engine) {
'use strict';
var MyEngine = void 0,
myEngine = void 0,
myEngineInstance = void 0;
QUnit.module('Ember.Engine initializers', {
setup: function () {},
teardown: function () {
(0, _emberMetal.run)(function () {
if (myEngineInstance) {
myEngineInstance.destroy();
}
if (myEngine) {
myEngine.destroy();
}
});
}
});
QUnit.test('initializers require proper \'name\' and \'initialize\' properties', function () {
MyEngine = _engine.default.extend();
expectAssertion(function () {
(0, _emberMetal.run)(function () {
MyEngine.initializer({ name: 'initializer' });
});
});
expectAssertion(function () {
(0, _emberMetal.run)(function () {
MyEngine.initializer({
initialize: function () {}
});
});
});
});
QUnit.test('initializers are passed an Engine', function () {
MyEngine = _engine.default.extend();
MyEngine.initializer({
name: 'initializer',
initialize: function (engine) {
ok(engine instanceof _engine.default, 'initialize is passed an Engine');
}
});
myEngine = MyEngine.create();
myEngineInstance = myEngine.buildInstance();
});
QUnit.test('initializers can be registered in a specified order', function () {
var order = [];
MyEngine = _engine.default.extend();
MyEngine.initializer({
name: 'fourth',
after: 'third',
initialize: function (engine) {
order.push('fourth');
}
});
MyEngine.initializer({
name: 'second',
after: 'first',
before: 'third',
initialize: function (engine) {
order.push('second');
}
});
MyEngine.initializer({
name: 'fifth',
after: 'fourth',
before: 'sixth',
initialize: function (engine) {
order.push('fifth');
}
});
MyEngine.initializer({
name: 'first',
before: 'second',
initialize: function (engine) {
order.push('first');
}
});
MyEngine.initializer({
name: 'third',
initialize: function (engine) {
order.push('third');
}
});
MyEngine.initializer({
name: 'sixth',
initialize: function (engine) {
order.push('sixth');
}
});
myEngine = MyEngine.create();
myEngineInstance = myEngine.buildInstance();
deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']);
});
QUnit.test('initializers can be registered in a specified order as an array', function () {
var order = [];
MyEngine = _engine.default.extend();
MyEngine.initializer({
name: 'third',
initialize: function (engine) {
order.push('third');
}
});
MyEngine.initializer({
name: 'second',
after: 'first',
before: ['third', 'fourth'],
initialize: function (engine) {
order.push('second');
}
});
MyEngine.initializer({
name: 'fourth',
after: ['second', 'third'],
initialize: function (engine) {
order.push('fourth');
}
});
MyEngine.initializer({
name: 'fifth',
after: 'fourth',
before: 'sixth',
initialize: function (engine) {
order.push('fifth');
}
});
MyEngine.initializer({
name: 'first',
before: ['second'],
initialize: function (engine) {
order.push('first');
}
});
MyEngine.initializer({
name: 'sixth',
initialize: function (engine) {
order.push('sixth');
}
});
myEngine = MyEngine.create();
myEngineInstance = myEngine.buildInstance();
deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']);
});
QUnit.test('initializers can have multiple dependencies', function () {
var order = [];
MyEngine = _engine.default.extend();
var a = {
name: 'a',
before: 'b',
initialize: function (engine) {
order.push('a');
}
};
var b = {
name: 'b',
initialize: function (engine) {
order.push('b');
}
};
var c = {
name: 'c',
after: 'b',
initialize: function (engine) {
order.push('c');
}
};
var afterB = {
name: 'after b',
after: 'b',
initialize: function (engine) {
order.push('after b');
}
};
var afterC = {
name: 'after c',
after: 'c',
initialize: function (engine) {
order.push('after c');
}
};
MyEngine.initializer(b);
MyEngine.initializer(a);
MyEngine.initializer(afterC);
MyEngine.initializer(afterB);
MyEngine.initializer(c);
myEngine = MyEngine.create();
myEngineInstance = myEngine.buildInstance();
ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b');
ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c');
ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB');
ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC');
});
QUnit.test('initializers set on Engine subclasses are not shared between engines', function () {
var firstInitializerRunCount = 0;
var secondInitializerRunCount = 0;
var FirstEngine = _engine.default.extend();
FirstEngine.initializer({
name: 'first',
initialize: function (engine) {
firstInitializerRunCount++;
}
});
var SecondEngine = _engine.default.extend();
SecondEngine.initializer({
name: 'second',
initialize: function (engine) {
secondInitializerRunCount++;
}
});
var firstEngine = FirstEngine.create();
var firstEngineInstance = firstEngine.buildInstance();
equal(firstInitializerRunCount, 1, 'first initializer only was run');
equal(secondInitializerRunCount, 0, 'first initializer only was run');
var secondEngine = SecondEngine.create();
var secondEngineInstance = secondEngine.buildInstance();
equal(firstInitializerRunCount, 1, 'second initializer only was run');
equal(secondInitializerRunCount, 1, 'second initializer only was run');
(0, _emberMetal.run)(function () {
firstEngineInstance.destroy();
secondEngineInstance.destroy();
firstEngine.destroy();
secondEngine.destroy();
});
});
QUnit.test('initializers are concatenated', function () {
var firstInitializerRunCount = 0;
var secondInitializerRunCount = 0;
var FirstEngine = _engine.default.extend();
FirstEngine.initializer({
name: 'first',
initialize: function (engine) {
firstInitializerRunCount++;
}
});
var SecondEngine = FirstEngine.extend();
SecondEngine.initializer({
name: 'second',
initialize: function (engine) {
secondInitializerRunCount++;
}
});
var firstEngine = FirstEngine.create();
var firstEngineInstance = firstEngine.buildInstance();
equal(firstInitializerRunCount, 1, 'first initializer only was run when base class created');
equal(secondInitializerRunCount, 0, 'second initializer was not run when first base class created');
firstInitializerRunCount = 0;
var secondEngine = SecondEngine.create();
var secondEngineInstance = secondEngine.buildInstance();
equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created');
equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created');
(0, _emberMetal.run)(function () {
firstEngineInstance.destroy();
secondEngineInstance.destroy();
firstEngine.destroy();
secondEngine.destroy();
});
});
QUnit.test('initializers are per-engine', function () {
expect(2);
var FirstEngine = _engine.default.extend();
FirstEngine.initializer({
name: 'abc',
initialize: function (engine) {}
});
expectAssertion(function () {
FirstEngine.initializer({
name: 'abc',
initialize: function (engine) {}
});
});
var SecondEngine = _engine.default.extend();
SecondEngine.instanceInitializer({
name: 'abc',
initialize: function (engine) {}
});
ok(true, 'Two engines can have initializers named the same.');
});
QUnit.test('initializers are executed in their own context', function () {
expect(1);
MyEngine = _engine.default.extend();
MyEngine.initializer({
name: 'coolInitializer',
myProperty: 'cool',
initialize: function (engine) {
equal(this.myProperty, 'cool', 'should have access to its own context');
}
});
myEngine = MyEngine.create();
myEngineInstance = myEngine.buildInstance();
});
});
QUnit.module('ESLint | ember-application/tests/system/engine_initializers_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/engine_initializers_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/engine_instance_initializers_test', ['ember-metal', 'ember-application/system/engine', 'ember-application/system/engine-instance', 'ember-application/system/engine-parent'], function (_emberMetal, _engine, _engineInstance, _engineParent) {
'use strict';
var MyEngine = void 0,
myEngine = void 0,
myEngineInstance = void 0;
function buildEngineInstance(EngineClass) {
var engineInstance = EngineClass.buildInstance();
(0, _engineParent.setEngineParent)(engineInstance, {
lookup: function () {
return {};
},
resolveRegistration: function () {
return {};
}
});
return engineInstance;
}
QUnit.module('Ember.Engine instance initializers', {
setup: function () {},
teardown: function () {
(0, _emberMetal.run)(function () {
if (myEngineInstance) {
myEngineInstance.destroy();
}
if (myEngine) {
myEngine.destroy();
}
});
}
});
QUnit.test('initializers require proper \'name\' and \'initialize\' properties', function () {
MyEngine = _engine.default.extend();
expectAssertion(function () {
(0, _emberMetal.run)(function () {
MyEngine.instanceInitializer({ name: 'initializer' });
});
});
expectAssertion(function () {
(0, _emberMetal.run)(function () {
MyEngine.instanceInitializer({
initialize: function () {}
});
});
});
});
QUnit.test('initializers are passed an engine instance', function () {
MyEngine = _engine.default.extend();
MyEngine.instanceInitializer({
name: 'initializer',
initialize: function (instance) {
ok(instance instanceof _engineInstance.default, 'initialize is passed an engine instance');
}
});
myEngine = MyEngine.create();
myEngineInstance = buildEngineInstance(myEngine);
return myEngineInstance.boot();
});
QUnit.test('initializers can be registered in a specified order', function () {
var order = [];
MyEngine = _engine.default.extend();
MyEngine.instanceInitializer({
name: 'fourth',
after: 'third',
initialize: function (engine) {
order.push('fourth');
}
});
MyEngine.instanceInitializer({
name: 'second',
after: 'first',
before: 'third',
initialize: function (engine) {
order.push('second');
}
});
MyEngine.instanceInitializer({
name: 'fifth',
after: 'fourth',
before: 'sixth',
initialize: function (engine) {
order.push('fifth');
}
});
MyEngine.instanceInitializer({
name: 'first',
before: 'second',
initialize: function (engine) {
order.push('first');
}
});
MyEngine.instanceInitializer({
name: 'third',
initialize: function (engine) {
order.push('third');
}
});
MyEngine.instanceInitializer({
name: 'sixth',
initialize: function (engine) {
order.push('sixth');
}
});
myEngine = MyEngine.create();
myEngineInstance = buildEngineInstance(myEngine);
return myEngineInstance.boot().then(function () {
deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']);
});
});
QUnit.test('initializers can be registered in a specified order as an array', function () {
var order = [];
MyEngine = _engine.default.extend();
MyEngine.instanceInitializer({
name: 'third',
initialize: function (engine) {
order.push('third');
}
});
MyEngine.instanceInitializer({
name: 'second',
after: 'first',
before: ['third', 'fourth'],
initialize: function (engine) {
order.push('second');
}
});
MyEngine.instanceInitializer({
name: 'fourth',
after: ['second', 'third'],
initialize: function (engine) {
order.push('fourth');
}
});
MyEngine.instanceInitializer({
name: 'fifth',
after: 'fourth',
before: 'sixth',
initialize: function (engine) {
order.push('fifth');
}
});
MyEngine.instanceInitializer({
name: 'first',
before: ['second'],
initialize: function (engine) {
order.push('first');
}
});
MyEngine.instanceInitializer({
name: 'sixth',
initialize: function (engine) {
order.push('sixth');
}
});
myEngine = MyEngine.create();
myEngineInstance = buildEngineInstance(myEngine);
return myEngineInstance.boot().then(function () {
deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']);
});
});
QUnit.test('initializers can have multiple dependencies', function () {
var order = [];
MyEngine = _engine.default.extend();
var a = {
name: 'a',
before: 'b',
initialize: function (engine) {
order.push('a');
}
};
var b = {
name: 'b',
initialize: function (engine) {
order.push('b');
}
};
var c = {
name: 'c',
after: 'b',
initialize: function (engine) {
order.push('c');
}
};
var afterB = {
name: 'after b',
after: 'b',
initialize: function (engine) {
order.push('after b');
}
};
var afterC = {
name: 'after c',
after: 'c',
initialize: function (engine) {
order.push('after c');
}
};
MyEngine.instanceInitializer(b);
MyEngine.instanceInitializer(a);
MyEngine.instanceInitializer(afterC);
MyEngine.instanceInitializer(afterB);
MyEngine.instanceInitializer(c);
myEngine = MyEngine.create();
myEngineInstance = buildEngineInstance(myEngine);
return myEngineInstance.boot().then(function () {
ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b');
ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c');
ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB');
ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC');
});
});
QUnit.test('initializers set on Engine subclasses should not be shared between engines', function () {
var firstInitializerRunCount = 0;
var secondInitializerRunCount = 0;
var FirstEngine = _engine.default.extend();
var firstEngine = void 0,
firstEngineInstance = void 0;
FirstEngine.instanceInitializer({
name: 'first',
initialize: function (engine) {
firstInitializerRunCount++;
}
});
var SecondEngine = _engine.default.extend();
var secondEngine = void 0,
secondEngineInstance = void 0;
SecondEngine.instanceInitializer({
name: 'second',
initialize: function (engine) {
secondInitializerRunCount++;
}
});
firstEngine = FirstEngine.create();
firstEngineInstance = buildEngineInstance(firstEngine);
return firstEngineInstance.boot().then(function () {
equal(firstInitializerRunCount, 1, 'first initializer only was run');
equal(secondInitializerRunCount, 0, 'first initializer only was run');
secondEngine = SecondEngine.create();
secondEngineInstance = buildEngineInstance(secondEngine);
return secondEngineInstance.boot();
}).then(function () {
equal(firstInitializerRunCount, 1, 'second initializer only was run');
equal(secondInitializerRunCount, 1, 'second initializer only was run');
(0, _emberMetal.run)(function () {
firstEngineInstance.destroy();
secondEngineInstance.destroy();
firstEngine.destroy();
secondEngine.destroy();
});
});
});
QUnit.test('initializers are concatenated', function () {
var firstInitializerRunCount = 0;
var secondInitializerRunCount = 0;
var FirstEngine = _engine.default.extend();
FirstEngine.instanceInitializer({
name: 'first',
initialize: function (engine) {
firstInitializerRunCount++;
}
});
var SecondEngine = FirstEngine.extend();
SecondEngine.instanceInitializer({
name: 'second',
initialize: function (engine) {
secondInitializerRunCount++;
}
});
var firstEngine = FirstEngine.create();
var firstEngineInstance = buildEngineInstance(firstEngine);
var secondEngine = void 0,
secondEngineInstance = void 0;
return firstEngineInstance.boot().then(function () {
equal(firstInitializerRunCount, 1, 'first initializer only was run when base class created');
equal(secondInitializerRunCount, 0, 'second initializer was not run when first base class created');
firstInitializerRunCount = 0;
secondEngine = SecondEngine.create();
secondEngineInstance = buildEngineInstance(secondEngine);
return secondEngineInstance.boot();
}).then(function () {
equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created');
equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created');
(0, _emberMetal.run)(function () {
firstEngineInstance.destroy();
secondEngineInstance.destroy();
firstEngine.destroy();
secondEngine.destroy();
});
});
});
QUnit.test('initializers are per-engine', function () {
expect(2);
var FirstEngine = _engine.default.extend();
FirstEngine.instanceInitializer({
name: 'abc',
initialize: function (engine) {}
});
expectAssertion(function () {
FirstEngine.instanceInitializer({
name: 'abc',
initialize: function (engine) {}
});
});
var SecondEngine = _engine.default.extend();
SecondEngine.instanceInitializer({
name: 'abc',
initialize: function (engine) {}
});
ok(true, 'Two engines can have initializers named the same.');
});
QUnit.test('initializers are executed in their own context', function () {
expect(1);
var MyEngine = _engine.default.extend();
MyEngine.instanceInitializer({
name: 'coolInitializer',
myProperty: 'cool',
initialize: function (engine) {
equal(this.myProperty, 'cool', 'should have access to its own context');
}
});
myEngine = MyEngine.create();
myEngineInstance = buildEngineInstance(myEngine);
return myEngineInstance.boot();
});
});
QUnit.module('ESLint | ember-application/tests/system/engine_instance_initializers_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/engine_instance_initializers_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/engine_instance_test', ['ember-application/system/engine', 'ember-application/system/engine-instance', 'ember-application/system/engine-parent', 'ember-metal', 'internal-test-helpers'], function (_engine, _engineInstance, _engineParent, _emberMetal, _internalTestHelpers) {
'use strict';
var engine = void 0,
engineInstance = void 0;
QUnit.module('Ember.EngineInstance', {
setup: function () {
(0, _emberMetal.run)(function () {
engine = _engine.default.create({ router: null });
});
},
teardown: function () {
if (engineInstance) {
(0, _emberMetal.run)(engineInstance, 'destroy');
}
if (engine) {
(0, _emberMetal.run)(engine, 'destroy');
}
}
});
QUnit.test('an engine instance can be created based upon a base engine', function () {
(0, _emberMetal.run)(function () {
engineInstance = _engineInstance.default.create({ base: engine });
});
ok(engineInstance, 'instance should be created');
equal(engineInstance.base, engine, 'base should be set to engine');
});
QUnit.test('unregistering a factory clears all cached instances of that factory', function (assert) {
assert.expect(3);
engineInstance = (0, _emberMetal.run)(function () {
return _engineInstance.default.create({ base: engine });
});
var PostComponent = (0, _internalTestHelpers.factory)();
engineInstance.register('component:post', PostComponent);
var postComponent1 = engineInstance.lookup('component:post');
assert.ok(postComponent1, 'lookup creates instance');
engineInstance.unregister('component:post');
engineInstance.register('component:post', PostComponent);
var postComponent2 = engineInstance.lookup('component:post');
assert.ok(postComponent2, 'lookup creates instance');
assert.notStrictEqual(postComponent1, postComponent2, 'lookup creates a brand new instance because previous one was reset');
});
QUnit.test('can be booted when its parent has been set', function (assert) {
assert.expect(3);
engineInstance = (0, _emberMetal.run)(function () {
return _engineInstance.default.create({ base: engine });
});
expectAssertion(function () {
engineInstance._bootSync();
}, 'An engine instance\'s parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.');
(0, _engineParent.setEngineParent)(engineInstance, {});
// Stub `cloneParentDependencies`, the internals of which are tested along
// with application instances.
engineInstance.cloneParentDependencies = function () {
assert.ok(true, 'parent dependencies are cloned');
};
return engineInstance.boot().then(function () {
assert.ok(true, 'boot successful');
});
});
QUnit.test('can build a child instance of a registered engine', function (assert) {
var ChatEngine = _engine.default.extend();
var chatEngineInstance = void 0;
engine.register('engine:chat', ChatEngine);
(0, _emberMetal.run)(function () {
engineInstance = _engineInstance.default.create({ base: engine });
// Try to build an unregistered engine.
throws(function () {
engineInstance.buildChildEngineInstance('fake');
}, 'You attempted to mount the engine \'fake\', but it is not registered with its parent.');
// Build the `chat` engine, registered above.
chatEngineInstance = engineInstance.buildChildEngineInstance('chat');
});
assert.ok(chatEngineInstance, 'child engine instance successfully created');
assert.strictEqual((0, _engineParent.getEngineParent)(chatEngineInstance), engineInstance, 'child engine instance is assigned the correct parent');
});
});
QUnit.module('ESLint | ember-application/tests/system/engine_instance_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/engine_instance_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/engine_parent_test', ['ember-application/system/engine-parent'], function (_engineParent) {
'use strict';
QUnit.module('EngineParent', {});
QUnit.test('An engine\'s parent can be set with `setEngineParent` and retrieved with `getEngineParent`', function () {
var engine = {};
var parent = {};
strictEqual((0, _engineParent.getEngineParent)(engine), undefined, 'parent has not been set');
(0, _engineParent.setEngineParent)(engine, parent);
strictEqual((0, _engineParent.getEngineParent)(engine), parent, 'parent has been set');
strictEqual(engine[_engineParent.ENGINE_PARENT], parent, 'parent has been set to the ENGINE_PARENT symbol');
});
});
QUnit.module('ESLint | ember-application/tests/system/engine_parent_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/engine_parent_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/engine_test', ['ember-babel', 'ember-environment', 'ember-metal', 'ember-application/system/engine', 'ember-runtime', 'container', 'ember-application/tests/test-helpers/registry-check'], function (_emberBabel, _emberEnvironment, _emberMetal, _engine, _emberRuntime, _container, _registryCheck) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['-bucket-cache:main'], ['-bucket-cache:main']),
_templateObject2 = (0, _emberBabel.taggedTemplateLiteralLoose)(['template:components/-default'], ['template:components/-default']);
var engine = void 0;
var originalLookup = _emberEnvironment.context.lookup;
var lookup = void 0;
QUnit.module('Ember.Engine', {
setup: function () {
lookup = _emberEnvironment.context.lookup = {};
engine = (0, _emberMetal.run)(function () {
return _engine.default.create();
});
},
teardown: function () {
_emberEnvironment.context.lookup = originalLookup;
if (engine) {
(0, _emberMetal.run)(engine, 'destroy');
}
}
});
QUnit.test('acts like a namespace', function () {
engine = (0, _emberMetal.run)(function () {
return lookup.TestEngine = _engine.default.create();
});
engine.Foo = _emberRuntime.Object.extend();
equal(engine.Foo.toString(), 'TestEngine.Foo', 'Classes pick up their parent namespace');
});
QUnit.test('builds a registry', function () {
strictEqual(engine.resolveRegistration('application:main'), engine, 'application:main is registered');
deepEqual(engine.registeredOptionsForType('component'), { singleton: false }, 'optionsForType \'component\'');
deepEqual(engine.registeredOptionsForType('view'), { singleton: false }, 'optionsForType \'view\'');
(0, _registryCheck.verifyRegistration)(engine, 'controller:basic');
(0, _registryCheck.verifyInjection)(engine, 'view', '_viewRegistry', '-view-registry:main');
(0, _registryCheck.verifyInjection)(engine, 'route', '_topLevelViewTemplate', 'template:-outlet');
(0, _registryCheck.verifyInjection)(engine, 'view:-outlet', 'namespace', 'application:main');
(0, _registryCheck.verifyInjection)(engine, 'controller', 'target', 'router:main');
(0, _registryCheck.verifyInjection)(engine, 'controller', 'namespace', 'application:main');
(0, _registryCheck.verifyInjection)(engine, 'router', '_bucketCache', (0, _container.privatize)(_templateObject));
(0, _registryCheck.verifyInjection)(engine, 'route', '_bucketCache', (0, _container.privatize)(_templateObject));
(0, _registryCheck.verifyInjection)(engine, 'route', 'router', 'router:main');
(0, _registryCheck.verifyRegistration)(engine, 'component:-text-field');
(0, _registryCheck.verifyRegistration)(engine, 'component:-text-area');
(0, _registryCheck.verifyRegistration)(engine, 'component:-checkbox');
(0, _registryCheck.verifyRegistration)(engine, 'component:link-to');
(0, _registryCheck.verifyRegistration)(engine, 'service:-routing');
(0, _registryCheck.verifyInjection)(engine, 'service:-routing', 'router', 'router:main');
// DEBUGGING
(0, _registryCheck.verifyRegistration)(engine, 'resolver-for-debugging:main');
(0, _registryCheck.verifyInjection)(engine, 'container-debug-adapter:main', 'resolver', 'resolver-for-debugging:main');
(0, _registryCheck.verifyInjection)(engine, 'data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main');
(0, _registryCheck.verifyRegistration)(engine, 'container-debug-adapter:main');
(0, _registryCheck.verifyRegistration)(engine, 'component-lookup:main');
(0, _registryCheck.verifyInjection)(engine, 'service:-dom-changes', 'document', 'service:-document');
(0, _registryCheck.verifyInjection)(engine, 'service:-dom-tree-construction', 'document', 'service:-document');
(0, _registryCheck.verifyRegistration)(engine, 'view:-outlet');
(0, _registryCheck.verifyRegistration)(engine, (0, _container.privatize)(_templateObject2));
(0, _registryCheck.verifyRegistration)(engine, 'template:-outlet');
(0, _registryCheck.verifyInjection)(engine, 'view:-outlet', 'template', 'template:-outlet');
(0, _registryCheck.verifyInjection)(engine, 'template', 'env', 'service:-glimmer-environment');
deepEqual(engine.registeredOptionsForType('helper'), { instantiate: false }, 'optionsForType \'helper\'');
});
});
QUnit.module('ESLint | ember-application/tests/system/engine_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/engine_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/initializers_test', ['ember-babel', 'ember-utils', 'internal-test-helpers', 'ember-application', 'ember-views'], function (_emberBabel, _emberUtils, _internalTestHelpers, _emberApplication, _emberViews) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Ember.Application initializers', function (_AutobootApplicationT) {
(0, _emberBabel.inherits)(_class, _AutobootApplicationT);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
(0, _emberViews.jQuery)('#qunit-fixture').html('\n
ONE
\n
TWO
\n ');
return (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT.call(this));
}
_class.prototype.createSecondApplication = function createSecondApplication(options) {
var MyApplication = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emberApplication.Application;
var myOptions = (0, _emberUtils.assign)(this.applicationOptions, {
rootElement: '#two'
}, options);
var secondApp = this.secondApp = MyApplication.create(myOptions);
return secondApp;
};
_class.prototype.teardown = function teardown() {
var _this2 = this;
_AutobootApplicationT.prototype.teardown.call(this);
if (this.secondApp) {
this.runTask(function () {
return _this2.secondApp.destroy();
});
}
};
_class.prototype['@test initializers require proper \'name\' and \'initialize\' properties'] = function () {
var MyApplication = _emberApplication.Application.extend();
expectAssertion(function () {
MyApplication.initializer({ name: 'initializer' });
});
expectAssertion(function () {
MyApplication.initializer({
initialize: function () {}
});
});
};
_class.prototype['@test initializers that throw errors cause the boot promise to reject with the error'] = function (assert) {
var _this3 = this;
assert.expect(2);
var MyApplication = _emberApplication.Application.extend();
MyApplication.initializer({
name: 'initializer',
initialize: function () {
throw new Error('boot failure');
}
});
this.runTask(function () {
_this3.createApplication({
autoboot: false
}, MyApplication);
});
var app = this.application;
try {
this.runTask(function () {
app.boot().then(function (app) {
assert.ok(false, 'The boot promise should not resolve when there is a boot error');
}, function (error) {
assert.ok(error instanceof Error, 'The boot promise should reject with an error');
assert.equal(error.message, 'boot failure');
});
});
} catch (error) {
assert.ok(false, 'The boot method should not throw');
throw error;
}
};
_class.prototype['@test initializers are passed an App'] = function (assert) {
var _this4 = this;
var MyApplication = _emberApplication.Application.extend();
MyApplication.initializer({
name: 'initializer',
initialize: function (App) {
assert.ok(App instanceof _emberApplication.Application, 'initialize is passed an Application');
}
});
this.runTask(function () {
return _this4.createApplication({}, MyApplication);
});
};
_class.prototype['@test initializers can be registered in a specified order'] = function (assert) {
var _this5 = this;
var order = [];
var MyApplication = _emberApplication.Application.extend();
MyApplication.initializer({
name: 'fourth',
after: 'third',
initialize: function (registry) {
order.push('fourth');
}
});
MyApplication.initializer({
name: 'second',
after: 'first',
before: 'third',
initialize: function (registry) {
order.push('second');
}
});
MyApplication.initializer({
name: 'fifth',
after: 'fourth',
before: 'sixth',
initialize: function (registry) {
order.push('fifth');
}
});
MyApplication.initializer({
name: 'first',
before: 'second',
initialize: function (registry) {
order.push('first');
}
});
MyApplication.initializer({
name: 'third',
initialize: function (registry) {
order.push('third');
}
});
MyApplication.initializer({
name: 'sixth',
initialize: function (registry) {
order.push('sixth');
}
});
this.runTask(function () {
return _this5.createApplication({}, MyApplication);
});
assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']);
};
_class.prototype['@test initializers can be registered in a specified order as an array'] = function (assert) {
var _this6 = this;
var order = [];
var MyApplication = _emberApplication.Application.extend();
MyApplication.initializer({
name: 'third',
initialize: function (registry) {
order.push('third');
}
});
MyApplication.initializer({
name: 'second',
after: 'first',
before: ['third', 'fourth'],
initialize: function (registry) {
order.push('second');
}
});
MyApplication.initializer({
name: 'fourth',
after: ['second', 'third'],
initialize: function (registry) {
order.push('fourth');
}
});
MyApplication.initializer({
name: 'fifth',
after: 'fourth',
before: 'sixth',
initialize: function (registry) {
order.push('fifth');
}
});
MyApplication.initializer({
name: 'first',
before: ['second'],
initialize: function (registry) {
order.push('first');
}
});
MyApplication.initializer({
name: 'sixth',
initialize: function (registry) {
order.push('sixth');
}
});
this.runTask(function () {
return _this6.createApplication({}, MyApplication);
});
assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']);
};
_class.prototype['@test initializers can have multiple dependencies'] = function (assert) {
var _this7 = this;
var order = [];
var MyApplication = _emberApplication.Application.extend();
var a = {
name: 'a',
before: 'b',
initialize: function (registry) {
order.push('a');
}
};
var b = {
name: 'b',
initialize: function (registry) {
order.push('b');
}
};
var c = {
name: 'c',
after: 'b',
initialize: function (registry) {
order.push('c');
}
};
var afterB = {
name: 'after b',
after: 'b',
initialize: function (registry) {
order.push('after b');
}
};
var afterC = {
name: 'after c',
after: 'c',
initialize: function (registry) {
order.push('after c');
}
};
MyApplication.initializer(b);
MyApplication.initializer(a);
MyApplication.initializer(afterC);
MyApplication.initializer(afterB);
MyApplication.initializer(c);
this.runTask(function () {
return _this7.createApplication({}, MyApplication);
});
assert.ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b');
assert.ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c');
assert.ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB');
assert.ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC');
};
_class.prototype['@test initializers set on Application subclasses are not shared between apps'] = function (assert) {
var _this8 = this;
var firstInitializerRunCount = 0;
var secondInitializerRunCount = 0;
var FirstApp = _emberApplication.Application.extend();
FirstApp.initializer({
name: 'first',
initialize: function (registry) {
firstInitializerRunCount++;
}
});
var SecondApp = _emberApplication.Application.extend();
SecondApp.initializer({
name: 'second',
initialize: function (registry) {
secondInitializerRunCount++;
}
});
this.runTask(function () {
return _this8.createApplication({}, FirstApp);
});
assert.equal(firstInitializerRunCount, 1, 'first initializer only was run');
assert.equal(secondInitializerRunCount, 0, 'first initializer only was run');
this.runTask(function () {
return _this8.createSecondApplication({}, SecondApp);
});
assert.equal(firstInitializerRunCount, 1, 'second initializer only was run');
assert.equal(secondInitializerRunCount, 1, 'second initializer only was run');
};
_class.prototype['@test initializers are concatenated'] = function (assert) {
var _this9 = this;
var firstInitializerRunCount = 0;
var secondInitializerRunCount = 0;
var FirstApp = _emberApplication.Application.extend();
FirstApp.initializer({
name: 'first',
initialize: function (registry) {
firstInitializerRunCount++;
}
});
var SecondApp = FirstApp.extend();
SecondApp.initializer({
name: 'second',
initialize: function (registry) {
secondInitializerRunCount++;
}
});
this.runTask(function () {
return _this9.createApplication({}, FirstApp);
});
assert.equal(firstInitializerRunCount, 1, 'first initializer only was run when base class created');
assert.equal(secondInitializerRunCount, 0, 'first initializer only was run when base class created');
firstInitializerRunCount = 0;
this.runTask(function () {
return _this9.createSecondApplication({}, SecondApp);
});
assert.equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created');
assert.equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created');
};
_class.prototype['@test initializers are per-app'] = function (assert) {
assert.expect(2);
var FirstApp = _emberApplication.Application.extend();
FirstApp.initializer({
name: 'abc',
initialize: function (app) {}
});
expectAssertion(function () {
FirstApp.initializer({
name: 'abc',
initialize: function (app) {}
});
});
var SecondApp = _emberApplication.Application.extend();
SecondApp.instanceInitializer({
name: 'abc',
initialize: function (app) {}
});
assert.ok(true, 'Two apps can have initializers named the same.');
};
_class.prototype['@test initializers are executed in their own context'] = function (assert) {
var _this10 = this;
assert.expect(1);
var MyApplication = _emberApplication.Application.extend();
MyApplication.initializer({
name: 'coolInitializer',
myProperty: 'cool',
initialize: function (application) {
assert.equal(this.myProperty, 'cool', 'should have access to its own context');
}
});
this.runTask(function () {
return _this10.createApplication({}, MyApplication);
});
};
_class.prototype['@test initializers throw a deprecation warning when receiving a second argument'] = function (assert) {
var _this11 = this;
assert.expect(1);
var MyApplication = _emberApplication.Application.extend();
MyApplication.initializer({
name: 'deprecated',
initialize: function (registry, application) {}
});
expectDeprecation(function () {
_this11.runTask(function () {
return _this11.createApplication({}, MyApplication);
});
}, /The `initialize` method for Application initializer 'deprecated' should take only one argument - `App`, an instance of an `Application`./);
};
(0, _emberBabel.createClass)(_class, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_AutobootApplicationT.prototype.applicationOptions, {
rootElement: '#one'
});
}
}]);
return _class;
}(_internalTestHelpers.AutobootApplicationTestCase));
});
QUnit.module('ESLint | ember-application/tests/system/initializers_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/initializers_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/instance_initializers_test', ['ember-babel', 'ember-utils', 'internal-test-helpers', 'ember-application', 'ember-views'], function (_emberBabel, _emberUtils, _internalTestHelpers, _emberApplication, _emberViews) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Ember.Application instance initializers', function (_AutobootApplicationT) {
(0, _emberBabel.inherits)(_class, _AutobootApplicationT);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
(0, _emberViews.jQuery)('#qunit-fixture').html('\n
ONE
\n
TWO
\n ');
return (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT.call(this));
}
_class.prototype.createSecondApplication = function createSecondApplication(options) {
var MyApplication = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emberApplication.Application;
var myOptions = (0, _emberUtils.assign)(this.applicationOptions, {
rootElement: '#two'
}, options);
var secondApp = this.secondApp = MyApplication.create(myOptions);
return secondApp;
};
_class.prototype.teardown = function teardown() {
var _this2 = this;
_AutobootApplicationT.prototype.teardown.call(this);
if (this.secondApp) {
this.runTask(function () {
return _this2.secondApp.destroy();
});
}
};
_class.prototype['@test initializers require proper \'name\' and \'initialize\' properties'] = function () {
var _this3 = this;
var MyApplication = _emberApplication.Application.extend();
expectAssertion(function () {
MyApplication.instanceInitializer({ name: 'initializer' });
});
expectAssertion(function () {
MyApplication.instanceInitializer({
initialize: function () {}
});
});
this.runTask(function () {
return _this3.createApplication({}, MyApplication);
});
};
_class.prototype['@test initializers are passed an app instance'] = function (assert) {
var _this4 = this;
var MyApplication = _emberApplication.Application.extend();
MyApplication.instanceInitializer({
name: 'initializer',
initialize: function (instance) {
assert.ok(instance instanceof _emberApplication.ApplicationInstance, 'initialize is passed an application instance');
}
});
this.runTask(function () {
return _this4.createApplication({}, MyApplication);
});
};
_class.prototype['@test initializers can be registered in a specified order'] = function (assert) {
var _this5 = this;
var order = [];
var MyApplication = _emberApplication.Application.extend();
MyApplication.instanceInitializer({
name: 'fourth',
after: 'third',
initialize: function (registry) {
order.push('fourth');
}
});
MyApplication.instanceInitializer({
name: 'second',
after: 'first',
before: 'third',
initialize: function (registry) {
order.push('second');
}
});
MyApplication.instanceInitializer({
name: 'fifth',
after: 'fourth',
before: 'sixth',
initialize: function (registry) {
order.push('fifth');
}
});
MyApplication.instanceInitializer({
name: 'first',
before: 'second',
initialize: function (registry) {
order.push('first');
}
});
MyApplication.instanceInitializer({
name: 'third',
initialize: function (registry) {
order.push('third');
}
});
MyApplication.instanceInitializer({
name: 'sixth',
initialize: function (registry) {
order.push('sixth');
}
});
this.runTask(function () {
return _this5.createApplication({}, MyApplication);
});
assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']);
};
_class.prototype['@test initializers can be registered in a specified order as an array'] = function (assert) {
var _this6 = this;
var order = [];
var MyApplication = _emberApplication.Application.extend();
MyApplication.instanceInitializer({
name: 'third',
initialize: function (registry) {
order.push('third');
}
});
MyApplication.instanceInitializer({
name: 'second',
after: 'first',
before: ['third', 'fourth'],
initialize: function (registry) {
order.push('second');
}
});
MyApplication.instanceInitializer({
name: 'fourth',
after: ['second', 'third'],
initialize: function (registry) {
order.push('fourth');
}
});
MyApplication.instanceInitializer({
name: 'fifth',
after: 'fourth',
before: 'sixth',
initialize: function (registry) {
order.push('fifth');
}
});
MyApplication.instanceInitializer({
name: 'first',
before: ['second'],
initialize: function (registry) {
order.push('first');
}
});
MyApplication.instanceInitializer({
name: 'sixth',
initialize: function (registry) {
order.push('sixth');
}
});
this.runTask(function () {
return _this6.createApplication({}, MyApplication);
});
assert.deepEqual(order, ['first', 'second', 'third', 'fourth', 'fifth', 'sixth']);
};
_class.prototype['@test initializers can have multiple dependencies'] = function (assert) {
var _this7 = this;
var order = [];
var MyApplication = _emberApplication.Application.extend();
var a = {
name: 'a',
before: 'b',
initialize: function (registry) {
order.push('a');
}
};
var b = {
name: 'b',
initialize: function (registry) {
order.push('b');
}
};
var c = {
name: 'c',
after: 'b',
initialize: function (registry) {
order.push('c');
}
};
var afterB = {
name: 'after b',
after: 'b',
initialize: function (registry) {
order.push('after b');
}
};
var afterC = {
name: 'after c',
after: 'c',
initialize: function (registry) {
order.push('after c');
}
};
MyApplication.instanceInitializer(b);
MyApplication.instanceInitializer(a);
MyApplication.instanceInitializer(afterC);
MyApplication.instanceInitializer(afterB);
MyApplication.instanceInitializer(c);
this.runTask(function () {
return _this7.createApplication({}, MyApplication);
});
assert.ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b');
assert.ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c');
assert.ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB');
assert.ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC');
};
_class.prototype['@test initializers set on Application subclasses should not be shared between apps'] = function (assert) {
var _this8 = this;
var firstInitializerRunCount = 0;
var secondInitializerRunCount = 0;
var FirstApp = _emberApplication.Application.extend();
FirstApp.instanceInitializer({
name: 'first',
initialize: function (registry) {
firstInitializerRunCount++;
}
});
var SecondApp = _emberApplication.Application.extend();
SecondApp.instanceInitializer({
name: 'second',
initialize: function (registry) {
secondInitializerRunCount++;
}
});
this.runTask(function () {
return _this8.createApplication({}, FirstApp);
});
assert.equal(firstInitializerRunCount, 1, 'first initializer only was run');
assert.equal(secondInitializerRunCount, 0, 'first initializer only was run');
this.runTask(function () {
return _this8.createSecondApplication({}, SecondApp);
});
assert.equal(firstInitializerRunCount, 1, 'second initializer only was run');
assert.equal(secondInitializerRunCount, 1, 'second initializer only was run');
};
_class.prototype['@test initializers are concatenated'] = function (assert) {
var _this9 = this;
var firstInitializerRunCount = 0;
var secondInitializerRunCount = 0;
var FirstApp = _emberApplication.Application.extend();
FirstApp.instanceInitializer({
name: 'first',
initialize: function (registry) {
firstInitializerRunCount++;
}
});
var SecondApp = FirstApp.extend();
SecondApp.instanceInitializer({
name: 'second',
initialize: function (registry) {
secondInitializerRunCount++;
}
});
this.runTask(function () {
return _this9.createApplication({}, FirstApp);
});
equal(firstInitializerRunCount, 1, 'first initializer only was run when base class created');
equal(secondInitializerRunCount, 0, 'first initializer only was run when base class created');
firstInitializerRunCount = 0;
this.runTask(function () {
return _this9.createSecondApplication({}, SecondApp);
});
equal(firstInitializerRunCount, 1, 'first initializer was run when subclass created');
equal(secondInitializerRunCount, 1, 'second initializers was run when subclass created');
};
_class.prototype['@test initializers are per-app'] = function (assert) {
var _this10 = this;
assert.expect(2);
var FirstApp = _emberApplication.Application.extend();
FirstApp.instanceInitializer({
name: 'abc',
initialize: function (app) {}
});
expectAssertion(function () {
FirstApp.instanceInitializer({
name: 'abc',
initialize: function (app) {}
});
});
this.runTask(function () {
return _this10.createApplication({}, FirstApp);
});
var SecondApp = _emberApplication.Application.extend();
SecondApp.instanceInitializer({
name: 'abc',
initialize: function (app) {}
});
this.runTask(function () {
return _this10.createSecondApplication({}, SecondApp);
});
assert.ok(true, 'Two apps can have initializers named the same.');
};
_class.prototype['@test initializers are run before ready hook'] = function (assert) {
var _this11 = this;
assert.expect(2);
var MyApplication = _emberApplication.Application.extend({
ready: function () {
assert.ok(true, 'ready is called');
readyWasCalled = false;
}
});
var readyWasCalled = false;
MyApplication.instanceInitializer({
name: 'initializer',
initialize: function () {
assert.ok(!readyWasCalled, 'ready is not yet called');
}
});
this.runTask(function () {
return _this11.createApplication({}, MyApplication);
});
};
_class.prototype['@test initializers are executed in their own context'] = function (assert) {
var _this12 = this;
assert.expect(1);
var MyApplication = _emberApplication.Application.extend();
MyApplication.instanceInitializer({
name: 'coolInitializer',
myProperty: 'cool',
initialize: function (registry, application) {
assert.equal(this.myProperty, 'cool', 'should have access to its own context');
}
});
this.runTask(function () {
return _this12.createApplication({}, MyApplication);
});
};
_class.prototype['@test initializers get an instance on app reset'] = function (assert) {
var _this13 = this;
assert.expect(2);
var MyApplication = _emberApplication.Application.extend();
MyApplication.instanceInitializer({
name: 'giveMeAnInstance',
initialize: function (instance) {
assert.ok(!!instance, 'Initializer got an instance');
}
});
this.runTask(function () {
return _this13.createApplication({}, MyApplication);
});
this.runTask(function () {
return _this13.application.reset();
});
};
(0, _emberBabel.createClass)(_class, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_AutobootApplicationT.prototype.applicationOptions, {
rootElement: '#one'
});
}
}]);
return _class;
}(_internalTestHelpers.AutobootApplicationTestCase));
});
QUnit.module('ESLint | ember-application/tests/system/instance_initializers_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/instance_initializers_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/logging_test', ['ember-babel', 'internal-test-helpers', 'ember-console', 'ember-runtime', 'ember-routing', 'ember-utils'], function (_emberBabel, _internalTestHelpers, _emberConsole, _emberRuntime, _emberRouting, _emberUtils) {
'use strict';
var LoggingApplicationTestCase = function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(LoggingApplicationTestCase, _ApplicationTestCase);
function LoggingApplicationTestCase() {
(0, _emberBabel.classCallCheck)(this, LoggingApplicationTestCase);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.call(this));
_this.logs = {};
_this._originalLogger = _emberConsole.default.info;
_emberConsole.default.info = function (_, _ref) {
var fullName = _ref.fullName;
if (!_this.logs.hasOwnProperty(fullName)) {
_this.logs[fullName] = 0;
}
_this.logs[fullName]++;
};
_this.router.map(function () {
this.route('posts', { resetNamespace: true });
});
return _this;
}
LoggingApplicationTestCase.prototype.teardown = function teardown() {
_emberConsole.default.info = this._originalLogger;
_ApplicationTestCase.prototype.teardown.call(this);
};
return LoggingApplicationTestCase;
}(_internalTestHelpers.ApplicationTestCase);
(0, _internalTestHelpers.moduleFor)('Ember.Application with LOG_ACTIVE_GENERATION=true', function (_LoggingApplicationTe) {
(0, _emberBabel.inherits)(_class, _LoggingApplicationTe);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _LoggingApplicationTe.apply(this, arguments));
}
_class.prototype['@test log class generation if logging enabled'] = function testLogClassGenerationIfLoggingEnabled(assert) {
if (EmberDev && EmberDev.runningProdBuild) {
assert.ok(true, 'Logging does not occur in production builds');
return;
}
this.visit('/posts');
assert.equal(Object.keys(this.logs).length, 4, 'expected logs');
};
_class.prototype['@test actively generated classes get logged'] = function testActivelyGeneratedClassesGetLogged(assert) {
if (EmberDev && EmberDev.runningProdBuild) {
assert.ok(true, 'Logging does not occur in production builds');
return;
}
this.visit('/posts');
assert.equal(this.logs['controller:application'], 1, 'expected: ApplicationController was generated');
assert.equal(this.logs['controller:posts'], 1, 'expected: PostsController was generated');
assert.equal(this.logs['route:application'], 1, 'expected: ApplicationRoute was generated');
assert.equal(this.logs['route:posts'], 1, 'expected: PostsRoute was generated');
};
_class.prototype['@test predefined classes do not get logged'] = function testPredefinedClassesDoNotGetLogged(assert) {
this.add('controller:application', _emberRuntime.Controller.extend());
this.add('controller:posts', _emberRuntime.Controller.extend());
this.add('route:application', _emberRouting.Route.extend());
this.add('route:posts', _emberRouting.Route.extend());
this.visit('/posts');
assert.ok(!this.logs['controller:application'], 'did not expect: ApplicationController was generated');
assert.ok(!this.logs['controller:posts'], 'did not expect: PostsController was generated');
assert.ok(!this.logs['route:application'], 'did not expect: ApplicationRoute was generated');
assert.ok(!this.logs['route:posts'], 'did not expect: PostsRoute was generated');
};
(0, _emberBabel.createClass)(_class, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_LoggingApplicationTe.prototype.applicationOptions, {
LOG_ACTIVE_GENERATION: true
});
}
}]);
return _class;
}(LoggingApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Ember.Application when LOG_ACTIVE_GENERATION=false', function (_LoggingApplicationTe2) {
(0, _emberBabel.inherits)(_class2, _LoggingApplicationTe2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _LoggingApplicationTe2.apply(this, arguments));
}
_class2.prototype['@test do NOT log class generation if logging disabled'] = function (assert) {
this.visit('/posts');
assert.equal(Object.keys(this.logs).length, 0, 'expected logs');
};
(0, _emberBabel.createClass)(_class2, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_LoggingApplicationTe2.prototype.applicationOptions, {
LOG_ACTIVE_GENERATION: false
});
}
}]);
return _class2;
}(LoggingApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Ember.Application with LOG_VIEW_LOOKUPS=true', function (_LoggingApplicationTe3) {
(0, _emberBabel.inherits)(_class3, _LoggingApplicationTe3);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
return (0, _emberBabel.possibleConstructorReturn)(this, _LoggingApplicationTe3.apply(this, arguments));
}
_class3.prototype['@test log when template and view are missing when flag is active'] = function (assert) {
if (EmberDev && EmberDev.runningProdBuild) {
assert.ok(true, 'Logging does not occur in production builds');
return;
}
this.addTemplate('application', '{{outlet}}');
this.visit('/');
this.visit('/posts');
assert.equal(this.logs['template:application'], undefined, 'expected: Should not log template:application since it exists.');
assert.equal(this.logs['template:index'], 1, 'expected: Could not find "index" template or view.');
assert.equal(this.logs['template:posts'], 1, 'expected: Could not find "posts" template or view.');
};
(0, _emberBabel.createClass)(_class3, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_LoggingApplicationTe3.prototype.applicationOptions, {
LOG_VIEW_LOOKUPS: true
});
}
}]);
return _class3;
}(LoggingApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Ember.Application with LOG_VIEW_LOOKUPS=false', function (_LoggingApplicationTe4) {
(0, _emberBabel.inherits)(_class4, _LoggingApplicationTe4);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
return (0, _emberBabel.possibleConstructorReturn)(this, _LoggingApplicationTe4.apply(this, arguments));
}
_class4.prototype['@test do not log when template and view are missing when flag is not true'] = function (assert) {
this.visit('/posts');
assert.equal(Object.keys(this.logs).length, 0, 'expected no logs');
};
_class4.prototype['@test do not log which views are used with templates when flag is not true'] = function (assert) {
this.visit('/posts');
assert.equal(Object.keys(this.logs).length, 0, 'expected no logs');
};
(0, _emberBabel.createClass)(_class4, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_LoggingApplicationTe4.prototype.applicationOptions, {
LOG_VIEW_LOOKUPS: false
});
}
}]);
return _class4;
}(LoggingApplicationTestCase));
});
QUnit.module('ESLint | ember-application/tests/system/logging_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/logging_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/readiness_test', ['ember-metal', 'ember-application/system/application'], function (_emberMetal, _application) {
'use strict';
var jQuery = void 0,
application = void 0,
Application = void 0;
var readyWasCalled = void 0,
domReady = void 0,
readyCallbacks = void 0;
// We are using a small mock of jQuery because jQuery is third-party code with
// very well-defined semantics, and we want to confirm that a jQuery stub run
// in a more minimal server environment that implements this behavior will be
// sufficient for Ember's requirements.
QUnit.module('Application readiness', {
setup: function () {
readyWasCalled = 0;
readyCallbacks = [];
var jQueryInstance = {
ready: function (callback) {
readyCallbacks.push(callback);
if (jQuery.isReady) {
domReady();
}
}
};
jQuery = function () {
return jQueryInstance;
};
jQuery.isReady = false;
var domReadyCalled = 0;
domReady = function () {
if (domReadyCalled !== 0) {
return;
}
domReadyCalled++;
for (var i = 0; i < readyCallbacks.length; i++) {
readyCallbacks[i]();
}
};
Application = _application.default.extend({
$: jQuery,
ready: function () {
readyWasCalled++;
}
});
},
teardown: function () {
if (application) {
(0, _emberMetal.run)(function () {
return application.destroy();
});
}
}
});
// These tests are confirming that if the callbacks passed into jQuery's ready hook is called
// synchronously during the application's initialization, we get the same behavior as if
// it was triggered after initialization.
QUnit.test('Ember.Application\'s ready event is called right away if jQuery is already ready', function () {
jQuery.isReady = true;
(0, _emberMetal.run)(function () {
application = Application.create({ router: false });
equal(readyWasCalled, 0, 'ready is not called until later');
});
equal(readyWasCalled, 1, 'ready was called');
domReady();
equal(readyWasCalled, 1, 'application\'s ready was not called again');
});
QUnit.test('Ember.Application\'s ready event is called after the document becomes ready', function () {
(0, _emberMetal.run)(function () {
application = Application.create({ router: false });
});
equal(readyWasCalled, 0, 'ready wasn\'t called yet');
domReady();
equal(readyWasCalled, 1, 'ready was called now that DOM is ready');
});
QUnit.test('Ember.Application\'s ready event can be deferred by other components', function () {
(0, _emberMetal.run)(function () {
application = Application.create({ router: false });
application.deferReadiness();
});
equal(readyWasCalled, 0, 'ready wasn\'t called yet');
domReady();
equal(readyWasCalled, 0, 'ready wasn\'t called yet');
(0, _emberMetal.run)(function () {
application.advanceReadiness();
equal(readyWasCalled, 0);
});
equal(readyWasCalled, 1, 'ready was called now all readiness deferrals are advanced');
});
QUnit.test('Ember.Application\'s ready event can be deferred by other components', function () {
jQuery.isReady = false;
(0, _emberMetal.run)(function () {
application = Application.create({ router: false });
application.deferReadiness();
equal(readyWasCalled, 0, 'ready wasn\'t called yet');
});
domReady();
equal(readyWasCalled, 0, 'ready wasn\'t called yet');
(0, _emberMetal.run)(function () {
application.advanceReadiness();
});
equal(readyWasCalled, 1, 'ready was called now all readiness deferrals are advanced');
expectAssertion(function () {
application.deferReadiness();
});
});
});
QUnit.module('ESLint | ember-application/tests/system/readiness_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/readiness_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/reset_test', ['ember-babel', 'ember-metal', 'ember-runtime', 'ember-routing', 'internal-test-helpers'], function (_emberBabel, _emberMetal, _emberRuntime, _emberRouting, _internalTestHelpers) {
'use strict';
var application = void 0,
Application = void 0;
(0, _internalTestHelpers.moduleFor)('Ember.Application - resetting', function (_AutobootApplicationT) {
(0, _emberBabel.inherits)(_class, _AutobootApplicationT);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT.apply(this, arguments));
}
_class.prototype['@test Brings its own run-loop if not provided'] = function testBringsItsOwnRunLoopIfNotProvided(assert) {
var _this2 = this;
assert.expect(0);
(0, _emberMetal.run)(function () {
return _this2.createApplication();
});
this.application.reset();
};
_class.prototype['@test Does not bring its own run loop if one is already provided'] = function testDoesNotBringItsOwnRunLoopIfOneIsAlreadyProvided(assert) {
var _this3 = this;
assert.expect(3);
var didBecomeReady = false;
(0, _emberMetal.run)(function () {
return _this3.createApplication();
});
(0, _emberMetal.run)(function () {
_this3.application.ready = function () {
didBecomeReady = true;
};
_this3.application.reset();
_this3.application.deferReadiness();
assert.ok(!didBecomeReady, 'app is not ready');
});
assert.ok(!didBecomeReady, 'app is not ready');
(0, _emberMetal.run)(this.application, 'advanceReadiness');
assert.ok(didBecomeReady, 'app is ready');
};
_class.prototype['@test When an application is reset, new instances of controllers are generated'] = function testWhenAnApplicationIsResetNewInstancesOfControllersAreGenerated(assert) {
var _this4 = this;
(0, _emberMetal.run)(function () {
_this4.createApplication();
_this4.add('controller:academic', _emberRuntime.Controller.extend());
});
var firstController = this.applicationInstance.lookup('controller:academic');
var secondController = this.applicationInstance.lookup('controller:academic');
this.application.reset();
var thirdController = this.applicationInstance.lookup('controller:academic');
assert.strictEqual(firstController, secondController, 'controllers looked up in succession should be the same instance');
ok(firstController.isDestroying, 'controllers are destroyed when their application is reset');
assert.notStrictEqual(firstController, thirdController, 'controllers looked up after the application is reset should not be the same instance');
};
_class.prototype['@test When an application is reset, the eventDispatcher is destroyed and recreated'] = function testWhenAnApplicationIsResetTheEventDispatcherIsDestroyedAndRecreated(assert) {
var _this5 = this;
var eventDispatcherWasSetup = 0;
var eventDispatcherWasDestroyed = 0;
var mockEventDispatcher = {
setup: function () {
eventDispatcherWasSetup++;
},
destroy: function () {
eventDispatcherWasDestroyed++;
}
};
(0, _emberMetal.run)(function () {
_this5.createApplication();
_this5.add('event_dispatcher:main', { create: function () {
return mockEventDispatcher;
} });
assert.equal(eventDispatcherWasSetup, 0);
assert.equal(eventDispatcherWasDestroyed, 0);
});
assert.equal(eventDispatcherWasSetup, 1);
assert.equal(eventDispatcherWasDestroyed, 0);
this.application.reset();
assert.equal(eventDispatcherWasDestroyed, 1);
assert.equal(eventDispatcherWasSetup, 2, 'setup called after reset');
};
_class.prototype['@test When an application is reset, the router URL is reset to `/`'] = function testWhenAnApplicationIsResetTheRouterURLIsResetTo(assert) {
var _this6 = this;
(0, _emberMetal.run)(function () {
_this6.createApplication();
_this6.add('router:main', _emberRouting.Router.extend({
location: 'none'
}));
_this6.router.map(function () {
this.route('one');
this.route('two');
});
});
this.visit('/one');
this.application.reset();
var applicationController = this.applicationInstance.lookup('controller:application');
var router = this.applicationInstance.lookup('router:main');
var location = router.get('location');
assert.equal(location.getURL(), '');
assert.equal((0, _emberMetal.get)(applicationController, 'currentPath'), 'index');
this.visit('/one');
assert.equal((0, _emberMetal.get)(applicationController, 'currentPath'), 'one');
};
_class.prototype['@test When an application with advance/deferReadiness is reset, the app does correctly become ready after reset'] = function testWhenAnApplicationWithAdvanceDeferReadinessIsResetTheAppDoesCorrectlyBecomeReadyAfterReset(assert) {
var _this7 = this;
var readyCallCount = 0;
(0, _emberMetal.run)(function () {
_this7.createApplication({
ready: function () {
readyCallCount++;
}
});
_this7.application.deferReadiness();
assert.equal(readyCallCount, 0, 'ready has not yet been called');
});
(0, _emberMetal.run)(this.application, 'advanceReadiness');
assert.equal(readyCallCount, 1, 'ready was called once');
this.application.reset();
assert.equal(readyCallCount, 2, 'ready was called twice');
};
return _class;
}(_internalTestHelpers.AutobootApplicationTestCase));
});
QUnit.module('ESLint | ember-application/tests/system/reset_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/reset_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/system/visit_test', ['ember-babel', 'internal-test-helpers', 'ember-runtime', 'ember-metal', 'ember-application/system/application', 'ember-application/system/application-instance', 'ember-application/system/engine', 'ember-routing', 'ember-glimmer', 'ember-template-compiler', 'ember-views'], function (_emberBabel, _internalTestHelpers, _emberRuntime, _emberMetal, _application, _applicationInstance, _engine, _emberRouting, _emberGlimmer, _emberTemplateCompiler, _emberViews) {
'use strict';
function expectAsyncError() {
_emberRuntime.RSVP.off('error');
}
(0, _internalTestHelpers.moduleFor)('Ember.Application - visit()', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.apply(this, arguments));
}
_class.prototype.teardown = function teardown() {
_emberRuntime.RSVP.on('error', _emberRuntime.onerrorDefault);
_ApplicationTestCase.prototype.teardown.call(this);
};
_class.prototype.createApplication = function createApplication(options) {
return _ApplicationTestCase.prototype.createApplication.call(this, options, _application.default.extend());
};
_class.prototype['@test Applications with autoboot set to false do not autoboot'] = function (assert) {
var _this2 = this;
function delay(time) {
return new _emberRuntime.RSVP.Promise(function (resolve) {
return _emberMetal.run.later(resolve, time);
});
}
var appBooted = 0;
var instanceBooted = 0;
this.application.initializer({
name: 'assert-no-autoboot',
initialize: function () {
appBooted++;
}
});
this.application.instanceInitializer({
name: 'assert-no-autoboot',
initialize: function () {
instanceBooted++;
}
});
assert.ok(!this.applicationInstance, 'precond - no instance');
assert.ok(appBooted === 0, 'precond - not booted');
assert.ok(instanceBooted === 0, 'precond - not booted');
// Continue after 500ms
return delay(500).then(function () {
assert.ok(appBooted === 0, '500ms elapsed without app being booted');
assert.ok(instanceBooted === 0, '500ms elapsed without instances being booted');
return _this2.runTask(function () {
return _this2.application.boot();
});
}).then(function () {
assert.ok(appBooted === 1, 'app should boot when manually calling `app.boot()`');
assert.ok(instanceBooted === 0, 'no instances should be booted automatically when manually calling `app.boot()');
});
};
_class.prototype['@test calling visit() on an app without first calling boot() should boot the app'] = function (assert) {
var appBooted = 0;
var instanceBooted = 0;
this.application.initializer({
name: 'assert-no-autoboot',
initialize: function () {
appBooted++;
}
});
this.application.instanceInitializer({
name: 'assert-no-autoboot',
initialize: function () {
instanceBooted++;
}
});
return this.visit('/').then(function () {
assert.ok(appBooted === 1, 'the app should be booted`');
assert.ok(instanceBooted === 1, 'an instances should be booted');
});
};
_class.prototype['@test calling visit() on an already booted app should not boot it again'] = function (assert) {
var _this3 = this;
var appBooted = 0;
var instanceBooted = 0;
this.application.initializer({
name: 'assert-no-autoboot',
initialize: function () {
appBooted++;
}
});
this.application.instanceInitializer({
name: 'assert-no-autoboot',
initialize: function () {
instanceBooted++;
}
});
return this.runTask(function () {
return _this3.application.boot();
}).then(function () {
assert.ok(appBooted === 1, 'the app should be booted');
assert.ok(instanceBooted === 0, 'no instances should be booted');
return _this3.visit('/');
}).then(function () {
assert.ok(appBooted === 1, 'the app should not be booted again');
assert.ok(instanceBooted === 1, 'an instance should be booted');
/*
* Destroy the instance.
*/
return _this3.runTask(function () {
_this3.applicationInstance.destroy();
_this3.applicationInstance = null;
});
}).then(function () {
/*
* Visit on the application a second time. The application should remain
* booted, but a new instance will be created.
*/
return _this3.visit('/');
}).then(function () {
assert.ok(appBooted === 1, 'the app should not be booted again');
assert.ok(instanceBooted === 2, 'another instance should be booted');
});
};
_class.prototype['@test visit() rejects on application boot failure'] = function (assert) {
this.application.initializer({
name: 'error',
initialize: function () {
throw new Error('boot failure');
}
});
expectAsyncError();
return this.visit('/').then(function () {
assert.ok(false, 'It should not resolve the promise');
}, function (error) {
assert.ok(error instanceof Error, 'It should reject the promise with the boot error');
assert.equal(error.message, 'boot failure');
});
};
_class.prototype['@test visit() rejects on instance boot failure'] = function (assert) {
this.application.instanceInitializer({
name: 'error',
initialize: function () {
throw new Error('boot failure');
}
});
expectAsyncError();
return this.visit('/').then(function () {
assert.ok(false, 'It should not resolve the promise');
}, function (error) {
assert.ok(error instanceof Error, 'It should reject the promise with the boot error');
assert.equal(error.message, 'boot failure');
});
};
_class.prototype['@test visit() follows redirects'] = function (assert) {
this.router.map(function () {
this.route('a');
this.route('b', { path: '/b/:b' });
this.route('c', { path: '/c/:c' });
});
this.add('route:a', _emberRouting.Route.extend({
afterModel: function () {
this.replaceWith('b', 'zomg');
}
}));
this.add('route:b', _emberRouting.Route.extend({
afterModel: function (params) {
this.transitionTo('c', params.b);
}
}));
/*
* First call to `visit` is `this.application.visit` and returns the
* applicationInstance.
*/
return this.visit('/a').then(function (instance) {
assert.ok(instance instanceof _applicationInstance.default, 'promise is resolved with an ApplicationInstance');
assert.equal(instance.getURL(), '/c/zomg', 'It should follow all redirects');
});
};
_class.prototype['@test visit() rejects if an error occurred during a transition'] = function (assert) {
this.router.map(function () {
this.route('a');
this.route('b', { path: '/b/:b' });
this.route('c', { path: '/c/:c' });
});
this.add('route:a', _emberRouting.Route.extend({
afterModel: function () {
this.replaceWith('b', 'zomg');
}
}));
this.add('route:b', _emberRouting.Route.extend({
afterModel: function (params) {
this.transitionTo('c', params.b);
}
}));
this.add('route:c', _emberRouting.Route.extend({
afterModel: function (params) {
throw new Error('transition failure');
}
}));
expectAsyncError();
return this.visit('/a').then(function () {
assert.ok(false, 'It should not resolve the promise');
}, function (error) {
assert.ok(error instanceof Error, 'It should reject the promise with the boot error');
assert.equal(error.message, 'transition failure');
});
};
_class.prototype['@test visit() chain'] = function (assert) {
this.router.map(function () {
this.route('a');
this.route('b');
this.route('c');
});
return this.visit('/').then(function (instance) {
assert.ok(instance instanceof _applicationInstance.default, 'promise is resolved with an ApplicationInstance');
assert.equal(instance.getURL(), '/');
return instance.visit('/a');
}).then(function (instance) {
assert.ok(instance instanceof _applicationInstance.default, 'promise is resolved with an ApplicationInstance');
assert.equal(instance.getURL(), '/a');
return instance.visit('/b');
}).then(function (instance) {
assert.ok(instance instanceof _applicationInstance.default, 'promise is resolved with an ApplicationInstance');
assert.equal(instance.getURL(), '/b');
return instance.visit('/c');
}).then(function (instance) {
assert.ok(instance instanceof _applicationInstance.default, 'promise is resolved with an ApplicationInstance');
assert.equal(instance.getURL(), '/c');
});
};
_class.prototype['@test visit() returns a promise that resolves when the view has rendered'] = function (assert) {
var _this4 = this;
this.addTemplate('application', '
Hello world
');
assert.strictEqual(this.$().children().length, 0, 'there are no elements in the fixture element');
return this.visit('/').then(function (instance) {
assert.ok(instance instanceof _applicationInstance.default, 'promise is resolved with an ApplicationInstance');
assert.equal(_this4.$('.ember-view h1').text(), 'Hello world', 'the application was rendered once the promise resolves');
});
};
_class.prototype['@test visit() returns a promise that resolves without rendering when shouldRender is set to false'] = function (assert) {
var _this5 = this;
assert.expect(3);
this.addTemplate('application', '
Hello world
');
assert.strictEqual(this.$().children().length, 0, 'there are no elements in the fixture element');
return this.visit('/', { shouldRender: false }).then(function (instance) {
assert.ok(instance instanceof _applicationInstance.default, 'promise is resolved with an ApplicationInstance');
assert.strictEqual(_this5.$().children().length, 0, 'there are still no elements in the fixture element after visit');
});
};
_class.prototype['@test visit() renders a template when shouldRender is set to true'] = function (assert) {
var _this6 = this;
assert.expect(3);
this.addTemplate('application', '
Hello world
');
assert.strictEqual(this.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element');
return this.visit('/', { shouldRender: true }).then(function (instance) {
assert.ok(instance instanceof _applicationInstance.default, 'promise is resolved with an ApplicationInstance');
assert.strictEqual(_this6.$().children().length, 1, 'there is 1 element in the fixture element after visit');
});
};
_class.prototype['@test visit() returns a promise that resolves without rendering when shouldRender is set to false with Engines'] = function (assert) {
var _this7 = this;
assert.expect(3);
this.router.map(function () {
this.mount('blog');
});
this.addTemplate('application', '
Hello world
');
// Register engine
var BlogEngine = _engine.default.extend();
this.add('engine:blog', BlogEngine);
// Register engine route map
var BlogMap = function () {};
this.add('route-map:blog', BlogMap);
assert.strictEqual(this.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element');
return this.visit('/blog', { shouldRender: false }).then(function (instance) {
assert.ok(instance instanceof _applicationInstance.default, 'promise is resolved with an ApplicationInstance');
assert.strictEqual(_this7.$().children().length, 0, 'there are still no elements in the fixture element after visit');
});
};
_class.prototype['@test visit() does not setup the event_dispatcher:main if isInteractive is false (with Engines) GH#15615'] = function (assert) {
var _this8 = this;
assert.expect(3);
this.router.map(function () {
this.mount('blog');
});
this.addTemplate('application', '
Hello world
{{outlet}}');
this.add('event_dispatcher:main', {
create: function () {
throw new Error('should not happen!');
}
});
// Register engine
var BlogEngine = _engine.default.extend({
init: function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
this._super.apply(this, args);
this.register('template:application', (0, _emberTemplateCompiler.compile)('{{cache-money}}'));
this.register('template:components/cache-money', (0, _emberTemplateCompiler.compile)('\n
Dis cache money
\n '));
this.register('component:cache-money', _emberGlimmer.Component.extend({}));
}
});
this.add('engine:blog', BlogEngine);
// Register engine route map
var BlogMap = function () {};
this.add('route-map:blog', BlogMap);
assert.strictEqual(this.$('#qunit-fixture').children().length, 0, 'there are no elements in the fixture element');
return this.visit('/blog', { isInteractive: false }).then(function (instance) {
assert.ok(instance instanceof _applicationInstance.default, 'promise is resolved with an ApplicationInstance');
assert.strictEqual(_this8.$().find('p').text(), 'Dis cache money', 'Engine component is resolved');
});
};
_class.prototype['@test visit() on engine resolves engine component'] = function (assert) {
var _this9 = this;
assert.expect(2);
this.router.map(function () {
this.mount('blog');
});
// Register engine
var BlogEngine = _engine.default.extend({
init: function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
this._super.apply(this, args);
this.register('template:application', (0, _emberTemplateCompiler.compile)('{{cache-money}}'));
this.register('template:components/cache-money', (0, _emberTemplateCompiler.compile)('\n
Dis cache money
\n '));
this.register('component:cache-money', _emberGlimmer.Component.extend({}));
}
});
this.add('engine:blog', BlogEngine);
// Register engine route map
var BlogMap = function () {};
this.add('route-map:blog', BlogMap);
assert.strictEqual(this.$().children().length, 0, 'there are no elements in the fixture element');
return this.visit('/blog', { shouldRender: true }).then(function (instance) {
assert.strictEqual(_this9.$().find('p').text(), 'Dis cache money', 'Engine component is resolved');
});
};
_class.prototype['@test visit() on engine resolves engine helper'] = function (assert) {
var _this10 = this;
assert.expect(2);
this.router.map(function () {
this.mount('blog');
});
// Register engine
var BlogEngine = _engine.default.extend({
init: function () {
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
this._super.apply(this, args);
this.register('template:application', (0, _emberTemplateCompiler.compile)('{{swag}}'));
this.register('helper:swag', (0, _emberGlimmer.helper)(function () {
return 'turnt up';
}));
}
});
this.add('engine:blog', BlogEngine);
// Register engine route map
var BlogMap = function () {};
this.add('route-map:blog', BlogMap);
assert.strictEqual(this.$().children().length, 0, 'there are no elements in the fixture element');
return this.visit('/blog', { shouldRender: true }).then(function () {
assert.strictEqual(_this10.$().text(), 'turnt up', 'Engine component is resolved');
});
};
_class.prototype['@test Ember Islands-style setup'] = function (assert) {
var _this11 = this;
var xFooInitCalled = false;
var xFooDidInsertElementCalled = false;
var xBarInitCalled = false;
var xBarDidInsertElementCalled = false;
this.router.map(function () {
this.route('show', { path: '/:component_name' });
});
this.add('route:show', _emberRouting.Route.extend({
queryParams: {
data: { refreshModel: true }
},
model: function (params) {
return {
componentName: params.component_name,
componentData: params.data ? JSON.parse(params.data) : undefined
};
}
}));
var Counter = _emberRuntime.Object.extend({
value: 0,
increment: function () {
this.incrementProperty('value');
}
});
this.add('service:isolatedCounter', Counter);
this.add('service:sharedCounter', Counter.create());
this.application.registerOptions('service:sharedCounter', { instantiate: false });
this.addTemplate('show', '{{component model.componentName model=model.componentData}}');
this.addTemplate('components/x-foo', '\n
X-Foo
\n
Hello {{model.name}}, I have been clicked {{isolatedCounter.value}} times ({{sharedCounter.value}} times combined)!
'
});
this.render('{{hi-mom}}');
var _getViewBounds = (0, _emberViews.getViewBounds)(component),
parentElement = _getViewBounds.parentElement,
firstNode = _getViewBounds.firstNode,
lastNode = _getViewBounds.lastNode;
assert.equal(parentElement, this.element, 'a regular component should have the right parentElement');
assert.equal(firstNode, component.element, 'a regular component should have a single node that is its element');
assert.equal(lastNode, component.element, 'a regular component should have a single node that is its element');
};
_class2.prototype['@test getViewBounds on a tagless component'] = function testGetViewBoundsOnATaglessComponent(assert) {
var component = void 0;
this.registerComponent('hi-mom', {
ComponentClass: _helpers.Component.extend({
tagName: '',
init: function () {
this._super.apply(this, arguments);
component = this;
}
}),
template: 'Hi,mom!'
});
this.render('{{hi-mom}}');
var _getViewBounds2 = (0, _emberViews.getViewBounds)(component),
parentElement = _getViewBounds2.parentElement,
firstNode = _getViewBounds2.firstNode,
lastNode = _getViewBounds2.lastNode;
assert.equal(parentElement, this.element, 'a tagless component should have the right parentElement');
assert.equal(firstNode, this.$('#start-node')[0], 'a tagless component should have a range enclosing all of its nodes');
assert.equal(lastNode, this.$('#before-end-node')[0].nextSibling, 'a tagless component should have a range enclosing all of its nodes');
};
_class2.prototype['@test getViewClientRects'] = function testGetViewClientRects(assert) {
if (!hasGetClientRects || !ClientRectListCtor) {
assert.ok(true, 'The test environment does not support the DOM API required to run this test.');
return;
}
var component = void 0;
this.registerComponent('hi-mom', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
}
}),
template: '
Hi, mom!
'
});
this.render('{{hi-mom}}');
assert.ok((0, _emberViews.getViewClientRects)(component) instanceof ClientRectListCtor);
};
_class2.prototype['@test getViewBoundingClientRect'] = function testGetViewBoundingClientRect(assert) {
if (!hasGetBoundingClientRect || !ClientRectCtor) {
assert.ok(true, 'The test environment does not support the DOM API required to run this test.');
return;
}
var component = void 0;
this.registerComponent('hi-mom', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
}
}),
template: '
Hi, mom!
'
});
this.render('{{hi-mom}}');
assert.ok((0, _emberViews.getViewBoundingClientRect)(component) instanceof ClientRectCtor);
};
return _class2;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/utils-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/utils-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/web-component-fallback-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-metal'], function (_emberBabel, _testCase, _emberMetal) {
'use strict';
(0, _testCase.moduleFor)('Components test: web component fallback', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class, _RenderingTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.apply(this, arguments));
}
_class.prototype['@test custom elements are rendered'] = function testCustomElementsAreRendered() {
var template = 'hello';
this.render(template);
this.assertHTML(template);
this.assertStableRerender();
};
_class.prototype['@test custom elements can have bound attributes'] = function testCustomElementsCanHaveBoundAttributes() {
var _this2 = this;
var template = 'hello';
this.render(template, { name: 'Robert' });
this.assertHTML('hello');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'name', 'Kris');
});
this.assertHTML('hello');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'name', 'Robert');
});
this.assertHTML('hello');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/web-component-fallback-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/web-component-fallback-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/will-destroy-element-hook-test', ['ember-babel', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-case'], function (_emberBabel, _emberMetal, _helpers, _testCase) {
'use strict';
(0, _testCase.moduleFor)('Component willDestroyElement hook', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class, _RenderingTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.apply(this, arguments));
}
_class.prototype['@test it calls willDestroyElement when removed by if'] = function testItCallsWillDestroyElementWhenRemovedByIf(assert) {
var _this2 = this;
var didInsertElementCount = 0;
var willDestroyElementCount = 0;
var FooBarComponent = _helpers.Component.extend({
didInsertElement: function () {
didInsertElementCount++;
assert.notEqual(this.element.parentNode, null, 'precond component is in DOM');
},
willDestroyElement: function () {
willDestroyElementCount++;
assert.notEqual(this.element.parentNode, null, 'has not been removed from DOM yet');
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{#if switch}}{{foo-bar}}{{/if}}', { switch: true });
assert.equal(didInsertElementCount, 1, 'didInsertElement was called once');
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'switch', false);
});
assert.equal(willDestroyElementCount, 1, 'willDestroyElement was called once');
this.assertText('');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/will-destroy-element-hook-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/content-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal', 'ember-debug', 'ember-runtime', 'ember-glimmer/tests/utils/test-helpers', 'ember-views', 'ember-glimmer/tests/utils/helpers'], function (_emberBabel, _testCase, _abstractTestCase, _emberMetal, _emberDebug, _emberRuntime, _testHelpers, _emberViews, _helpers) {
'use strict';
/* globals EmberDev */
(0, _testCase.moduleFor)('Static content tests', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class, _RenderingTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.apply(this, arguments));
}
_class.prototype['@test it can render a static text node'] = function testItCanRenderAStaticTextNode() {
var _this2 = this;
this.render('hello');
var text1 = this.assertTextNode(this.firstChild, 'hello');
this.runTask(function () {
return _this2.rerender();
});
var text2 = this.assertTextNode(this.firstChild, 'hello');
this.assertSameNode(text1, text2);
};
_class.prototype['@test it can render a static element'] = function testItCanRenderAStaticElement() {
var _this3 = this;
this.render('
hello
');
var p1 = this.assertElement(this.firstChild, { tagName: 'p' });
var text1 = this.assertTextNode(this.firstChild.firstChild, 'hello');
this.runTask(function () {
return _this3.rerender();
});
var p2 = this.assertElement(this.firstChild, { tagName: 'p' });
var text2 = this.assertTextNode(this.firstChild.firstChild, 'hello');
this.assertSameNode(p1, p2);
this.assertSameNode(text1, text2);
};
_class.prototype['@test it can render a static template'] = function testItCanRenderAStaticTemplate() {
var _this4 = this;
var template = '\n
\n
Welcome to Ember.js
\n
\n
\n
Why you should use Ember.js?
\n \n
It\'s great
\n
It\'s awesome
\n
It\'s Ember.js
\n \n
\n \n ';
this.render(template);
this.assertHTML(template);
this.runTask(function () {
return _this4.rerender();
});
this.assertHTML(template);
};
return _class;
}(_testCase.RenderingTest));
var DynamicContentTest = function (_RenderingTest2) {
(0, _emberBabel.inherits)(DynamicContentTest, _RenderingTest2);
function DynamicContentTest() {
(0, _emberBabel.classCallCheck)(this, DynamicContentTest);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest2.apply(this, arguments));
}
DynamicContentTest.prototype.renderPath = function renderPath(path) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
throw new Error('Not implemented: `renderValues`');
};
DynamicContentTest.prototype.assertIsEmpty = function assertIsEmpty() {
this.assert.strictEqual(this.firstChild, null);
};
DynamicContentTest.prototype.assertContent = function assertContent(content) {
throw new Error('Not implemented: `assertContent`');
};
DynamicContentTest.prototype['@test it can render a dynamic path'] = function testItCanRenderADynamicPath() {
var _this6 = this;
this.renderPath('message', { message: 'hello' });
this.assertContent('hello');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this6.context, 'message', 'goodbye');
});
this.assertContent('goodbye');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this6.context, 'message', 'hello');
});
this.assertContent('hello');
this.assertInvariants();
};
DynamicContentTest.prototype['@test resolves the string length properly'] = function testResolvesTheStringLengthProperly() {
var _this7 = this;
this.render('
', {
model: {
foo: 'foo',
bar: 'bar'
}
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static bar' } });
this.runTask(function () {
return _this44.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static bar' } });
this.runTask(function () {
(0, _emberMetal.set)(_this44.context, 'model.bar', null);
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static ' } });
this.runTask(function () {
(0, _emberMetal.set)(_this44.context, 'model', {
foo: 'foo',
bar: 'bar'
});
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': 'foo static bar' } });
};
return _class7;
}(_testCase.RenderingTest));
var warnings = void 0,
originalWarn = void 0;
var StyleTest = function (_RenderingTest4) {
(0, _emberBabel.inherits)(StyleTest, _RenderingTest4);
function StyleTest() {
(0, _emberBabel.classCallCheck)(this, StyleTest);
var _this45 = (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest4.apply(this, arguments));
warnings = [];
originalWarn = (0, _emberDebug.getDebugFunction)('warn');
(0, _emberDebug.setDebugFunction)('warn', function (message, test) {
if (!test) {
warnings.push(message);
}
});
return _this45;
}
StyleTest.prototype.teardown = function teardown() {
var _RenderingTest4$proto;
(_RenderingTest4$proto = _RenderingTest4.prototype.teardown).call.apply(_RenderingTest4$proto, [this].concat(Array.prototype.slice.call(arguments)));
(0, _emberDebug.setDebugFunction)('warn', originalWarn);
};
StyleTest.prototype.assertStyleWarning = function assertStyleWarning(style) {
this.assert.deepEqual(warnings, [(0, _emberViews.constructStyleDeprecationMessage)(style)]);
};
StyleTest.prototype.assertNoWarning = function assertNoWarning() {
this.assert.deepEqual(warnings, []);
};
return StyleTest;
}(_testCase.RenderingTest);
(0, _testCase.moduleFor)('Inline style tests', function (_StyleTest) {
(0, _emberBabel.inherits)(_class8, _StyleTest);
function _class8() {
(0, _emberBabel.classCallCheck)(this, _class8);
return (0, _emberBabel.possibleConstructorReturn)(this, _StyleTest.apply(this, arguments));
}
_class8.prototype['@test can set dynamic style'] = function testCanSetDynamicStyle() {
var _this47 = this;
this.render('', {
model: {
style: 'width: 60px;'
}
});
this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } });
this.runTask(function () {
return _this47.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this47.context, 'model.style', 'height: 60px;');
});
this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'height: 60px;' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this47.context, 'model.style', null);
});
this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: {} });
this.runTask(function () {
return (0, _emberMetal.set)(_this47.context, 'model', { style: 'width: 60px;' });
});
this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } });
};
_class8.prototype['@test can set dynamic style with -html-safe'] = function testCanSetDynamicStyleWithHtmlSafe() {
var _this48 = this;
this.render('', {
model: {
style: 'width: 60px;'
}
});
this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } });
this.runTask(function () {
return _this48.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this48.context, 'model.style', 'height: 60px;');
});
this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'height: 60px;' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this48.context, 'model', { style: 'width: 60px;' });
});
this.assertElement(this.firstChild, { tagName: 'div', content: '', attrs: { 'style': 'width: 60px;' } });
};
return _class8;
}(StyleTest));
if (!EmberDev.runningProdBuild) {
(0, _testCase.moduleFor)('Inline style tests - warnings', function (_StyleTest2) {
(0, _emberBabel.inherits)(_class9, _StyleTest2);
function _class9() {
(0, _emberBabel.classCallCheck)(this, _class9);
return (0, _emberBabel.possibleConstructorReturn)(this, _StyleTest2.apply(this, arguments));
}
_class9.prototype['@test specifying generates a warning'] = function testSpecifyingDivStyleUserValueDivGeneratesAWarning(assert) {
var userValue = 'width: 42px';
this.render('', {
userValue: userValue
});
this.assertStyleWarning(userValue);
};
_class9.prototype['@test specifying `attributeBindings: ["style"]` generates a warning'] = function testSpecifyingAttributeBindingsStyleGeneratesAWarning(assert) {
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['style']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
var userValue = 'width: 42px';
this.render('{{foo-bar style=userValue}}', {
userValue: userValue
});
this.assertStyleWarning(userValue);
};
_class9.prototype['@test specifying `` works properly without a warning'] = function testSpecifyingDivStyleUserValueDivWorksProperlyWithoutAWarning(assert) {
this.render('', {
userValue: 'width: 42px'
});
this.assertNoWarning();
};
_class9.prototype['@test specifying `` works properly with a SafeString'] = function testSpecifyingDivStyleUserValueDivWorksProperlyWithASafeString(assert) {
this.render('', {
userValue: new _helpers.SafeString('width: 42px')
});
this.assertNoWarning();
};
_class9.prototype['@test null value do not generate htmlsafe warning'] = function testNullValueDoNotGenerateHtmlsafeWarning(assert) {
this.render('', {
userValue: null
});
this.assertNoWarning();
};
_class9.prototype['@test undefined value do not generate htmlsafe warning'] = function testUndefinedValueDoNotGenerateHtmlsafeWarning(assert) {
this.render('');
this.assertNoWarning();
};
_class9.prototype['@test no warnings are triggered when using `-html-safe`'] = function testNoWarningsAreTriggeredWhenUsingHtmlSafe(assert) {
this.render('', {
userValue: 'width: 42px'
});
this.assertNoWarning();
};
_class9.prototype['@test no warnings are triggered when a safe string is quoted'] = function testNoWarningsAreTriggeredWhenASafeStringIsQuoted(assert) {
this.render('', {
userValue: new _helpers.SafeString('width: 42px')
});
this.assertNoWarning();
};
_class9.prototype['@test binding warning is triggered when an unsafe string is quoted'] = function testBindingWarningIsTriggeredWhenAnUnsafeStringIsQuoted(assert) {
var userValue = 'width: 42px';
this.render('', {
userValue: userValue
});
this.assertStyleWarning(userValue);
};
_class9.prototype['@test binding warning is triggered when a safe string for a complete property is concatenated in place'] = function testBindingWarningIsTriggeredWhenASafeStringForACompletePropertyIsConcatenatedInPlace(assert) {
var userValue = 'width: 42px';
this.render('', {
userValue: new _helpers.SafeString('width: 42px')
});
this.assertStyleWarning('color: green; ' + userValue);
};
_class9.prototype['@test binding warning is triggered when a safe string for a value is concatenated in place'] = function testBindingWarningIsTriggeredWhenASafeStringForAValueIsConcatenatedInPlace(assert) {
var userValue = '42px';
this.render('', {
userValue: new _helpers.SafeString(userValue)
});
this.assertStyleWarning('color: green; width: ' + userValue);
};
_class9.prototype['@test binding warning is triggered when a safe string for a property name is concatenated in place'] = function testBindingWarningIsTriggeredWhenASafeStringForAPropertyNameIsConcatenatedInPlace(assert) {
var userValue = 'width';
this.render('', {
userProperty: new _helpers.SafeString(userValue)
});
this.assertStyleWarning('color: green; ' + userValue + ': 42px');
};
return _class9;
}(StyleTest));
}
});
QUnit.module('ESLint | ember-glimmer/tests/integration/content-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/content-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/custom-component-manager-test', ['ember-babel', '@glimmer/runtime', 'ember-glimmer/tests/utils/test-case', 'ember/features', 'ember-glimmer'], function (_emberBabel, _runtime, _testCase, _features, _emberGlimmer) {
'use strict';
if (_features.GLIMMER_CUSTOM_COMPONENT_MANAGER) {
var TestLayoutCompiler = function () {
function TestLayoutCompiler(template) {
(0, _emberBabel.classCallCheck)(this, TestLayoutCompiler);
this.template = template;
}
TestLayoutCompiler.prototype.compile = function compile(builder) {
builder.wrapLayout(this.template);
builder.tag.dynamic(function () {
return _runtime.PrimitiveReference.create('p');
});
builder.attrs.static('class', 'hey-oh-lets-go');
builder.attrs.static('manager-id', 'test');
};
return TestLayoutCompiler;
}();
var TestComponentManager = function (_AbstractComponentMan) {
(0, _emberBabel.inherits)(TestComponentManager, _AbstractComponentMan);
function TestComponentManager() {
(0, _emberBabel.classCallCheck)(this, TestComponentManager);
return (0, _emberBabel.possibleConstructorReturn)(this, _AbstractComponentMan.apply(this, arguments));
}
TestComponentManager.prototype.create = function create(env, definition, args, dynamicScope, caller, hasBlock) {
return definition.ComponentClass.create();
};
TestComponentManager.prototype.layoutFor = function layoutFor(definition, bucket, env) {
return env.getCompiledBlock(TestLayoutCompiler, definition.template);
};
return TestComponentManager;
}(_emberGlimmer.AbstractComponentManager);
(0, _testCase.moduleFor)('Components test: curly components with custom manager', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class, _RenderingTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.apply(this, arguments));
}
_class.prototype['@test it can render a basic component with custom component manager'] = function testItCanRenderABasicComponentWithCustomComponentManager(assert) {
var managerId = 'test';
this.owner.register('component-manager:' + managerId, new TestComponentManager());
this.registerComponent('foo-bar', {
template: '{{use-component-manager "' + managerId + '"}}hello',
managerId: managerId
});
this.render('{{foo-bar}}');
assert.equal(this.firstChild.className, 'hey-oh-lets-go', 'class name was set correctly');
assert.equal(this.firstChild.tagName, 'P', 'tag name was set correctly');
assert.equal(this.firstChild.getAttribute('manager-id'), managerId, 'custom attribute was set correctly');
};
return _class;
}(_testCase.RenderingTest));
}
});
QUnit.module('ESLint | ember-glimmer/tests/integration/custom-component-manager-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/custom-component-manager-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/event-dispatcher-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal', 'ember/features', 'ember-views'], function (_emberBabel, _testCase, _helpers, _emberMetal, _features, _emberViews) {
'use strict';
var canDataTransfer = !!document.createEvent('HTMLEvents').dataTransfer;
function fireNativeWithDataTransfer(node, type, dataTransfer) {
var event = document.createEvent('HTMLEvents');
event.initEvent(type, true, true);
event.dataTransfer = dataTransfer;
node.dispatchEvent(event);
}
(0, _testCase.moduleFor)('EventDispatcher', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class, _RenderingTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.apply(this, arguments));
}
_class.prototype['@test events bubble view hierarchy for form elements'] = function testEventsBubbleViewHierarchyForFormElements(assert) {
var _this2 = this;
var receivedEvent = void 0;
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
change: function (event) {
receivedEvent = event;
}
}),
template: ''
});
this.render('{{x-foo}}');
this.runTask(function () {
return _this2.$('#is-done').trigger('change');
});
assert.ok(receivedEvent, 'change event was triggered');
assert.strictEqual(receivedEvent.target, this.$('#is-done')[0]);
};
_class.prototype['@test events bubble to parent view'] = function testEventsBubbleToParentView(assert) {
var _this3 = this;
var receivedEvent = void 0;
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
change: function (event) {
receivedEvent = event;
}
}),
template: '{{yield}}'
});
this.registerComponent('x-bar', {
ComponentClass: _helpers.Component.extend({
change: function () {}
}),
template: ''
});
this.render('{{#x-foo}}{{x-bar}}{{/x-foo}}');
this.runTask(function () {
return _this3.$('#is-done').trigger('change');
});
assert.ok(receivedEvent, 'change event was triggered');
assert.strictEqual(receivedEvent.target, this.$('#is-done')[0]);
};
_class.prototype['@test events bubbling up can be prevented'] = function testEventsBubblingUpCanBePrevented(assert) {
var _this4 = this;
var hasReceivedEvent = void 0;
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
change: function () {
hasReceivedEvent = true;
}
}),
template: '{{yield}}'
});
this.registerComponent('x-bar', {
ComponentClass: _helpers.Component.extend({
change: function () {
return false;
}
}),
template: ''
});
this.render('{{#x-foo}}{{x-bar}}{{/x-foo}}');
this.runTask(function () {
return _this4.$('#is-done').trigger('change');
});
assert.notOk(hasReceivedEvent, 'change event has not been received');
};
_class.prototype['@test dispatches to the nearest event manager'] = function testDispatchesToTheNearestEventManager(assert) {
var _this5 = this;
var receivedEvent = void 0;
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
click: function (event) {
assert.notOk(true, 'should not trigger `click` on component');
},
eventManager: {
click: function (event) {
receivedEvent = event;
}
}
}),
template: ''
});
expectDeprecation(/`eventManager` has been deprecated/);
this.render('{{x-foo}}');
this.runTask(function () {
return _this5.$('#is-done').trigger('click');
});
assert.strictEqual(receivedEvent.target, this.$('#is-done')[0]);
};
_class.prototype['@test event manager can re-dispatch to the component'] = function testEventManagerCanReDispatchToTheComponent(assert) {
var _this6 = this;
var handlers = [];
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
click: function () {
handlers.push('component');
},
eventManager: {
click: function (event, component) {
handlers.push('eventManager');
// Re-dispatch event when you get it.
//
// The second parameter tells the dispatcher
// that this event has been handled. This
// API will clearly need to be reworked since
// multiple eventManagers in a single view
// hierarchy would break, but it shows that
// re-dispatching works
component.$().trigger('click', this);
}
}
}),
template: ''
});
expectDeprecation(/`eventManager` has been deprecated/);
this.render('{{x-foo}}');
this.runTask(function () {
return _this6.$('#is-done').trigger('click');
});
assert.deepEqual(handlers, ['eventManager', 'component']);
};
_class.prototype['@test event handlers are wrapped in a run loop'] = function testEventHandlersAreWrappedInARunLoop(assert) {
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
change: function () {
assert.ok(_emberMetal.run.currentRunLoop, 'a run loop should have started');
}
}),
template: ''
});
this.render('{{x-foo}}');
this.$('#is-done').trigger('click');
};
return _class;
}(_testCase.RenderingTest));
(0, _testCase.moduleFor)('EventDispatcher#setup', function (_RenderingTest2) {
(0, _emberBabel.inherits)(_class2, _RenderingTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
var _this7 = (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest2.call(this));
var dispatcher = _this7.owner.lookup('event_dispatcher:main');
(0, _emberMetal.run)(dispatcher, 'destroy');
_this7.owner.__container__.reset('event_dispatcher:main');
_this7.dispatcher = _this7.owner.lookup('event_dispatcher:main');
return _this7;
}
_class2.prototype['@test additional events can be specified'] = function testAdditionalEventsCanBeSpecified(assert) {
this.dispatcher.setup({ myevent: 'myEvent' });
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
myEvent: function () {
assert.ok(true, 'custom event was triggered');
}
}),
template: '
Hello!
'
});
this.render('{{x-foo}}');
this.$('div').trigger('myevent');
};
_class2.prototype['@test eventManager is deprecated'] = function testEventManagerIsDeprecated(assert) {
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
eventManager: {
myEvent: function () {}
}
}),
template: '
Hello!
'
});
expectDeprecation(/`eventManager` has been deprecated/);
this.render('{{x-foo}}');
};
_class2.prototype['@test a rootElement can be specified'] = function testARootElementCanBeSpecified(assert) {
this.$().append('');
this.dispatcher.setup({ myevent: 'myEvent' }, '#app');
assert.ok(this.$('#app').hasClass('ember-application'), 'custom rootElement was used');
assert.equal(this.dispatcher.rootElement, '#app', 'the dispatchers rootElement was updated');
};
_class2.prototype['@test default events can be disabled via `customEvents`'] = function testDefaultEventsCanBeDisabledViaCustomEvents(assert) {
this.dispatcher.setup({ click: null });
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
click: function () {
assert.ok(false, 'click method was called');
},
null: function () {
assert.ok(false, 'null method was called');
},
doubleClick: function () {
assert.ok(true, 'a non-disabled event is still handled properly');
}
}),
template: '
Hello!
'
});
this.render('{{x-foo}}');
this.$('div').trigger('click');
this.$('div').trigger('dblclick');
};
_class2.prototype['@test throws if specified rootElement does not exist'] = function testThrowsIfSpecifiedRootElementDoesNotExist(assert) {
var _this8 = this;
assert.throws(function () {
_this8.dispatcher.setup({ myevent: 'myEvent' }, '#app');
});
};
return _class2;
}(_testCase.RenderingTest));
(0, _testCase.moduleFor)('custom EventDispatcher subclass with #setup', function (_RenderingTest3) {
(0, _emberBabel.inherits)(_class3, _RenderingTest3);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
var _this9 = (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest3.call(this));
var dispatcher = _this9.owner.lookup('event_dispatcher:main');
(0, _emberMetal.run)(dispatcher, 'destroy');
_this9.owner.__container__.reset('event_dispatcher:main');
_this9.owner.unregister('event_dispatcher:main');
return _this9;
}
_class3.prototype['@test canDispatchToEventManager is deprecated in EventDispatcher'] = function testCanDispatchToEventManagerIsDeprecatedInEventDispatcher(assert) {
var MyDispatcher = _emberViews.EventDispatcher.extend({
canDispatchToEventManager: null
});
this.owner.register('event_dispatcher:main', MyDispatcher);
expectDeprecation(/`canDispatchToEventManager` has been deprecated/);
this.owner.lookup('event_dispatcher:main');
};
return _class3;
}(_testCase.RenderingTest));
if (_features.EMBER_IMPROVED_INSTRUMENTATION) {
(0, _testCase.moduleFor)('EventDispatcher - Instrumentation', function (_RenderingTest4) {
(0, _emberBabel.inherits)(_class4, _RenderingTest4);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest4.apply(this, arguments));
}
_class4.prototype.teardown = function teardown() {
_RenderingTest4.prototype.teardown.call(this);
(0, _emberMetal.instrumentationReset)();
};
_class4.prototype['@test instruments triggered events'] = function testInstrumentsTriggeredEvents(assert) {
var clicked = 0;
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
click: function (evt) {
clicked++;
}
}),
template: '
{{render \'home\'}}');
}, /Please refactor [\w\{\}"` ]+ to a component/);
this.assertText('HIBYE');
};
_class.prototype['@test uses `controller:basic` as the basis for a generated controller when none exists for specified name'] = function testUsesControllerBasicAsTheBasisForAGeneratedControllerWhenNoneExistsForSpecifiedName() {
var _this3 = this;
this.owner.register('controller:basic', _emberRuntime.Controller.extend({
isBasicController: true
}));
this.registerTemplate('home', '{{isBasicController}}');
expectDeprecation(function () {
_this3.render('{{render \'home\'}}');
}, /Please refactor [\w\{\}"` ]+ to a component/);
this.assertText('true');
};
_class.prototype['@test generates a controller if none exists'] = function testGeneratesAControllerIfNoneExists() {
var _this4 = this;
this.registerTemplate('home', '
{{render \'home\'}}');
}, /Please refactor [\w\{\}"` ]+ to a component/);
this.assertText('HI(generated home controller)');
};
_class.prototype['@test should use controller with the same name as template if present'] = function testShouldUseControllerWithTheSameNameAsTemplateIfPresent() {
var _this5 = this;
this.owner.register('controller:home', _emberRuntime.Controller.extend({ name: 'home' }));
this.registerTemplate('home', '{{name}}
{{render \'foo\'}}');
}, /Please refactor [\w\{\}"` ]+ to a component/);
this.assertText('HIFOOBARBAZ');
};
_class.prototype['@test should have assertion if the template does not exist'] = function testShouldHaveAssertionIfTheTemplateDoesNotExist() {
var _this7 = this;
this.owner.register('controller:oops', _emberRuntime.Controller.extend());
expectDeprecation(function () {
expectAssertion(function () {
_this7.render('
HI
{{render \'oops\'}}');
}, 'You used `{{render \'oops\'}}`, but \'oops\' can not be found as a template.');
}, /Please refactor [\w\{\}"` ]+ to a component/);
};
_class.prototype['@test should render given template with the singleton controller as its context'] = function testShouldRenderGivenTemplateWithTheSingletonControllerAsItsContext() {
var _this8 = this;
this.owner.register('controller:post', _emberRuntime.Controller.extend({
init: function () {
this.set('title', 'It\'s Simple Made Easy');
}
}));
this.registerTemplate('post', '
{{render \'post\' post}}', {
post: {
title: 'It\'s Simple Made Easy'
}
});
}, /Please refactor [\w\{\}"` ]+ to a component/);
this.assertText('HIIt\'s Simple Made Easy');
this.runTask(function () {
return _this10.rerender();
});
this.assertText('HIIt\'s Simple Made Easy');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'post.title', 'Rails is omakase');
});
this.assertText('HIRails is omakase');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'post', { title: 'It\'s Simple Made Easy' });
});
this.assertText('HIIt\'s Simple Made Easy');
};
_class.prototype['@test should destroy the non-singleton controllers on teardown'] = function testShouldDestroyTheNonSingletonControllersOnTeardown(assert) {
var _this11 = this;
var willDestroyFired = 0;
this.owner.register('controller:post', _emberRuntime.Controller.extend({
willDestroy: function () {
this._super.apply(this, arguments);
willDestroyFired++;
}
}));
this.registerTemplate('post', '
{{model.title}}
');
expectDeprecation(function () {
_this11.render('{{#if showPost}}{{render \'post\' post}}{{else}}Nothing here{{/if}}', {
showPost: false,
post: {
title: 'It\'s Simple Made Easy'
}
});
}, /Please refactor [\w\{\}"` ]+ to a component/);
this.assertText('Nothing here');
assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller');
this.runTask(function () {
return _this11.rerender();
});
this.assertText('Nothing here');
assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'showPost', true);
});
this.assertText('It\'s Simple Made Easy');
assert.strictEqual(willDestroyFired, 0, 'it did not destroy the controller');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'showPost', false);
});
this.assertText('Nothing here');
assert.strictEqual(willDestroyFired, 1, 'it did destroy the controller');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'showPost', true);
});
this.assertText('It\'s Simple Made Easy');
assert.strictEqual(willDestroyFired, 1, 'it did not destroy the controller');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'showPost', false);
});
this.assertText('Nothing here');
assert.strictEqual(willDestroyFired, 2, 'it did destroy the controller');
};
_class.prototype['@test with a supplied model should not fire observers on the controller'] = function testWithASuppliedModelShouldNotFireObserversOnTheController() {
var _this12 = this;
this.owner.register('controller:post', _emberRuntime.Controller.extend());
this.registerTemplate('post', '
{{model.title}}
');
var postDidChange = 0;
expectDeprecation(function () {
_this12.render('
HI
{{render \'post\' post}}', {
postDidChange: (0, _emberMetal.observer)('post', function () {
postDidChange++;
}),
post: {
title: 'It\'s Simple Made Easy'
}
});
}, /Please refactor [\w\{\}"` ]+ to a component/);
this.assertText('HIIt\'s Simple Made Easy');
this.runTask(function () {
return _this12.rerender();
});
this.assertText('HIIt\'s Simple Made Easy');
};
_class.prototype['@test should raise an error when a given controller name does not resolve to a controller'] = function testShouldRaiseAnErrorWhenAGivenControllerNameDoesNotResolveToAController() {
var _this13 = this;
this.registerTemplate('home', '
{{render "home" controller="postss"}}');
}, /The controller name you supplied \'postss\' did not resolve to a controller./);
}, /Please refactor [\w\{\}"` ]+ to a component/);
};
_class.prototype['@test should render with given controller'] = function testShouldRenderWithGivenController(assert) {
var _this14 = this;
this.registerTemplate('home', '{{uniqueId}}');
var id = 0;
var model = {};
this.owner.register('controller:posts', _emberRuntime.Controller.extend({
init: function () {
this._super.apply(this, arguments);
this.uniqueId = id++;
this.set('model', model);
}
}));
expectDeprecation(function () {
_this14.render('{{render "home" controller="posts"}}');
}, /Please refactor [\w\{\}"` ]+ to a component/);
var renderedController = this.owner.lookup('controller:posts');
var uniqueId = renderedController.get('uniqueId');
var renderedModel = renderedController.get('model');
assert.equal(uniqueId, 0);
assert.equal(renderedModel, model);
this.assertText('0');
this.runTask(function () {
return _this14.rerender();
});
assert.equal(uniqueId, 0);
assert.equal(renderedModel, model);
this.assertText('0');
};
_class.prototype['@test should render templates with models multiple times'] = function testShouldRenderTemplatesWithModelsMultipleTimes(assert) {
var _this15 = this;
this.owner.register('controller:post', _emberRuntime.Controller.extend());
this.registerTemplate('post', '
{{render \'post\' post1}} {{render \'post\' post2}}', {
post1: {
title: 'Me First'
},
post2: {
title: 'Then me'
}
});
}, /Please refactor [\w\{\}"` ]+ to a component/);
this.assertText('HI Me First Then me');
this.runTask(function () {
return _this15.rerender();
});
this.assertText('HI Me First Then me');
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'post1.title', 'I am new');
});
this.assertText('HI I am new Then me');
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'post1', { title: 'Me First' });
});
this.assertText('HI Me First Then me');
};
_class.prototype['@test should not treat invocations with falsy contexts as context-less'] = function testShouldNotTreatInvocationsWithFalsyContextsAsContextLess(assert) {
var _this16 = this;
this.registerTemplate('post', '
{{render \'post\' zero}} {{render \'post\' nonexistent}}', {
model: {
zero: false
}
});
}, /Please refactor [\w\{\}"` ]+ to a component/);
assert.ok(this.$().text().match(/^HI ?NOTHING ?NOTHING$/));
};
_class.prototype['@test should render templates both with and without models'] = function testShouldRenderTemplatesBothWithAndWithoutModels(assert) {
var _this17 = this;
this.registerTemplate('post', '
Title:{{model.title}}
');
this.owner.register('controller:post', _emberRuntime.Controller.extend());
var post = {
title: 'Rails is omakase'
};
expectDeprecation(function () {
_this17.render('
HI
{{render \'post\'}} {{render \'post\' post}}', {
post: post
});
}, /Please refactor [\w\{\}"` ]+ to a component/);
assert.ok(this.$().text().match(/^HI ?Title: ?Title:Rails is omakase$/));
this.runTask(function () {
return _this17.rerender();
});
assert.ok(this.$().text().match(/^HI ?Title: ?Title:Rails is omakase$/));
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'post.title', 'Simple Made Easy');
});
assert.ok(this.$().text().match(/^HI ?Title: ?Title:Simple Made Easy$/));
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'post', { title: 'Rails is omakase' });
});
assert.ok(this.$().text().match(/^HI ?Title: ?Title:Rails is omakase$/));
};
_class.prototype['@test works with dot notation'] = function testWorksWithDotNotation() {
var _this18 = this;
this.registerTemplate('blog.post', '{{uniqueId}}');
var id = 0;
this.owner.register('controller:blog.post', _emberRuntime.Controller.extend({
init: function () {
this._super.apply(this, arguments);
this.uniqueId = id++;
}
}));
expectDeprecation(function () {
_this18.render('{{render "blog.post"}}');
}, /Please refactor [\w\.{\}"` ]+ to a component/);
this.assertText('0');
};
_class.prototype['@test throws an assertion if called with an unquoted template name'] = function testThrowsAnAssertionIfCalledWithAnUnquotedTemplateName() {
var _this19 = this;
this.registerTemplate('home', '
{{render home}}');
}, 'The first argument of {{render}} must be quoted, e.g. {{render "sidebar"}}.');
};
_class.prototype['@test throws an assertion if called with a literal for a model'] = function testThrowsAnAssertionIfCalledWithALiteralForAModel() {
var _this20 = this;
this.registerTemplate('home', '
\n ');
this.addTemplate('index', '{{index-wrapper}}');
this.runTask(function () {
_this28.application.advanceReadiness();
});
var _application$testHelp10 = this.application.testHelpers,
wait = _application$testHelp10.wait,
triggerEvent = _application$testHelp10.triggerEvent;
return wait().then(function () {
return triggerEvent('.input', '#limited', 'keydown', { keyCode: 13 });
}).then(function () {
assert.equal(event.keyCode, 13, 'options were passed');
assert.equal(event.type, 'keydown', 'correct event was triggered');
assert.equal(event.target.getAttribute('id'), 'inside-scope', 'triggered on the correct element');
});
};
return _class2;
}(HelpersApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('ember-testing: debugging helpers', function (_HelpersApplicationTe2) {
(0, _emberBabel.inherits)(_class3, _HelpersApplicationTe2);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
var _this29 = (0, _emberBabel.possibleConstructorReturn)(this, _HelpersApplicationTe2.call(this));
_this29.runTask(function () {
_this29.application.advanceReadiness();
});
return _this29;
}
_class3.prototype['@test pauseTest pauses'] = function (assert) {
assert.expect(1);
var _application$testHelp11 = this.application.testHelpers,
andThen = _application$testHelp11.andThen,
pauseTest = _application$testHelp11.pauseTest;
andThen(function () {
_test.default.adapter.asyncStart = function () {
assert.ok(true, 'Async start should be called after waiting for other helpers');
};
});
pauseTest();
};
_class3.prototype['@test resumeTest resumes paused tests'] = function (assert) {
assert.expect(1);
var _application$testHelp12 = this.application.testHelpers,
pauseTest = _application$testHelp12.pauseTest,
resumeTest = _application$testHelp12.resumeTest;
_emberMetal.run.later(function () {
return resumeTest();
}, 20);
return pauseTest().then(function () {
assert.ok(true, 'pauseTest promise was resolved');
});
};
_class3.prototype['@test resumeTest throws if nothing to resume'] = function (assert) {
var _this30 = this;
assert.expect(1);
assert.throws(function () {
_this30.application.testHelpers.resumeTest();
}, /Testing has not been paused. There is nothing to resume./);
};
return _class3;
}(HelpersApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('ember-testing: routing helpers', function (_HelpersTestCase3) {
(0, _emberBabel.inherits)(_class4, _HelpersTestCase3);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
var _this31 = (0, _emberBabel.possibleConstructorReturn)(this, _HelpersTestCase3.call(this));
_this31.runTask(function () {
_this31.createApplication();
_this31.application.setupForTesting();
_this31.application.injectTestHelpers();
_this31.router.map(function () {
this.route('posts', { resetNamespace: true }, function () {
this.route('new');
});
});
});
_this31.runTask(function () {
_this31.application.advanceReadiness();
});
return _this31;
}
_class4.prototype['@test currentRouteName for \'/\''] = function (assert) {
assert.expect(3);
var testHelpers = this.application.testHelpers;
return testHelpers.visit('/').then(function () {
assert.equal(testHelpers.currentRouteName(), 'index', 'should equal \'index\'.');
assert.equal(testHelpers.currentPath(), 'index', 'should equal \'index\'.');
assert.equal(testHelpers.currentURL(), '/', 'should equal \'/\'.');
});
};
_class4.prototype['@test currentRouteName for \'/posts\''] = function (assert) {
assert.expect(3);
var testHelpers = this.application.testHelpers;
return testHelpers.visit('/posts').then(function () {
assert.equal(testHelpers.currentRouteName(), 'posts.index', 'should equal \'posts.index\'.');
assert.equal(testHelpers.currentPath(), 'posts.index', 'should equal \'posts.index\'.');
assert.equal(testHelpers.currentURL(), '/posts', 'should equal \'/posts\'.');
});
};
_class4.prototype['@test currentRouteName for \'/posts/new\''] = function (assert) {
assert.expect(3);
var testHelpers = this.application.testHelpers;
return testHelpers.visit('/posts/new').then(function () {
assert.equal(testHelpers.currentRouteName(), 'posts.new', 'should equal \'posts.new\'.');
assert.equal(testHelpers.currentPath(), 'posts.new', 'should equal \'posts.new\'.');
assert.equal(testHelpers.currentURL(), '/posts/new', 'should equal \'/posts/new\'.');
});
};
return _class4;
}(HelpersTestCase));
(0, _internalTestHelpers.moduleFor)('ember-testing: pendingRequests', function (_HelpersApplicationTe3) {
(0, _emberBabel.inherits)(_class5, _HelpersApplicationTe3);
function _class5() {
(0, _emberBabel.classCallCheck)(this, _class5);
return (0, _emberBabel.possibleConstructorReturn)(this, _HelpersApplicationTe3.apply(this, arguments));
}
_class5.prototype['@test pendingRequests is maintained for ajaxSend and ajaxComplete events'] = function (assert) {
assert.equal((0, _pending_requests.pendingRequests)(), 0);
var xhr = { some: 'xhr' };
(0, _emberViews.jQuery)(document).trigger('ajaxSend', xhr);
assert.equal((0, _pending_requests.pendingRequests)(), 1, 'Ember.Test.pendingRequests was incremented');
(0, _emberViews.jQuery)(document).trigger('ajaxComplete', xhr);
assert.equal((0, _pending_requests.pendingRequests)(), 0, 'Ember.Test.pendingRequests was decremented');
};
_class5.prototype['@test pendingRequests is ignores ajaxComplete events from past setupForTesting calls'] = function (assert) {
assert.equal((0, _pending_requests.pendingRequests)(), 0);
var xhr = { some: 'xhr' };
(0, _emberViews.jQuery)(document).trigger('ajaxSend', xhr);
assert.equal((0, _pending_requests.pendingRequests)(), 1, 'Ember.Test.pendingRequests was incremented');
(0, _setup_for_testing.default)();
assert.equal((0, _pending_requests.pendingRequests)(), 0, 'Ember.Test.pendingRequests was reset');
var altXhr = { some: 'more xhr' };
(0, _emberViews.jQuery)(document).trigger('ajaxSend', altXhr);
assert.equal((0, _pending_requests.pendingRequests)(), 1, 'Ember.Test.pendingRequests was incremented');
(0, _emberViews.jQuery)(document).trigger('ajaxComplete', xhr);
assert.equal((0, _pending_requests.pendingRequests)(), 1, 'Ember.Test.pendingRequests is not impressed with your unexpected complete');
};
_class5.prototype['@test pendingRequests is reset by setupForTesting'] = function (assert) {
(0, _pending_requests.incrementPendingRequests)();
(0, _setup_for_testing.default)();
assert.equal((0, _pending_requests.pendingRequests)(), 0, 'pendingRequests is reset');
};
return _class5;
}(HelpersApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('ember-testing: async router', function (_HelpersTestCase4) {
(0, _emberBabel.inherits)(_class6, _HelpersTestCase4);
function _class6() {
(0, _emberBabel.classCallCheck)(this, _class6);
var _this33 = (0, _emberBabel.possibleConstructorReturn)(this, _HelpersTestCase4.call(this));
_this33.runTask(function () {
_this33.createApplication();
_this33.router.map(function () {
this.route('user', { resetNamespace: true }, function () {
this.route('profile');
this.route('edit');
});
});
// Emulate a long-running unscheduled async operation.
var resolveLater = function () {
return new _emberRuntime.RSVP.Promise(function (resolve) {
/*
* The wait() helper has a 10ms tick. We should resolve() after
* at least one tick to test whether wait() held off while the
* async router was still loading. 20ms should be enough.
*/
_emberMetal.run.later(resolve, { firstName: 'Tom' }, 20);
});
};
_this33.add('route:user', _emberRouting.Route.extend({
model: function () {
return resolveLater();
}
}));
_this33.add('route:user.profile', _emberRouting.Route.extend({
beforeModel: function () {
var _this34 = this;
return resolveLater().then(function () {
return _this34.transitionTo('user.edit');
});
}
}));
_this33.application.setupForTesting();
});
_this33.application.injectTestHelpers();
_this33.runTask(function () {
_this33.application.advanceReadiness();
});
return _this33;
}
_class6.prototype['@test currentRouteName for \'/user\''] = function (assert) {
var _this35 = this;
assert.expect(4);
var testHelpers = this.application.testHelpers;
return testHelpers.visit('/user').then(function () {
assert.equal(testHelpers.currentRouteName(), 'user.index', 'should equal \'user.index\'.');
assert.equal(testHelpers.currentPath(), 'user.index', 'should equal \'user.index\'.');
assert.equal(testHelpers.currentURL(), '/user', 'should equal \'/user\'.');
var userRoute = _this35.applicationInstance.lookup('route:user');
assert.equal(userRoute.get('controller.model.firstName'), 'Tom', 'should equal \'Tom\'.');
});
};
_class6.prototype['@test currentRouteName for \'/user/profile\''] = function (assert) {
var _this36 = this;
assert.expect(4);
var testHelpers = this.application.testHelpers;
return testHelpers.visit('/user/profile').then(function () {
assert.equal(testHelpers.currentRouteName(), 'user.edit', 'should equal \'user.edit\'.');
assert.equal(testHelpers.currentPath(), 'user.edit', 'should equal \'user.edit\'.');
assert.equal(testHelpers.currentURL(), '/user/edit', 'should equal \'/user/edit\'.');
var userRoute = _this36.applicationInstance.lookup('route:user');
assert.equal(userRoute.get('controller.model.firstName'), 'Tom', 'should equal \'Tom\'.');
});
};
return _class6;
}(HelpersTestCase));
(0, _internalTestHelpers.moduleFor)('ember-testing: can override built-in helpers', function (_HelpersTestCase5) {
(0, _emberBabel.inherits)(_class7, _HelpersTestCase5);
function _class7() {
(0, _emberBabel.classCallCheck)(this, _class7);
var _this37 = (0, _emberBabel.possibleConstructorReturn)(this, _HelpersTestCase5.call(this));
_this37.runTask(function () {
_this37.createApplication();
_this37.application.setupForTesting();
});
_this37._originalVisitHelper = _test.default._helpers.visit;
_this37._originalFindHelper = _test.default._helpers.find;
return _this37;
}
_class7.prototype.teardown = function teardown() {
_test.default._helpers.visit = this._originalVisitHelper;
_test.default._helpers.find = this._originalFindHelper;
_HelpersTestCase5.prototype.teardown.call(this);
};
_class7.prototype['@test can override visit helper'] = function (assert) {
assert.expect(1);
_test.default.registerHelper('visit', function () {
assert.ok(true, 'custom visit helper was called');
});
this.application.injectTestHelpers();
return this.application.testHelpers.visit();
};
_class7.prototype['@test can override find helper'] = function (assert) {
assert.expect(1);
_test.default.registerHelper('find', function () {
assert.ok(true, 'custom find helper was called');
return ['not empty array'];
});
this.application.injectTestHelpers();
return this.application.testHelpers.findWithAssert('.who-cares');
};
return _class7;
}(HelpersTestCase));
});
QUnit.module('ESLint | ember-testing/tests/helpers_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-testing/tests/helpers_test.js should pass ESLint\n\n');
});
enifed('ember-testing/tests/integration_test', ['ember-babel', 'internal-test-helpers', 'ember-testing/test', 'ember-runtime', 'ember-routing'], function (_emberBabel, _internalTestHelpers, _test, _emberRuntime, _emberRouting) {
'use strict';
(0, _internalTestHelpers.moduleFor)('ember-testing Integration tests of acceptance', function (_AutobootApplicationT) {
(0, _emberBabel.inherits)(_class, _AutobootApplicationT);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT.call(this));
_this.modelContent = [];
_this._originalAdapter = _test.default.adapter;
_this.runTask(function () {
_this.createApplication();
_this.addTemplate('people', '\n
\n {{#each model as |person|}}\n
{{person.firstName}}
\n {{/each}}\n
\n ');
_this.router.map(function () {
this.route('people', { path: '/' });
});
_this.add('route:people', _emberRouting.Route.extend({
model: function () {
return _this.modelContent;
}
}));
_this.application.setupForTesting();
});
_this.runTask(function () {
_this.application.reset();
});
_this.application.injectTestHelpers();
return _this;
}
_class.prototype.teardown = function teardown() {
_AutobootApplicationT.prototype.teardown.call(this);
_test.default.adapter = this._originalAdapter;
};
_class.prototype['@test template is bound to empty array of people'] = function (assert) {
var _this2 = this;
this.runTask(function () {
return _this2.application.advanceReadiness();
});
window.visit('/').then(function () {
var rows = window.find('.name').length;
assert.equal(rows, 0, 'successfully stubbed an empty array of people');
});
};
_class.prototype['@test template is bound to array of 2 people'] = function (assert) {
var _this3 = this;
this.modelContent = (0, _emberRuntime.A)([]);
this.modelContent.pushObject({ firstName: 'x' });
this.modelContent.pushObject({ firstName: 'y' });
this.runTask(function () {
return _this3.application.advanceReadiness();
});
window.visit('/').then(function () {
var rows = window.find('.name').length;
assert.equal(rows, 2, 'successfully stubbed a non empty array of people');
});
};
_class.prototype['@test \'visit\' can be called without advanceReadiness.'] = function (assert) {
window.visit('/').then(function () {
var rows = window.find('.name').length;
assert.equal(rows, 0, 'stubbed an empty array of people without calling advanceReadiness.');
});
};
return _class;
}(_internalTestHelpers.AutobootApplicationTestCase));
});
QUnit.module('ESLint | ember-testing/tests/integration_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-testing/tests/integration_test.js should pass ESLint\n\n');
});
enifed('ember-testing/tests/reexports_test', ['ember', 'internal-test-helpers'], function (_ember, _internalTestHelpers) {
'use strict';
QUnit.module('ember-testing reexports');
[
// ember-testing
['Test', 'ember-testing'], ['Test.Adapter', 'ember-testing', 'Adapter'], ['Test.QUnitAdapter', 'ember-testing', 'QUnitAdapter'], ['setupForTesting', 'ember-testing']].forEach(function (reexport) {
var path = reexport[0],
moduleId = reexport[1],
exportName = reexport[2];
// default path === exportName if none present
if (!exportName) {
exportName = path;
}
QUnit.test('Ember.' + path + ' exports correctly', function (assert) {
(0, _internalTestHelpers.confirmExport)(_ember.default, assert, path, moduleId, exportName);
});
});
});
QUnit.module('ESLint | ember-testing/tests/reexports_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-testing/tests/reexports_test.js should pass ESLint\n\n');
});
enifed('ember-testing/tests/simple_setup', ['ember-metal', 'ember-views'], function (_emberMetal, _emberViews) {
'use strict';
var App;
QUnit.module('Simple Testing Setup', {
teardown: function () {
if (App) {
App.removeTestHelpers();
(0, _emberViews.jQuery)('#ember-testing-container, #ember-testing').remove();
(0, _emberMetal.run)(App, 'destroy');
App = null;
}
}
});
});
QUnit.module('ESLint | ember-testing/tests/simple_setup.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-testing/tests/simple_setup.js should pass ESLint\n\n');
});
enifed('ember-testing/tests/test/waiters-test', ['ember-babel', 'ember-testing/test/waiters'], function (_emberBabel, _waiters) {
'use strict';
var Waiters = function () {
function Waiters() {
(0, _emberBabel.classCallCheck)(this, Waiters);
this._waiters = [];
}
Waiters.prototype.add = function add() {
this._waiters.push([].concat(Array.prototype.slice.call(arguments)));
};
Waiters.prototype.register = function register() {
this.forEach(function () {
_waiters.registerWaiter.apply(undefined, arguments);
});
};
Waiters.prototype.unregister = function unregister() {
this.forEach(function () {
_waiters.unregisterWaiter.apply(undefined, arguments);
});
};
Waiters.prototype.forEach = function forEach(callback) {
for (var i = 0; i < this._waiters.length; i++) {
var args = this._waiters[i];
callback.apply(undefined, args);
}
};
Waiters.prototype.check = function check() {
this.register();
var result = (0, _waiters.checkWaiters)();
this.unregister();
return result;
};
return Waiters;
}();
QUnit.module('ember-testing: waiters', {
setup: function () {
this.waiters = new Waiters();
},
teardown: function () {
this.waiters.unregister();
}
});
QUnit.test('registering a waiter', function (assert) {
assert.expect(2);
var obj = { foo: true };
this.waiters.add(obj, function () {
assert.ok(this.foo, 'has proper `this` context');
return true;
});
this.waiters.add(function () {
assert.ok(true, 'is called');
return true;
});
this.waiters.check();
});
QUnit.test('unregistering a waiter', function (assert) {
assert.expect(2);
var obj = { foo: true };
this.waiters.add(obj, function () {
assert.ok(true, 'precond - waiter with context is registered');
return true;
});
this.waiters.add(function () {
assert.ok(true, 'precond - waiter without context is registered');
return true;
});
this.waiters.check();
this.waiters.unregister();
(0, _waiters.checkWaiters)();
});
QUnit.test('checkWaiters returns false if all waiters return true', function (assert) {
assert.expect(3);
this.waiters.add(function () {
assert.ok(true, 'precond - waiter is registered');
return true;
});
this.waiters.add(function () {
assert.ok(true, 'precond - waiter is registered');
return true;
});
assert.notOk(this.waiters.check(), 'checkWaiters returns true if all waiters return true');
});
QUnit.test('checkWaiters returns true if any waiters return false', function (assert) {
assert.expect(3);
this.waiters.add(function () {
assert.ok(true, 'precond - waiter is registered');
return true;
});
this.waiters.add(function () {
assert.ok(true, 'precond - waiter is registered');
return false;
});
assert.ok(this.waiters.check(), 'checkWaiters returns false if any waiters return false');
});
QUnit.test('checkWaiters short circuits after first falsey waiter', function (assert) {
assert.expect(2);
this.waiters.add(function () {
assert.ok(true, 'precond - waiter is registered');
return false;
});
this.waiters.add(function () {
assert.notOk(true, 'waiter should not be called');
});
assert.ok(this.waiters.check(), 'checkWaiters returns false if any waiters return false');
});
});
QUnit.module('ESLint | ember-testing/tests/test/waiters-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-testing/tests/test/waiters-test.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-utils.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-utils.js should pass ESLint\n\n');
});
enifed('ember-utils/tests/assign_test', ['ember-utils'], function (_emberUtils) {
'use strict';
QUnit.module('Ember.assign');
QUnit.test('merging objects', function () {
var trgt = { a: 1 };
var src1 = { b: 2 };
var src2 = { c: 3 };
(0, _emberUtils.assignPolyfill)(trgt, src1, src2);
deepEqual(trgt, { a: 1, b: 2, c: 3 }, 'assign copies values from one or more source objects to a target object');
deepEqual(src1, { b: 2 }, 'assign does not change source object 1');
deepEqual(src2, { c: 3 }, 'assign does not change source object 2');
});
QUnit.test('merging objects with same property', function () {
var trgt = { a: 1, b: 1 };
var src1 = { a: 2, b: 2 };
var src2 = { a: 3 };
(0, _emberUtils.assignPolyfill)(trgt, src1, src2);
deepEqual(trgt, { a: 3, b: 2 }, 'properties are overwritten by other objects that have the same properties later in the parameters order');
});
QUnit.test('null', function () {
var trgt = { a: 1 };
(0, _emberUtils.assignPolyfill)(trgt, null);
deepEqual(trgt, { a: 1 }, 'null as a source parameter is ignored');
});
QUnit.test('undefined', function () {
var trgt = { a: 1 };
(0, _emberUtils.assignPolyfill)(trgt, null);
deepEqual(trgt, { a: 1 }, 'undefined as a source parameter is ignored');
});
});
QUnit.module('ESLint | ember-utils/tests/assign_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-utils/tests/assign_test.js should pass ESLint\n\n');
});
enifed('ember-utils/tests/can_invoke_test', ['ember-utils'], function (_emberUtils) {
'use strict';
var obj = void 0;
QUnit.module('Ember.canInvoke', {
setup: function () {
obj = {
foobar: 'foobar',
aMethodThatExists: function () {}
};
},
teardown: function () {
obj = undefined;
}
});
QUnit.test('should return false if the object doesn\'t exist', function () {
equal((0, _emberUtils.canInvoke)(undefined, 'aMethodThatDoesNotExist'), false);
});
QUnit.test('should return true for falsy values that have methods', function () {
equal((0, _emberUtils.canInvoke)(false, 'valueOf'), true);
equal((0, _emberUtils.canInvoke)('', 'charAt'), true);
equal((0, _emberUtils.canInvoke)(0, 'toFixed'), true);
});
QUnit.test('should return true if the method exists on the object', function () {
equal((0, _emberUtils.canInvoke)(obj, 'aMethodThatExists'), true);
});
QUnit.test('should return false if the method doesn\'t exist on the object', function () {
equal((0, _emberUtils.canInvoke)(obj, 'aMethodThatDoesNotExist'), false);
});
QUnit.test('should return false if the property exists on the object but is a non-function', function () {
equal((0, _emberUtils.canInvoke)(obj, 'foobar'), false);
});
});
QUnit.module('ESLint | ember-utils/tests/can_invoke_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-utils/tests/can_invoke_test.js should pass ESLint\n\n');
});
enifed('ember-utils/tests/checkHasSuper_test', ['ember-environment', 'ember-utils'], function (_emberEnvironment, _emberUtils) {
'use strict';
QUnit.module('checkHasSuper');
// Only run this test on browsers that we are certain should have function
// source available. This allows the test suite to continue to pass on other
// platforms that correctly (for them) fall back to the "always wrap" code.
if (_emberEnvironment.environment.isPhantom || _emberEnvironment.environment.isChrome || _emberEnvironment.environment.isFirefox) {
QUnit.test('does not super wrap needlessly [GH #12462]', function (assert) {
assert.notOk((0, _emberUtils.checkHasSuper)(function () {}), 'empty function does not have super');
});
}
});
QUnit.module('ESLint | ember-utils/tests/checkHasSuper_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-utils/tests/checkHasSuper_test.js should pass ESLint\n\n');
});
enifed('ember-utils/tests/generate_guid_test', ['ember-utils'], function (_emberUtils) {
'use strict';
QUnit.module('Ember.generateGuid');
QUnit.test('Prefix', function () {
var a = {};
ok((0, _emberUtils.generateGuid)(a, 'tyrell').indexOf('tyrell') > -1, 'guid can be prefixed');
});
});
QUnit.module('ESLint | ember-utils/tests/generate_guid_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-utils/tests/generate_guid_test.js should pass ESLint\n\n');
});
enifed('ember-utils/tests/guid_for_test', ['ember-utils'], function (_emberUtils) {
'use strict';
QUnit.module('guidFor');
function sameGuid(a, b, message) {
equal((0, _emberUtils.guidFor)(a), (0, _emberUtils.guidFor)(b), message);
}
function diffGuid(a, b, message) {
ok((0, _emberUtils.guidFor)(a) !== (0, _emberUtils.guidFor)(b), message);
}
function nanGuid(obj) {
var type = typeof obj;
ok(isNaN(parseInt((0, _emberUtils.guidFor)(obj), 0)), 'guids for ' + type + 'don\'t parse to numbers');
}
QUnit.test('Object', function () {
var a = {};
var b = {};
sameGuid(a, a, 'same object always yields same guid');
diffGuid(a, b, 'different objects yield different guids');
nanGuid(a);
});
QUnit.test('strings', function () {
var a = 'string A';
var aprime = 'string A';
var b = 'String B';
sameGuid(a, a, 'same string always yields same guid');
sameGuid(a, aprime, 'identical strings always yield the same guid');
diffGuid(a, b, 'different strings yield different guids');
nanGuid(a);
});
QUnit.test('numbers', function () {
var a = 23;
var aprime = 23;
var b = 34;
sameGuid(a, a, 'same numbers always yields same guid');
sameGuid(a, aprime, 'identical numbers always yield the same guid');
diffGuid(a, b, 'different numbers yield different guids');
nanGuid(a);
});
QUnit.test('numbers', function () {
var a = true;
var aprime = true;
var b = false;
sameGuid(a, a, 'same booleans always yields same guid');
sameGuid(a, aprime, 'identical booleans always yield the same guid');
diffGuid(a, b, 'different boolean yield different guids');
nanGuid(a);
nanGuid(b);
});
QUnit.test('null and undefined', function () {
var a = null;
var aprime = null;
var b = void 0;
sameGuid(a, a, 'null always returns the same guid');
sameGuid(b, b, 'undefined always returns the same guid');
sameGuid(a, aprime, 'different nulls return the same guid');
diffGuid(a, b, 'null and undefined return different guids');
nanGuid(a);
nanGuid(b);
});
QUnit.test('arrays', function () {
var a = ['a', 'b', 'c'];
var aprime = ['a', 'b', 'c'];
var b = ['1', '2', '3'];
sameGuid(a, a, 'same instance always yields same guid');
diffGuid(a, aprime, 'identical arrays always yield the same guid');
diffGuid(a, b, 'different arrays yield different guids');
nanGuid(a);
});
});
QUnit.module('ESLint | ember-utils/tests/guid_for_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-utils/tests/guid_for_test.js should pass ESLint\n\n');
});
enifed('ember-utils/tests/inspect_test', ['ember-utils'], function (_emberUtils) {
'use strict';
// Symbol is not defined on pre-ES2015 runtimes, so this let's us safely test
// for it's existence (where a simple `if (Symbol)` would ReferenceError)
var HAS_NATIVE_SYMBOL = typeof Symbol === 'function';
QUnit.module('Ember.inspect');
QUnit.test('strings', function () {
equal((0, _emberUtils.inspect)('foo'), 'foo');
});
QUnit.test('numbers', function () {
equal((0, _emberUtils.inspect)(2.6), '2.6');
});
QUnit.test('null', function () {
equal((0, _emberUtils.inspect)(null), 'null');
});
QUnit.test('undefined', function () {
equal((0, _emberUtils.inspect)(undefined), 'undefined');
});
QUnit.test('true', function () {
equal((0, _emberUtils.inspect)(true), 'true');
});
QUnit.test('false', function () {
equal((0, _emberUtils.inspect)(false), 'false');
});
QUnit.test('object', function () {
equal((0, _emberUtils.inspect)({}), '{}');
equal((0, _emberUtils.inspect)({ foo: 'bar' }), '{foo: bar}');
equal((0, _emberUtils.inspect)({
foo: function () {
return this;
}
}), '{foo: function() { ... }}');
});
QUnit.test('objects without a prototype', function () {
var prototypelessObj = Object.create(null);
equal((0, _emberUtils.inspect)({ foo: prototypelessObj }), '{foo: [object Object]}');
});
QUnit.test('array', function () {
equal((0, _emberUtils.inspect)([1, 2, 3]), '[1,2,3]');
});
QUnit.test('regexp', function () {
equal((0, _emberUtils.inspect)(/regexp/), '/regexp/');
});
QUnit.test('date', function () {
var inspected = (0, _emberUtils.inspect)(new Date('Sat Apr 30 2011 13:24:11'));
ok(inspected.match(/Sat Apr 30/), 'The inspected date has its date');
ok(inspected.match(/2011/), 'The inspected date has its year');
ok(inspected.match(/13:24:11/), 'The inspected date has its time');
});
QUnit.test('inspect outputs the toString() representation of Symbols', function () {
if (HAS_NATIVE_SYMBOL) {
var symbol = Symbol('test');
equal((0, _emberUtils.inspect)(symbol), 'Symbol(test)');
} else {
expect(0);
}
});
});
QUnit.module('ESLint | ember-utils/tests/inspect_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-utils/tests/inspect_test.js should pass ESLint\n\n');
});
enifed('ember-utils/tests/make_array_test', ['ember-utils'], function (_emberUtils) {
'use strict';
QUnit.module('Ember.makeArray');
QUnit.test('undefined', function () {
deepEqual((0, _emberUtils.makeArray)(), []);
deepEqual((0, _emberUtils.makeArray)(undefined), []);
});
QUnit.test('null', function () {
deepEqual((0, _emberUtils.makeArray)(null), []);
});
QUnit.test('string', function () {
deepEqual((0, _emberUtils.makeArray)('lindsay'), ['lindsay']);
});
QUnit.test('number', function () {
deepEqual((0, _emberUtils.makeArray)(0), [0]);
deepEqual((0, _emberUtils.makeArray)(1), [1]);
});
QUnit.test('array', function () {
deepEqual((0, _emberUtils.makeArray)([1, 2, 42]), [1, 2, 42]);
});
QUnit.test('true', function () {
deepEqual((0, _emberUtils.makeArray)(true), [true]);
});
QUnit.test('false', function () {
deepEqual((0, _emberUtils.makeArray)(false), [false]);
});
QUnit.test('object', function () {
deepEqual((0, _emberUtils.makeArray)({}), [{}]);
});
});
QUnit.module('ESLint | ember-utils/tests/make_array_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-utils/tests/make_array_test.js should pass ESLint\n\n');
});
enifed('ember-utils/tests/to-string-test', ['ember-utils'], function (_emberUtils) {
'use strict';
QUnit.module('ember-utils toString');
QUnit.test('toString uses an object\'s toString method when available', function () {
var obj = {
toString: function () {
return 'bob';
}
};
strictEqual((0, _emberUtils.toString)(obj), 'bob');
});
QUnit.test('toString falls back to Object.prototype.toString', function () {
var obj = Object.create(null);
strictEqual((0, _emberUtils.toString)(obj), {}.toString());
});
QUnit.test('toString does not fail when called on Arrays with objects without toString method', function () {
var obj = Object.create(null);
var arr = [obj, 2];
strictEqual((0, _emberUtils.toString)(arr), {}.toString() + ',2');
});
});
QUnit.module('ESLint | ember-utils/tests/to-string-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-utils/tests/to-string-test.js should pass ESLint\n\n');
});
enifed('ember-utils/tests/try_invoke_test', ['ember-utils'], function (_emberUtils) {
'use strict';
var obj = void 0;
QUnit.module('Ember.tryInvoke', {
setup: function () {
obj = {
aMethodThatExists: function () {
return true;
},
aMethodThatTakesArguments: function (arg1, arg2) {
return arg1 === arg2;
}
};
},
teardown: function () {
obj = undefined;
}
});
QUnit.test('should return undefined when the object doesn\'t exist', function () {
equal((0, _emberUtils.tryInvoke)(undefined, 'aMethodThatDoesNotExist'), undefined);
});
QUnit.test('should return undefined when asked to perform a method that doesn\'t exist on the object', function () {
equal((0, _emberUtils.tryInvoke)(obj, 'aMethodThatDoesNotExist'), undefined);
});
QUnit.test('should return what the method returns when asked to perform a method that exists on the object', function () {
equal((0, _emberUtils.tryInvoke)(obj, 'aMethodThatExists'), true);
});
QUnit.test('should return what the method returns when asked to perform a method that takes arguments and exists on the object', function () {
equal((0, _emberUtils.tryInvoke)(obj, 'aMethodThatTakesArguments', [true, true]), true);
});
});
QUnit.module('ESLint | ember-utils/tests/try_invoke_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-utils/tests/try_invoke_test.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/compat/attrs.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/compat/attrs.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/compat/fallback-view-registry.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/compat/fallback-view-registry.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/component_lookup.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/component_lookup.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/index.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/index.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/mixins/action_support.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/mixins/action_support.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/mixins/child_views_support.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/mixins/child_views_support.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/mixins/class_names_support.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/mixins/class_names_support.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/mixins/text_support.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/mixins/text_support.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/mixins/view_state_support.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/mixins/view_state_support.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/mixins/view_support.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/mixins/view_support.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/system/action_manager.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/system/action_manager.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/system/event_dispatcher.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/system/event_dispatcher.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/system/ext.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/system/ext.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/system/jquery.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/system/jquery.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/system/lookup_partial.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/system/lookup_partial.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/system/utils.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/system/utils.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/utils/lookup-component.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/utils/lookup-component.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/views/core_view.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/views/core_view.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/views/states.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/views/states.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/views/states/default.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/views/states/default.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/views/states/destroying.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/views/states/destroying.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/views/states/has_element.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/views/states/has_element.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/views/states/in_dom.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/views/states/in_dom.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-views/views/states/pre_render.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-views/views/states/pre_render.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember/index.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/index.js should pass ESLint\n\n');
});
enifed('ember/tests/application_lifecycle_test', ['ember-babel', 'internal-test-helpers', 'ember-application', 'ember-routing', 'ember-glimmer'], function (_emberBabel, _internalTestHelpers, _emberApplication, _emberRouting, _emberGlimmer) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Application Lifecycle - route hooks', function (_AutobootApplicationT) {
(0, _emberBabel.inherits)(_class, _AutobootApplicationT);
_class.prototype.createApplication = function createApplication() {
var _AutobootApplicationT2;
var application = (_AutobootApplicationT2 = _AutobootApplicationT.prototype.createApplication).call.apply(_AutobootApplicationT2, [this].concat(Array.prototype.slice.call(arguments)));
this.add('router:main', _emberRouting.Router.extend({
location: 'none'
}));
return application;
};
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT.call(this));
var menuItem = _this.menuItem = {};
_this.runTask(function () {
_this.createApplication();
var SettingRoute = _emberRouting.Route.extend({
setupController: function () {
this.controller.set('selectedMenuItem', menuItem);
},
deactivate: function () {
this.controller.set('selectedMenuItem', null);
}
});
_this.add('route:index', SettingRoute);
_this.add('route:application', SettingRoute);
});
return _this;
}
_class.prototype['@test Resetting the application allows controller properties to be set when a route deactivates'] = function (assert) {
var indexController = this.indexController,
applicationController = this.applicationController;
assert.equal(indexController.get('selectedMenuItem'), this.menuItem);
assert.equal(applicationController.get('selectedMenuItem'), this.menuItem);
this.application.reset();
assert.equal(indexController.get('selectedMenuItem'), null);
assert.equal(applicationController.get('selectedMenuItem'), null);
};
_class.prototype['@test Destroying the application resets the router before the appInstance is destroyed'] = function (assert) {
var _this2 = this;
var indexController = this.indexController,
applicationController = this.applicationController;
assert.equal(indexController.get('selectedMenuItem'), this.menuItem);
assert.equal(applicationController.get('selectedMenuItem'), this.menuItem);
this.runTask(function () {
_this2.application.destroy();
});
assert.equal(indexController.get('selectedMenuItem'), null);
assert.equal(applicationController.get('selectedMenuItem'), null);
};
(0, _emberBabel.createClass)(_class, [{
key: 'indexController',
get: function () {
return this.applicationInstance.lookup('controller:index');
}
}, {
key: 'applicationController',
get: function () {
return this.applicationInstance.lookup('controller:application');
}
}]);
return _class;
}(_internalTestHelpers.AutobootApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Application Lifecycle', function (_AutobootApplicationT3) {
(0, _emberBabel.inherits)(_class2, _AutobootApplicationT3);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT3.apply(this, arguments));
}
_class2.prototype.createApplication = function createApplication() {
var _AutobootApplicationT4;
var application = (_AutobootApplicationT4 = _AutobootApplicationT3.prototype.createApplication).call.apply(_AutobootApplicationT4, [this].concat(Array.prototype.slice.call(arguments)));
this.add('router:main', _emberRouting.Router.extend({
location: 'none'
}));
return application;
};
_class2.prototype['@test Destroying a route after the router does create an undestroyed \'toplevelView\''] = function (assert) {
var _this4 = this;
this.runTask(function () {
_this4.createApplication();
_this4.addTemplate('index', 'Index!');
_this4.addTemplate('application', 'Application! {{outlet}}');
});
var router = this.applicationInstance.lookup('router:main');
var route = this.applicationInstance.lookup('route:index');
this.runTask(function () {
return router.destroy();
});
equal(router._toplevelView, null, 'the toplevelView was cleared');
this.runTask(function () {
return route.destroy();
});
equal(router._toplevelView, null, 'the toplevelView was not reinitialized');
this.runTask(function () {
return _this4.application.destroy();
});
equal(router._toplevelView, null, 'the toplevelView was not reinitialized');
};
_class2.prototype['@test initializers can augment an applications customEvents hash'] = function (assert) {
var _this5 = this;
assert.expect(1);
var MyApplication = _emberApplication.Application.extend();
MyApplication.initializer({
name: 'customize-things',
initialize: function (application) {
application.customEvents = {
wowza: 'wowza'
};
}
});
this.runTask(function () {
_this5.createApplication({}, MyApplication);
_this5.add('component:foo-bar', _emberGlimmer.Component.extend({
wowza: function () {
assert.ok(true, 'fired the event!');
}
}));
_this5.addTemplate('application', '{{foo-bar}}');
_this5.addTemplate('components/foo-bar', '');
});
this.$('#wowza-thingy').trigger('wowza');
};
_class2.prototype['@test instanceInitializers can augment an the customEvents hash'] = function (assert) {
var _this6 = this;
assert.expect(1);
var MyApplication = _emberApplication.Application.extend();
MyApplication.instanceInitializer({
name: 'customize-things',
initialize: function (application) {
application.customEvents = {
herky: 'jerky'
};
}
});
this.runTask(function () {
_this6.createApplication({}, MyApplication);
_this6.add('component:foo-bar', _emberGlimmer.Component.extend({
jerky: function () {
assert.ok(true, 'fired the event!');
}
}));
_this6.addTemplate('application', '{{foo-bar}}');
_this6.addTemplate('components/foo-bar', '');
});
this.$('#herky-thingy').trigger('herky');
};
return _class2;
}(_internalTestHelpers.AutobootApplicationTestCase));
});
QUnit.module('ESLint | ember/tests/application_lifecycle_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/application_lifecycle_test.js should pass ESLint\n\n');
});
enifed('ember/tests/component_context_test', ['ember-babel', 'ember-runtime', 'ember-glimmer', 'internal-test-helpers'], function (_emberBabel, _emberRuntime, _emberGlimmer, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Application Lifecycle - Component Context', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.apply(this, arguments));
}
_class.prototype['@test Components with a block should have the proper content when a template is provided'] = function testComponentsWithABlockShouldHaveTheProperContentWhenATemplateIsProvided(assert) {
var _this2 = this;
this.addTemplate('application', '\n
\n {{#my-component}}{{text}}{{/my-component}}\n
\n ');
this.add('controller:application', _emberRuntime.Controller.extend({
'text': 'outer'
}));
this.addComponent('my-component', {
ComponentClass: _emberGlimmer.Component.extend({
text: 'inner'
}),
template: '{{text}}-{{yield}}'
});
this.visit('/').then(function () {
var text = _this2.$('#wrapper').text().trim();
assert.equal(text, 'inner-outer', 'The component is composed correctly');
});
};
_class.prototype['@test Components with a block should yield the proper content without a template provided'] = function testComponentsWithABlockShouldYieldTheProperContentWithoutATemplateProvided(assert) {
var _this3 = this;
this.addTemplate('application', '\n
\n {{#my-component}}{{text}}{{/my-component}}\n
\n ');
this.add('controller:application', _emberRuntime.Controller.extend({
'text': 'outer'
}));
this.addComponent('my-component', {
ComponentClass: _emberGlimmer.Component.extend({
text: 'inner'
})
});
this.visit('/').then(function () {
var text = _this3.$('#wrapper').text().trim();
assert.equal(text, 'outer', 'The component is composed correctly');
});
};
_class.prototype['@test Components without a block should have the proper content when a template is provided'] = function testComponentsWithoutABlockShouldHaveTheProperContentWhenATemplateIsProvided(assert) {
var _this4 = this;
this.addTemplate('application', '\n
{{my-component}}
\n ');
this.add('controller:application', _emberRuntime.Controller.extend({
'text': 'outer'
}));
this.addComponent('my-component', {
ComponentClass: _emberGlimmer.Component.extend({
text: 'inner'
}),
template: '{{text}}'
});
this.visit('/').then(function () {
var text = _this4.$('#wrapper').text().trim();
assert.equal(text, 'inner', 'The component is composed correctly');
});
};
_class.prototype['@test Components without a block should have the proper content'] = function testComponentsWithoutABlockShouldHaveTheProperContent(assert) {
var _this5 = this;
this.addTemplate('application', '\n
{{my-component}}
\n ');
this.add('controller:application', _emberRuntime.Controller.extend({
'text': 'outer'
}));
this.addComponent('my-component', {
ComponentClass: _emberGlimmer.Component.extend({
didInsertElement: function () {
this.$().html('Some text inserted by jQuery');
}
})
});
this.visit('/').then(function () {
var text = _this5.$('#wrapper').text().trim();
assert.equal(text, 'Some text inserted by jQuery', 'The component is composed correctly');
});
};
_class.prototype['@test properties of a component without a template should not collide with internal structures [DEPRECATED]'] = function testPropertiesOfAComponentWithoutATemplateShouldNotCollideWithInternalStructuresDEPRECATED(assert) {
var _this6 = this;
this.addTemplate('application', '\n
{{my-component data=foo}}
');
this.add('controller:application', _emberRuntime.Controller.extend({
'text': 'outer',
'foo': 'Some text inserted by jQuery'
}));
this.addComponent('my-component', {
ComponentClass: _emberGlimmer.Component.extend({
didInsertElement: function () {
this.$().html(this.get('data'));
}
})
});
this.visit('/').then(function () {
var text = _this6.$('#wrapper').text().trim();
assert.equal(text, 'Some text inserted by jQuery', 'The component is composed correctly');
});
};
_class.prototype['@test attrs property of a component without a template should not collide with internal structures'] = function testAttrsPropertyOfAComponentWithoutATemplateShouldNotCollideWithInternalStructures(assert) {
var _this7 = this;
this.addTemplate('application', '\n
{{my-component attrs=foo}}
\n ');
this.add('controller:application', _emberRuntime.Controller.extend({
'text': 'outer',
'foo': 'Some text inserted by jQuery'
}));
this.addComponent('my-component', {
ComponentClass: _emberGlimmer.Component.extend({
didInsertElement: function () {
// FIXME: I'm unsure if this is even the right way to access attrs
this.$().html(this.get('attrs.attrs.value'));
}
})
});
this.visit('/').then(function () {
var text = _this7.$('#wrapper').text().trim();
assert.equal(text, 'Some text inserted by jQuery', 'The component is composed correctly');
});
};
_class.prototype['@test Components trigger actions in the parents context when called from within a block'] = function testComponentsTriggerActionsInTheParentsContextWhenCalledFromWithinABlock(assert) {
var _this8 = this;
this.addTemplate('application', '\n
\n ');
this.add('controller:application', _emberRuntime.Controller.extend({
actions: {
fizzbuzz: function () {
ok(true, 'action triggered on parent');
}
}
}));
this.addComponent('my-component', { ComponentClass: _emberGlimmer.Component.extend({}) });
this.visit('/').then(function () {
_this8.$('#fizzbuzz', '#wrapper').click();
});
};
_class.prototype['@test Components trigger actions in the components context when called from within its template'] = function testComponentsTriggerActionsInTheComponentsContextWhenCalledFromWithinItsTemplate(assert) {
var _this9 = this;
this.addTemplate('application', '\n
{{#my-component}}{{text}}{{/my-component}}
\n ');
this.add('controller:application', _emberRuntime.Controller.extend({
actions: {
fizzbuzz: function () {
ok(false, 'action on the wrong context');
}
}
}));
this.addComponent('my-component', {
ComponentClass: _emberGlimmer.Component.extend({
actions: {
fizzbuzz: function () {
ok(true, 'action triggered on component');
}
}
}),
template: 'Fizzbuzz'
});
this.visit('/').then(function () {
_this9.$('#fizzbuzz', '#wrapper').click();
});
};
return _class;
}(_internalTestHelpers.ApplicationTestCase));
});
QUnit.module('ESLint | ember/tests/component_context_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/component_context_test.js should pass ESLint\n\n');
});
enifed('ember/tests/component_registration_test', ['ember-babel', 'ember-runtime', 'ember-glimmer', 'internal-test-helpers'], function (_emberBabel, _emberRuntime, _emberGlimmer, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Application Lifecycle - Component Registration', function (_AutobootApplicationT) {
(0, _emberBabel.inherits)(_class, _AutobootApplicationT);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT.apply(this, arguments));
}
_class.prototype['@test The helper becomes the body of the component'] = function testTheHelperBecomesTheBodyOfTheComponent(assert) {
var _this2 = this;
this.runTask(function () {
_this2.createApplication();
_this2.addTemplate('components/expand-it', '
hello {{yield}}
');
_this2.addTemplate('application', 'Hello world {{#expand-it}}world{{/expand-it}}');
});
var text = this.$('div.ember-view > div.ember-view').text().trim();
assert.equal(text, 'hello world', 'The component is composed correctly');
};
_class.prototype['@test If a component is registered, it is used'] = function testIfAComponentIsRegisteredItIsUsed(assert) {
var _this3 = this;
this.runTask(function () {
_this3.createApplication();
_this3.addTemplate('components/expand-it', '
hello {{yield}}
');
_this3.addTemplate('application', 'Hello world {{#expand-it}}world{{/expand-it}}');
_this3.applicationInstance.register('component:expand-it', _emberGlimmer.Component.extend({
classNames: 'testing123'
}));
});
var text = this.$('div.testing123').text().trim();
assert.equal(text, 'hello world', 'The component is composed correctly');
};
_class.prototype['@test Late-registered components can be rendered with custom `layout` property'] = function testLateRegisteredComponentsCanBeRenderedWithCustomLayoutProperty(assert) {
var _this4 = this;
this.runTask(function () {
_this4.createApplication();
_this4.addTemplate('application', '
there goes {{my-hero}}
');
_this4.applicationInstance.register('component:my-hero', _emberGlimmer.Component.extend({
classNames: 'testing123',
layout: _this4.compile('watch him as he GOES')
}));
});
var text = this.$('#wrapper').text().trim();
assert.equal(text, 'there goes watch him as he GOES', 'The component is composed correctly');
};
_class.prototype['@test Late-registered components can be rendered with template registered on the container'] = function testLateRegisteredComponentsCanBeRenderedWithTemplateRegisteredOnTheContainer(assert) {
var _this5 = this;
this.runTask(function () {
_this5.createApplication();
_this5.addTemplate('application', '
hello world {{sally-rutherford}}-{{#sally-rutherford}}!!!{{/sally-rutherford}}
');
_this5.applicationInstance.register('template:components/sally-rutherford', _this5.compile('funkytowny{{yield}}'));
_this5.applicationInstance.register('component:sally-rutherford', _emberGlimmer.Component);
});
var text = this.$('#wrapper').text().trim();
assert.equal(text, 'hello world funkytowny-funkytowny!!!', 'The component is composed correctly');
};
_class.prototype['@test Late-registered components can be rendered with ONLY the template registered on the container'] = function testLateRegisteredComponentsCanBeRenderedWithONLYTheTemplateRegisteredOnTheContainer(assert) {
var _this6 = this;
this.runTask(function () {
_this6.createApplication();
_this6.addTemplate('application', '
hello world {{borf-snorlax}}-{{#borf-snorlax}}!!!{{/borf-snorlax}}
');
_this6.applicationInstance.register('template:components/borf-snorlax', _this6.compile('goodfreakingTIMES{{yield}}'));
});
var text = this.$('#wrapper').text().trim();
assert.equal(text, 'hello world goodfreakingTIMES-goodfreakingTIMES!!!', 'The component is composed correctly');
};
_class.prototype['@test Assigning layoutName to a component should setup the template as a layout'] = function testAssigningLayoutNameToAComponentShouldSetupTheTemplateAsALayout(assert) {
var _this7 = this;
assert.expect(1);
this.runTask(function () {
_this7.createApplication();
_this7.addTemplate('application', '
{{#my-component}}{{text}}{{/my-component}}
');
_this7.addTemplate('foo-bar-baz', '{{text}}-{{yield}}');
_this7.applicationInstance.register('controller:application', _emberRuntime.Controller.extend({
text: 'outer'
}));
_this7.applicationInstance.register('component:my-component', _emberGlimmer.Component.extend({
text: 'inner',
layoutName: 'foo-bar-baz'
}));
});
var text = this.$('#wrapper').text().trim();
assert.equal(text, 'inner-outer', 'The component is composed correctly');
};
_class.prototype['@test Assigning layoutName and layout to a component should use the `layout` value'] = function testAssigningLayoutNameAndLayoutToAComponentShouldUseTheLayoutValue(assert) {
var _this8 = this;
assert.expect(1);
this.runTask(function () {
_this8.createApplication();
_this8.addTemplate('application', '
{{#my-component}}{{text}}{{/my-component}}
');
_this8.addTemplate('foo-bar-baz', 'No way!');
_this8.applicationInstance.register('controller:application', _emberRuntime.Controller.extend({
text: 'outer'
}));
_this8.applicationInstance.register('component:my-component', _emberGlimmer.Component.extend({
text: 'inner',
layoutName: 'foo-bar-baz',
layout: _this8.compile('{{text}}-{{yield}}')
}));
});
var text = this.$('#wrapper').text().trim();
assert.equal(text, 'inner-outer', 'The component is composed correctly');
};
_class.prototype['@test Assigning defaultLayout to a component should set it up as a layout if no layout was found [DEPRECATED]'] = function testAssigningDefaultLayoutToAComponentShouldSetItUpAsALayoutIfNoLayoutWasFoundDEPRECATED(assert) {
var _this9 = this;
assert.expect(2);
expectDeprecation(function () {
_this9.runTask(function () {
_this9.createApplication();
_this9.addTemplate('application', '
{{#my-component}}{{text}}{{/my-component}}
');
_this9.applicationInstance.register('controller:application', _emberRuntime.Controller.extend({
text: 'outer'
}));
_this9.applicationInstance.register('component:my-component', _emberGlimmer.Component.extend({
text: 'inner',
defaultLayout: _this9.compile('{{text}}-{{yield}}')
}));
});
});
var text = this.$('#wrapper').text().trim();
assert.equal(text, 'inner-outer', 'The component is composed correctly');
};
_class.prototype['@test Assigning defaultLayout to a component should set it up as a layout if layout was found [DEPRECATED]'] = function testAssigningDefaultLayoutToAComponentShouldSetItUpAsALayoutIfLayoutWasFoundDEPRECATED(assert) {
var _this10 = this;
assert.expect(2);
expectDeprecation(function () {
_this10.runTask(function () {
_this10.createApplication();
_this10.addTemplate('application', '
{{#my-component}}{{text}}{{/my-component}}
');
_this10.addTemplate('components/my-component', '{{text}}-{{yield}}');
_this10.applicationInstance.register('controller:application', _emberRuntime.Controller.extend({
text: 'outer'
}));
_this10.applicationInstance.register('component:my-component', _emberGlimmer.Component.extend({
text: 'inner',
defaultLayout: _this10.compile('should not see this!')
}));
});
}, /Specifying `defaultLayout` to .+ is deprecated\./);
var text = this.$('#wrapper').text().trim();
assert.equal(text, 'inner-outer', 'The component is composed correctly');
};
_class.prototype['@test Using name of component that does not exist'] = function testUsingNameOfComponentThatDoesNotExist() {
var _this11 = this;
expectAssertion(function () {
_this11.runTask(function () {
_this11.createApplication();
_this11.addTemplate('application', '
{{#no-good}} {{/no-good}}
');
});
}, /.* named "no-good" .*/);
};
return _class;
}(_internalTestHelpers.AutobootApplicationTestCase));
});
QUnit.module('ESLint | ember/tests/component_registration_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/component_registration_test.js should pass ESLint\n\n');
});
enifed('ember/tests/controller_test', ['ember-babel', 'ember-runtime', 'internal-test-helpers', 'ember-glimmer'], function (_emberBabel, _emberRuntime, _internalTestHelpers, _emberGlimmer) {
'use strict';
/*
In Ember 1.x, controllers subtly affect things like template scope
and action targets in exciting and often inscrutable ways. This test
file contains integration tests that verify the correct behavior of
the many parts of the system that change and rely upon controller scope,
from the runtime up to the templating layer.
*/
(0, _internalTestHelpers.moduleFor)('Template scoping examples', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.apply(this, arguments));
}
_class.prototype['@test Actions inside an outlet go to the associated controller'] = function testActionsInsideAnOutletGoToTheAssociatedController(assert) {
var _this2 = this;
this.add('controller:index', _emberRuntime.Controller.extend({
actions: {
componentAction: function () {
assert.ok(true, 'controller received the action');
}
}
}));
this.addComponent('component-with-action', {
ComponentClass: _emberGlimmer.Component.extend({
classNames: ['component-with-action'],
click: function () {
this.sendAction();
}
})
});
this.addTemplate('index', '{{component-with-action action="componentAction"}}');
return this.visit('/').then(function () {
_this2.runTask(function () {
return _this2.$('.component-with-action').click();
});
});
};
return _class;
}(_internalTestHelpers.ApplicationTestCase));
});
QUnit.module('ESLint | ember/tests/controller_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/controller_test.js should pass ESLint\n\n');
});
enifed('ember/tests/error_handler_test', ['ember', 'ember-metal'], function (_ember, _emberMetal) {
'use strict';
var ONERROR = _ember.default.onerror;
var ADAPTER = _ember.default.Test && _ember.default.Test.adapter;
var TESTING = _ember.default.testing;
QUnit.module('error_handler', {
teardown: function () {
_ember.default.onerror = ONERROR;
_ember.default.testing = TESTING;
if (_ember.default.Test) {
_ember.default.Test.adapter = ADAPTER;
}
}
});
function runThatThrows(message) {
return (0, _emberMetal.run)(function () {
throw new Error(message);
});
}
test('by default there is no onerror', function (assert) {
_ember.default.onerror = undefined;
assert.throws(runThatThrows, Error);
assert.equal(_ember.default.onerror, undefined);
});
test('when Ember.onerror is registered', function (assert) {
assert.expect(2);
_ember.default.onerror = function (error) {
assert.ok(true, 'onerror called');
throw error;
};
assert.throws(runThatThrows, Error);
// Ember.onerror = ONERROR;
});
if (true) {
test('when Ember.Test.adapter is registered', function (assert) {
assert.expect(2);
_ember.default.Test.adapter = {
exception: function (error) {
assert.ok(true, 'adapter called');
throw error;
}
};
assert.throws(runThatThrows, Error);
});
test('when both Ember.onerror Ember.Test.adapter are registered', function (assert) {
assert.expect(2);
// takes precedence
_ember.default.Test.adapter = {
exception: function (error) {
assert.ok(true, 'adapter called');
throw error;
}
};
_ember.default.onerror = function (error) {
assert.ok(false, 'onerror was NEVER called');
throw error;
};
assert.throws(runThatThrows, Error);
});
}
QUnit.test('Ember.run does not swallow exceptions by default (Ember.testing = true)', function () {
_ember.default.testing = true;
var error = new Error('the error');
throws(function () {
_ember.default.run(function () {
throw error;
});
}, error);
});
QUnit.test('Ember.run does not swallow exceptions by default (Ember.testing = false)', function () {
_ember.default.testing = false;
var error = new Error('the error');
throws(function () {
_ember.default.run(function () {
throw error;
});
}, error);
});
});
QUnit.module('ESLint | ember/tests/error_handler_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/error_handler_test.js should pass ESLint\n\n');
});
enifed('ember/tests/global-api-test', ['ember-metal', 'ember-runtime'], function (_emberMetal, _emberRuntime) {
'use strict';
QUnit.module('Global API Tests');
function confirmExport(property, internal) {
QUnit.test('confirm ' + property + ' is exported', function () {
var theExport = (0, _emberMetal.get)(window, property);
ok(theExport + ' is exported');
if (internal !== undefined) {
equal(theExport, internal, theExport + ' is exported properly');
}
});
}
confirmExport('Ember.DefaultResolver');
confirmExport('Ember.generateController');
confirmExport('Ember.Helper');
confirmExport('Ember.Helper.helper');
confirmExport('Ember.isArray', _emberRuntime.isArray);
});
QUnit.module('ESLint | ember/tests/global-api-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/global-api-test.js should pass ESLint\n\n');
});
enifed('ember/tests/helpers/helper_registration_test', ['ember-babel', 'internal-test-helpers', 'ember-runtime', 'ember-glimmer'], function (_emberBabel, _internalTestHelpers, _emberRuntime, _emberGlimmer) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Application Lifecycle - Helper Registration', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.apply(this, arguments));
}
_class.prototype['@test Unbound dashed helpers registered on the container can be late-invoked'] = function testUnboundDashedHelpersRegisteredOnTheContainerCanBeLateInvoked(assert) {
var _this2 = this;
this.addTemplate('application', '
{{x-borf}} {{x-borf \'YES\'}}
');
var myHelper = (0, _emberGlimmer.helper)(function (params) {
return params[0] || 'BORF';
});
this.application.register('helper:x-borf', myHelper);
return this.visit('/').then(function () {
assert.equal(_this2.$('#wrapper').text(), 'BORF YES', 'The helper was invoked from the container');
});
};
_class.prototype['@test Bound helpers registered on the container can be late-invoked'] = function testBoundHelpersRegisteredOnTheContainerCanBeLateInvoked(assert) {
var _this3 = this;
this.addTemplate('application', '
{{x-reverse}} {{x-reverse foo}}
');
this.add('controller:application', _emberRuntime.Controller.extend({
foo: 'alex'
}));
this.application.register('helper:x-reverse', (0, _emberGlimmer.helper)(function (_ref) {
var value = _ref[0];
return value ? value.split('').reverse().join('') : '--';
}));
return this.visit('/').then(function () {
assert.equal(_this3.$('#wrapper').text(), '-- xela', 'The bound helper was invoked from the container');
});
};
_class.prototype['@test Undashed helpers registered on the container can be invoked'] = function testUndashedHelpersRegisteredOnTheContainerCanBeInvoked(assert) {
var _this4 = this;
this.addTemplate('application', '
{{omg}}|{{yorp \'boo\'}}|{{yorp \'ya\'}}
');
this.application.register('helper:omg', (0, _emberGlimmer.helper)(function () {
return 'OMG';
}));
this.application.register('helper:yorp', (0, _emberGlimmer.helper)(function (_ref2) {
var value = _ref2[0];
return value;
}));
return this.visit('/').then(function () {
assert.equal(_this4.$('#wrapper').text(), 'OMG|boo|ya', 'The helper was invoked from the container');
});
};
_class.prototype['@test Helpers can receive injections'] = function testHelpersCanReceiveInjections(assert) {
this.addTemplate('application', '
{{full-name}}
');
var serviceCalled = false;
this.add('service:name-builder', _emberRuntime.Service.extend({
build: function () {
serviceCalled = true;
}
}));
this.add('helper:full-name', _emberGlimmer.Helper.extend({
nameBuilder: _emberRuntime.inject.service('name-builder'),
compute: function () {
this.get('nameBuilder').build();
}
}));
return this.visit('/').then(function () {
assert.ok(serviceCalled, 'service was injected, method called');
});
};
return _class;
}(_internalTestHelpers.ApplicationTestCase));
});
QUnit.module('ESLint | ember/tests/helpers/helper_registration_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/helpers/helper_registration_test.js should pass ESLint\n\n');
});
enifed('ember/tests/helpers/link_to_test', ['ember-babel', 'ember-console', 'internal-test-helpers', 'ember-runtime', 'ember-metal', 'ember-routing', 'ember-views', 'ember/features'], function (_emberBabel, _emberConsole, _internalTestHelpers, _emberRuntime, _emberMetal, _emberRouting, _emberViews, _features) {
'use strict';
// IE includes the host name
function normalizeUrl(url) {
return url.replace(/https?:\/\/[^\/]+/, '');
}
function shouldNotBeActive(assert, element) {
checkActive(assert, element, false);
}
function shouldBeActive(assert, element) {
checkActive(assert, element, true);
}
function checkActive(assert, element, active) {
var classList = element.attr('class');
assert.equal(classList.indexOf('active') > -1, active, element + ' active should be ' + active);
}
(0, _internalTestHelpers.moduleFor)('The {{link-to}} helper - basic tests', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.call(this));
_this.router.map(function () {
this.route('about');
});
_this.addTemplate('index', '\n
\n {{#link-to \'index\' id=\'home-link\'}}Home{{/link-to}}\n {{#link-to \'about\' id=\'self-link\'}}Self{{/link-to}}\n ');
return _this;
}
_class.prototype['@test The {{link-to}} helper moves into the named route'] = function testTheLinkToHelperMovesIntoTheNamedRoute(assert) {
this.visit('/');
assert.equal(this.$('h3:contains(Home)').length, 1, 'The home template was rendered');
assert.equal(this.$('#self-link.active').length, 1, 'The self-link was rendered with active class');
assert.equal(this.$('#about-link:not(.active)').length, 1, 'The other link was rendered without active class');
this.click('#about-link');
assert.equal(this.$('h3:contains(About)').length, 1, 'The about template was rendered');
assert.equal(this.$('#self-link.active').length, 1, 'The self-link was rendered with active class');
assert.equal(this.$('#home-link:not(.active)').length, 1, 'The other link was rendered without active class');
};
_class.prototype['@test the {{link-to}} helper doesn\'t add an href when the tagName isn\'t \'a\''] = function (assert) {
this.addTemplate('index', '\n {{#link-to \'about\' id=\'about-link\' tagName=\'div\'}}About{{/link-to}}\n ');
this.visit('/');
assert.equal(this.$('#about-link').attr('href'), undefined, 'there is no href attribute');
};
_class.prototype['@test the {{link-to}} applies a \'disabled\' class when disabled'] = function (assert) {
this.addTemplate('index', '\n {{#link-to "about" id="about-link-static" disabledWhen="shouldDisable"}}About{{/link-to}}\n {{#link-to "about" id="about-link-dynamic" disabledWhen=dynamicDisabledWhen}}About{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
shouldDisable: true,
dynamicDisabledWhen: 'shouldDisable'
}));
this.visit('/');
assert.equal(this.$('#about-link-static.disabled').length, 1, 'The static link is disabled when its disabledWhen is true');
assert.equal(this.$('#about-link-dynamic.disabled').length, 1, 'The dynamic link is disabled when its disabledWhen is true');
var controller = this.applicationInstance.lookup('controller:index');
this.runTask(function () {
return controller.set('dynamicDisabledWhen', false);
});
assert.equal(this.$('#about-link-dynamic.disabled').length, 0, 'The dynamic link is re-enabled when its disabledWhen becomes false');
};
_class.prototype['@test the {{link-to}} doesn\'t apply a \'disabled\' class if disabledWhen is not provided'] = function (assert) {
this.addTemplate('index', '{{#link-to "about" id="about-link"}}About{{/link-to}}');
this.visit('/');
assert.ok(!this.$('#about-link').hasClass('disabled'), 'The link is not disabled if disabledWhen not provided');
};
_class.prototype['@test the {{link-to}} helper supports a custom disabledClass'] = function (assert) {
this.addTemplate('index', '\n {{#link-to "about" id="about-link" disabledWhen=true disabledClass="do-not-want"}}About{{/link-to}}\n ');
this.visit('/');
assert.equal(this.$('#about-link.do-not-want').length, 1, 'The link can apply a custom disabled class');
};
_class.prototype['@test the {{link-to}} helper supports a custom disabledClass set via bound param'] = function (assert) {
this.addTemplate('index', '\n {{#link-to "about" id="about-link" disabledWhen=true disabledClass=disabledClass}}About{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
disabledClass: 'do-not-want'
}));
this.visit('/');
assert.equal(this.$('#about-link.do-not-want').length, 1, 'The link can apply a custom disabled class via bound param');
};
_class.prototype['@test the {{link-to}} helper does not respond to clicks when disabled'] = function (assert) {
this.addTemplate('index', '\n {{#link-to "about" id="about-link" disabledWhen=true}}About{{/link-to}}\n ');
this.visit('/');
this.click('#about-link');
assert.equal(this.$('h3:contains(About)').length, 0, 'Transitioning did not occur');
};
_class.prototype['@test the {{link-to}} helper responds to clicks according to its disabledWhen bound param'] = function (assert) {
this.addTemplate('index', '\n {{#link-to "about" id="about-link" disabledWhen=disabledWhen}}About{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
disabledWhen: true
}));
this.visit('/');
this.click('#about-link');
assert.equal(this.$('h3:contains(About)').length, 0, 'Transitioning did not occur');
var controller = this.applicationInstance.lookup('controller:index');
this.runTask(function () {
return controller.set('disabledWhen', false);
});
this.click('#about-link');
assert.equal(this.$('h3:contains(About)').length, 1, 'Transitioning did occur when disabledWhen became false');
};
_class.prototype['@test The {{link-to}} helper supports a custom activeClass'] = function (assert) {
this.addTemplate('index', '\n
Home
\n {{#link-to \'about\' id=\'about-link\'}}About{{/link-to}}\n {{#link-to \'index\' id=\'self-link\' activeClass=\'zomg-active\'}}Self{{/link-to}}\n ');
this.visit('/');
assert.equal(this.$('h3:contains(Home)').length, 1, 'The home template was rendered');
assert.equal(this.$('#self-link.zomg-active').length, 1, 'The self-link was rendered with active class');
assert.equal(this.$('#about-link:not(.active)').length, 1, 'The other link was rendered without active class');
};
_class.prototype['@test The {{link-to}} helper supports a custom activeClass from a bound param'] = function (assert) {
this.addTemplate('index', '\n
Home
\n {{#link-to \'about\' id=\'about-link\'}}About{{/link-to}}\n {{#link-to \'index\' id=\'self-link\' activeClass=activeClass}}Self{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
activeClass: 'zomg-active'
}));
this.visit('/');
assert.equal(this.$('h3:contains(Home)').length, 1, 'The home template was rendered');
assert.equal(this.$('#self-link.zomg-active').length, 1, 'The self-link was rendered with active class');
assert.equal(this.$('#about-link:not(.active)').length, 1, 'The other link was rendered without active class');
};
_class.prototype['@test The {{link-to}} helper supports \'classNameBindings\' with custom values [GH #11699]'] = function (assert) {
this.addTemplate('index', '\n
Home
\n {{#link-to \'about\' id=\'about-link\' classNameBindings=\'foo:foo-is-true:foo-is-false\'}}About{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
foo: false
}));
this.visit('/');
assert.equal(this.$('#about-link.foo-is-false').length, 1, 'The about-link was rendered with the falsy class');
var controller = this.applicationInstance.lookup('controller:index');
this.runTask(function () {
return controller.set('foo', true);
});
assert.equal(this.$('#about-link.foo-is-true').length, 1, 'The about-link was rendered with the truthy class after toggling the property');
};
return _class;
}(_internalTestHelpers.ApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('The {{link-to}} helper - location hooks', function (_ApplicationTestCase2) {
(0, _emberBabel.inherits)(_class2, _ApplicationTestCase2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
var _this2 = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase2.call(this));
_this2.updateCount = 0;
_this2.replaceCount = 0;
var testContext = _this2;
_this2.add('location:none', _emberRouting.NoneLocation.extend({
setURL: function () {
testContext.updateCount++;
return this._super.apply(this, arguments);
},
replaceURL: function () {
testContext.replaceCount++;
return this._super.apply(this, arguments);
}
}));
_this2.router.map(function () {
this.route('about');
});
_this2.addTemplate('index', '\n
\n {{#link-to \'about\' id=\'about-link\' replace=true}}About{{/link-to}}\n ');
this.visit('/');
this.click('#about-link');
assert.equal(this.updateCount, this.updateCountAfterVisit, 'setURL should not be called');
assert.equal(this.replaceCount, this.replaceCountAfterVisit + 1, 'replaceURL should be called once');
};
_class2.prototype['@test The {{link-to}} helper supports URL replacement via replace=boundTruthyThing'] = function testTheLinkToHelperSupportsURLReplacementViaReplaceBoundTruthyThing(assert) {
this.addTemplate('index', '\n
Home
\n {{#link-to \'about\' id=\'about-link\' replace=boundTruthyThing}}About{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
boundTruthyThing: true
}));
this.visit('/');
this.click('#about-link');
assert.equal(this.updateCount, this.updateCountAfterVisit, 'setURL should not be called');
assert.equal(this.replaceCount, this.replaceCountAfterVisit + 1, 'replaceURL should be called once');
};
_class2.prototype['@test The {{link-to}} helper supports setting replace=boundFalseyThing'] = function testTheLinkToHelperSupportsSettingReplaceBoundFalseyThing(assert) {
this.addTemplate('index', '\n
Home
\n {{#link-to \'about\' id=\'about-link\' replace=boundFalseyThing}}About{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
boundFalseyThing: false
}));
this.visit('/');
this.click('#about-link');
assert.equal(this.updateCount, this.updateCountAfterVisit + 1, 'setURL should be called');
assert.equal(this.replaceCount, this.replaceCountAfterVisit, 'replaceURL should not be called');
};
return _class2;
}(_internalTestHelpers.ApplicationTestCase));
if (_features.EMBER_IMPROVED_INSTRUMENTATION) {
(0, _internalTestHelpers.moduleFor)('The {{link-to}} helper with EMBER_IMPROVED_INSTRUMENTATION', function (_ApplicationTestCase4) {
(0, _emberBabel.inherits)(_class3, _ApplicationTestCase4);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
var _this3 = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase4.call(this));
_this3.router.map(function () {
this.route('about');
});
_this3.addTemplate('index', '\n
\n {{#link-to \'index\' id=\'home-link\'}}Home{{/link-to}}\n {{#link-to \'about\' id=\'self-link\'}}Self{{/link-to}}\n ');
_this3.visit('/');
return _this3;
}
_class3.prototype['@test The {{link-to}} helper fires an interaction event'] = function testTheLinkToHelperFiresAnInteractionEvent(assert) {
assert.expect(2);
(0, _emberMetal.instrumentationSubscribe)('interaction.link-to', {
before: function () {
assert.ok(true, 'instrumentation subscriber was called');
},
after: function () {
assert.ok(true, 'instrumentation subscriber was called');
}
});
this.click('#about-link');
};
_class3.prototype['@test The {{link-to}} helper interaction event includes the route name'] = function testTheLinkToHelperInteractionEventIncludesTheRouteName(assert) {
assert.expect(2);
(0, _emberMetal.instrumentationSubscribe)('interaction.link-to', {
before: function (name, timestamp, _ref) {
var routeName = _ref.routeName;
assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name');
},
after: function (name, timestamp, _ref2) {
var routeName = _ref2.routeName;
assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name');
}
});
this.click('#about-link');
};
_class3.prototype['@test The {{link-to}} helper interaction event includes the transition in the after hook'] = function testTheLinkToHelperInteractionEventIncludesTheTransitionInTheAfterHook(assert) {
assert.expect(1);
(0, _emberMetal.instrumentationSubscribe)('interaction.link-to', {
before: function () {},
after: function (name, timestamp, _ref3) {
var transition = _ref3.transition;
assert.equal(transition.targetName, 'about', 'instrumentation subscriber was passed route name');
}
});
this.click('#about-link');
};
return _class3;
}(_internalTestHelpers.ApplicationTestCase));
}
(0, _internalTestHelpers.moduleFor)('The {{link-to}} helper - nested routes and link-to arguments', function (_ApplicationTestCase5) {
(0, _emberBabel.inherits)(_class4, _ApplicationTestCase5);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase5.apply(this, arguments));
}
_class4.prototype['@test The {{link-to}} helper supports leaving off .index for nested routes'] = function testTheLinkToHelperSupportsLeavingOffIndexForNestedRoutes(assert) {
this.router.map(function () {
this.route('about', function () {
this.route('item');
});
});
this.addTemplate('about', '
About
{{outlet}}');
this.addTemplate('about.index', '
Index
');
this.addTemplate('about.item', '
{{#link-to \'about\'}}About{{/link-to}}
');
this.visit('/about/item');
assert.equal(normalizeUrl(this.$('#item a').attr('href')), '/about');
};
_class4.prototype['@test The {{link-to}} helper supports currentWhen (DEPRECATED)'] = function testTheLinkToHelperSupportsCurrentWhenDEPRECATED(assert) {
expectDeprecation('Usage of `currentWhen` is deprecated, use `current-when` instead.');
this.router.map(function () {
this.route('index', { path: '/' }, function () {
this.route('about');
});
this.route('item');
});
this.addTemplate('index', '
Home
{{outlet}}');
this.addTemplate('index.about', '\n {{#link-to \'item\' id=\'other-link\' currentWhen=\'index\'}}ITEM{{/link-to}}\n ');
this.visit('/about');
assert.equal(this.$('#other-link.active').length, 1, 'The link is active since current-when is a parent route');
};
_class4.prototype['@test The {{link-to}} helper supports custom, nested, current-when'] = function (assert) {
this.router.map(function () {
this.route('index', { path: '/' }, function () {
this.route('about');
});
this.route('item');
});
this.addTemplate('index', '
Home
{{outlet}}');
this.addTemplate('index.about', '\n {{#link-to \'item\' id=\'other-link\' current-when=\'index\'}}ITEM{{/link-to}}\n ');
this.visit('/about');
equal(this.$('#other-link.active').length, 1, 'The link is active since current-when is a parent route');
};
_class4.prototype['@test The {{link-to}} helper does not disregard current-when when it is given explicitly for a route'] = function (assert) {
this.router.map(function () {
this.route('index', { path: '/' }, function () {
this.route('about');
});
this.route('items', function () {
this.route('item');
});
});
this.addTemplate('index', '
Home
{{outlet}}');
this.addTemplate('index.about', '\n {{#link-to \'items\' id=\'other-link\' current-when=\'index\'}}ITEM{{/link-to}}\n ');
this.visit('/about');
assert.equal(this.$('#other-link.active').length, 1, 'The link is active when current-when is given for explicitly for a route');
};
_class4.prototype['@test The {{link-to}} helper does not disregard current-when when it is set via a bound param'] = function testTheLinkToHelperDoesNotDisregardCurrentWhenWhenItIsSetViaABoundParam(assert) {
this.router.map(function () {
this.route('index', { path: '/' }, function () {
this.route('about');
});
this.route('items', function () {
this.route('item');
});
});
this.add('controller:index.about', _emberRuntime.Controller.extend({
currentWhen: 'index'
}));
this.addTemplate('index', '
Home
{{outlet}}');
this.addTemplate('index.about', '{{#link-to \'items\' id=\'other-link\' current-when=currentWhen}}ITEM{{/link-to}}');
this.visit('/about');
assert.equal(this.$('#other-link.active').length, 1, 'The link is active when current-when is given for explicitly for a route');
};
_class4.prototype['@test The {{link-to}} helper supports multiple current-when routes'] = function testTheLinkToHelperSupportsMultipleCurrentWhenRoutes(assert) {
this.router.map(function () {
this.route('index', { path: '/' }, function () {
this.route('about');
});
this.route('item');
this.route('foo');
});
this.addTemplate('index', '
Home
{{outlet}}');
this.addTemplate('index.about', '{{#link-to \'item\' id=\'link1\' current-when=\'item index\'}}ITEM{{/link-to}}');
this.addTemplate('item', '{{#link-to \'item\' id=\'link2\' current-when=\'item index\'}}ITEM{{/link-to}}');
this.addTemplate('foo', '{{#link-to \'item\' id=\'link3\' current-when=\'item index\'}}ITEM{{/link-to}}');
this.visit('/about');
assert.equal(this.$('#link1.active').length, 1, 'The link is active since current-when contains the parent route');
this.visit('/item');
assert.equal(this.$('#link2.active').length, 1, 'The link is active since you are on the active route');
this.visit('/foo');
assert.equal(this.$('#link3.active').length, 0, 'The link is not active since current-when does not contain the active route');
};
_class4.prototype['@test The {{link-to}} helper supports boolean values for current-when'] = function testTheLinkToHelperSupportsBooleanValuesForCurrentWhen(assert) {
this.router.map(function (match) {
this.route('index', { path: '/' }, function () {
this.route('about');
});
this.route('item');
});
this.addTemplate('index', '
Home
{{outlet}}');
this.addTemplate('index.about', '{{#link-to \'item\' id=\'other-link\' current-when=true}}ITEM{{/link-to}}');
this.visit('/about');
assert.equal(this.$('#other-link').length, 1, 'The link is active since current-when is true');
};
_class4.prototype['@test The {{link-to}} helper defaults to bubbling'] = function testTheLinkToHelperDefaultsToBubbling(assert) {
this.addTemplate('about', '\n
\n {{#link-to \'about\' id=\'about-link\'}}About{{/link-to}}\n ');
this.add('route:about', _emberRouting.Route.extend({
model: function () {
return [{ id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, { id: 'erik', name: 'Erik Brynroflsson' }];
}
}));
this.visit('/about');
assert.equal(this.$('h3:contains(List)').length, 1, 'The home template was rendered');
assert.equal(normalizeUrl(this.$('#home-link').attr('href')), '/', 'The home link points back at /');
this.click('li a:contains(Yehuda)');
assert.equal(this.$('h3:contains(Item)').length, 1, 'The item template was rendered');
assert.equal(this.$('p').text(), 'Yehuda Katz', 'The name is correct');
this.click('#home-link');
this.click('#about-link');
assert.equal(normalizeUrl(this.$('li a:contains(Yehuda)').attr('href')), '/item/yehuda');
assert.equal(normalizeUrl(this.$('li a:contains(Tom)').attr('href')), '/item/tom');
assert.equal(normalizeUrl(this.$('li a:contains(Erik)').attr('href')), '/item/erik');
this.click('li a:contains(Erik)');
assert.equal(this.$('h3:contains(Item)').length, 1, 'The item template was rendered');
assert.equal(this.$('p').text(), 'Erik Brynroflsson', 'The name is correct');
};
_class4.prototype['@test The {{link-to}} helper binds some anchor html tag common attributes'] = function (assert) {
this.addTemplate('index', '\n
Home
\n {{#link-to \'index\' id=\'self-link\' title=\'title-attr\' rel=\'rel-attr\' tabindex=\'-1\'}}\n Self\n {{/link-to}}\n ');
this.visit('/');
var link = this.$('#self-link');
assert.equal(link.attr('title'), 'title-attr', 'The self-link contains title attribute');
assert.equal(link.attr('rel'), 'rel-attr', 'The self-link contains rel attribute');
assert.equal(link.attr('tabindex'), '-1', 'The self-link contains tabindex attribute');
};
_class4.prototype['@test The {{link-to}} helper supports \'target\' attribute'] = function (assert) {
this.addTemplate('index', '\n
Home
\n {{#link-to \'index\' id=\'self-link\' target=\'_blank\'}}Self{{/link-to}}\n ');
this.visit('/');
var link = this.$('#self-link');
assert.equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute');
};
_class4.prototype['@test The {{link-to}} helper supports \'target\' attribute specified as a bound param'] = function (assert) {
this.addTemplate('index', '
Home
{{#link-to \'index\' id=\'self-link\' target=boundLinkTarget}}Self{{/link-to}}');
this.add('controller:index', _emberRuntime.Controller.extend({
boundLinkTarget: '_blank'
}));
this.visit('/');
var link = this.$('#self-link');
assert.equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute');
};
_class4.prototype['@test the {{link-to}} helper calls preventDefault'] = function (assert) {
this.router.map(function () {
this.route('about');
});
this.addTemplate('index', '\n {{#link-to \'about\' id=\'about-link\'}}About{{/link-to}}\n ');
this.visit('/');
var event = _emberViews.jQuery.Event('click');
this.$('#about-link').trigger(event);
assert.equal(event.isDefaultPrevented(), true, 'should preventDefault');
};
_class4.prototype['@test the {{link-to}} helper does not call preventDefault if \'preventDefault=false\' is passed as an option'] = function (assert) {
this.router.map(function () {
this.route('about');
});
this.addTemplate('index', '\n {{#link-to \'about\' id=\'about-link\' preventDefault=false}}About{{/link-to}}\n ');
this.visit('/');
var event = _emberViews.jQuery.Event('click');
this.$('#about-link').trigger(event);
assert.equal(event.isDefaultPrevented(), false, 'should not preventDefault');
};
_class4.prototype['@test the {{link-to}} helper does not call preventDefault if \'preventDefault=boundFalseyThing\' is passed as an option'] = function (assert) {
this.router.map(function () {
this.route('about');
});
this.addTemplate('index', '\n {{#link-to \'about\' id=\'about-link\' preventDefault=boundFalseyThing}}About{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
boundFalseyThing: false
}));
this.visit('/');
var event = _emberViews.jQuery.Event('click');
this.$('#about-link').trigger(event);
equal(event.isDefaultPrevented(), false, 'should not preventDefault');
};
_class4.prototype['@test The {{link-to}} helper does not call preventDefault if \'target\' attribute is provided'] = function (assert) {
this.addTemplate('index', '\n
Home
\n {{#link-to \'index\' id=\'self-link\' target=\'_blank\'}}Self{{/link-to}}\n ');
this.visit('/');
var event = _emberViews.jQuery.Event('click');
this.$('#self-link').trigger(event);
assert.equal(event.isDefaultPrevented(), false, 'should not preventDefault when target attribute is specified');
};
_class4.prototype['@test The {{link-to}} helper should preventDefault when \'target = _self\''] = function (assert) {
this.addTemplate('index', '\n
Home
\n {{#link-to \'index\' id=\'self-link\' target=\'_self\'}}Self{{/link-to}}\n ');
this.visit('/');
var event = _emberViews.jQuery.Event('click');
this.$('#self-link').trigger(event);
equal(event.isDefaultPrevented(), true, 'should preventDefault when target attribute is `_self`');
};
_class4.prototype['@test The {{link-to}} helper should not transition if target is not equal to _self or empty'] = function (assert) {
this.addTemplate('index', '\n {{#link-to \'about\' id=\'about-link\' replace=true target=\'_blank\'}}\n About\n {{/link-to}}\n ');
this.router.map(function () {
this.route('about');
});
this.visit('/');
this.click('#about-link');
var currentRouteName = this.applicationInstance.lookup('controller:application').get('currentRouteName');
assert.notEqual(currentRouteName, 'about', 'link-to should not transition if target is not equal to _self or empty');
};
_class4.prototype['@test The {{link-to}} helper accepts string/numeric arguments'] = function (assert) {
this.router.map(function () {
this.route('filter', { path: '/filters/:filter' });
this.route('post', { path: '/post/:post_id' });
this.route('repo', { path: '/repo/:owner/:name' });
});
this.add('controller:filter', _emberRuntime.Controller.extend({
filter: 'unpopular',
repo: { owner: 'ember', name: 'ember.js' },
post_id: 123
}));
this.addTemplate('filter', '\n
{{filter}}
\n {{#link-to "filter" "unpopular" id="link"}}Unpopular{{/link-to}}\n {{#link-to "filter" filter id="path-link"}}Unpopular{{/link-to}}\n {{#link-to "post" post_id id="post-path-link"}}Post{{/link-to}}\n {{#link-to "post" 123 id="post-number-link"}}Post{{/link-to}}\n {{#link-to "repo" repo id="repo-object-link"}}Repo{{/link-to}}\n ');
this.visit('/filters/popular');
assert.equal(normalizeUrl(this.$('#link').attr('href')), '/filters/unpopular');
assert.equal(normalizeUrl(this.$('#path-link').attr('href')), '/filters/unpopular');
assert.equal(normalizeUrl(this.$('#post-path-link').attr('href')), '/post/123');
assert.equal(normalizeUrl(this.$('#post-number-link').attr('href')), '/post/123');
assert.equal(normalizeUrl(this.$('#repo-object-link').attr('href')), '/repo/ember/ember.js');
};
_class4.prototype['@test Issue 4201 - Shorthand for route.index shouldn\'t throw errors about context arguments'] = function (assert) {
assert.expect(2);
this.router.map(function () {
this.route('lobby', function () {
this.route('index', { path: ':lobby_id' });
this.route('list');
});
});
this.add('route:lobby.index', _emberRouting.Route.extend({
model: function (params) {
assert.equal(params.lobby_id, 'foobar');
return params.lobby_id;
}
}));
this.addTemplate('lobby.index', '\n {{#link-to \'lobby\' \'foobar\' id=\'lobby-link\'}}Lobby{{/link-to}}\n ');
this.addTemplate('lobby.list', '\n {{#link-to \'lobby\' \'foobar\' id=\'lobby-link\'}}Lobby{{/link-to}}\n ');
this.visit('/lobby/list');
this.click('#lobby-link');
shouldBeActive(assert, this.$('#lobby-link'));
};
_class4.prototype['@test Quoteless route param performs property lookup'] = function (assert) {
var _this5 = this;
this.router.map(function () {
this.route('about');
});
this.addTemplate('index', '\n {{#link-to \'index\' id=\'string-link\'}}string{{/link-to}}\n {{#link-to foo id=\'path-link\'}}path{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
foo: 'index'
}));
var assertEquality = function (href) {
assert.equal(normalizeUrl(_this5.$('#string-link').attr('href')), '/');
assert.equal(normalizeUrl(_this5.$('#path-link').attr('href')), href);
};
this.visit('/');
assertEquality('/');
var controller = this.applicationInstance.lookup('controller:index');
this.runTask(function () {
return controller.set('foo', 'about');
});
assertEquality('/about');
};
_class4.prototype['@test The {{link-to}} helper refreshes href element when one of params changes'] = function (assert) {
this.router.map(function () {
this.route('post', { path: '/posts/:post_id' });
});
var post = { id: '1' };
var secondPost = { id: '2' };
this.addTemplate('index', '\n {{#link-to "post" post id="post"}}post{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend());
this.visit('/');
var indexController = this.applicationInstance.lookup('controller:index');
this.runTask(function () {
return indexController.set('post', post);
});
assert.equal(normalizeUrl(this.$('#post').attr('href')), '/posts/1', 'precond - Link has rendered href attr properly');
this.runTask(function () {
return indexController.set('post', secondPost);
});
assert.equal(this.$('#post').attr('href'), '/posts/2', 'href attr was updated after one of the params had been changed');
this.runTask(function () {
return indexController.set('post', null);
});
assert.equal(this.$('#post').attr('href'), '#', 'href attr becomes # when one of the arguments in nullified');
};
_class4.prototype['@test The {{link-to}} helper is active when a route is active'] = function (assert) {
this.router.map(function () {
this.route('about', function () {
this.route('item');
});
});
this.addTemplate('about', '\n
\n ');
this.visit('/about');
assert.equal(this.$('#about-link.active').length, 1, 'The about route link is active');
assert.equal(this.$('#item-link.active').length, 0, 'The item route link is inactive');
this.visit('/about/item');
assert.equal(this.$('#about-link.active').length, 1, 'The about route link is active');
assert.equal(this.$('#item-link.active').length, 1, 'The item route link is active');
};
_class4.prototype['@test The {{link-to}} helper works in an #each\'d array of string route names'] = function (assert) {
var _this6 = this;
this.router.map(function () {
this.route('foo');
this.route('bar');
this.route('rar');
});
this.add('controller:index', _emberRuntime.Controller.extend({
routeNames: (0, _emberRuntime.A)(['foo', 'bar', 'rar']),
route1: 'bar',
route2: 'foo'
}));
this.addTemplate('index', '\n {{#each routeNames as |routeName|}}\n {{#link-to routeName}}{{routeName}}{{/link-to}}\n {{/each}}\n {{#each routeNames as |r|}}\n {{#link-to r}}{{r}}{{/link-to}}\n {{/each}}\n {{#link-to route1}}a{{/link-to}}\n {{#link-to route2}}b{{/link-to}}\n ');
this.visit('/');
var linksEqual = function (links, expected) {
equal(links.length, expected.length, 'Has correct number of links');
var idx = void 0;
for (idx = 0; idx < links.length; idx++) {
var href = _this6.$(links[idx]).attr('href');
// Old IE includes the whole hostname as well
assert.equal(href.slice(-expected[idx].length), expected[idx], 'Expected link to be \'' + expected[idx] + '\', but was \'' + href + '\'');
}
};
linksEqual(this.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/bar', '/foo']);
var indexController = this.applicationInstance.lookup('controller:index');
this.runTask(function () {
return indexController.set('route1', 'rar');
});
linksEqual(this.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']);
this.runTask(function () {
return indexController.routeNames.shiftObject();
});
linksEqual(this.$('a'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']);
};
_class4.prototype['@test The non-block form {{link-to}} helper moves into the named route'] = function (assert) {
assert.expect(3);
this.router.map(function () {
this.route('contact');
});
this.addTemplate('index', '\n
\n {{link-to \'Home\' \'index\' id=\'home-link\'}}\n {{link-to \'Self\' \'contact\' id=\'self-link\'}}\n ');
this.visit('/');
this.click('#contact-link');
assert.equal(this.$('h3:contains(Contact)').length, 1, 'The contact template was rendered');
assert.equal(this.$('#self-link.active').length, 1, 'The self-link was rendered with active class');
assert.equal(this.$('#home-link:not(.active)').length, 1, 'The other link was rendered without active class');
};
_class4.prototype['@test The non-block form {{link-to}} helper updates the link text when it is a binding'] = function (assert) {
assert.expect(8);
this.router.map(function () {
this.route('contact');
});
this.add('controller:index', _emberRuntime.Controller.extend({
contactName: 'Jane'
}));
this.addTemplate('index', '\n
\n {{link-to \'Home\' \'index\' id=\'home-link\'}}\n {{link-to \'Self\' \'contact\' id=\'self-link\'}}\n ');
this.visit('/');
assert.equal(this.$('#contact-link:contains(Jane)').length, 1, 'The link title is correctly resolved');
var controller = this.applicationInstance.lookup('controller:index');
this.runTask(function () {
return controller.set('contactName', 'Joe');
});
assert.equal(this.$('#contact-link:contains(Joe)').length, 1, 'The link title is correctly updated when the bound property changes');
this.runTask(function () {
return controller.set('contactName', 'Robert');
});
assert.equal(this.$('#contact-link:contains(Robert)').length, 1, 'The link title is correctly updated when the bound property changes a second time');
this.click('#contact-link');
assert.equal(this.$('h3:contains(Contact)').length, 1, 'The contact template was rendered');
assert.equal(this.$('#self-link.active').length, 1, 'The self-link was rendered with active class');
assert.equal(this.$('#home-link:not(.active)').length, 1, 'The other link was rendered without active class');
this.click('#home-link');
assert.equal(this.$('h3:contains(Home)').length, 1, 'The index template was rendered');
assert.equal(this.$('#contact-link:contains(Robert)').length, 1, 'The link title is correctly updated when the route changes');
};
_class4.prototype['@test The non-block form {{link-to}} helper moves into the named route with context'] = function (assert) {
assert.expect(5);
this.router.map(function () {
this.route('item', { path: '/item/:id' });
});
this.add('route:index', _emberRouting.Route.extend({
model: function () {
return [{ id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, { id: 'erik', name: 'Erik Brynroflsson' }];
}
}));
this.addTemplate('index', '\n
Home
\n
\n {{#each model as |person|}}\n
\n {{link-to person.name \'item\' person}}\n
\n {{/each}}\n
\n ');
this.addTemplate('item', '\n
Item
\n
{{model.name}}
\n {{#link-to \'index\' id=\'home-link\'}}Home{{/link-to}}\n ');
this.visit('/');
this.click('li a:contains(Yehuda)');
assert.equal(this.$('h3:contains(Item)').length, 1, 'The item template was rendered');
assert.equal(this.$('p').text(), 'Yehuda Katz', 'The name is correct');
this.click('#home-link');
assert.equal(normalizeUrl(this.$('li a:contains(Yehuda)').attr('href')), '/item/yehuda');
assert.equal(normalizeUrl(this.$('li a:contains(Tom)').attr('href')), '/item/tom');
assert.equal(normalizeUrl(this.$('li a:contains(Erik)').attr('href')), '/item/erik');
};
_class4.prototype['@test The non-block form {{link-to}} performs property lookup'] = function (assert) {
var _this7 = this;
this.router.map(function () {
this.route('about');
});
this.addTemplate('index', '\n {{link-to \'string\' \'index\' id=\'string-link\'}}\n {{link-to path foo id=\'path-link\'}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
foo: 'index'
}));
this.visit('/');
var assertEquality = function (href) {
assert.equal(normalizeUrl(_this7.$('#string-link').attr('href')), '/');
assert.equal(normalizeUrl(_this7.$('#path-link').attr('href')), href);
};
assertEquality('/');
var controller = this.applicationInstance.lookup('controller:index');
this.runTask(function () {
return controller.set('foo', 'about');
});
assertEquality('/about');
};
_class4.prototype['@test The non-block form {{link-to}} protects against XSS'] = function (assert) {
this.addTemplate('application', '{{link-to display \'index\' id=\'link\'}}');
this.add('controller:application', _emberRuntime.Controller.extend({
display: 'blahzorz'
}));
this.visit('/');
assert.equal(this.$('#link').text(), 'blahzorz');
var controller = this.applicationInstance.lookup('controller:application');
this.runTask(function () {
return controller.set('display', 'BLAMMO');
});
assert.equal(this.$('#link').text(), 'BLAMMO');
assert.equal(this.$('b').length, 0);
};
_class4.prototype['@test the {{link-to}} helper does not throw an error if its route has exited'] = function (assert) {
assert.expect(0);
this.router.map(function () {
this.route('post', { path: 'post/:post_id' });
});
this.addTemplate('application', '\n {{#link-to \'index\' id=\'home-link\'}}Home{{/link-to}}\n {{#link-to \'post\' defaultPost id=\'default-post-link\'}}Default Post{{/link-to}}\n {{#if currentPost}}\n {{#link-to \'post\' currentPost id=\'current-post-link\'}}Current Post{{/link-to}}\n {{/if}}\n ');
this.add('controller:application', _emberRuntime.Controller.extend({
defaultPost: { id: 1 },
postController: _emberRuntime.inject.controller('post'),
currentPost: (0, _emberMetal.alias)('postController.model')
}));
this.add('controller:post', _emberRuntime.Controller.extend());
this.add('route:post', _emberRouting.Route.extend({
model: function () {
return { id: 2 };
},
serialize: function (model) {
return { post_id: model.id };
}
}));
this.visit('/');
this.click('#default-post-link');
this.click('#home-link');
this.click('#current-post-link');
this.click('#home-link');
};
_class4.prototype['@test {{link-to}} active property respects changing parent route context'] = function (assert) {
this.router.map(function () {
this.route('things', { path: '/things/:name' }, function () {
this.route('other');
});
});
this.addTemplate('application', '\n {{link-to \'OMG\' \'things\' \'omg\' id=\'omg-link\'}}\n {{link-to \'LOL\' \'things\' \'lol\' id=\'lol-link\'}}\n ');
this.visit('/things/omg');
shouldBeActive(assert, this.$('#omg-link'));
shouldNotBeActive(assert, this.$('#lol-link'));
this.visit('/things/omg/other');
shouldBeActive(assert, this.$('#omg-link'));
shouldNotBeActive(assert, this.$('#lol-link'));
};
_class4.prototype['@test {{link-to}} populates href with default query param values even without query-params object'] = function (assert) {
this.add('controller:index', _emberRuntime.Controller.extend({
queryParams: ['foo'],
foo: '123'
}));
this.addTemplate('index', '{{#link-to \'index\' id=\'the-link\'}}Index{{/link-to}}');
this.visit('/');
assert.equal(this.$('#the-link').attr('href'), '/', 'link has right href');
};
_class4.prototype['@test {{link-to}} populates href with default query param values with empty query-params object'] = function (assert) {
this.add('controller:index', _emberRuntime.Controller.extend({
queryParams: ['foo'],
foo: '123'
}));
this.addTemplate('index', '\n {{#link-to \'index\' (query-params) id=\'the-link\'}}Index{{/link-to}}\n ');
this.visit('/');
assert.equal(this.$('#the-link').attr('href'), '/', 'link has right href');
};
_class4.prototype['@test {{link-to}} with only query-params and a block updates when route changes'] = function (assert) {
this.router.map(function () {
this.route('about');
});
this.add('controller:application', _emberRuntime.Controller.extend({
queryParams: ['foo', 'bar'],
foo: '123',
bar: 'yes'
}));
this.addTemplate('application', '\n {{#link-to (query-params foo=\'456\' bar=\'NAW\') id=\'the-link\'}}Index{{/link-to}}\n ');
this.visit('/');
assert.equal(this.$('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href');
this.visit('/about');
assert.equal(this.$('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href');
};
_class4.prototype['@test Block-less {{link-to}} with only query-params updates when route changes'] = function (assert) {
this.router.map(function () {
this.route('about');
});
this.add('controller:application', _emberRuntime.Controller.extend({
queryParams: ['foo', 'bar'],
foo: '123',
bar: 'yes'
}));
this.addTemplate('application', '\n {{link-to "Index" (query-params foo=\'456\' bar=\'NAW\') id=\'the-link\'}}\n ');
this.visit('/');
assert.equal(this.$('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href');
this.visit('/about');
assert.equal(this.$('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href');
};
_class4.prototype['@test The {{link-to}} helper can use dynamic params'] = function (assert) {
this.router.map(function () {
this.route('foo', { path: 'foo/:some/:thing' });
this.route('bar', { path: 'bar/:some/:thing/:else' });
});
this.add('controller:index', _emberRuntime.Controller.extend({
init: function () {
this._super.apply(this, arguments);
this.dynamicLinkParams = ['foo', 'one', 'two'];
}
}));
this.addTemplate('index', '\n
Home
\n {{#link-to params=dynamicLinkParams id="dynamic-link"}}Dynamic{{/link-to}}\n ');
this.visit('/');
var link = this.$('#dynamic-link');
assert.equal(link.attr('href'), '/foo/one/two');
var controller = this.applicationInstance.lookup('controller:index');
this.runTask(function () {
controller.set('dynamicLinkParams', ['bar', 'one', 'two', 'three']);
});
assert.equal(link.attr('href'), '/bar/one/two/three');
};
_class4.prototype['@test GJ: {{link-to}} to a parent root model hook which performs a \'transitionTo\' has correct active class #13256'] = function (assert) {
assert.expect(1);
this.router.map(function () {
this.route('parent', function () {
this.route('child');
});
});
this.add('route:parent', _emberRouting.Route.extend({
afterModel: function (transition) {
this.transitionTo('parent.child');
}
}));
this.addTemplate('application', '\n {{link-to \'Parent\' \'parent\' id=\'parent-link\'}}\n ');
this.visit('/');
this.click('#parent-link');
shouldBeActive(assert, this.$('#parent-link'));
};
return _class4;
}(_internalTestHelpers.ApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('The {{link-to}} helper - loading states and warnings', function (_ApplicationTestCase6) {
(0, _emberBabel.inherits)(_class5, _ApplicationTestCase6);
function _class5() {
(0, _emberBabel.classCallCheck)(this, _class5);
var _this8 = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase6.call(this));
_this8._oldWarn = _emberConsole.default.warn;
_this8.warnCalled = false;
_emberConsole.default.warn = function () {
return _this8.warnCalled = true;
};
return _this8;
}
_class5.prototype.teardown = function teardown() {
_emberConsole.default.warn = this._oldWarn;
_ApplicationTestCase6.prototype.teardown.call(this);
};
_class5.prototype['@test link-to with null/undefined dynamic parameters are put in a loading state'] = function (assert) {
assert.expect(19);
this.router.map(function () {
this.route('thing', { path: '/thing/:thing_id' });
this.route('about');
});
this.addTemplate('index', '\n {{#link-to destinationRoute routeContext loadingClass=\'i-am-loading\' id=\'context-link\'}}\n string\n {{/link-to}}\n {{#link-to secondRoute loadingClass=loadingClass id=\'static-link\'}}\n string\n {{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
destinationRoute: null,
routeContext: null,
loadingClass: 'i-am-loading'
}));
this.add('route:about', _emberRouting.Route.extend({
activate: function () {
assert.ok(true, 'About was entered');
}
}));
this.visit('/');
function assertLinkStatus(link, url) {
if (url) {
assert.equal(normalizeUrl(link.attr('href')), url, 'loaded link-to has expected href');
assert.ok(!link.hasClass('i-am-loading'), 'loaded linkComponent has no loadingClass');
} else {
assert.equal(normalizeUrl(link.attr('href')), '#', "unloaded link-to has href='#'");
assert.ok(link.hasClass('i-am-loading'), 'loading linkComponent has loadingClass');
}
}
var contextLink = this.$('#context-link');
var staticLink = this.$('#static-link');
var controller = this.applicationInstance.lookup('controller:index');
assertLinkStatus(contextLink);
assertLinkStatus(staticLink);
this.warnCalled = false;
this.click(contextLink);
assert.ok(this.warnCalled, 'Logger.warn was called from clicking loading link');
// Set the destinationRoute (context is still null).
this.runTask(function () {
return controller.set('destinationRoute', 'thing');
});
assertLinkStatus(contextLink);
// Set the routeContext to an id
this.runTask(function () {
return controller.set('routeContext', '456');
});
assertLinkStatus(contextLink, '/thing/456');
// Test that 0 isn't interpreted as falsy.
this.runTask(function () {
return controller.set('routeContext', 0);
});
assertLinkStatus(contextLink, '/thing/0');
// Set the routeContext to an object
this.runTask(function () {
controller.set('routeContext', { id: 123 });
});
assertLinkStatus(contextLink, '/thing/123');
// Set the destinationRoute back to null.
this.runTask(function () {
return controller.set('destinationRoute', null);
});
assertLinkStatus(contextLink);
this.warnCalled = false;
this.click(staticLink);
assert.ok(this.warnCalled, 'Logger.warn was called from clicking loading link');
this.runTask(function () {
return controller.set('secondRoute', 'about');
});
assertLinkStatus(staticLink, '/about');
// Click the now-active link
this.click(staticLink);
};
return _class5;
}(_internalTestHelpers.ApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('The {{link-to}} helper - globals mode app', function (_AutobootApplicationT) {
(0, _emberBabel.inherits)(_class6, _AutobootApplicationT);
function _class6() {
(0, _emberBabel.classCallCheck)(this, _class6);
return (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT.apply(this, arguments));
}
_class6.prototype['@test the {{link-to}} helper throws a useful error if you invoke it wrong'] = function (assert) {
var _this10 = this;
assert.expect(1);
assert.throws(function () {
_this10.runTask(function () {
_this10.createApplication();
_this10.add('router:main', _emberRouting.Router.extend({
location: 'none'
}));
_this10.router.map(function () {
this.route('post', { path: 'post/:post_id' });
});
_this10.addTemplate('application', '{{#link-to \'post\'}}Post{{/link-to}}');
});
}, /(You attempted to define a `\{\{link-to "post"\}\}` but did not pass the parameters required for generating its dynamic segments.|You must provide param `post_id` to `generate`)/);
};
return _class6;
}(_internalTestHelpers.AutobootApplicationTestCase));
});
QUnit.module('ESLint | ember/tests/helpers/link_to_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/helpers/link_to_test.js should pass ESLint\n\n');
});
enifed('ember/tests/helpers/link_to_test/link_to_transitioning_classes_test', ['ember-babel', 'ember-runtime', 'ember-routing', 'internal-test-helpers'], function (_emberBabel, _emberRuntime, _emberRouting, _internalTestHelpers) {
'use strict';
function assertHasClass(assert, selector, label) {
var testLabel = selector.attr('id') + ' should have class ' + label;
assert.equal(selector.hasClass(label), true, testLabel);
}
function assertHasNoClass(assert, selector, label) {
var testLabel = selector.attr('id') + ' should not have class ' + label;
assert.equal(selector.hasClass(label), false, testLabel);
}
(0, _internalTestHelpers.moduleFor)('The {{link-to}} helper: .transitioning-in .transitioning-out CSS classes', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this2 = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.call(this));
_this2.aboutDefer = _emberRuntime.RSVP.defer();
_this2.otherDefer = _emberRuntime.RSVP.defer();
_this2.newsDefer = _emberRuntime.RSVP.defer();
var _this = _this2;
_this2.router.map(function () {
this.route('about');
this.route('other');
this.route('news');
});
_this2.add('route:about', _emberRouting.Route.extend({
model: function () {
return _this.aboutDefer.promise;
}
}));
_this2.add('route:other', _emberRouting.Route.extend({
model: function () {
return _this.otherDefer.promise;
}
}));
_this2.add('route:news', _emberRouting.Route.extend({
model: function () {
return _this.newsDefer.promise;
}
}));
_this2.addTemplate('application', '\n {{outlet}}\n {{link-to \'Index\' \'index\' id=\'index-link\'}}\n {{link-to \'About\' \'about\' id=\'about-link\'}}\n {{link-to \'Other\' \'other\' id=\'other-link\'}}\n {{link-to \'News\' \'news\' activeClass=false id=\'news-link\'}}\n ');
_this2.visit('/');
return _this2;
}
_class.prototype.teardown = function teardown() {
_ApplicationTestCase.prototype.teardown.call(this);
this.aboutDefer = null;
this.otherDefer = null;
this.newsDefer = null;
};
_class.prototype['@test while a transition is underway'] = function testWhileATransitionIsUnderway(assert) {
var _this3 = this;
var $index = this.$('#index-link');
var $about = this.$('#about-link');
var $other = this.$('#other-link');
$about.click();
assertHasClass(assert, $index, 'active');
assertHasNoClass(assert, $about, 'active');
assertHasNoClass(assert, $other, 'active');
assertHasNoClass(assert, $index, 'ember-transitioning-in');
assertHasClass(assert, $about, 'ember-transitioning-in');
assertHasNoClass(assert, $other, 'ember-transitioning-in');
assertHasClass(assert, $index, 'ember-transitioning-out');
assertHasNoClass(assert, $about, 'ember-transitioning-out');
assertHasNoClass(assert, $other, 'ember-transitioning-out');
this.runTask(function () {
return _this3.aboutDefer.resolve();
});
assertHasNoClass(assert, $index, 'active');
assertHasClass(assert, $about, 'active');
assertHasNoClass(assert, $other, 'active');
assertHasNoClass(assert, $index, 'ember-transitioning-in');
assertHasNoClass(assert, $about, 'ember-transitioning-in');
assertHasNoClass(assert, $other, 'ember-transitioning-in');
assertHasNoClass(assert, $index, 'ember-transitioning-out');
assertHasNoClass(assert, $about, 'ember-transitioning-out');
assertHasNoClass(assert, $other, 'ember-transitioning-out');
};
_class.prototype['@test while a transition is underway with activeClass is false'] = function testWhileATransitionIsUnderwayWithActiveClassIsFalse(assert) {
var _this4 = this;
var $index = this.$('#index-link');
var $news = this.$('#news-link');
var $other = this.$('#other-link');
$news.click();
assertHasClass(assert, $index, 'active');
assertHasNoClass(assert, $news, 'active');
assertHasNoClass(assert, $other, 'active');
assertHasNoClass(assert, $index, 'ember-transitioning-in');
assertHasClass(assert, $news, 'ember-transitioning-in');
assertHasNoClass(assert, $other, 'ember-transitioning-in');
assertHasClass(assert, $index, 'ember-transitioning-out');
assertHasNoClass(assert, $news, 'ember-transitioning-out');
assertHasNoClass(assert, $other, 'ember-transitioning-out');
this.runTask(function () {
return _this4.newsDefer.resolve();
});
assertHasNoClass(assert, $index, 'active');
assertHasNoClass(assert, $news, 'active');
assertHasNoClass(assert, $other, 'active');
assertHasNoClass(assert, $index, 'ember-transitioning-in');
assertHasNoClass(assert, $news, 'ember-transitioning-in');
assertHasNoClass(assert, $other, 'ember-transitioning-in');
assertHasNoClass(assert, $index, 'ember-transitioning-out');
assertHasNoClass(assert, $news, 'ember-transitioning-out');
assertHasNoClass(assert, $other, 'ember-transitioning-out');
};
return _class;
}(_internalTestHelpers.ApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('The {{link-to}} helper: .transitioning-in .transitioning-out CSS classes - nested link-to\'s', function (_ApplicationTestCase2) {
(0, _emberBabel.inherits)(_class2, _ApplicationTestCase2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
var _this5 = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase2.call(this));
_this5.aboutDefer = _emberRuntime.RSVP.defer();
_this5.otherDefer = _emberRuntime.RSVP.defer();
var _this = _this5;
_this5.router.map(function () {
this.route('parent-route', function () {
this.route('about');
this.route('other');
});
});
_this5.add('route:parent-route.about', _emberRouting.Route.extend({
model: function () {
return _this.aboutDefer.promise;
}
}));
_this5.add('route:parent-route.other', _emberRouting.Route.extend({
model: function () {
return _this.otherDefer.promise;
}
}));
_this5.addTemplate('application', '\n {{outlet}}\n {{#link-to \'index\' tagName=\'li\'}}\n {{link-to \'Index\' \'index\' id=\'index-link\'}}\n {{/link-to}}\n {{#link-to \'parent-route.about\' tagName=\'li\'}}\n {{link-to \'About\' \'parent-route.about\' id=\'about-link\'}}\n {{/link-to}}\n {{#link-to \'parent-route.other\' tagName=\'li\'}}\n {{link-to \'Other\' \'parent-route.other\' id=\'other-link\'}}\n {{/link-to}}\n ');
_this5.visit('/');
return _this5;
}
_class2.prototype.resolveAbout = function resolveAbout() {
var _this6 = this;
return this.runTask(function () {
_this6.aboutDefer.resolve();
_this6.aboutDefer = _emberRuntime.RSVP.defer();
});
};
_class2.prototype.resolveOther = function resolveOther() {
var _this7 = this;
return this.runTask(function () {
_this7.otherDefer.resolve();
_this7.otherDefer = _emberRuntime.RSVP.defer();
});
};
_class2.prototype.teardown = function teardown() {
_ApplicationTestCase2.prototype.teardown.call(this);
this.aboutDefer = null;
this.otherDefer = null;
};
_class2.prototype['@test while a transition is underway with nested link-to\'s'] = function (assert) {
var $index = this.$('#index-link');
var $about = this.$('#about-link');
var $other = this.$('#other-link');
$about.click();
assertHasClass(assert, $index, 'active');
assertHasNoClass(assert, $about, 'active');
assertHasNoClass(assert, $about, 'active');
assertHasNoClass(assert, $index, 'ember-transitioning-in');
assertHasClass(assert, $about, 'ember-transitioning-in');
assertHasNoClass(assert, $other, 'ember-transitioning-in');
assertHasClass(assert, $index, 'ember-transitioning-out');
assertHasNoClass(assert, $about, 'ember-transitioning-out');
assertHasNoClass(assert, $other, 'ember-transitioning-out');
this.resolveAbout();
assertHasNoClass(assert, $index, 'active');
assertHasClass(assert, $about, 'active');
assertHasNoClass(assert, $other, 'active');
assertHasNoClass(assert, $index, 'ember-transitioning-in');
assertHasNoClass(assert, $about, 'ember-transitioning-in');
assertHasNoClass(assert, $other, 'ember-transitioning-in');
assertHasNoClass(assert, $index, 'ember-transitioning-out');
assertHasNoClass(assert, $about, 'ember-transitioning-out');
assertHasNoClass(assert, $other, 'ember-transitioning-out');
$other.click();
assertHasNoClass(assert, $index, 'active');
assertHasClass(assert, $about, 'active');
assertHasNoClass(assert, $other, 'active');
assertHasNoClass(assert, $index, 'ember-transitioning-in');
assertHasNoClass(assert, $about, 'ember-transitioning-in');
assertHasClass(assert, $other, 'ember-transitioning-in');
assertHasNoClass(assert, $index, 'ember-transitioning-out');
assertHasClass(assert, $about, 'ember-transitioning-out');
assertHasNoClass(assert, $other, 'ember-transitioning-out');
this.resolveOther();
assertHasNoClass(assert, $index, 'active');
assertHasNoClass(assert, $about, 'active');
assertHasClass(assert, $other, 'active');
assertHasNoClass(assert, $index, 'ember-transitioning-in');
assertHasNoClass(assert, $about, 'ember-transitioning-in');
assertHasNoClass(assert, $other, 'ember-transitioning-in');
assertHasNoClass(assert, $index, 'ember-transitioning-out');
assertHasNoClass(assert, $about, 'ember-transitioning-out');
assertHasNoClass(assert, $other, 'ember-transitioning-out');
$about.click();
assertHasNoClass(assert, $index, 'active');
assertHasNoClass(assert, $about, 'active');
assertHasClass(assert, $other, 'active');
assertHasNoClass(assert, $index, 'ember-transitioning-in');
assertHasClass(assert, $about, 'ember-transitioning-in');
assertHasNoClass(assert, $other, 'ember-transitioning-in');
assertHasNoClass(assert, $index, 'ember-transitioning-out');
assertHasNoClass(assert, $about, 'ember-transitioning-out');
assertHasClass(assert, $other, 'ember-transitioning-out');
this.resolveAbout();
assertHasNoClass(assert, $index, 'active');
assertHasClass(assert, $about, 'active');
assertHasNoClass(assert, $other, 'active');
assertHasNoClass(assert, $index, 'ember-transitioning-in');
assertHasNoClass(assert, $about, 'ember-transitioning-in');
assertHasNoClass(assert, $other, 'ember-transitioning-in');
assertHasNoClass(assert, $index, 'ember-transitioning-out');
assertHasNoClass(assert, $about, 'ember-transitioning-out');
assertHasNoClass(assert, $other, 'ember-transitioning-out');
};
return _class2;
}(_internalTestHelpers.ApplicationTestCase));
});
QUnit.module('ESLint | ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/helpers/link_to_test/link_to_transitioning_classes_test.js should pass ESLint\n\n');
});
enifed('ember/tests/helpers/link_to_test/link_to_with_query_params_test', ['ember-babel', 'ember-runtime', 'ember-routing', 'internal-test-helpers'], function (_emberBabel, _emberRuntime, _emberRouting, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('The {{link-to}} helper: invoking with query params', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.call(this));
var indexProperties = {
foo: '123',
bar: 'abc'
};
_this.add('controller:index', _emberRuntime.Controller.extend({
queryParams: ['foo', 'bar', 'abool'],
foo: indexProperties.foo,
bar: indexProperties.bar,
boundThing: 'OMG',
abool: true
}));
_this.add('controller:about', _emberRuntime.Controller.extend({
queryParams: ['baz', 'bat'],
baz: 'alex',
bat: 'borf'
}));
_this.indexProperties = indexProperties;
return _this;
}
_class.prototype.shouldNotBeActive = function shouldNotBeActive(assert, selector) {
this.checkActive(assert, selector, false);
};
_class.prototype.shouldBeActive = function shouldBeActive(assert, selector) {
this.checkActive(assert, selector, true);
};
_class.prototype.getController = function getController(name) {
return this.applicationInstance.lookup('controller:' + name);
};
_class.prototype.checkActive = function checkActive(assert, selector, active) {
var classList = this.$(selector)[0].className;
assert.equal(classList.indexOf('active') > -1, active, selector + ' active should be ' + active.toString());
};
_class.prototype['@test doesn\'t update controller QP properties on current route when invoked'] = function (assert) {
var _this2 = this;
this.addTemplate('index', '\n {{#link-to \'index\' id=\'the-link\'}}Index{{/link-to}}\n ');
return this.visit('/').then(function () {
_this2.click('#the-link');
var indexController = _this2.getController('index');
assert.deepEqual(indexController.getProperties('foo', 'bar'), _this2.indexProperties, 'controller QP properties do not update');
});
};
_class.prototype['@test doesn\'t update controller QP properties on current route when invoked (empty query-params obj)'] = function (assert) {
var _this3 = this;
this.addTemplate('index', '\n {{#link-to \'index\' (query-params) id=\'the-link\'}}Index{{/link-to}}\n ');
return this.visit('/').then(function () {
_this3.click('#the-link');
var indexController = _this3.getController('index');
assert.deepEqual(indexController.getProperties('foo', 'bar'), _this3.indexProperties, 'controller QP properties do not update');
});
};
_class.prototype['@test doesn\'t update controller QP properties on current route when invoked (empty query-params obj, inferred route)'] = function (assert) {
var _this4 = this;
this.addTemplate('index', '\n {{#link-to (query-params) id=\'the-link\'}}Index{{/link-to}}\n ');
return this.visit('/').then(function () {
_this4.click('#the-link');
var indexController = _this4.getController('index');
assert.deepEqual(indexController.getProperties('foo', 'bar'), _this4.indexProperties, 'controller QP properties do not update');
});
};
_class.prototype['@test updates controller QP properties on current route when invoked'] = function testUpdatesControllerQPPropertiesOnCurrentRouteWhenInvoked(assert) {
var _this5 = this;
this.addTemplate('index', '\n {{#link-to \'index\' (query-params foo=\'456\') id="the-link"}}\n Index\n {{/link-to}}\n ');
return this.visit('/').then(function () {
_this5.click('#the-link');
var indexController = _this5.getController('index');
assert.deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated');
});
};
_class.prototype['@test updates controller QP properties on current route when invoked (inferred route)'] = function testUpdatesControllerQPPropertiesOnCurrentRouteWhenInvokedInferredRoute(assert) {
var _this6 = this;
this.addTemplate('index', '\n {{#link-to (query-params foo=\'456\') id="the-link"}}\n Index\n {{/link-to}}\n ');
return this.visit('/').then(function () {
_this6.click('#the-link');
var indexController = _this6.getController('index');
assert.deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated');
});
};
_class.prototype['@test updates controller QP properties on other route after transitioning to that route'] = function testUpdatesControllerQPPropertiesOnOtherRouteAfterTransitioningToThatRoute(assert) {
var _this7 = this;
this.router.map(function () {
this.route('about');
});
this.addTemplate('index', '\n {{#link-to \'about\' (query-params baz=\'lol\') id=\'the-link\'}}\n About\n {{/link-to}}\n ');
return this.visit('/').then(function () {
var theLink = _this7.$('#the-link');
assert.equal(theLink.attr('href'), '/about?baz=lol');
_this7.runTask(function () {
return _this7.click('#the-link');
});
var aboutController = _this7.getController('about');
assert.deepEqual(aboutController.getProperties('baz', 'bat'), { baz: 'lol', bat: 'borf' }, 'about controller QP properties updated');
});
};
_class.prototype['@test supplied QP properties can be bound'] = function testSuppliedQPPropertiesCanBeBound(assert) {
var _this8 = this;
this.addTemplate('index', '\n {{#link-to (query-params foo=boundThing) id=\'the-link\'}}Index{{/link-to}}\n ');
return this.visit('/').then(function () {
var indexController = _this8.getController('index');
var theLink = _this8.$('#the-link');
assert.equal(theLink.attr('href'), '/?foo=OMG');
_this8.runTask(function () {
return indexController.set('boundThing', 'ASL');
});
assert.equal(theLink.attr('href'), '/?foo=ASL');
});
};
_class.prototype['@test supplied QP properties can be bound (booleans)'] = function testSuppliedQPPropertiesCanBeBoundBooleans(assert) {
var _this9 = this;
this.addTemplate('index', '\n {{#link-to (query-params abool=boundThing) id=\'the-link\'}}\n Index\n {{/link-to}}\n ');
return this.visit('/').then(function () {
var indexController = _this9.getController('index');
var theLink = _this9.$('#the-link');
assert.equal(theLink.attr('href'), '/?abool=OMG');
_this9.runTask(function () {
return indexController.set('boundThing', false);
});
assert.equal(theLink.attr('href'), '/?abool=false');
_this9.click('#the-link');
assert.deepEqual(indexController.getProperties('foo', 'bar', 'abool'), { foo: '123', bar: 'abc', abool: false }, 'bound bool QP properties update');
});
};
_class.prototype['@test href updates when unsupplied controller QP props change'] = function testHrefUpdatesWhenUnsuppliedControllerQPPropsChange(assert) {
var _this10 = this;
this.addTemplate('index', '\n {{#link-to (query-params foo=\'lol\') id=\'the-link\'}}Index{{/link-to}}\n ');
return this.visit('/').then(function () {
var indexController = _this10.getController('index');
var theLink = _this10.$('#the-link');
assert.equal(theLink.attr('href'), '/?foo=lol');
_this10.runTask(function () {
return indexController.set('bar', 'BORF');
});
assert.equal(theLink.attr('href'), '/?bar=BORF&foo=lol');
_this10.runTask(function () {
return indexController.set('foo', 'YEAH');
});
assert.equal(theLink.attr('href'), '/?bar=BORF&foo=lol');
});
};
_class.prototype['@test The {{link-to}} with only query params always transitions to the current route with the query params applied'] = function testTheLinkToWithOnlyQueryParamsAlwaysTransitionsToTheCurrentRouteWithTheQueryParamsApplied(assert) {
var _this11 = this;
// Test harness for bug #12033
this.addTemplate('cars', '\n {{#link-to \'cars.create\' id=\'create-link\'}}Create new car{{/link-to}}\n {{#link-to (query-params page=\'2\') id=\'page2-link\'}}Page 2{{/link-to}}\n {{outlet}}\n ');
this.addTemplate('cars.create', '{{#link-to \'cars\' id=\'close-link\'}}Close create form{{/link-to}}');
this.router.map(function () {
this.route('cars', function () {
this.route('create');
});
});
this.add('controller:cars', _emberRuntime.Controller.extend({
queryParams: ['page'],
page: 1
}));
return this.visit('/cars/create').then(function () {
var router = _this11.appRouter;
var carsController = _this11.getController('cars');
assert.equal(router.currentRouteName, 'cars.create');
_this11.runTask(function () {
return _this11.click('#close-link');
});
assert.equal(router.currentRouteName, 'cars.index');
assert.equal(router.get('url'), '/cars');
assert.equal(carsController.get('page'), 1, 'The page query-param is 1');
_this11.runTask(function () {
return _this11.click('#page2-link');
});
assert.equal(router.currentRouteName, 'cars.index', 'The active route is still cars');
assert.equal(router.get('url'), '/cars?page=2', 'The url has been updated');
assert.equal(carsController.get('page'), 2, 'The query params have been updated');
});
};
_class.prototype['@test the {{link-to}} applies activeClass when query params are not changed'] = function testTheLinkToAppliesActiveClassWhenQueryParamsAreNotChanged(assert) {
var _this12 = this;
this.addTemplate('index', '\n {{#link-to (query-params foo=\'cat\') id=\'cat-link\'}}Index{{/link-to}}\n {{#link-to (query-params foo=\'dog\') id=\'dog-link\'}}Index{{/link-to}}\n {{#link-to \'index\' id=\'change-nothing\'}}Index{{/link-to}}\n ');
this.addTemplate('search', '\n {{#link-to (query-params search=\'same\') id=\'same-search\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'change\') id=\'change-search\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' archive=true) id=\'same-search-add-archive\'}}Index{{/link-to}}\n {{#link-to (query-params archive=true) id=\'only-add-archive\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' archive=true) id=\'both-same\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'different\' archive=true) id=\'change-one\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'different\' archive=false) id=\'remove-one\'}}Index{{/link-to}}\n {{outlet}}\n ');
this.addTemplate('search.results', '\n {{#link-to (query-params sort=\'title\') id=\'same-sort-child-only\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\') id=\'same-search-parent-only\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'change\') id=\'change-search-parent-only\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' sort=\'title\') id=\'same-search-same-sort-child-and-parent\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'same\' sort=\'author\') id=\'same-search-different-sort-child-and-parent\'}}Index{{/link-to}}\n {{#link-to (query-params search=\'change\' sort=\'title\') id=\'change-search-same-sort-child-and-parent\'}}Index{{/link-to}}\n {{#link-to (query-params foo=\'dog\') id=\'dog-link\'}}Index{{/link-to}}\n ');
this.router.map(function () {
this.route('search', function () {
this.route('results');
});
});
this.add('controller:search', _emberRuntime.Controller.extend({
queryParams: ['search', 'archive'],
search: '',
archive: false
}));
this.add('controller:search.results', _emberRuntime.Controller.extend({
queryParams: ['sort', 'showDetails'],
sort: 'title',
showDetails: true
}));
return this.visit('/').then(function () {
_this12.shouldNotBeActive(assert, '#cat-link');
_this12.shouldNotBeActive(assert, '#dog-link');
return _this12.visit('/?foo=cat');
}).then(function () {
_this12.shouldBeActive(assert, '#cat-link');
_this12.shouldNotBeActive(assert, '#dog-link');
return _this12.visit('/?foo=dog');
}).then(function () {
_this12.shouldBeActive(assert, '#dog-link');
_this12.shouldNotBeActive(assert, '#cat-link');
_this12.shouldBeActive(assert, '#change-nothing');
return _this12.visit('/search?search=same');
}).then(function () {
_this12.shouldBeActive(assert, '#same-search');
_this12.shouldNotBeActive(assert, '#change-search');
_this12.shouldNotBeActive(assert, '#same-search-add-archive');
_this12.shouldNotBeActive(assert, '#only-add-archive');
_this12.shouldNotBeActive(assert, '#remove-one');
return _this12.visit('/search?search=same&archive=true');
}).then(function () {
_this12.shouldBeActive(assert, '#both-same');
_this12.shouldNotBeActive(assert, '#change-one');
return _this12.visit('/search/results?search=same&sort=title&showDetails=true');
}).then(function () {
_this12.shouldBeActive(assert, '#same-sort-child-only');
_this12.shouldBeActive(assert, '#same-search-parent-only');
_this12.shouldNotBeActive(assert, '#change-search-parent-only');
_this12.shouldBeActive(assert, '#same-search-same-sort-child-and-parent');
_this12.shouldNotBeActive(assert, '#same-search-different-sort-child-and-parent');
_this12.shouldNotBeActive(assert, '#change-search-same-sort-child-and-parent');
});
};
_class.prototype['@test the {{link-to}} applies active class when query-param is a number'] = function testTheLinkToAppliesActiveClassWhenQueryParamIsANumber(assert) {
var _this13 = this;
this.addTemplate('index', '\n {{#link-to (query-params page=pageNumber) id=\'page-link\'}}\n Index\n {{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
queryParams: ['page'],
page: 1,
pageNumber: 5
}));
return this.visit('/').then(function () {
_this13.shouldNotBeActive(assert, '#page-link');
return _this13.visit('/?page=5');
}).then(function () {
_this13.shouldBeActive(assert, '#page-link');
});
};
_class.prototype['@test the {{link-to}} applies active class when query-param is an array'] = function testTheLinkToAppliesActiveClassWhenQueryParamIsAnArray(assert) {
var _this14 = this;
this.addTemplate('index', '\n {{#link-to (query-params pages=pagesArray) id=\'array-link\'}}Index{{/link-to}}\n {{#link-to (query-params pages=biggerArray) id=\'bigger-link\'}}Index{{/link-to}}\n {{#link-to (query-params pages=emptyArray) id=\'empty-link\'}}Index{{/link-to}}\n ');
this.add('controller:index', _emberRuntime.Controller.extend({
queryParams: ['pages'],
pages: [],
pagesArray: [1, 2],
biggerArray: [1, 2, 3],
emptyArray: []
}));
return this.visit('/').then(function () {
_this14.shouldNotBeActive(assert, '#array-link');
return _this14.visit('/?pages=%5B1%2C2%5D');
}).then(function () {
_this14.shouldBeActive(assert, '#array-link');
_this14.shouldNotBeActive(assert, '#bigger-link');
_this14.shouldNotBeActive(assert, '#empty-link');
return _this14.visit('/?pages=%5B2%2C1%5D');
}).then(function () {
_this14.shouldNotBeActive(assert, '#array-link');
_this14.shouldNotBeActive(assert, '#bigger-link');
_this14.shouldNotBeActive(assert, '#empty-link');
return _this14.visit('/?pages=%5B1%2C2%2C3%5D');
}).then(function () {
_this14.shouldBeActive(assert, '#bigger-link');
_this14.shouldNotBeActive(assert, '#array-link');
_this14.shouldNotBeActive(assert, '#empty-link');
});
};
_class.prototype['@test the {{link-to}} helper applies active class to the parent route'] = function testTheLinkToHelperAppliesActiveClassToTheParentRoute(assert) {
var _this15 = this;
this.router.map(function () {
this.route('parent', function () {
this.route('child');
});
});
this.addTemplate('application', '\n {{#link-to \'parent\' id=\'parent-link\'}}Parent{{/link-to}}\n {{#link-to \'parent.child\' id=\'parent-child-link\'}}Child{{/link-to}}\n {{#link-to \'parent\' (query-params foo=cat) id=\'parent-link-qp\'}}Parent{{/link-to}}\n {{outlet}}\n ');
this.add('controller:parent.child', _emberRuntime.Controller.extend({
queryParams: ['foo'],
foo: 'bar'
}));
return this.visit('/').then(function () {
_this15.shouldNotBeActive(assert, '#parent-link');
_this15.shouldNotBeActive(assert, '#parent-child-link');
_this15.shouldNotBeActive(assert, '#parent-link-qp');
return _this15.visit('/parent/child?foo=dog');
}).then(function () {
_this15.shouldBeActive(assert, '#parent-link');
_this15.shouldNotBeActive(assert, '#parent-link-qp');
});
};
_class.prototype['@test The {{link-to}} helper disregards query-params in activeness computation when current-when is specified'] = function testTheLinkToHelperDisregardsQueryParamsInActivenessComputationWhenCurrentWhenIsSpecified(assert) {
var _this16 = this;
var appLink = void 0;
this.router.map(function () {
this.route('parent');
});
this.addTemplate('application', '\n {{#link-to \'parent\' (query-params page=1) current-when=\'parent\' id=\'app-link\'}}\n Parent\n {{/link-to}}\n {{outlet}}\n ');
this.addTemplate('parent', '\n {{#link-to \'parent\' (query-params page=1) current-when=\'parent\' id=\'parent-link\'}}\n Parent\n {{/link-to}}\n {{outlet}}\n ');
this.add('controller:parent', _emberRuntime.Controller.extend({
queryParams: ['page'],
page: 1
}));
return this.visit('/').then(function () {
appLink = _this16.$('#app-link');
assert.equal(appLink.attr('href'), '/parent');
_this16.shouldNotBeActive(assert, '#app-link');
return _this16.visit('/parent?page=2');
}).then(function () {
appLink = _this16.$('#app-link');
var router = _this16.appRouter;
assert.equal(appLink.attr('href'), '/parent');
_this16.shouldBeActive(assert, '#app-link');
assert.equal(_this16.$('#parent-link').attr('href'), '/parent');
_this16.shouldBeActive(assert, '#parent-link');
var parentController = _this16.getController('parent');
assert.equal(parentController.get('page'), 2);
_this16.runTask(function () {
return parentController.set('page', 3);
});
assert.equal(router.get('location.path'), '/parent?page=3');
_this16.shouldBeActive(assert, '#app-link');
_this16.shouldBeActive(assert, '#parent-link');
_this16.runTask(function () {
return _this16.click('#app-link');
});
assert.equal(router.get('location.path'), '/parent');
});
};
_class.prototype['@test link-to default query params while in active transition regression test'] = function testLinkToDefaultQueryParamsWhileInActiveTransitionRegressionTest(assert) {
var _this17 = this;
this.router.map(function () {
this.route('foos');
this.route('bars');
});
var foos = _emberRuntime.RSVP.defer();
var bars = _emberRuntime.RSVP.defer();
this.addTemplate('application', '\n {{link-to \'Foos\' \'foos\' id=\'foos-link\'}}\n {{link-to \'Baz Foos\' \'foos\' (query-params baz=true) id=\'baz-foos-link\'}}\n {{link-to \'Quux Bars\' \'bars\' (query-params quux=true) id=\'bars-link\'}}\n ');
this.add('controller:foos', _emberRuntime.Controller.extend({
queryParams: ['status'],
baz: false
}));
this.add('route:foos', _emberRouting.Route.extend({
model: function () {
return foos.promise;
}
}));
this.add('controller:bars', _emberRuntime.Controller.extend({
queryParams: ['status'],
quux: false
}));
this.add('route:bars', _emberRouting.Route.extend({
model: function () {
return bars.promise;
}
}));
return this.visit('/').then(function () {
var router = _this17.appRouter;
var foosLink = _this17.$('#foos-link');
var barsLink = _this17.$('#bars-link');
var bazLink = _this17.$('#baz-foos-link');
assert.equal(foosLink.attr('href'), '/foos');
assert.equal(bazLink.attr('href'), '/foos?baz=true');
assert.equal(barsLink.attr('href'), '/bars?quux=true');
assert.equal(router.get('location.path'), '/');
_this17.shouldNotBeActive(assert, '#foos-link');
_this17.shouldNotBeActive(assert, '#baz-foos-link');
_this17.shouldNotBeActive(assert, '#bars-link');
_this17.runTask(function () {
return barsLink.click();
});
_this17.shouldNotBeActive(assert, '#bars-link');
_this17.runTask(function () {
return foosLink.click();
});
_this17.shouldNotBeActive(assert, '#foos-link');
_this17.runTask(function () {
return foos.resolve();
});
assert.equal(router.get('location.path'), '/foos');
_this17.shouldBeActive(assert, '#foos-link');
});
};
return _class;
}(_internalTestHelpers.ApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('The {{link-to}} helper + query params - globals mode app', function (_AutobootApplicationT) {
(0, _emberBabel.inherits)(_class2, _AutobootApplicationT);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT.apply(this, arguments));
}
_class2.prototype['@test the {{link-to}} helper throws a useful error if you invoke it wrong'] = function (assert) {
var _this19 = this;
assert.expect(1);
expectAssertion(function () {
_this19.runTask(function () {
_this19.createApplication();
_this19.add('router:main', _emberRouting.Router.extend({
location: 'none'
}));
_this19.addTemplate('application', '{{#link-to id=\'the-link\'}}Index{{/link-to}}');
});
}, /You must provide one or more parameters to the link-to component/);
};
return _class2;
}(_internalTestHelpers.AutobootApplicationTestCase));
});
QUnit.module('ESLint | ember/tests/helpers/link_to_test/link_to_with_query_params_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/helpers/link_to_test/link_to_with_query_params_test.js should pass ESLint\n\n');
});
enifed('ember/tests/homepage_example_test', ['ember-babel', 'ember-routing', 'ember-metal', 'ember-runtime', 'internal-test-helpers'], function (_emberBabel, _emberRouting, _emberMetal, _emberRuntime, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('The example renders correctly', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.apply(this, arguments));
}
_class.prototype['@test Render index template into application outlet'] = function testRenderIndexTemplateIntoApplicationOutlet(assert) {
var _this2 = this;
this.addTemplate('application', '{{outlet}}');
this.addTemplate('index', '
'));
originalLoggerError = _emberConsole.default.error;
});
},
teardown: function () {
(0, _emberMetal.run)(function () {
App.destroy();
App = null;
(0, _emberGlimmer.setTemplates)({});
_emberConsole.default.error = originalLoggerError;
});
}
});
QUnit.test('The route controller specified via controllerName is used in render', function () {
Router.map(function () {
this.route('home', { path: '/' });
});
(0, _emberGlimmer.setTemplate)('alternative_home', (0, _emberTemplateCompiler.compile)('
alternative home: {{myValue}}
'));
App.HomeRoute = _emberRouting.Route.extend({
controllerName: 'myController',
renderTemplate: function () {
this.render('alternative_home');
}
});
registry.register('controller:myController', _emberRuntime.Controller.extend({
myValue: 'foo'
}));
bootApplication();
deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), 'route controller is set by controllerName');
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), 'alternative home: foo', 'The homepage template was rendered with data from the custom controller');
});
QUnit.test('The route controller specified via controllerName is used in render even when a controller with the routeName is available', function () {
Router.map(function () {
this.route('home', { path: '/' });
});
(0, _emberGlimmer.setTemplate)('home', (0, _emberTemplateCompiler.compile)('
home: {{myValue}}
'));
App.HomeRoute = _emberRouting.Route.extend({
controllerName: 'myController'
});
registry.register('controller:home', _emberRuntime.Controller.extend({
myValue: 'home'
}));
registry.register('controller:myController', _emberRuntime.Controller.extend({
myValue: 'myController'
}));
bootApplication();
deepEqual(container.lookup('route:home').controller, container.lookup('controller:myController'), 'route controller is set by controllerName');
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), 'home: myController', 'The homepage template was rendered with data from the custom controller');
});
QUnit.test('The Homepage with a `setupController` hook modifying other controllers', function () {
Router.map(function () {
this.route('home', { path: '/' });
});
App.HomeRoute = _emberRouting.Route.extend({
setupController: function (controller) {
(0, _emberMetal.set)(this.controllerFor('home'), 'hours', (0, _emberRuntime.A)(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm']));
}
});
(0, _emberGlimmer.setTemplate)('home', (0, _emberTemplateCompiler.compile)('
{{#each hours as |entry|}}
{{entry}}
{{/each}}
'));
bootApplication();
equal((0, _emberViews.jQuery)('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the hours context');
});
QUnit.test('The Homepage with a computed context that does not get overridden', function () {
Router.map(function () {
this.route('home', { path: '/' });
});
App.HomeController = _emberRuntime.Controller.extend({
model: (0, _emberMetal.computed)(function () {
return (0, _emberRuntime.A)(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm']);
})
});
(0, _emberGlimmer.setTemplate)('home', (0, _emberTemplateCompiler.compile)('
{{#each model as |passage|}}
{{passage}}
{{/each}}
'));
bootApplication();
equal((0, _emberViews.jQuery)('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the context intact');
});
QUnit.test('The Homepage getting its controller context via model', function () {
Router.map(function () {
this.route('home', { path: '/' });
});
App.HomeRoute = _emberRouting.Route.extend({
model: function () {
return (0, _emberRuntime.A)(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm']);
},
setupController: function (controller, model) {
equal(this.controllerFor('home'), controller);
(0, _emberMetal.set)(this.controllerFor('home'), 'hours', model);
}
});
(0, _emberGlimmer.setTemplate)('home', (0, _emberTemplateCompiler.compile)('
{{#each hours as |entry|}}
{{entry}}
{{/each}}
'));
bootApplication();
equal((0, _emberViews.jQuery)('ul li', '#qunit-fixture').eq(2).text(), 'Sunday: Noon to 6pm', 'The template was rendered with the hours context');
});
QUnit.test('The Specials Page getting its controller context by deserializing the params hash', function () {
Router.map(function () {
this.route('home', { path: '/' });
this.route('special', { path: '/specials/:menu_item_id' });
});
App.SpecialRoute = _emberRouting.Route.extend({
model: function (params) {
return _emberRuntime.Object.create({
menuItemId: params.menu_item_id
});
},
setupController: function (controller, model) {
(0, _emberMetal.set)(controller, 'model', model);
}
});
(0, _emberGlimmer.setTemplate)('special', (0, _emberTemplateCompiler.compile)('
{{model.menuItemId}}
'));
bootApplication();
registry.register('controller:special', _emberRuntime.Controller.extend());
handleURL('/specials/1');
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), '1', 'The model was used to render the template');
});
QUnit.test('The Specials Page defaults to looking models up via `find`', function () {
Router.map(function () {
this.route('home', { path: '/' });
this.route('special', { path: '/specials/:menu_item_id' });
});
App.MenuItem = _emberRuntime.Object.extend();
App.MenuItem.reopenClass({
find: function (id) {
return App.MenuItem.create({
id: id
});
}
});
App.SpecialRoute = _emberRouting.Route.extend({
setupController: function (controller, model) {
(0, _emberMetal.set)(controller, 'model', model);
}
});
(0, _emberGlimmer.setTemplate)('special', (0, _emberTemplateCompiler.compile)('
{{model.id}}
'));
bootApplication();
registry.register('controller:special', _emberRuntime.Controller.extend());
handleURL('/specials/1');
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), '1', 'The model was used to render the template');
});
QUnit.test('The Special Page returning a promise puts the app into a loading state until the promise is resolved', function () {
Router.map(function () {
this.route('home', { path: '/' });
this.route('special', { path: '/specials/:menu_item_id' });
});
var menuItem = void 0,
resolve = void 0;
App.MenuItem = _emberRuntime.Object.extend();
App.MenuItem.reopenClass({
find: function (id) {
menuItem = App.MenuItem.create({ id: id });
return new _emberRuntime.RSVP.Promise(function (res) {
resolve = res;
});
}
});
App.LoadingRoute = _emberRouting.Route.extend({});
App.SpecialRoute = _emberRouting.Route.extend({
setupController: function (controller, model) {
(0, _emberMetal.set)(controller, 'model', model);
}
});
(0, _emberGlimmer.setTemplate)('special', (0, _emberTemplateCompiler.compile)('
'));
bootApplication();
registry.register('controller:special', _emberRuntime.Controller.extend());
handleURL('/specials/1');
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), 'LOADING!', 'The app is in the loading state');
(0, _emberMetal.run)(function () {
return resolve(menuItem);
});
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), '1', 'The app is now in the specials state');
});
QUnit.test('The loading state doesn\'t get entered for promises that resolve on the same run loop', function () {
Router.map(function () {
this.route('home', { path: '/' });
this.route('special', { path: '/specials/:menu_item_id' });
});
App.MenuItem = _emberRuntime.Object.extend();
App.MenuItem.reopenClass({
find: function (id) {
return { id: id };
}
});
App.LoadingRoute = _emberRouting.Route.extend({
enter: function () {
ok(false, 'LoadingRoute shouldn\'t have been entered.');
}
});
App.SpecialRoute = _emberRouting.Route.extend({
setupController: function (controller, model) {
(0, _emberMetal.set)(controller, 'model', model);
}
});
(0, _emberGlimmer.setTemplate)('special', (0, _emberTemplateCompiler.compile)('
'));
Router.map(function () {
this.route('posts', function () {});
});
App.PostsRoute = _emberRouting.Route.extend({
renderTemplate: function () {
this.render();
this.render('posts/menu', {
into: 'application',
outlet: 'menu'
});
}
});
bootApplication();
handleURL('/posts');
equal((0, _emberViews.jQuery)('div.posts-menu:contains(postsMenu)', '#qunit-fixture').length, 1, 'The posts/menu template was rendered');
equal((0, _emberViews.jQuery)('p.posts-index:contains(postsIndex)', '#qunit-fixture').length, 1, 'The posts/index template was rendered');
});
QUnit.test('Generating a URL should not affect currentModel', function () {
Router.map(function () {
this.route('post', { path: '/posts/:post_id' });
});
var posts = {
1: { id: 1 },
2: { id: 2 }
};
App.PostRoute = _emberRouting.Route.extend({
model: function (params) {
return posts[params.post_id];
}
});
bootApplication();
handleURL('/posts/1');
var route = container.lookup('route:post');
equal(route.modelFor('post'), posts[1]);
var url = router.generate('post', posts[2]);
equal(url, '/posts/2');
equal(route.modelFor('post'), posts[1]);
});
QUnit.test('Generated route should be an instance of App.Route if provided', function () {
var generatedRoute = void 0;
Router.map(function () {
this.route('posts');
});
App.Route = _emberRouting.Route.extend();
bootApplication();
handleURL('/posts');
generatedRoute = container.lookup('route:posts');
ok(generatedRoute instanceof App.Route, 'should extend the correct route');
});
QUnit.test('Nested index route is not overridden by parent\'s implicit index route', function () {
Router.map(function () {
this.route('posts', function () {
this.route('index', { path: ':category' });
});
});
bootApplication();
(0, _emberMetal.run)(function () {
return router.transitionTo('posts', { category: 'emberjs' });
});
deepEqual(router.location.path, '/posts/emberjs');
});
QUnit.test('Application template does not duplicate when re-rendered', function () {
(0, _emberGlimmer.setTemplate)('application', (0, _emberTemplateCompiler.compile)('
I Render Once
{{outlet}}'));
Router.map(function () {
this.route('posts');
});
App.ApplicationRoute = _emberRouting.Route.extend({
model: function () {
return (0, _emberRuntime.A)();
}
});
bootApplication();
// should cause application template to re-render
handleURL('/posts');
equal((0, _emberViews.jQuery)('h3:contains(I Render Once)').length, 1);
});
QUnit.test('Child routes should render inside the application template if the application template causes a redirect', function () {
(0, _emberGlimmer.setTemplate)('application', (0, _emberTemplateCompiler.compile)('
App
{{outlet}}'));
(0, _emberGlimmer.setTemplate)('posts', (0, _emberTemplateCompiler.compile)('posts'));
Router.map(function () {
this.route('posts');
this.route('photos');
});
App.ApplicationRoute = _emberRouting.Route.extend({
afterModel: function () {
this.transitionTo('posts');
}
});
bootApplication();
equal((0, _emberViews.jQuery)('#qunit-fixture > div').text(), 'App posts');
});
QUnit.test('The template is not re-rendered when the route\'s context changes', function () {
Router.map(function () {
this.route('page', { path: '/page/:name' });
});
App.PageRoute = _emberRouting.Route.extend({
model: function (params) {
return _emberRuntime.Object.create({ name: params.name });
}
});
var insertionCount = 0;
App.FooBarComponent = _emberGlimmer.Component.extend({
didInsertElement: function () {
insertionCount += 1;
}
});
(0, _emberGlimmer.setTemplate)('page', (0, _emberTemplateCompiler.compile)('
{{model.name}}{{foo-bar}}
'));
bootApplication();
handleURL('/page/first');
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), 'first');
equal(insertionCount, 1);
handleURL('/page/second');
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), 'second');
equal(insertionCount, 1, 'view should have inserted only once');
(0, _emberMetal.run)(function () {
return router.transitionTo('page', _emberRuntime.Object.create({ name: 'third' }));
});
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), 'third');
equal(insertionCount, 1, 'view should still have inserted only once');
});
QUnit.test('The template is not re-rendered when two routes present the exact same template & controller', function () {
Router.map(function () {
this.route('first');
this.route('second');
this.route('third');
this.route('fourth');
});
// Note add a component to test insertion
var insertionCount = 0;
App.XInputComponent = _emberGlimmer.Component.extend({
didInsertElement: function () {
insertionCount += 1;
}
});
App.SharedRoute = _emberRouting.Route.extend({
setupController: function (controller) {
this.controllerFor('shared').set('message', 'This is the ' + this.routeName + ' message');
},
renderTemplate: function (controller, context) {
this.render('shared', { controller: 'shared' });
}
});
App.FirstRoute = App.SharedRoute.extend();
App.SecondRoute = App.SharedRoute.extend();
App.ThirdRoute = App.SharedRoute.extend();
App.FourthRoute = App.SharedRoute.extend();
App.SharedController = _emberRuntime.Controller.extend();
(0, _emberGlimmer.setTemplate)('shared', (0, _emberTemplateCompiler.compile)('
{{message}}{{x-input}}
'));
bootApplication();
handleURL('/first');
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), 'This is the first message');
equal(insertionCount, 1, 'expected one assertion');
// Transition by URL
handleURL('/second');
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), 'This is the second message');
equal(insertionCount, 1, 'expected one assertion');
// Then transition directly by route name
(0, _emberMetal.run)(function () {
router.transitionTo('third').then(function (value) {
ok(true, 'expected transition');
}, function (reason) {
ok(false, 'unexpected transition failure: ', QUnit.jsDump.parse(reason));
});
});
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), 'This is the third message');
equal(insertionCount, 1, 'expected one assertion');
// Lastly transition to a different view, with the same controller and template
handleURL('/fourth');
equal(insertionCount, 1, 'expected one assertion');
equal((0, _emberViews.jQuery)('p', '#qunit-fixture').text(), 'This is the fourth message');
});
QUnit.test('ApplicationRoute with model does not proxy the currentPath', function () {
var model = {};
var currentPath = void 0;
App.ApplicationRoute = _emberRouting.Route.extend({
model: function () {
return model;
}
});
App.ApplicationController = _emberRuntime.Controller.extend({
currentPathDidChange: (0, _emberMetal.observer)('currentPath', function () {
currentPath = (0, _emberMetal.get)(this, 'currentPath');
})
});
bootApplication();
equal(currentPath, 'index', 'currentPath is index');
equal('currentPath' in model, false, 'should have defined currentPath on controller');
});
QUnit.test('Promises encountered on app load put app into loading state until resolved', function () {
expect(2);
var deferred = _emberRuntime.RSVP.defer();
App.IndexRoute = _emberRouting.Route.extend({
model: function () {
return deferred.promise;
}
});
(0, _emberGlimmer.setTemplate)('index', (0, _emberTemplateCompiler.compile)('
'));
(0, _emberGlimmer.setTemplate)('other', (0, _emberTemplateCompiler.compile)('other'));
App.IndexRoute = _emberRouting.Route.extend({
renderTemplate: function () {
this.render({ into: 'sidebar' });
this.render('other', { into: 'index' });
},
actions: {
disconnect: function () {
this.disconnectOutlet({
parentView: 'index',
outlet: 'main'
});
}
}
});
bootApplication();
equal((0, _emberViews.jQuery)('#qunit-fixture .sidebar .index').text(), 'other');
(0, _emberMetal.run)(router, 'send', 'disconnect');
equal((0, _emberViews.jQuery)('#qunit-fixture .sidebar .index').text(), '');
});
QUnit.test('Can this.render({into:...}) nested render helpers', function () {
expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./);
expectDeprecation(function () {
(0, _emberGlimmer.setTemplate)('application', (0, _emberTemplateCompiler.compile)('{{render "sidebar"}}'));
}, /Please refactor [\w\{\}"` ]+ to a component/);
expectDeprecation(function () {
(0, _emberGlimmer.setTemplate)('sidebar', (0, _emberTemplateCompiler.compile)('
{{render "cart"}}
'));
}, /Please refactor [\w\{\}"` ]+ to a component/);
(0, _emberGlimmer.setTemplate)('cart', (0, _emberTemplateCompiler.compile)('
{{outlet}}
'));
(0, _emberGlimmer.setTemplate)('index', (0, _emberTemplateCompiler.compile)('other'));
(0, _emberGlimmer.setTemplate)('baz', (0, _emberTemplateCompiler.compile)('baz'));
App.IndexRoute = _emberRouting.Route.extend({
renderTemplate: function () {
this.render({ into: 'cart' });
},
actions: {
changeToBaz: function () {
this.disconnectOutlet({
parentView: 'cart',
outlet: 'main'
});
this.render('baz', { into: 'cart' });
}
}
});
bootApplication();
equal((0, _emberViews.jQuery)('#qunit-fixture .cart').text(), 'other');
(0, _emberMetal.run)(router, 'send', 'changeToBaz');
equal((0, _emberViews.jQuery)('#qunit-fixture .cart').text(), 'baz');
});
QUnit.test('Can disconnect from nested render helpers', function () {
expectDeprecation(/Rendering into a {{render}} helper that resolves to an {{outlet}} is deprecated./);
expectDeprecation(function () {
(0, _emberGlimmer.setTemplate)('application', (0, _emberTemplateCompiler.compile)('{{render "sidebar"}}'));
}, /Please refactor [\w\{\}"` ]+ to a component/);
expectDeprecation(function () {
(0, _emberGlimmer.setTemplate)('sidebar', (0, _emberTemplateCompiler.compile)('
{{render "cart"}}
'));
}, /Please refactor [\w\{\}"` ]+ to a component/);
(0, _emberGlimmer.setTemplate)('cart', (0, _emberTemplateCompiler.compile)('
{{outlet}}
'));
(0, _emberGlimmer.setTemplate)('index', (0, _emberTemplateCompiler.compile)('other'));
App.IndexRoute = _emberRouting.Route.extend({
renderTemplate: function () {
this.render({ into: 'cart' });
},
actions: {
disconnect: function () {
this.disconnectOutlet({
parentView: 'cart',
outlet: 'main'
});
}
}
});
bootApplication();
equal((0, _emberViews.jQuery)('#qunit-fixture .cart').text(), 'other');
(0, _emberMetal.run)(router, 'send', 'disconnect');
equal((0, _emberViews.jQuery)('#qunit-fixture .cart').text(), '');
});
QUnit.test('Components inside an outlet have their didInsertElement hook invoked when the route is displayed', function (assert) {
(0, _emberGlimmer.setTemplate)('index', (0, _emberTemplateCompiler.compile)('{{#if showFirst}}{{my-component}}{{else}}{{other-component}}{{/if}}'));
var myComponentCounter = 0;
var otherComponentCounter = 0;
var indexController = void 0;
App.IndexController = _emberRuntime.Controller.extend({
showFirst: true
});
App.IndexRoute = _emberRouting.Route.extend({
setupController: function (controller) {
indexController = controller;
}
});
App.MyComponentComponent = _emberGlimmer.Component.extend({
didInsertElement: function () {
myComponentCounter++;
}
});
App.OtherComponentComponent = _emberGlimmer.Component.extend({
didInsertElement: function () {
otherComponentCounter++;
}
});
bootApplication();
assert.strictEqual(myComponentCounter, 1, 'didInsertElement invoked on displayed component');
assert.strictEqual(otherComponentCounter, 0, 'didInsertElement not invoked on displayed component');
(0, _emberMetal.run)(function () {
return indexController.set('showFirst', false);
});
assert.strictEqual(myComponentCounter, 1, 'didInsertElement not invoked on displayed component');
assert.strictEqual(otherComponentCounter, 1, 'didInsertElement invoked on displayed component');
});
QUnit.test('Doesnt swallow exception thrown from willTransition', function () {
expect(1);
(0, _emberGlimmer.setTemplate)('application', (0, _emberTemplateCompiler.compile)('{{outlet}}'));
(0, _emberGlimmer.setTemplate)('index', (0, _emberTemplateCompiler.compile)('index'));
(0, _emberGlimmer.setTemplate)('other', (0, _emberTemplateCompiler.compile)('other'));
Router.map(function () {
this.route('other', function () {});
});
App.IndexRoute = _emberRouting.Route.extend({
actions: {
willTransition: function () {
throw new Error('boom');
}
}
});
bootApplication();
throws(function () {
(0, _emberMetal.run)(function () {
return router.handleURL('/other');
});
}, /boom/, 'expected an exception but none was thrown');
});
QUnit.test('Exception if outlet name is undefined in render and disconnectOutlet', function (assert) {
App.ApplicationRoute = _emberRouting.Route.extend({
actions: {
showModal: function () {
this.render({
outlet: undefined,
parentView: 'application'
});
},
hideModal: function () {
this.disconnectOutlet({
outlet: undefined,
parentView: 'application'
});
}
}
});
bootApplication();
expectAssertion(function () {
(0, _emberMetal.run)(function () {
return router.send('showModal');
});
}, /You passed undefined as the outlet name/);
expectAssertion(function () {
(0, _emberMetal.run)(function () {
return router.send('hideModal');
});
}, /You passed undefined as the outlet name/);
});
QUnit.test('Route serializers work for Engines', function () {
expect(2);
// Register engine
var BlogEngine = _emberApplication.Engine.extend();
registry.register('engine:blog', BlogEngine);
// Register engine route map
var postSerialize = function (params) {
ok(true, 'serialize hook runs');
return {
post_id: params.id
};
};
var BlogMap = function () {
this.route('post', { path: '/post/:post_id', serialize: postSerialize });
};
registry.register('route-map:blog', BlogMap);
Router.map(function () {
this.mount('blog');
});
bootApplication();
equal(router._routerMicrolib.generate('blog.post', { id: '13' }), '/blog/post/13', 'url is generated properly');
});
QUnit.test('Defining a Route#serialize method in an Engine throws an error', function () {
expect(1);
// Register engine
var BlogEngine = _emberApplication.Engine.extend();
registry.register('engine:blog', BlogEngine);
// Register engine route map
var BlogMap = function () {
this.route('post');
};
registry.register('route-map:blog', BlogMap);
Router.map(function () {
this.mount('blog');
});
bootApplication();
var PostRoute = _emberRouting.Route.extend({
serialize: function () {}
});
container.lookup('engine:blog').register('route:post', PostRoute);
throws(function () {
return router.transitionTo('blog.post');
}, /Defining a custom serialize method on an Engine route is not supported/);
});
QUnit.test('App.destroy does not leave undestroyed views after clearing engines', function () {
expect(4);
var engineInstance = void 0;
// Register engine
var BlogEngine = _emberApplication.Engine.extend();
registry.register('engine:blog', BlogEngine);
var EngineIndexRoute = _emberRouting.Route.extend({
init: function () {
this._super.apply(this, arguments);
engineInstance = (0, _emberUtils.getOwner)(this);
}
});
// Register engine route map
var BlogMap = function () {
this.route('post');
};
registry.register('route-map:blog', BlogMap);
Router.map(function () {
this.mount('blog');
});
bootApplication();
var engine = container.lookup('engine:blog');
engine.register('route:index', EngineIndexRoute);
engine.register('template:index', (0, _emberTemplateCompiler.compile)('Engine Post!'));
handleURL('/blog');
var route = engineInstance.lookup('route:index');
(0, _emberMetal.run)(router, 'destroy');
equal(router._toplevelView, null, 'the toplevelView was cleared');
(0, _emberMetal.run)(route, 'destroy');
equal(router._toplevelView, null, 'the toplevelView was not reinitialized');
(0, _emberMetal.run)(App, 'destroy');
equal(router._toplevelView, null, 'the toplevelView was not reinitialized');
});
});
QUnit.module('ESLint | ember/tests/routing/basic_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/basic_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/decoupled_basic_test', ['ember-babel', 'ember-routing', 'ember-runtime', 'internal-test-helpers'], function (_emberBabel, _emberRouting, _emberRuntime, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Basic Routing - Decoupled from global resovler', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.call(this));
_this.addTemplate('home', '
Hours
');
_this.addTemplate('camelot', '
Is a silly place
');
_this.addTemplate('homepage', '
Megatroll
{{model.home}}
');
_this.router.map(function () {
this.route('home', { path: '/' });
});
return _this;
}
_class.prototype.getController = function getController(name) {
return this.applicationInstance.lookup('controller:' + name);
};
_class.prototype['@test warn on URLs not included in the route set'] = function testWarnOnURLsNotIncludedInTheRouteSet(assert) {
var _this2 = this;
return this.visit('/').then(function () {
expectAssertion(function () {
_this2.visit('/what-is-this-i-dont-even');
}, /'\/what-is-this-i-dont-even' did not match any routes/);
});
};
_class.prototype['@test The Homepage'] = function testTheHomepage(assert) {
var _this3 = this;
return this.visit('/').then(function () {
assert.equal(_this3.currentPath, 'home', 'currently on the home route');
var text = _this3.$('#app').text();
assert.equal(text, "Hours", 'the home template was rendered');
});
};
_class.prototype['@test The Homepage and the Camelot page with multiple Router.map calls'] = function (assert) {
var _this4 = this;
this.router.map(function () {
this.route('camelot', { path: '/camelot' });
});
return this.visit('/camelot').then(function () {
assert.equal(_this4.currentPath, 'camelot');
var text = _this4.$('#camelot').text();
assert.equal(text, "Is a silly place", 'the camelot template was rendered');
return _this4.visit('/');
}).then(function () {
assert.equal(_this4.currentPath, 'home');
var text = _this4.$('#app').text();
assert.equal(text, "Hours", 'the home template was rendered');
});
};
_class.prototype['@test The Homepage with explicit template name in renderTemplate'] = function (assert) {
var _this5 = this;
this.add('route:home', _emberRouting.Route.extend({
renderTemplate: function () {
this.render('homepage');
}
}));
return this.visit('/').then(function () {
var text = _this5.$('#troll').text();
assert.equal(text, "Megatroll", 'the homepage template was rendered');
});
};
_class.prototype['@test an alternate template will pull in an alternate controller'] = function (assert) {
var _this6 = this;
this.add('route:home', _emberRouting.Route.extend({
renderTemplate: function () {
this.render('homepage');
}
}));
this.add('controller:homepage', _emberRuntime.Controller.extend({
model: {
home: 'Comes from homepage'
}
}));
return this.visit('/').then(function () {
var text = _this6.$('p').text();
assert.equal(text, 'Comes from homepage', 'the homepage template was rendered');
});
};
_class.prototype['@test An alternate template will pull in an alternate controller instead of controllerName'] = function (assert) {
var _this7 = this;
this.add('route:home', _emberRouting.Route.extend({
controllerName: 'foo',
renderTemplate: function () {
this.render('homepage');
}
}));
this.add('controller:foo', _emberRuntime.Controller.extend({
model: {
home: 'Comes from foo'
}
}));
this.add('controller:homepage', _emberRuntime.Controller.extend({
model: {
home: 'Comes from homepage'
}
}));
return this.visit('/').then(function () {
var text = _this7.$('p').text();
assert.equal(text, 'Comes from homepage', 'the homepage template was rendered');
});
};
_class.prototype['@test The template will pull in an alternate controller via key/value'] = function (assert) {
var _this8 = this;
this.router.map(function () {
this.route('homepage', { path: '/' });
});
this.add('route:homepage', _emberRouting.Route.extend({
renderTemplate: function () {
this.render({ controller: 'home' });
}
}));
this.add('controller:home', _emberRuntime.Controller.extend({
model: {
home: 'Comes from home.'
}
}));
return this.visit('/').then(function () {
var text = _this8.$('p').text();
assert.equal(text, 'Comes from home.', 'the homepage template was rendered from data from the HomeController');
});
};
_class.prototype['@test The Homepage with explicit template name in renderTemplate and controller'] = function (assert) {
var _this9 = this;
this.add('controller:home', _emberRuntime.Controller.extend({
model: {
home: 'YES I AM HOME'
}
}));
this.add('route:home', _emberRouting.Route.extend({
renderTemplate: function () {
this.render('homepage');
}
}));
return this.visit('/').then(function () {
var text = _this9.$('p').text();
assert.equal(text, 'YES I AM HOME', 'The homepage template was rendered');
});
};
_class.prototype['@test Model passed via renderTemplate model is set as controller\'s model'] = function (assert) {
var _this10 = this;
this.addTemplate('bio', '
{{model.name}}
');
this.add('route:home', _emberRouting.Route.extend({
renderTemplate: function () {
this.render('bio', {
model: { name: 'emberjs' }
});
}
}));
return this.visit('/').then(function () {
var text = _this10.$('p').text();
assert.equal(text, 'emberjs', 'Passed model was set as controller\'s model');
});
};
_class.prototype['@test render uses templateName from route'] = function testRenderUsesTemplateNameFromRoute(assert) {
var _this11 = this;
this.addTemplate('the_real_home_template', '
THIS IS THE REAL HOME
');
this.add('route:home', _emberRouting.Route.extend({
templateName: 'the_real_home_template'
}));
return this.visit('/').then(function () {
var text = _this11.$('p').text();
assert.equal(text, 'THIS IS THE REAL HOME', 'the homepage template was rendered');
});
};
_class.prototype['@test defining templateName allows other templates to be rendered'] = function testDefiningTemplateNameAllowsOtherTemplatesToBeRendered(assert) {
var _this12 = this;
this.addTemplate('alert', '
Invader!
');
this.addTemplate('the_real_home_template', '
THIS IS THE REAL HOME
{{outlet \'alert\'}}');
this.add('route:home', _emberRouting.Route.extend({
templateName: 'the_real_home_template',
actions: {
showAlert: function () {
this.render('alert', {
into: 'home',
outlet: 'alert'
});
}
}
}));
return this.visit('/').then(function () {
var text = _this12.$('p').text();
assert.equal(text, 'THIS IS THE REAL HOME', 'the homepage template was rendered');
return _this12.runTask(function () {
return _this12.appRouter.send('showAlert');
});
}).then(function () {
var text = _this12.$('.alert-box').text();
assert.equal(text, 'Invader!', 'Template for alert was rendered into the outlet');
});
};
_class.prototype['@test templateName is still used when calling render with no name and options'] = function testTemplateNameIsStillUsedWhenCallingRenderWithNoNameAndOptions(assert) {
var _this13 = this;
this.addTemplate('alert', '
Invader!
');
this.addTemplate('home', '
THIS IS THE REAL HOME
{{outlet \'alert\'}}');
this.add('route:home', _emberRouting.Route.extend({
templateName: 'alert',
renderTemplate: function () {
this.render({});
}
}));
return this.visit('/').then(function () {
var text = _this13.$('.alert-box').text();
assert.equal(text, 'Invader!', 'default templateName was rendered into outlet');
});
};
_class.prototype['@test The Homepage with a `setupController` hook'] = function testTheHomepageWithASetupControllerHook(assert) {
var _this14 = this;
this.addTemplate('home', '
{{#each hours as |entry|}}\n
{{entry}}
\n {{/each}}\n
\n ');
this.add('route:home', _emberRouting.Route.extend({
setupController: function (controller) {
controller.set('hours', (0, _emberRuntime.A)(['Monday through Friday: 9am to 5pm', 'Saturday: Noon to Midnight', 'Sunday: Noon to 6pm']));
}
}));
return this.visit('/').then(function () {
var text = _this14.$('ul li').eq(2).text();
assert.equal(text, 'Sunday: Noon to 6pm', 'The template was rendered with the hours context');
});
};
_class.prototype['@test The route controller is still set when overriding the setupController hook'] = function (assert) {
var _this15 = this;
this.add('route:home', _emberRouting.Route.extend({
setupController: function () {
// no-op
// importantly, we are not calling this._super
}
}));
this.add('controller:home', _emberRuntime.Controller.extend());
return this.visit('/').then(function () {
var homeRoute = _this15.applicationInstance.lookup('route:home');
var homeController = _this15.applicationInstance.lookup('controller:home');
assert.equal(homeRoute.controller, homeController, 'route controller is the home controller');
});
};
_class.prototype['@test the route controller can be specified via controllerName'] = function testTheRouteControllerCanBeSpecifiedViaControllerName(assert) {
var _this16 = this;
this.addTemplate('home', '
{{myValue}}
');
this.add('route:home', _emberRouting.Route.extend({
controllerName: 'myController'
}));
this.add('controller:myController', _emberRuntime.Controller.extend({
myValue: 'foo'
}));
return this.visit('/').then(function () {
var homeRoute = _this16.applicationInstance.lookup('route:home');
var myController = _this16.applicationInstance.lookup('controller:myController');
var text = _this16.$('p').text();
assert.deepEqual(homeRoute.controller, myController, 'route controller is set by controllerName');
assert.equal(text, 'foo', 'The homepage template was rendered with data from the custom controller');
});
};
(0, _emberBabel.createClass)(_class, [{
key: 'currentPath',
get: function () {
return this.getController('application').get('currentPath');
}
}]);
return _class;
}(_internalTestHelpers.ApplicationTestCase));
});
QUnit.module('ESLint | ember/tests/routing/decoupled_basic_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/decoupled_basic_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/query_params_test', ['ember-babel', 'ember-runtime', 'ember-metal', 'ember-routing', 'ember-views', 'internal-test-helpers'], function (_emberBabel, _emberRuntime, _emberMetal, _emberRouting, _emberViews, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Query Params - main', function (_QueryParamTestCase) {
(0, _emberBabel.inherits)(_class, _QueryParamTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _QueryParamTestCase.apply(this, arguments));
}
_class.prototype.refreshModelWhileLoadingTest = function refreshModelWhileLoadingTest(loadingReturn) {
var _actions,
_this2 = this;
var assert = this.assert;
assert.expect(9);
var appModelCount = 0;
var promiseResolve = void 0;
this.add('route:application', _emberRouting.Route.extend({
queryParams: {
appomg: {
defaultValue: 'applol'
}
},
model: function (params) {
appModelCount++;
}
}));
this.setSingleQPController('index', 'omg', undefined, {
omg: undefined
});
var actionName = typeof loadingReturn !== 'undefined' ? 'loading' : 'ignore';
var indexModelCount = 0;
this.add('route:index', _emberRouting.Route.extend({
queryParams: {
omg: {
refreshModel: true
}
},
actions: (_actions = {}, _actions[actionName] = function () {
return loadingReturn;
}, _actions),
model: function (params) {
indexModelCount++;
if (indexModelCount === 2) {
assert.deepEqual(params, { omg: 'lex' });
return new _emberRuntime.RSVP.Promise(function (resolve) {
promiseResolve = resolve;
return;
});
} else if (indexModelCount === 3) {
assert.deepEqual(params, { omg: 'hello' }, 'Model hook reruns even if the previous one didn\'t finish');
}
}
}));
return this.visit('/').then(function () {
assert.equal(appModelCount, 1, 'appModelCount is 1');
assert.equal(indexModelCount, 1);
var indexController = _this2.getController('index');
_this2.setAndFlush(indexController, 'omg', 'lex');
assert.equal(appModelCount, 1, 'appModelCount is 1');
assert.equal(indexModelCount, 2);
_this2.setAndFlush(indexController, 'omg', 'hello');
assert.equal(appModelCount, 1, 'appModelCount is 1');
assert.equal(indexModelCount, 3);
(0, _emberMetal.run)(function () {
promiseResolve();
});
assert.equal((0, _emberMetal.get)(indexController, 'omg'), 'hello', 'At the end last value prevails');
});
};
_class.prototype['@test No replaceURL occurs on startup because default values don\'t show up in URL'] = function testNoReplaceURLOccursOnStartupBecauseDefaultValuesDonTShowUpInURL(assert) {
assert.expect(1);
this.setSingleQPController('index');
return this.visitAndAssert('/');
};
_class.prototype['@test Calling transitionTo does not lose query params already on the activeTransition'] = function testCallingTransitionToDoesNotLoseQueryParamsAlreadyOnTheActiveTransition(assert) {
var _this3 = this;
assert.expect(2);
this.router.map(function () {
this.route('parent', function () {
this.route('child');
this.route('sibling');
});
});
this.add('route:parent.child', _emberRouting.Route.extend({
afterModel: function () {
this.transitionTo('parent.sibling');
}
}));
this.setSingleQPController('parent');
return this.visit('/parent/child?foo=lol').then(function () {
_this3.assertCurrentPath('/parent/sibling?foo=lol', 'redirected to the sibling route, instead of child route');
assert.equal(_this3.getController('parent').get('foo'), 'lol', 'controller has value from the active transition');
});
};
_class.prototype['@test Single query params can be set on the controller and reflected in the url'] = function testSingleQueryParamsCanBeSetOnTheControllerAndReflectedInTheUrl(assert) {
var _this4 = this;
assert.expect(3);
this.router.map(function () {
this.route('home', { path: '/' });
});
this.setSingleQPController('home');
return this.visitAndAssert('/').then(function () {
var controller = _this4.getController('home');
_this4.setAndFlush(controller, 'foo', '456');
_this4.assertCurrentPath('/?foo=456');
_this4.setAndFlush(controller, 'foo', '987');
_this4.assertCurrentPath('/?foo=987');
});
};
_class.prototype['@test Query params can map to different url keys configured on the controller'] = function testQueryParamsCanMapToDifferentUrlKeysConfiguredOnTheController(assert) {
var _this5 = this;
assert.expect(6);
this.add('controller:index', _emberRuntime.Controller.extend({
queryParams: [{ foo: 'other_foo', bar: { as: 'other_bar' } }],
foo: 'FOO',
bar: 'BAR'
}));
return this.visitAndAssert('/').then(function () {
var controller = _this5.getController('index');
_this5.setAndFlush(controller, 'foo', 'LEX');
_this5.assertCurrentPath('/?other_foo=LEX', 'QP mapped correctly without \'as\'');
_this5.setAndFlush(controller, 'foo', 'WOO');
_this5.assertCurrentPath('/?other_foo=WOO', 'QP updated correctly without \'as\'');
_this5.transitionTo('/?other_foo=NAW');
assert.equal(controller.get('foo'), 'NAW', 'QP managed correctly on URL transition');
_this5.setAndFlush(controller, 'bar', 'NERK');
_this5.assertCurrentPath('/?other_bar=NERK&other_foo=NAW', 'QP mapped correctly with \'as\'');
_this5.setAndFlush(controller, 'bar', 'NUKE');
_this5.assertCurrentPath('/?other_bar=NUKE&other_foo=NAW', 'QP updated correctly with \'as\'');
});
};
_class.prototype['@test Routes have a private overridable serializeQueryParamKey hook'] = function testRoutesHaveAPrivateOverridableSerializeQueryParamKeyHook(assert) {
var _this6 = this;
assert.expect(2);
this.add('route:index', _emberRouting.Route.extend({
serializeQueryParamKey: _emberRuntime.String.dasherize
}));
this.setSingleQPController('index', 'funTimes', '');
return this.visitAndAssert('/').then(function () {
var controller = _this6.getController('index');
_this6.setAndFlush(controller, 'funTimes', 'woot');
_this6.assertCurrentPath('/?fun-times=woot');
});
};
_class.prototype['@test Can override inherited QP behavior by specifying queryParams as a computed property'] = function testCanOverrideInheritedQPBehaviorBySpecifyingQueryParamsAsAComputedProperty(assert) {
var _this7 = this;
assert.expect(3);
this.setSingleQPController('index', 'a', 0, {
queryParams: (0, _emberMetal.computed)(function () {
return ['c'];
}),
c: true
});
return this.visitAndAssert('/').then(function () {
var indexController = _this7.getController('index');
_this7.setAndFlush(indexController, 'a', 1);
_this7.assertCurrentPath('/', 'QP did not update due to being overriden');
_this7.setAndFlush(indexController, 'c', false);
_this7.assertCurrentPath('/?c=false', 'QP updated with overridden param');
});
};
_class.prototype['@test Can concatenate inherited QP behavior by specifying queryParams as an array'] = function testCanConcatenateInheritedQPBehaviorBySpecifyingQueryParamsAsAnArray(assert) {
var _this8 = this;
assert.expect(3);
this.setSingleQPController('index', 'a', 0, {
queryParams: ['c'],
c: true
});
return this.visitAndAssert('/').then(function () {
var indexController = _this8.getController('index');
_this8.setAndFlush(indexController, 'a', 1);
_this8.assertCurrentPath('/?a=1', 'Inherited QP did update');
_this8.setAndFlush(indexController, 'c', false);
_this8.assertCurrentPath('/?a=1&c=false', 'New QP did update');
});
};
_class.prototype['@test model hooks receives query params'] = function testModelHooksReceivesQueryParams(assert) {
assert.expect(2);
this.setSingleQPController('index');
this.add('route:index', _emberRouting.Route.extend({
model: function (params) {
assert.deepEqual(params, { foo: 'bar' });
}
}));
return this.visitAndAssert('/');
};
_class.prototype['@test model hooks receives query params with dynamic segment params'] = function testModelHooksReceivesQueryParamsWithDynamicSegmentParams(assert) {
assert.expect(2);
this.router.map(function () {
this.route('index', { path: '/:id' });
});
this.setSingleQPController('index');
this.add('route:index', _emberRouting.Route.extend({
model: function (params) {
assert.deepEqual(params, { foo: 'bar', id: 'baz' });
}
}));
return this.visitAndAssert('/baz');
};
_class.prototype['@test model hooks receives query params (overridden by incoming url value)'] = function testModelHooksReceivesQueryParamsOverriddenByIncomingUrlValue(assert) {
assert.expect(2);
this.router.map(function () {
this.route('index', { path: '/:id' });
});
this.setSingleQPController('index');
this.add('route:index', _emberRouting.Route.extend({
model: function (params) {
assert.deepEqual(params, { foo: 'baz', id: 'boo' });
}
}));
return this.visitAndAssert('/boo?foo=baz');
};
_class.prototype['@test error is thrown if dynamic segment and query param have same name'] = function testErrorIsThrownIfDynamicSegmentAndQueryParamHaveSameName(assert) {
var _this9 = this;
assert.expect(1);
this.router.map(function () {
this.route('index', { path: '/:foo' });
});
this.setSingleQPController('index');
expectAssertion(function () {
_this9.visitAndAssert('/boo?foo=baz');
}, 'The route \'index\' has both a dynamic segment and query param with name \'foo\'. Please rename one to avoid collisions.');
};
_class.prototype['@test query params have been set by the time setupController is called'] = function testQueryParamsHaveBeenSetByTheTimeSetupControllerIsCalled(assert) {
assert.expect(2);
this.setSingleQPController('application');
this.add('route:application', _emberRouting.Route.extend({
setupController: function (controller) {
assert.equal(controller.get('foo'), 'YEAH', 'controller\'s foo QP property set before setupController called');
}
}));
return this.visitAndAssert('/?foo=YEAH');
};
_class.prototype['@test mapped query params have been set by the time setupController is called'] = function testMappedQueryParamsHaveBeenSetByTheTimeSetupControllerIsCalled(assert) {
assert.expect(2);
this.setSingleQPController('application', { faz: 'foo' });
this.add('route:application', _emberRouting.Route.extend({
setupController: function (controller) {
assert.equal(controller.get('faz'), 'YEAH', 'controller\'s foo QP property set before setupController called');
}
}));
return this.visitAndAssert('/?foo=YEAH');
};
_class.prototype['@test Route#paramsFor fetches query params with default value'] = function testRouteParamsForFetchesQueryParamsWithDefaultValue(assert) {
assert.expect(2);
this.router.map(function () {
this.route('index', { path: '/:something' });
});
this.setSingleQPController('index');
this.add('route:index', _emberRouting.Route.extend({
model: function (params, transition) {
assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: 'bar' }, 'could retrieve params for index');
}
}));
return this.visitAndAssert('/baz');
};
_class.prototype['@test Route#paramsFor fetches query params with non-default value'] = function testRouteParamsForFetchesQueryParamsWithNonDefaultValue(assert) {
assert.expect(2);
this.router.map(function () {
this.route('index', { path: '/:something' });
});
this.setSingleQPController('index');
this.add('route:index', _emberRouting.Route.extend({
model: function (params, transition) {
assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: 'boo' }, 'could retrieve params for index');
}
}));
return this.visitAndAssert('/baz?foo=boo');
};
_class.prototype['@test Route#paramsFor fetches default falsy query params'] = function testRouteParamsForFetchesDefaultFalsyQueryParams(assert) {
assert.expect(2);
this.router.map(function () {
this.route('index', { path: '/:something' });
});
this.setSingleQPController('index', 'foo', false);
this.add('route:index', _emberRouting.Route.extend({
model: function (params, transition) {
assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: false }, 'could retrieve params for index');
}
}));
return this.visitAndAssert('/baz');
};
_class.prototype['@test Route#paramsFor fetches non-default falsy query params'] = function testRouteParamsForFetchesNonDefaultFalsyQueryParams(assert) {
assert.expect(2);
this.router.map(function () {
this.route('index', { path: '/:something' });
});
this.setSingleQPController('index', 'foo', true);
this.add('route:index', _emberRouting.Route.extend({
model: function (params, transition) {
assert.deepEqual(this.paramsFor('index'), { something: 'baz', foo: false }, 'could retrieve params for index');
}
}));
return this.visitAndAssert('/baz?foo=false');
};
_class.prototype['@test model hook can query prefix-less application params'] = function testModelHookCanQueryPrefixLessApplicationParams(assert) {
assert.expect(4);
this.setSingleQPController('application', 'appomg', 'applol');
this.setSingleQPController('index', 'omg', 'lol');
this.add('route:application', _emberRouting.Route.extend({
model: function (params) {
assert.deepEqual(params, { appomg: 'applol' });
}
}));
this.add('route:index', _emberRouting.Route.extend({
model: function (params) {
assert.deepEqual(params, { omg: 'lol' });
assert.deepEqual(this.paramsFor('application'), { appomg: 'applol' });
}
}));
return this.visitAndAssert('/');
};
_class.prototype['@test model hook can query prefix-less application params (overridden by incoming url value)'] = function testModelHookCanQueryPrefixLessApplicationParamsOverriddenByIncomingUrlValue(assert) {
assert.expect(4);
this.setSingleQPController('application', 'appomg', 'applol');
this.setSingleQPController('index', 'omg', 'lol');
this.add('route:application', _emberRouting.Route.extend({
model: function (params) {
assert.deepEqual(params, { appomg: 'appyes' });
}
}));
this.add('route:index', _emberRouting.Route.extend({
model: function (params) {
assert.deepEqual(params, { omg: 'yes' });
assert.deepEqual(this.paramsFor('application'), { appomg: 'appyes' });
}
}));
return this.visitAndAssert('/?appomg=appyes&omg=yes');
};
_class.prototype['@test can opt into full transition by setting refreshModel in route queryParams'] = function testCanOptIntoFullTransitionBySettingRefreshModelInRouteQueryParams(assert) {
var _this10 = this;
assert.expect(7);
this.setSingleQPController('application', 'appomg', 'applol');
this.setSingleQPController('index', 'omg', 'lol');
var appModelCount = 0;
this.add('route:application', _emberRouting.Route.extend({
model: function (params) {
appModelCount++;
}
}));
var indexModelCount = 0;
this.add('route:index', _emberRouting.Route.extend({
queryParams: {
omg: {
refreshModel: true
}
},
model: function (params) {
indexModelCount++;
if (indexModelCount === 1) {
assert.deepEqual(params, { omg: 'lol' }, 'params are correct on first pass');
} else if (indexModelCount === 2) {
assert.deepEqual(params, { omg: 'lex' }, 'params are correct on second pass');
}
}
}));
return this.visitAndAssert('/').then(function () {
assert.equal(appModelCount, 1, 'app model hook ran');
assert.equal(indexModelCount, 1, 'index model hook ran');
var indexController = _this10.getController('index');
_this10.setAndFlush(indexController, 'omg', 'lex');
assert.equal(appModelCount, 1, 'app model hook did not run again');
assert.equal(indexModelCount, 2, 'index model hook ran again due to refreshModel');
});
};
_class.prototype['@test refreshModel and replace work together'] = function testRefreshModelAndReplaceWorkTogether(assert) {
var _this11 = this;
assert.expect(8);
this.setSingleQPController('application', 'appomg', 'applol');
this.setSingleQPController('index', 'omg', 'lol');
var appModelCount = 0;
this.add('route:application', _emberRouting.Route.extend({
model: function (params) {
appModelCount++;
}
}));
var indexModelCount = 0;
this.add('route:index', _emberRouting.Route.extend({
queryParams: {
omg: {
refreshModel: true,
replace: true
}
},
model: function (params) {
indexModelCount++;
if (indexModelCount === 1) {
assert.deepEqual(params, { omg: 'lol' }, 'params are correct on first pass');
} else if (indexModelCount === 2) {
assert.deepEqual(params, { omg: 'lex' }, 'params are correct on second pass');
}
}
}));
return this.visitAndAssert('/').then(function () {
assert.equal(appModelCount, 1, 'app model hook ran');
assert.equal(indexModelCount, 1, 'index model hook ran');
var indexController = _this11.getController('index');
_this11.expectedReplaceURL = '/?omg=lex';
_this11.setAndFlush(indexController, 'omg', 'lex');
assert.equal(appModelCount, 1, 'app model hook did not run again');
assert.equal(indexModelCount, 2, 'index model hook ran again due to refreshModel');
});
};
_class.prototype['@test multiple QP value changes only cause a single model refresh'] = function testMultipleQPValueChangesOnlyCauseASingleModelRefresh(assert) {
var _this12 = this;
assert.expect(2);
this.setSingleQPController('index', 'alex', 'lol');
this.setSingleQPController('index', 'steely', 'lel');
var refreshCount = 0;
this.add('route:index', _emberRouting.Route.extend({
queryParams: {
alex: {
refreshModel: true
},
steely: {
refreshModel: true
}
},
refresh: function () {
refreshCount++;
}
}));
return this.visitAndAssert('/').then(function () {
var indexController = _this12.getController('index');
(0, _emberMetal.run)(indexController, 'setProperties', { alex: 'fran', steely: 'david' });
assert.equal(refreshCount, 1, 'index refresh hook only run once');
});
};
_class.prototype['@test refreshModel does not cause a second transition during app boot '] = function testRefreshModelDoesNotCauseASecondTransitionDuringAppBoot(assert) {
assert.expect(1);
this.setSingleQPController('application', 'appomg', 'applol');
this.setSingleQPController('index', 'omg', 'lol');
this.add('route:index', _emberRouting.Route.extend({
queryParams: {
omg: {
refreshModel: true
}
},
refresh: function () {
assert.ok(false);
}
}));
return this.visitAndAssert('/?appomg=hello&omg=world');
};
_class.prototype['@test queryParams are updated when a controller property is set and the route is refreshed. Issue #13263 '] = function testQueryParamsAreUpdatedWhenAControllerPropertyIsSetAndTheRouteIsRefreshedIssue13263(assert) {
var _this13 = this;
this.addTemplate('application', '{{foo}}{{outlet}}');
this.setSingleQPController('application', 'foo', 1, {
actions: {
increment: function () {
this.incrementProperty('foo');
this.send('refreshRoute');
}
}
});
this.add('route:application', _emberRouting.Route.extend({
actions: {
refreshRoute: function () {
this.refresh();
}
}
}));
return this.visitAndAssert('/').then(function () {
assert.equal((0, _emberViews.jQuery)('#test-value').text().trim(), '1');
(0, _emberMetal.run)((0, _emberViews.jQuery)('#test-button'), 'click');
assert.equal((0, _emberViews.jQuery)('#test-value').text().trim(), '2');
_this13.assertCurrentPath('/?foo=2');
(0, _emberMetal.run)((0, _emberViews.jQuery)('#test-button'), 'click');
assert.equal((0, _emberViews.jQuery)('#test-value').text().trim(), '3');
_this13.assertCurrentPath('/?foo=3');
});
};
_class.prototype['@test Use Ember.get to retrieve query params \'refreshModel\' configuration'] = function testUseEmberGetToRetrieveQueryParamsRefreshModelConfiguration(assert) {
var _this14 = this;
assert.expect(7);
this.setSingleQPController('application', 'appomg', 'applol');
this.setSingleQPController('index', 'omg', 'lol');
var appModelCount = 0;
this.add('route:application', _emberRouting.Route.extend({
model: function (params) {
appModelCount++;
}
}));
var indexModelCount = 0;
this.add('route:index', _emberRouting.Route.extend({
queryParams: _emberRuntime.Object.create({
unknownProperty: function (keyName) {
return { refreshModel: true };
}
}),
model: function (params) {
indexModelCount++;
if (indexModelCount === 1) {
assert.deepEqual(params, { omg: 'lol' });
} else if (indexModelCount === 2) {
assert.deepEqual(params, { omg: 'lex' });
}
}
}));
return this.visitAndAssert('/').then(function () {
assert.equal(appModelCount, 1);
assert.equal(indexModelCount, 1);
var indexController = _this14.getController('index');
_this14.setAndFlush(indexController, 'omg', 'lex');
assert.equal(appModelCount, 1);
assert.equal(indexModelCount, 2);
});
};
_class.prototype['@test can use refreshModel even with URL changes that remove QPs from address bar'] = function testCanUseRefreshModelEvenWithURLChangesThatRemoveQPsFromAddressBar(assert) {
var _this15 = this;
assert.expect(4);
this.setSingleQPController('index', 'omg', 'lol');
var indexModelCount = 0;
this.add('route:index', _emberRouting.Route.extend({
queryParams: {
omg: {
refreshModel: true
}
},
model: function (params) {
indexModelCount++;
var data = void 0;
if (indexModelCount === 1) {
data = 'foo';
} else if (indexModelCount === 2) {
data = 'lol';
}
assert.deepEqual(params, { omg: data }, 'index#model receives right data');
}
}));
return this.visitAndAssert('/?omg=foo').then(function () {
_this15.transitionTo('/');
var indexController = _this15.getController('index');
assert.equal(indexController.get('omg'), 'lol');
});
};
_class.prototype['@test can opt into a replace query by specifying replace:true in the Route config hash'] = function testCanOptIntoAReplaceQueryBySpecifyingReplaceTrueInTheRouteConfigHash(assert) {
var _this16 = this;
assert.expect(2);
this.setSingleQPController('application', 'alex', 'matchneer');
this.add('route:application', _emberRouting.Route.extend({
queryParams: {
alex: {
replace: true
}
}
}));
return this.visitAndAssert('/').then(function () {
var appController = _this16.getController('application');
_this16.expectedReplaceURL = '/?alex=wallace';
_this16.setAndFlush(appController, 'alex', 'wallace');
});
};
_class.prototype['@test Route query params config can be configured using property name instead of URL key'] = function testRouteQueryParamsConfigCanBeConfiguredUsingPropertyNameInsteadOfURLKey(assert) {
var _this17 = this;
assert.expect(2);
this.add('controller:application', _emberRuntime.Controller.extend({
queryParams: [{ commitBy: 'commit_by' }]
}));
this.add('route:application', _emberRouting.Route.extend({
queryParams: {
commitBy: {
replace: true
}
}
}));
return this.visitAndAssert('/').then(function () {
var appController = _this17.getController('application');
_this17.expectedReplaceURL = '/?commit_by=igor_seb';
_this17.setAndFlush(appController, 'commitBy', 'igor_seb');
});
};
_class.prototype['@test An explicit replace:false on a changed QP always wins and causes a pushState'] = function testAnExplicitReplaceFalseOnAChangedQPAlwaysWinsAndCausesAPushState(assert) {
var _this18 = this;
assert.expect(3);
this.add('controller:application', _emberRuntime.Controller.extend({
queryParams: ['alex', 'steely'],
alex: 'matchneer',
steely: 'dan'
}));
this.add('route:application', _emberRouting.Route.extend({
queryParams: {
alex: {
replace: true
},
steely: {
replace: false
}
}
}));
return this.visit('/').then(function () {
var appController = _this18.getController('application');
_this18.expectedPushURL = '/?alex=wallace&steely=jan';
(0, _emberMetal.run)(appController, 'setProperties', { alex: 'wallace', steely: 'jan' });
_this18.expectedPushURL = '/?alex=wallace&steely=fran';
(0, _emberMetal.run)(appController, 'setProperties', { steely: 'fran' });
_this18.expectedReplaceURL = '/?alex=sriracha&steely=fran';
(0, _emberMetal.run)(appController, 'setProperties', { alex: 'sriracha' });
});
};
_class.prototype['@test can opt into full transition by setting refreshModel in route queryParams when transitioning from child to parent'] = function testCanOptIntoFullTransitionBySettingRefreshModelInRouteQueryParamsWhenTransitioningFromChildToParent(assert) {
this.addTemplate('parent', '{{outlet}}');
this.addTemplate('parent.child', '{{link-to \'Parent\' \'parent\' (query-params foo=\'change\') id=\'parent-link\'}}');
this.router.map(function () {
this.route('parent', function () {
this.route('child');
});
});
var parentModelCount = 0;
this.add('route:parent', _emberRouting.Route.extend({
model: function () {
parentModelCount++;
},
queryParams: {
foo: {
refreshModel: true
}
}
}));
this.setSingleQPController('parent', 'foo', 'abc');
return this.visit('/parent/child?foo=lol').then(function () {
assert.equal(parentModelCount, 1);
(0, _emberMetal.run)((0, _emberViews.jQuery)('#parent-link'), 'click');
assert.equal(parentModelCount, 2);
});
};
_class.prototype['@test Use Ember.get to retrieve query params \'replace\' configuration'] = function testUseEmberGetToRetrieveQueryParamsReplaceConfiguration(assert) {
var _this19 = this;
assert.expect(2);
this.setSingleQPController('application', 'alex', 'matchneer');
this.add('route:application', _emberRouting.Route.extend({
queryParams: _emberRuntime.Object.create({
unknownProperty: function (keyName) {
// We are simulating all qps requiring refresh
return { replace: true };
}
})
}));
return this.visitAndAssert('/').then(function () {
var appController = _this19.getController('application');
_this19.expectedReplaceURL = '/?alex=wallace';
_this19.setAndFlush(appController, 'alex', 'wallace');
});
};
_class.prototype['@test can override incoming QP values in setupController'] = function testCanOverrideIncomingQPValuesInSetupController(assert) {
var _this20 = this;
assert.expect(3);
this.router.map(function () {
this.route('about');
});
this.setSingleQPController('index', 'omg', 'lol');
this.add('route:index', _emberRouting.Route.extend({
setupController: function (controller) {
assert.ok(true, 'setupController called');
controller.set('omg', 'OVERRIDE');
},
actions: {
queryParamsDidChange: function () {
assert.ok(false, 'queryParamsDidChange shouldn\'t fire');
}
}
}));
return this.visitAndAssert('/about').then(function () {
_this20.transitionTo('index');
_this20.assertCurrentPath('/?omg=OVERRIDE');
});
};
_class.prototype['@test can override incoming QP array values in setupController'] = function testCanOverrideIncomingQPArrayValuesInSetupController(assert) {
var _this21 = this;
assert.expect(3);
this.router.map(function () {
this.route('about');
});
this.setSingleQPController('index', 'omg', ['lol']);
this.add('route:index', _emberRouting.Route.extend({
setupController: function (controller) {
assert.ok(true, 'setupController called');
controller.set('omg', ['OVERRIDE']);
},
actions: {
queryParamsDidChange: function () {
assert.ok(false, 'queryParamsDidChange shouldn\'t fire');
}
}
}));
return this.visitAndAssert('/about').then(function () {
_this21.transitionTo('index');
_this21.assertCurrentPath('/?omg=' + encodeURIComponent(JSON.stringify(['OVERRIDE'])));
});
};
_class.prototype['@test URL transitions that remove QPs still register as QP changes'] = function testURLTransitionsThatRemoveQPsStillRegisterAsQPChanges(assert) {
var _this22 = this;
assert.expect(2);
this.setSingleQPController('index', 'omg', 'lol');
return this.visit('/?omg=borf').then(function () {
var indexController = _this22.getController('index');
assert.equal(indexController.get('omg'), 'borf');
_this22.transitionTo('/');
assert.equal(indexController.get('omg'), 'lol');
});
};
_class.prototype['@test Subresource naming style is supported'] = function testSubresourceNamingStyleIsSupported(assert) {
var _this23 = this;
assert.expect(5);
this.router.map(function () {
this.route('abc.def', { path: '/abcdef' }, function () {
this.route('zoo');
});
});
this.addTemplate('application', '{{link-to \'A\' \'abc.def\' (query-params foo=\'123\') id=\'one\'}}{{link-to \'B\' \'abc.def.zoo\' (query-params foo=\'123\' bar=\'456\') id=\'two\'}}{{outlet}}');
this.setSingleQPController('abc.def', 'foo', 'lol');
this.setSingleQPController('abc.def.zoo', 'bar', 'haha');
return this.visitAndAssert('/').then(function () {
assert.equal((0, _emberViews.jQuery)('#one').attr('href'), '/abcdef?foo=123');
assert.equal((0, _emberViews.jQuery)('#two').attr('href'), '/abcdef/zoo?bar=456&foo=123');
(0, _emberMetal.run)((0, _emberViews.jQuery)('#one'), 'click');
_this23.assertCurrentPath('/abcdef?foo=123');
(0, _emberMetal.run)((0, _emberViews.jQuery)('#two'), 'click');
_this23.assertCurrentPath('/abcdef/zoo?bar=456&foo=123');
});
};
_class.prototype['@test transitionTo supports query params'] = function testTransitionToSupportsQueryParams(assert) {
var _this24 = this;
this.setSingleQPController('index', 'foo', 'lol');
return this.visitAndAssert('/').then(function () {
_this24.transitionTo({ queryParams: { foo: 'borf' } });
_this24.assertCurrentPath('/?foo=borf', 'shorthand supported');
_this24.transitionTo({ queryParams: { 'index:foo': 'blaf' } });
_this24.assertCurrentPath('/?foo=blaf', 'longform supported');
_this24.transitionTo({ queryParams: { 'index:foo': false } });
_this24.assertCurrentPath('/?foo=false', 'longform supported (bool)');
_this24.transitionTo({ queryParams: { foo: false } });
_this24.assertCurrentPath('/?foo=false', 'shorhand supported (bool)');
});
};
_class.prototype['@test transitionTo supports query params (multiple)'] = function testTransitionToSupportsQueryParamsMultiple(assert) {
var _this25 = this;
this.add('controller:index', _emberRuntime.Controller.extend({
queryParams: ['foo', 'bar'],
foo: 'lol',
bar: 'wat'
}));
return this.visitAndAssert('/').then(function () {
_this25.transitionTo({ queryParams: { foo: 'borf' } });
_this25.assertCurrentPath('/?foo=borf', 'shorthand supported');
_this25.transitionTo({ queryParams: { 'index:foo': 'blaf' } });
_this25.assertCurrentPath('/?foo=blaf', 'longform supported');
_this25.transitionTo({ queryParams: { 'index:foo': false } });
_this25.assertCurrentPath('/?foo=false', 'longform supported (bool)');
_this25.transitionTo({ queryParams: { foo: false } });
_this25.assertCurrentPath('/?foo=false', 'shorhand supported (bool)');
});
};
_class.prototype['@test setting controller QP to empty string doesn\'t generate null in URL'] = function testSettingControllerQPToEmptyStringDoesnTGenerateNullInURL(assert) {
var _this26 = this;
assert.expect(1);
this.setSingleQPController('index', 'foo', '123');
return this.visit('/').then(function () {
var controller = _this26.getController('index');
_this26.expectedPushURL = '/?foo=';
_this26.setAndFlush(controller, 'foo', '');
});
};
_class.prototype['@test setting QP to empty string doesn\'t generate null in URL'] = function testSettingQPToEmptyStringDoesnTGenerateNullInURL(assert) {
var _this27 = this;
assert.expect(1);
this.add('route:index', _emberRouting.Route.extend({
queryParams: {
foo: {
defaultValue: '123'
}
}
}));
return this.visit('/').then(function () {
var controller = _this27.getController('index');
_this27.expectedPushURL = '/?foo=';
_this27.setAndFlush(controller, 'foo', '');
});
};
_class.prototype['@test A default boolean value deserializes QPs as booleans rather than strings'] = function testADefaultBooleanValueDeserializesQPsAsBooleansRatherThanStrings(assert) {
var _this28 = this;
assert.expect(3);
this.setSingleQPController('index', 'foo', false);
this.add('route:index', _emberRouting.Route.extend({
model: function (params) {
assert.equal(params.foo, true, 'model hook received foo as boolean true');
}
}));
return this.visit('/?foo=true').then(function () {
var controller = _this28.getController('index');
assert.equal(controller.get('foo'), true);
_this28.transitionTo('/?foo=false');
assert.equal(controller.get('foo'), false);
});
};
_class.prototype['@test Query param without value are empty string'] = function testQueryParamWithoutValueAreEmptyString(assert) {
var _this29 = this;
assert.expect(1);
this.add('controller:index', _emberRuntime.Controller.extend({
queryParams: ['foo'],
foo: ''
}));
return this.visit('/?foo=').then(function () {
var controller = _this29.getController('index');
assert.equal(controller.get('foo'), '');
});
};
_class.prototype['@test Array query params can be set'] = function testArrayQueryParamsCanBeSet(assert) {
var _this30 = this;
assert.expect(2);
this.router.map(function () {
this.route('home', { path: '/' });
});
this.setSingleQPController('home', 'foo', []);
return this.visit('/').then(function () {
var controller = _this30.getController('home');
_this30.setAndFlush(controller, 'foo', [1, 2]);
_this30.assertCurrentPath('/?foo=%5B1%2C2%5D');
_this30.setAndFlush(controller, 'foo', [3, 4]);
_this30.assertCurrentPath('/?foo=%5B3%2C4%5D');
});
};
_class.prototype['@test (de)serialization: arrays'] = function testDeSerializationArrays(assert) {
var _this31 = this;
assert.expect(4);
this.setSingleQPController('index', 'foo', [1]);
return this.visitAndAssert('/').then(function () {
_this31.transitionTo({ queryParams: { foo: [2, 3] } });
_this31.assertCurrentPath('/?foo=%5B2%2C3%5D', 'shorthand supported');
_this31.transitionTo({ queryParams: { 'index:foo': [4, 5] } });
_this31.assertCurrentPath('/?foo=%5B4%2C5%5D', 'longform supported');
_this31.transitionTo({ queryParams: { foo: [] } });
_this31.assertCurrentPath('/?foo=%5B%5D', 'longform supported');
});
};
_class.prototype['@test Url with array query param sets controller property to array'] = function testUrlWithArrayQueryParamSetsControllerPropertyToArray(assert) {
var _this32 = this;
assert.expect(1);
this.setSingleQPController('index', 'foo', '');
return this.visit('/?foo[]=1&foo[]=2&foo[]=3').then(function () {
var controller = _this32.getController('index');
assert.deepEqual(controller.get('foo'), ['1', '2', '3']);
});
};
_class.prototype['@test Array query params can be pushed/popped'] = function testArrayQueryParamsCanBePushedPopped(assert) {
var _this33 = this;
assert.expect(17);
this.router.map(function () {
this.route('home', { path: '/' });
});
this.setSingleQPController('home', 'foo', (0, _emberRuntime.A)());
return this.visitAndAssert('/').then(function () {
var controller = _this33.getController('home');
(0, _emberMetal.run)(controller.foo, 'pushObject', 1);
_this33.assertCurrentPath('/?foo=%5B1%5D');
assert.deepEqual(controller.foo, [1]);
(0, _emberMetal.run)(controller.foo, 'popObject');
_this33.assertCurrentPath('/');
assert.deepEqual(controller.foo, []);
(0, _emberMetal.run)(controller.foo, 'pushObject', 1);
_this33.assertCurrentPath('/?foo=%5B1%5D');
assert.deepEqual(controller.foo, [1]);
(0, _emberMetal.run)(controller.foo, 'popObject');
_this33.assertCurrentPath('/');
assert.deepEqual(controller.foo, []);
(0, _emberMetal.run)(controller.foo, 'pushObject', 1);
_this33.assertCurrentPath('/?foo=%5B1%5D');
assert.deepEqual(controller.foo, [1]);
(0, _emberMetal.run)(controller.foo, 'pushObject', 2);
_this33.assertCurrentPath('/?foo=%5B1%2C2%5D');
assert.deepEqual(controller.foo, [1, 2]);
(0, _emberMetal.run)(controller.foo, 'popObject');
_this33.assertCurrentPath('/?foo=%5B1%5D');
assert.deepEqual(controller.foo, [1]);
(0, _emberMetal.run)(controller.foo, 'unshiftObject', 'lol');
_this33.assertCurrentPath('/?foo=%5B%22lol%22%2C1%5D');
assert.deepEqual(controller.foo, ['lol', 1]);
});
};
_class.prototype['@test Overwriting with array with same content shouldn\'t refire update'] = function testOverwritingWithArrayWithSameContentShouldnTRefireUpdate(assert) {
var _this34 = this;
assert.expect(4);
this.router.map(function () {
this.route('home', { path: '/' });
});
var modelCount = 0;
this.add('route:home', _emberRouting.Route.extend({
model: function () {
modelCount++;
}
}));
this.setSingleQPController('home', 'foo', (0, _emberRuntime.A)([1]));
return this.visitAndAssert('/').then(function () {
assert.equal(modelCount, 1);
var controller = _this34.getController('home');
_this34.setAndFlush(controller, 'model', (0, _emberRuntime.A)([1]));
assert.equal(modelCount, 1);
_this34.assertCurrentPath('/');
});
};
_class.prototype['@test Defaulting to params hash as the model should not result in that params object being watched'] = function testDefaultingToParamsHashAsTheModelShouldNotResultInThatParamsObjectBeingWatched(assert) {
var _this35 = this;
assert.expect(1);
this.router.map(function () {
this.route('other');
});
// This causes the params hash, which is returned as a route's
// model if no other model could be resolved given the provided
// params (and no custom model hook was defined), to be watched,
// unless we return a copy of the params hash.
this.setSingleQPController('application', 'woot', 'wat');
this.add('route:other', _emberRouting.Route.extend({
model: function (p, trans) {
var m = (0, _emberMetal.peekMeta)(trans.params.application);
assert.ok(m === undefined, 'A meta object isn\'t constructed for this params POJO');
}
}));
return this.visit('/').then(function () {
_this35.transitionTo('other');
});
};
_class.prototype['@test Setting bound query param property to null or undefined does not serialize to url'] = function testSettingBoundQueryParamPropertyToNullOrUndefinedDoesNotSerializeToUrl(assert) {
var _this36 = this;
assert.expect(9);
this.router.map(function () {
this.route('home');
});
this.setSingleQPController('home', 'foo', [1, 2]);
return this.visitAndAssert('/home').then(function () {
var controller = _this36.getController('home');
assert.deepEqual(controller.get('foo'), [1, 2]);
_this36.assertCurrentPath('/home');
_this36.setAndFlush(controller, 'foo', (0, _emberRuntime.A)([1, 3]));
_this36.assertCurrentPath('/home?foo=%5B1%2C3%5D');
return _this36.transitionTo('/home').then(function () {
assert.deepEqual(controller.get('foo'), [1, 2]);
_this36.assertCurrentPath('/home');
_this36.setAndFlush(controller, 'foo', null);
_this36.assertCurrentPath('/home', 'Setting property to null');
_this36.setAndFlush(controller, 'foo', (0, _emberRuntime.A)([1, 3]));
_this36.assertCurrentPath('/home?foo=%5B1%2C3%5D');
_this36.setAndFlush(controller, 'foo', undefined);
_this36.assertCurrentPath('/home', 'Setting property to undefined');
});
});
};
_class.prototype['@test {{link-to}} with null or undefined QPs does not get serialized into url'] = function testLinkToWithNullOrUndefinedQPsDoesNotGetSerializedIntoUrl(assert) {
var _this37 = this;
assert.expect(3);
this.addTemplate('home', '{{link-to \'Home\' \'home\' (query-params foo=nullValue) id=\'null-link\'}}{{link-to \'Home\' \'home\' (query-params foo=undefinedValue) id=\'undefined-link\'}}');
this.router.map(function () {
this.route('home');
});
this.setSingleQPController('home', 'foo', [], {
nullValue: null,
undefinedValue: undefined
});
return this.visitAndAssert('/home').then(function () {
assert.equal(_this37.$('#null-link').attr('href'), '/home');
assert.equal(_this37.$('#undefined-link').attr('href'), '/home');
});
};
_class.prototype['@test A child of a resource route still defaults to parent route\'s model even if the child route has a query param'] = function testAChildOfAResourceRouteStillDefaultsToParentRouteSModelEvenIfTheChildRouteHasAQueryParam(assert) {
assert.expect(2);
this.setSingleQPController('index', 'woot', undefined, {
woot: undefined
});
this.add('route:application', _emberRouting.Route.extend({
model: function (p, trans) {
return { woot: true };
}
}));
this.add('route:index', _emberRouting.Route.extend({
setupController: function (controller, model) {
assert.deepEqual(model, { woot: true }, 'index route inherited model route from parent route');
}
}));
return this.visitAndAssert('/');
};
_class.prototype['@test opting into replace does not affect transitions between routes'] = function testOptingIntoReplaceDoesNotAffectTransitionsBetweenRoutes(assert) {
var _this38 = this;
assert.expect(5);
this.addTemplate('application', '{{link-to \'Foo\' \'foo\' id=\'foo-link\'}}{{link-to \'Bar\' \'bar\' id=\'bar-no-qp-link\'}}{{link-to \'Bar\' \'bar\' (query-params raytiley=\'isthebest\') id=\'bar-link\'}}{{outlet}}');
this.router.map(function () {
this.route('foo');
this.route('bar');
});
this.setSingleQPController('bar', 'raytiley', 'israd');
this.add('route:bar', _emberRouting.Route.extend({
queryParams: {
raytiley: {
replace: true
}
}
}));
return this.visit('/').then(function () {
var controller = _this38.getController('bar');
_this38.expectedPushURL = '/foo';
(0, _emberMetal.run)((0, _emberViews.jQuery)('#foo-link'), 'click');
_this38.expectedPushURL = '/bar';
(0, _emberMetal.run)((0, _emberViews.jQuery)('#bar-no-qp-link'), 'click');
_this38.expectedReplaceURL = '/bar?raytiley=woot';
_this38.setAndFlush(controller, 'raytiley', 'woot');
_this38.expectedPushURL = '/foo';
(0, _emberMetal.run)((0, _emberViews.jQuery)('#foo-link'), 'click');
_this38.expectedPushURL = '/bar?raytiley=isthebest';
(0, _emberMetal.run)((0, _emberViews.jQuery)('#bar-link'), 'click');
});
};
_class.prototype['@test undefined isn\'t serialized or deserialized into a string'] = function testUndefinedIsnTSerializedOrDeserializedIntoAString(assert) {
var _this39 = this;
assert.expect(4);
this.router.map(function () {
this.route('example');
});
this.addTemplate('application', '{{link-to \'Example\' \'example\' (query-params foo=undefined) id=\'the-link\'}}');
this.setSingleQPController('example', 'foo', undefined, {
foo: undefined
});
this.add('route:example', _emberRouting.Route.extend({
model: function (params) {
assert.deepEqual(params, { foo: undefined });
}
}));
return this.visitAndAssert('/').then(function () {
assert.equal(_this39.$('#the-link').attr('href'), '/example', 'renders without undefined qp serialized');
return _this39.transitionTo('example', { queryParams: { foo: undefined } }).then(function () {
_this39.assertCurrentPath('/example');
});
});
};
_class.prototype['@test when refreshModel is true and loading hook is undefined, model hook will rerun when QPs change even if previous did not finish'] = function testWhenRefreshModelIsTrueAndLoadingHookIsUndefinedModelHookWillRerunWhenQPsChangeEvenIfPreviousDidNotFinish(assert) {
return this.refreshModelWhileLoadingTest();
};
_class.prototype['@test when refreshModel is true and loading hook returns false, model hook will rerun when QPs change even if previous did not finish'] = function testWhenRefreshModelIsTrueAndLoadingHookReturnsFalseModelHookWillRerunWhenQPsChangeEvenIfPreviousDidNotFinish(assert) {
return this.refreshModelWhileLoadingTest(false);
};
_class.prototype['@test when refreshModel is true and loading hook returns true, model hook will rerun when QPs change even if previous did not finish'] = function testWhenRefreshModelIsTrueAndLoadingHookReturnsTrueModelHookWillRerunWhenQPsChangeEvenIfPreviousDidNotFinish(assert) {
return this.refreshModelWhileLoadingTest(true);
};
_class.prototype['@test warn user that Route\'s queryParams configuration must be an Object, not an Array'] = function testWarnUserThatRouteSQueryParamsConfigurationMustBeAnObjectNotAnArray(assert) {
var _this40 = this;
assert.expect(1);
this.add('route:application', _emberRouting.Route.extend({
queryParams: [{ commitBy: { replace: true } }]
}));
expectAssertion(function () {
_this40.visit('/');
}, 'You passed in `[{"commitBy":{"replace":true}}]` as the value for `queryParams` but `queryParams` cannot be an Array');
};
_class.prototype['@test handle route names that clash with Object.prototype properties'] = function testHandleRouteNamesThatClashWithObjectPrototypeProperties(assert) {
var _this41 = this;
assert.expect(1);
this.router.map(function () {
this.route('constructor');
});
this.add('route:constructor', _emberRouting.Route.extend({
queryParams: {
foo: {
defaultValue: '123'
}
}
}));
return this.visit('/').then(function () {
_this41.transitionTo('constructor', { queryParams: { foo: '999' } });
var controller = _this41.getController('constructor');
assert.equal((0, _emberMetal.get)(controller, 'foo'), '999');
});
};
return _class;
}(_internalTestHelpers.QueryParamTestCase));
});
QUnit.module('ESLint | ember/tests/routing/query_params_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/query_params_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test', ['ember-babel', 'ember-runtime', 'ember-routing', 'ember-metal', 'ember-views', 'internal-test-helpers'], function (_emberBabel, _emberRuntime, _emberRouting, _emberMetal, _emberViews, _internalTestHelpers) {
'use strict';
var ModelDependentQPTestCase = function (_QueryParamTestCase) {
(0, _emberBabel.inherits)(ModelDependentQPTestCase, _QueryParamTestCase);
function ModelDependentQPTestCase() {
(0, _emberBabel.classCallCheck)(this, ModelDependentQPTestCase);
return (0, _emberBabel.possibleConstructorReturn)(this, _QueryParamTestCase.apply(this, arguments));
}
ModelDependentQPTestCase.prototype.boot = function boot() {
this.setupApplication();
return this.visitApplication();
};
ModelDependentQPTestCase.prototype.teardown = function teardown() {
var _QueryParamTestCase$p;
(_QueryParamTestCase$p = _QueryParamTestCase.prototype.teardown).call.apply(_QueryParamTestCase$p, [this].concat(Array.prototype.slice.call(arguments)));
this.assert.ok(!this.expectedModelHookParams, 'there should be no pending expectation of expected model hook params');
};
ModelDependentQPTestCase.prototype.reopenController = function reopenController(name, options) {
this.application.resolveRegistration('controller:' + name).reopen(options);
};
ModelDependentQPTestCase.prototype.reopenRoute = function reopenRoute(name, options) {
this.application.resolveRegistration('route:' + name).reopen(options);
};
ModelDependentQPTestCase.prototype.queryParamsStickyTest1 = function queryParamsStickyTest1(urlPrefix) {
var _this2 = this;
var assert = this.assert;
assert.expect(14);
return this.boot().then(function () {
(0, _emberMetal.run)(_this2.$link1, 'click');
_this2.assertCurrentPath(urlPrefix + '/a-1');
_this2.setAndFlush(_this2.controller, 'q', 'lol');
assert.equal(_this2.$link1.attr('href'), urlPrefix + '/a-1?q=lol');
assert.equal(_this2.$link2.attr('href'), urlPrefix + '/a-2');
assert.equal(_this2.$link3.attr('href'), urlPrefix + '/a-3');
(0, _emberMetal.run)(_this2.$link2, 'click');
assert.equal(_this2.controller.get('q'), 'wat');
assert.equal(_this2.controller.get('z'), 0);
assert.deepEqual(_this2.controller.get('model'), { id: 'a-2' });
assert.equal(_this2.$link1.attr('href'), urlPrefix + '/a-1?q=lol');
assert.equal(_this2.$link2.attr('href'), urlPrefix + '/a-2');
assert.equal(_this2.$link3.attr('href'), urlPrefix + '/a-3');
});
};
ModelDependentQPTestCase.prototype.queryParamsStickyTest2 = function queryParamsStickyTest2(urlPrefix) {
var _this3 = this;
var assert = this.assert;
assert.expect(24);
return this.boot().then(function () {
_this3.expectedModelHookParams = { id: 'a-1', q: 'lol', z: 0 };
_this3.transitionTo(urlPrefix + '/a-1?q=lol');
assert.deepEqual(_this3.controller.get('model'), { id: 'a-1' });
assert.equal(_this3.controller.get('q'), 'lol');
assert.equal(_this3.controller.get('z'), 0);
assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1?q=lol');
assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2');
assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3');
_this3.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 0 };
_this3.transitionTo(urlPrefix + '/a-2?q=lol');
assert.deepEqual(_this3.controller.get('model'), { id: 'a-2' }, 'controller\'s model changed to a-2');
assert.equal(_this3.controller.get('q'), 'lol');
assert.equal(_this3.controller.get('z'), 0);
assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1?q=lol');
assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2?q=lol');
assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3');
_this3.expectedModelHookParams = { id: 'a-3', q: 'lol', z: 123 };
_this3.transitionTo(urlPrefix + '/a-3?q=lol&z=123');
assert.equal(_this3.controller.get('q'), 'lol');
assert.equal(_this3.controller.get('z'), 123);
assert.equal(_this3.$link1.attr('href'), urlPrefix + '/a-1?q=lol');
assert.equal(_this3.$link2.attr('href'), urlPrefix + '/a-2?q=lol');
assert.equal(_this3.$link3.attr('href'), urlPrefix + '/a-3?q=lol&z=123');
});
};
ModelDependentQPTestCase.prototype.queryParamsStickyTest3 = function queryParamsStickyTest3(urlPrefix, articleLookup) {
var _this4 = this;
var assert = this.assert;
assert.expect(32);
this.addTemplate('application', '{{#each articles as |a|}} {{link-to \'Article\' \'' + articleLookup + '\' a.id id=a.id}} {{/each}}');
return this.boot().then(function () {
_this4.expectedModelHookParams = { id: 'a-1', q: 'wat', z: 0 };
_this4.transitionTo(articleLookup, 'a-1');
assert.deepEqual(_this4.controller.get('model'), { id: 'a-1' });
assert.equal(_this4.controller.get('q'), 'wat');
assert.equal(_this4.controller.get('z'), 0);
assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1');
assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2');
assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3');
_this4.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 0 };
_this4.transitionTo(articleLookup, 'a-2', { queryParams: { q: 'lol' } });
assert.deepEqual(_this4.controller.get('model'), { id: 'a-2' });
assert.equal(_this4.controller.get('q'), 'lol');
assert.equal(_this4.controller.get('z'), 0);
assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1');
assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=lol');
assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3');
_this4.expectedModelHookParams = { id: 'a-3', q: 'hay', z: 0 };
_this4.transitionTo(articleLookup, 'a-3', { queryParams: { q: 'hay' } });
assert.deepEqual(_this4.controller.get('model'), { id: 'a-3' });
assert.equal(_this4.controller.get('q'), 'hay');
assert.equal(_this4.controller.get('z'), 0);
assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1');
assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=lol');
assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3?q=hay');
_this4.expectedModelHookParams = { id: 'a-2', q: 'lol', z: 1 };
_this4.transitionTo(articleLookup, 'a-2', { queryParams: { z: 1 } });
assert.deepEqual(_this4.controller.get('model'), { id: 'a-2' });
assert.equal(_this4.controller.get('q'), 'lol');
assert.equal(_this4.controller.get('z'), 1);
assert.equal(_this4.$link1.attr('href'), urlPrefix + '/a-1');
assert.equal(_this4.$link2.attr('href'), urlPrefix + '/a-2?q=lol&z=1');
assert.equal(_this4.$link3.attr('href'), urlPrefix + '/a-3?q=hay');
});
};
ModelDependentQPTestCase.prototype.queryParamsStickyTest4 = function queryParamsStickyTest4(urlPrefix, articleLookup) {
var _this5 = this;
var assert = this.assert;
assert.expect(24);
this.setupApplication();
this.reopenController(articleLookup, {
queryParams: { q: { scope: 'controller' } }
});
return this.visitApplication().then(function () {
(0, _emberMetal.run)(_this5.$link1, 'click');
_this5.assertCurrentPath(urlPrefix + '/a-1');
_this5.setAndFlush(_this5.controller, 'q', 'lol');
assert.equal(_this5.$link1.attr('href'), urlPrefix + '/a-1?q=lol');
assert.equal(_this5.$link2.attr('href'), urlPrefix + '/a-2?q=lol');
assert.equal(_this5.$link3.attr('href'), urlPrefix + '/a-3?q=lol');
(0, _emberMetal.run)(_this5.$link2, 'click');
assert.equal(_this5.controller.get('q'), 'lol');
assert.equal(_this5.controller.get('z'), 0);
assert.deepEqual(_this5.controller.get('model'), { id: 'a-2' });
assert.equal(_this5.$link1.attr('href'), urlPrefix + '/a-1?q=lol');
assert.equal(_this5.$link2.attr('href'), urlPrefix + '/a-2?q=lol');
assert.equal(_this5.$link3.attr('href'), urlPrefix + '/a-3?q=lol');
_this5.expectedModelHookParams = { id: 'a-3', q: 'haha', z: 123 };
_this5.transitionTo(urlPrefix + '/a-3?q=haha&z=123');
assert.deepEqual(_this5.controller.get('model'), { id: 'a-3' });
assert.equal(_this5.controller.get('q'), 'haha');
assert.equal(_this5.controller.get('z'), 123);
assert.equal(_this5.$link1.attr('href'), urlPrefix + '/a-1?q=haha');
assert.equal(_this5.$link2.attr('href'), urlPrefix + '/a-2?q=haha');
assert.equal(_this5.$link3.attr('href'), urlPrefix + '/a-3?q=haha&z=123');
_this5.setAndFlush(_this5.controller, 'q', 'woot');
assert.equal(_this5.$link1.attr('href'), urlPrefix + '/a-1?q=woot');
assert.equal(_this5.$link2.attr('href'), urlPrefix + '/a-2?q=woot');
assert.equal(_this5.$link3.attr('href'), urlPrefix + '/a-3?q=woot&z=123');
});
};
ModelDependentQPTestCase.prototype.queryParamsStickyTest5 = function queryParamsStickyTest5(urlPrefix, commentsLookupKey) {
var _this6 = this;
var assert = this.assert;
assert.expect(12);
return this.boot().then(function () {
_this6.transitionTo(commentsLookupKey, 'a-1');
var commentsCtrl = _this6.getController(commentsLookupKey);
assert.equal(commentsCtrl.get('page'), 1);
_this6.assertCurrentPath(urlPrefix + '/a-1/comments');
_this6.setAndFlush(commentsCtrl, 'page', 2);
_this6.assertCurrentPath(urlPrefix + '/a-1/comments?page=2');
_this6.setAndFlush(commentsCtrl, 'page', 3);
_this6.assertCurrentPath(urlPrefix + '/a-1/comments?page=3');
_this6.transitionTo(commentsLookupKey, 'a-2');
assert.equal(commentsCtrl.get('page'), 1);
_this6.assertCurrentPath(urlPrefix + '/a-2/comments');
_this6.transitionTo(commentsLookupKey, 'a-1');
assert.equal(commentsCtrl.get('page'), 3);
_this6.assertCurrentPath(urlPrefix + '/a-1/comments?page=3');
});
};
ModelDependentQPTestCase.prototype.queryParamsStickyTest6 = function queryParamsStickyTest6(urlPrefix, articleLookup, commentsLookup) {
var _this7 = this;
var assert = this.assert;
assert.expect(13);
this.setupApplication();
this.reopenRoute(articleLookup, {
resetController: function (controller, isExiting) {
this.controllerFor(commentsLookup).set('page', 1);
if (isExiting) {
controller.set('q', 'imdone');
}
}
});
this.addTemplate('about', '{{link-to \'A\' \'' + commentsLookup + '\' \'a-1\' id=\'one\'}} {{link-to \'B\' \'' + commentsLookup + '\' \'a-2\' id=\'two\'}}');
return this.visitApplication().then(function () {
_this7.transitionTo(commentsLookup, 'a-1');
var commentsCtrl = _this7.getController(commentsLookup);
assert.equal(commentsCtrl.get('page'), 1);
_this7.assertCurrentPath(urlPrefix + '/a-1/comments');
_this7.setAndFlush(commentsCtrl, 'page', 2);
_this7.assertCurrentPath(urlPrefix + '/a-1/comments?page=2');
_this7.transitionTo(commentsLookup, 'a-2');
assert.equal(commentsCtrl.get('page'), 1);
assert.equal(_this7.controller.get('q'), 'wat');
_this7.transitionTo(commentsLookup, 'a-1');
_this7.assertCurrentPath(urlPrefix + '/a-1/comments');
assert.equal(commentsCtrl.get('page'), 1);
_this7.transitionTo('about');
assert.equal((0, _emberViews.jQuery)('#one').attr('href'), urlPrefix + '/a-1/comments?q=imdone');
assert.equal((0, _emberViews.jQuery)('#two').attr('href'), urlPrefix + '/a-2/comments');
});
};
return ModelDependentQPTestCase;
}(_internalTestHelpers.QueryParamTestCase);
(0, _internalTestHelpers.moduleFor)('Query Params - model-dependent state', function (_ModelDependentQPTest) {
(0, _emberBabel.inherits)(_class, _ModelDependentQPTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ModelDependentQPTest.apply(this, arguments));
}
_class.prototype.setupApplication = function setupApplication() {
this.router.map(function () {
this.route('article', { path: '/a/:id' }, function () {
this.route('comments', { resetNamespace: true });
});
this.route('about');
});
var articles = (0, _emberRuntime.A)([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]);
this.add('controller:application', _emberRuntime.Controller.extend({
articles: articles
}));
var self = this;
var assert = this.assert;
this.add('route:article', _emberRouting.Route.extend({
model: function (params) {
if (self.expectedModelHookParams) {
assert.deepEqual(params, self.expectedModelHookParams, 'the ArticleRoute model hook received the expected merged dynamic segment + query params hash');
self.expectedModelHookParams = null;
}
return articles.findBy('id', params.id);
}
}));
this.add('controller:article', _emberRuntime.Controller.extend({
queryParams: ['q', 'z'],
q: 'wat',
z: 0
}));
this.add('controller:comments', _emberRuntime.Controller.extend({
queryParams: 'page',
page: 1
}));
this.addTemplate('application', '{{#each articles as |a|}} 1{{link-to \'Article\' \'article\' a id=a.id}} {{/each}} {{outlet}}');
};
_class.prototype.visitApplication = function visitApplication() {
var _this9 = this;
return this.visit('/').then(function () {
var assert = _this9.assert;
_this9.$link1 = (0, _emberViews.jQuery)('#a-1');
_this9.$link2 = (0, _emberViews.jQuery)('#a-2');
_this9.$link3 = (0, _emberViews.jQuery)('#a-3');
assert.equal(_this9.$link1.attr('href'), '/a/a-1');
assert.equal(_this9.$link2.attr('href'), '/a/a-2');
assert.equal(_this9.$link3.attr('href'), '/a/a-3');
_this9.controller = _this9.getController('article');
});
};
_class.prototype['@test query params have \'model\' stickiness by default'] = function testQueryParamsHaveModelStickinessByDefault() {
return this.queryParamsStickyTest1('/a');
};
_class.prototype['@test query params have \'model\' stickiness by default (url changes)'] = function testQueryParamsHaveModelStickinessByDefaultUrlChanges() {
return this.queryParamsStickyTest2('/a');
};
_class.prototype['@test query params have \'model\' stickiness by default (params-based transitions)'] = function testQueryParamsHaveModelStickinessByDefaultParamsBasedTransitions() {
return this.queryParamsStickyTest3('/a', 'article');
};
_class.prototype['@test \'controller\' stickiness shares QP state between models'] = function testControllerStickinessSharesQPStateBetweenModels() {
return this.queryParamsStickyTest4('/a', 'article');
};
_class.prototype['@test \'model\' stickiness is scoped to current or first dynamic parent route'] = function testModelStickinessIsScopedToCurrentOrFirstDynamicParentRoute() {
return this.queryParamsStickyTest5('/a', 'comments');
};
_class.prototype['@test can reset query params using the resetController hook'] = function testCanResetQueryParamsUsingTheResetControllerHook() {
return this.queryParamsStickyTest6('/a', 'article', 'comments');
};
return _class;
}(ModelDependentQPTestCase));
(0, _internalTestHelpers.moduleFor)('Query Params - model-dependent state (nested)', function (_ModelDependentQPTest2) {
(0, _emberBabel.inherits)(_class2, _ModelDependentQPTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _ModelDependentQPTest2.apply(this, arguments));
}
_class2.prototype.setupApplication = function setupApplication() {
this.router.map(function () {
this.route('site', function () {
this.route('article', { path: '/a/:id' }, function () {
this.route('comments');
});
});
this.route('about');
});
var site_articles = (0, _emberRuntime.A)([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]);
this.add('controller:application', _emberRuntime.Controller.extend({
articles: site_articles
}));
var self = this;
var assert = this.assert;
this.add('route:site.article', _emberRouting.Route.extend({
model: function (params) {
if (self.expectedModelHookParams) {
assert.deepEqual(params, self.expectedModelHookParams, 'the ArticleRoute model hook received the expected merged dynamic segment + query params hash');
self.expectedModelHookParams = null;
}
return site_articles.findBy('id', params.id);
}
}));
this.add('controller:site.article', _emberRuntime.Controller.extend({
queryParams: ['q', 'z'],
q: 'wat',
z: 0
}));
this.add('controller:site.article.comments', _emberRuntime.Controller.extend({
queryParams: 'page',
page: 1
}));
this.addTemplate('application', '{{#each articles as |a|}} {{link-to \'Article\' \'site.article\' a id=a.id}} {{/each}} {{outlet}}');
};
_class2.prototype.visitApplication = function visitApplication() {
var _this11 = this;
return this.visit('/').then(function () {
var assert = _this11.assert;
_this11.$link1 = (0, _emberViews.jQuery)('#a-1');
_this11.$link2 = (0, _emberViews.jQuery)('#a-2');
_this11.$link3 = (0, _emberViews.jQuery)('#a-3');
assert.equal(_this11.$link1.attr('href'), '/site/a/a-1');
assert.equal(_this11.$link2.attr('href'), '/site/a/a-2');
assert.equal(_this11.$link3.attr('href'), '/site/a/a-3');
_this11.controller = _this11.getController('site.article');
});
};
_class2.prototype['@test query params have \'model\' stickiness by default'] = function testQueryParamsHaveModelStickinessByDefault() {
return this.queryParamsStickyTest1('/site/a');
};
_class2.prototype['@test query params have \'model\' stickiness by default (url changes)'] = function testQueryParamsHaveModelStickinessByDefaultUrlChanges() {
return this.queryParamsStickyTest2('/site/a');
};
_class2.prototype['@test query params have \'model\' stickiness by default (params-based transitions)'] = function testQueryParamsHaveModelStickinessByDefaultParamsBasedTransitions() {
return this.queryParamsStickyTest3('/site/a', 'site.article');
};
_class2.prototype['@test \'controller\' stickiness shares QP state between models'] = function testControllerStickinessSharesQPStateBetweenModels() {
return this.queryParamsStickyTest4('/site/a', 'site.article');
};
_class2.prototype['@test \'model\' stickiness is scoped to current or first dynamic parent route'] = function testModelStickinessIsScopedToCurrentOrFirstDynamicParentRoute() {
return this.queryParamsStickyTest5('/site/a', 'site.article.comments');
};
_class2.prototype['@test can reset query params using the resetController hook'] = function testCanResetQueryParamsUsingTheResetControllerHook() {
return this.queryParamsStickyTest6('/site/a', 'site.article', 'site.article.comments');
};
return _class2;
}(ModelDependentQPTestCase));
(0, _internalTestHelpers.moduleFor)('Query Params - model-dependent state (nested & more than 1 dynamic segment)', function (_ModelDependentQPTest3) {
(0, _emberBabel.inherits)(_class3, _ModelDependentQPTest3);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
return (0, _emberBabel.possibleConstructorReturn)(this, _ModelDependentQPTest3.apply(this, arguments));
}
_class3.prototype.setupApplication = function setupApplication() {
this.router.map(function () {
this.route('site', { path: '/site/:site_id' }, function () {
this.route('article', { path: '/a/:article_id' }, function () {
this.route('comments');
});
});
});
var sites = (0, _emberRuntime.A)([{ id: 's-1' }, { id: 's-2' }, { id: 's-3' }]);
var site_articles = (0, _emberRuntime.A)([{ id: 'a-1' }, { id: 'a-2' }, { id: 'a-3' }]);
this.add('controller:application', _emberRuntime.Controller.extend({
siteArticles: site_articles,
sites: sites,
allSitesAllArticles: (0, _emberMetal.computed)({
get: function () {
var ret = [];
var siteArticles = this.siteArticles;
var sites = this.sites;
sites.forEach(function (site) {
ret = ret.concat(siteArticles.map(function (article) {
return { id: site.id + '-' + article.id, site_id: site.id, article_id: article.id };
}));
});
return ret;
}
})
}));
var self = this;
var assert = this.assert;
this.add('route:site', _emberRouting.Route.extend({
model: function (params) {
if (self.expectedSiteModelHookParams) {
assert.deepEqual(params, self.expectedSiteModelHookParams, 'the SiteRoute model hook received the expected merged dynamic segment + query params hash');
self.expectedSiteModelHookParams = null;
}
return sites.findBy('id', params.site_id);
}
}));
this.add('route:site.article', _emberRouting.Route.extend({
model: function (params) {
if (self.expectedArticleModelHookParams) {
assert.deepEqual(params, self.expectedArticleModelHookParams, 'the SiteArticleRoute model hook received the expected merged dynamic segment + query params hash');
self.expectedArticleModelHookParams = null;
}
return site_articles.findBy('id', params.article_id);
}
}));
this.add('controller:site', _emberRuntime.Controller.extend({
queryParams: ['country'],
country: 'au'
}));
this.add('controller:site.article', _emberRuntime.Controller.extend({
queryParams: ['q', 'z'],
q: 'wat',
z: 0
}));
this.add('controller:site.article.comments', _emberRuntime.Controller.extend({
queryParams: ['page'],
page: 1
}));
this.addTemplate('application', '{{#each allSitesAllArticles as |a|}} {{#link-to \'site.article\' a.site_id a.article_id id=a.id}}Article [{{a.site_id}}] [{{a.article_id}}]{{/link-to}} {{/each}} {{outlet}}');
};
_class3.prototype.visitApplication = function visitApplication() {
var _this13 = this;
return this.visit('/').then(function () {
var assert = _this13.assert;
_this13.links = {};
_this13.links['s-1-a-1'] = (0, _emberViews.jQuery)('#s-1-a-1');
_this13.links['s-1-a-2'] = (0, _emberViews.jQuery)('#s-1-a-2');
_this13.links['s-1-a-3'] = (0, _emberViews.jQuery)('#s-1-a-3');
_this13.links['s-2-a-1'] = (0, _emberViews.jQuery)('#s-2-a-1');
_this13.links['s-2-a-2'] = (0, _emberViews.jQuery)('#s-2-a-2');
_this13.links['s-2-a-3'] = (0, _emberViews.jQuery)('#s-2-a-3');
_this13.links['s-3-a-1'] = (0, _emberViews.jQuery)('#s-3-a-1');
_this13.links['s-3-a-2'] = (0, _emberViews.jQuery)('#s-3-a-2');
_this13.links['s-3-a-3'] = (0, _emberViews.jQuery)('#s-3-a-3');
assert.equal(_this13.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1');
assert.equal(_this13.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2');
assert.equal(_this13.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3');
assert.equal(_this13.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1');
assert.equal(_this13.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2');
assert.equal(_this13.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3');
assert.equal(_this13.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1');
assert.equal(_this13.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2');
assert.equal(_this13.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3');
_this13.site_controller = _this13.getController('site');
_this13.article_controller = _this13.getController('site.article');
});
};
_class3.prototype['@test query params have \'model\' stickiness by default'] = function testQueryParamsHaveModelStickinessByDefault(assert) {
var _this14 = this;
assert.expect(59);
return this.boot().then(function () {
(0, _emberMetal.run)(_this14.links['s-1-a-1'], 'click');
assert.deepEqual(_this14.site_controller.get('model'), { id: 's-1' });
assert.deepEqual(_this14.article_controller.get('model'), { id: 'a-1' });
_this14.assertCurrentPath('/site/s-1/a/a-1');
_this14.setAndFlush(_this14.article_controller, 'q', 'lol');
assert.equal(_this14.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol');
assert.equal(_this14.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2');
assert.equal(_this14.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3');
assert.equal(_this14.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol');
assert.equal(_this14.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2');
assert.equal(_this14.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3');
assert.equal(_this14.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol');
assert.equal(_this14.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2');
assert.equal(_this14.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3');
_this14.setAndFlush(_this14.site_controller, 'country', 'us');
assert.equal(_this14.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?country=us&q=lol');
assert.equal(_this14.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?country=us');
assert.equal(_this14.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?country=us');
assert.equal(_this14.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol');
assert.equal(_this14.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2');
assert.equal(_this14.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3');
assert.equal(_this14.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol');
assert.equal(_this14.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2');
assert.equal(_this14.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3');
(0, _emberMetal.run)(_this14.links['s-1-a-2'], 'click');
assert.equal(_this14.site_controller.get('country'), 'us');
assert.equal(_this14.article_controller.get('q'), 'wat');
assert.equal(_this14.article_controller.get('z'), 0);
assert.deepEqual(_this14.site_controller.get('model'), { id: 's-1' });
assert.deepEqual(_this14.article_controller.get('model'), { id: 'a-2' });
assert.equal(_this14.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?country=us&q=lol');
assert.equal(_this14.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?country=us');
assert.equal(_this14.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?country=us');
assert.equal(_this14.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol');
assert.equal(_this14.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2');
assert.equal(_this14.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3');
assert.equal(_this14.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol');
assert.equal(_this14.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2');
assert.equal(_this14.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3');
(0, _emberMetal.run)(_this14.links['s-2-a-2'], 'click');
assert.equal(_this14.site_controller.get('country'), 'au');
assert.equal(_this14.article_controller.get('q'), 'wat');
assert.equal(_this14.article_controller.get('z'), 0);
assert.deepEqual(_this14.site_controller.get('model'), { id: 's-2' });
assert.deepEqual(_this14.article_controller.get('model'), { id: 'a-2' });
assert.equal(_this14.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?country=us&q=lol');
assert.equal(_this14.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?country=us');
assert.equal(_this14.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?country=us');
assert.equal(_this14.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol');
assert.equal(_this14.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2');
assert.equal(_this14.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3');
assert.equal(_this14.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol');
assert.equal(_this14.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2');
assert.equal(_this14.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3');
});
};
_class3.prototype['@test query params have \'model\' stickiness by default (url changes)'] = function testQueryParamsHaveModelStickinessByDefaultUrlChanges(assert) {
var _this15 = this;
assert.expect(88);
return this.boot().then(function () {
_this15.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' };
_this15.expectedArticleModelHookParams = { article_id: 'a-1', q: 'lol', z: 0 };
_this15.transitionTo('/site/s-1/a/a-1?q=lol');
assert.deepEqual(_this15.site_controller.get('model'), { id: 's-1' }, 'site controller\'s model is s-1');
assert.deepEqual(_this15.article_controller.get('model'), { id: 'a-1' }, 'article controller\'s model is a-1');
assert.equal(_this15.site_controller.get('country'), 'au');
assert.equal(_this15.article_controller.get('q'), 'lol');
assert.equal(_this15.article_controller.get('z'), 0);
assert.equal(_this15.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol');
assert.equal(_this15.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2');
assert.equal(_this15.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3');
assert.equal(_this15.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?q=lol');
assert.equal(_this15.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2');
assert.equal(_this15.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3');
assert.equal(_this15.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol');
assert.equal(_this15.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2');
assert.equal(_this15.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3');
_this15.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' };
_this15.expectedArticleModelHookParams = { article_id: 'a-1', q: 'lol', z: 0 };
_this15.transitionTo('/site/s-2/a/a-1?country=us&q=lol');
assert.deepEqual(_this15.site_controller.get('model'), { id: 's-2' }, 'site controller\'s model is s-2');
assert.deepEqual(_this15.article_controller.get('model'), { id: 'a-1' }, 'article controller\'s model is a-1');
assert.equal(_this15.site_controller.get('country'), 'us');
assert.equal(_this15.article_controller.get('q'), 'lol');
assert.equal(_this15.article_controller.get('z'), 0);
assert.equal(_this15.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol');
assert.equal(_this15.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2');
assert.equal(_this15.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3');
assert.equal(_this15.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol');
assert.equal(_this15.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us');
assert.equal(_this15.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us');
assert.equal(_this15.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol');
assert.equal(_this15.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2');
assert.equal(_this15.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3');
_this15.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' };
_this15.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 0 };
_this15.transitionTo('/site/s-2/a/a-2?country=us&q=lol');
assert.deepEqual(_this15.site_controller.get('model'), { id: 's-2' }, 'site controller\'s model is s-2');
assert.deepEqual(_this15.article_controller.get('model'), { id: 'a-2' }, 'article controller\'s model is a-2');
assert.equal(_this15.site_controller.get('country'), 'us');
assert.equal(_this15.article_controller.get('q'), 'lol');
assert.equal(_this15.article_controller.get('z'), 0);
assert.equal(_this15.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol');
assert.equal(_this15.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol');
assert.equal(_this15.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3');
assert.equal(_this15.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol');
assert.equal(_this15.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol');
assert.equal(_this15.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us');
assert.equal(_this15.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol');
assert.equal(_this15.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol');
assert.equal(_this15.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3');
_this15.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' };
_this15.expectedArticleModelHookParams = { article_id: 'a-3', q: 'lol', z: 123 };
_this15.transitionTo('/site/s-2/a/a-3?country=us&q=lol&z=123');
assert.deepEqual(_this15.site_controller.get('model'), { id: 's-2' }, 'site controller\'s model is s-2');
assert.deepEqual(_this15.article_controller.get('model'), { id: 'a-3' }, 'article controller\'s model is a-3');
assert.equal(_this15.site_controller.get('country'), 'us');
assert.equal(_this15.article_controller.get('q'), 'lol');
assert.equal(_this15.article_controller.get('z'), 123);
assert.equal(_this15.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol');
assert.equal(_this15.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol');
assert.equal(_this15.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=lol&z=123');
assert.equal(_this15.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol');
assert.equal(_this15.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol');
assert.equal(_this15.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=lol&z=123');
assert.equal(_this15.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=lol');
assert.equal(_this15.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol');
assert.equal(_this15.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=lol&z=123');
_this15.expectedSiteModelHookParams = { site_id: 's-3', country: 'nz' };
_this15.expectedArticleModelHookParams = { article_id: 'a-3', q: 'lol', z: 123 };
_this15.transitionTo('/site/s-3/a/a-3?country=nz&q=lol&z=123');
assert.deepEqual(_this15.site_controller.get('model'), { id: 's-3' }, 'site controller\'s model is s-3');
assert.deepEqual(_this15.article_controller.get('model'), { id: 'a-3' }, 'article controller\'s model is a-3');
assert.equal(_this15.site_controller.get('country'), 'nz');
assert.equal(_this15.article_controller.get('q'), 'lol');
assert.equal(_this15.article_controller.get('z'), 123);
assert.equal(_this15.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=lol');
assert.equal(_this15.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol');
assert.equal(_this15.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=lol&z=123');
assert.equal(_this15.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=lol');
assert.equal(_this15.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol');
assert.equal(_this15.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=lol&z=123');
assert.equal(_this15.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?country=nz&q=lol');
assert.equal(_this15.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?country=nz&q=lol');
assert.equal(_this15.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?country=nz&q=lol&z=123');
});
};
_class3.prototype['@test query params have \'model\' stickiness by default (params-based transitions)'] = function testQueryParamsHaveModelStickinessByDefaultParamsBasedTransitions(assert) {
var _this16 = this;
assert.expect(118);
return this.boot().then(function () {
_this16.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' };
_this16.expectedArticleModelHookParams = { article_id: 'a-1', q: 'wat', z: 0 };
_this16.transitionTo('site.article', 's-1', 'a-1');
assert.deepEqual(_this16.site_controller.get('model'), { id: 's-1' });
assert.deepEqual(_this16.article_controller.get('model'), { id: 'a-1' });
assert.equal(_this16.site_controller.get('country'), 'au');
assert.equal(_this16.article_controller.get('q'), 'wat');
assert.equal(_this16.article_controller.get('z'), 0);
assert.equal(_this16.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1');
assert.equal(_this16.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2');
assert.equal(_this16.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3');
assert.equal(_this16.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1');
assert.equal(_this16.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2');
assert.equal(_this16.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3');
assert.equal(_this16.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1');
assert.equal(_this16.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2');
assert.equal(_this16.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3');
_this16.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' };
_this16.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 0 };
_this16.transitionTo('site.article', 's-1', 'a-2', { queryParams: { q: 'lol' } });
assert.deepEqual(_this16.site_controller.get('model'), { id: 's-1' });
assert.deepEqual(_this16.article_controller.get('model'), { id: 'a-2' });
assert.equal(_this16.site_controller.get('country'), 'au');
assert.equal(_this16.article_controller.get('q'), 'lol');
assert.equal(_this16.article_controller.get('z'), 0);
assert.equal(_this16.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1');
assert.equal(_this16.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol');
assert.equal(_this16.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3');
assert.equal(_this16.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1');
assert.equal(_this16.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?q=lol');
assert.equal(_this16.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3');
assert.equal(_this16.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1');
assert.equal(_this16.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol');
assert.equal(_this16.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3');
_this16.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' };
_this16.expectedArticleModelHookParams = { article_id: 'a-3', q: 'hay', z: 0 };
_this16.transitionTo('site.article', 's-1', 'a-3', { queryParams: { q: 'hay' } });
assert.deepEqual(_this16.site_controller.get('model'), { id: 's-1' });
assert.deepEqual(_this16.article_controller.get('model'), { id: 'a-3' });
assert.equal(_this16.site_controller.get('country'), 'au');
assert.equal(_this16.article_controller.get('q'), 'hay');
assert.equal(_this16.article_controller.get('z'), 0);
assert.equal(_this16.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1');
assert.equal(_this16.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol');
assert.equal(_this16.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay');
assert.equal(_this16.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1');
assert.equal(_this16.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?q=lol');
assert.equal(_this16.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?q=hay');
assert.equal(_this16.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1');
assert.equal(_this16.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol');
assert.equal(_this16.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay');
_this16.expectedSiteModelHookParams = { site_id: 's-1', country: 'au' };
_this16.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 1 };
_this16.transitionTo('site.article', 's-1', 'a-2', { queryParams: { z: 1 } });
assert.deepEqual(_this16.site_controller.get('model'), { id: 's-1' });
assert.deepEqual(_this16.article_controller.get('model'), { id: 'a-2' });
assert.equal(_this16.site_controller.get('country'), 'au');
assert.equal(_this16.article_controller.get('q'), 'lol');
assert.equal(_this16.article_controller.get('z'), 1);
assert.equal(_this16.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1');
assert.equal(_this16.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1');
assert.equal(_this16.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay');
assert.equal(_this16.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1');
assert.equal(_this16.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?q=lol&z=1');
assert.equal(_this16.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?q=hay');
assert.equal(_this16.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1');
assert.equal(_this16.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol&z=1');
assert.equal(_this16.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay');
_this16.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' };
_this16.expectedArticleModelHookParams = { article_id: 'a-2', q: 'lol', z: 1 };
_this16.transitionTo('site.article', 's-2', 'a-2', { queryParams: { country: 'us' } });
assert.deepEqual(_this16.site_controller.get('model'), { id: 's-2' });
assert.deepEqual(_this16.article_controller.get('model'), { id: 'a-2' });
assert.equal(_this16.site_controller.get('country'), 'us');
assert.equal(_this16.article_controller.get('q'), 'lol');
assert.equal(_this16.article_controller.get('z'), 1);
assert.equal(_this16.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1');
assert.equal(_this16.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1');
assert.equal(_this16.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay');
assert.equal(_this16.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us');
assert.equal(_this16.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol&z=1');
assert.equal(_this16.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=hay');
assert.equal(_this16.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1');
assert.equal(_this16.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol&z=1');
assert.equal(_this16.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay');
_this16.expectedSiteModelHookParams = { site_id: 's-2', country: 'us' };
_this16.expectedArticleModelHookParams = { article_id: 'a-1', q: 'yeah', z: 0 };
_this16.transitionTo('site.article', 's-2', 'a-1', { queryParams: { q: 'yeah' } });
assert.deepEqual(_this16.site_controller.get('model'), { id: 's-2' });
assert.deepEqual(_this16.article_controller.get('model'), { id: 'a-1' });
assert.equal(_this16.site_controller.get('country'), 'us');
assert.equal(_this16.article_controller.get('q'), 'yeah');
assert.equal(_this16.article_controller.get('z'), 0);
assert.equal(_this16.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=yeah');
assert.equal(_this16.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1');
assert.equal(_this16.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay');
assert.equal(_this16.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=yeah');
assert.equal(_this16.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol&z=1');
assert.equal(_this16.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=hay');
assert.equal(_this16.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?q=yeah');
assert.equal(_this16.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?q=lol&z=1');
assert.equal(_this16.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?q=hay');
_this16.expectedSiteModelHookParams = { site_id: 's-3', country: 'nz' };
_this16.expectedArticleModelHookParams = { article_id: 'a-3', q: 'hay', z: 3 };
_this16.transitionTo('site.article', 's-3', 'a-3', { queryParams: { country: 'nz', z: 3 } });
assert.deepEqual(_this16.site_controller.get('model'), { id: 's-3' });
assert.deepEqual(_this16.article_controller.get('model'), { id: 'a-3' });
assert.equal(_this16.site_controller.get('country'), 'nz');
assert.equal(_this16.article_controller.get('q'), 'hay');
assert.equal(_this16.article_controller.get('z'), 3);
assert.equal(_this16.links['s-1-a-1'].attr('href'), '/site/s-1/a/a-1?q=yeah');
assert.equal(_this16.links['s-1-a-2'].attr('href'), '/site/s-1/a/a-2?q=lol&z=1');
assert.equal(_this16.links['s-1-a-3'].attr('href'), '/site/s-1/a/a-3?q=hay&z=3');
assert.equal(_this16.links['s-2-a-1'].attr('href'), '/site/s-2/a/a-1?country=us&q=yeah');
assert.equal(_this16.links['s-2-a-2'].attr('href'), '/site/s-2/a/a-2?country=us&q=lol&z=1');
assert.equal(_this16.links['s-2-a-3'].attr('href'), '/site/s-2/a/a-3?country=us&q=hay&z=3');
assert.equal(_this16.links['s-3-a-1'].attr('href'), '/site/s-3/a/a-1?country=nz&q=yeah');
assert.equal(_this16.links['s-3-a-2'].attr('href'), '/site/s-3/a/a-2?country=nz&q=lol&z=1');
assert.equal(_this16.links['s-3-a-3'].attr('href'), '/site/s-3/a/a-3?country=nz&q=hay&z=3');
});
};
return _class3;
}(ModelDependentQPTestCase));
});
QUnit.module('ESLint | ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/query_params_test/model_dependent_state_with_query_params_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/query_params_test/overlapping_query_params_test', ['ember-babel', 'ember-runtime', 'ember-routing', 'ember-metal', 'internal-test-helpers'], function (_emberBabel, _emberRuntime, _emberRouting, _emberMetal, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Query Params - overlapping query param property names', function (_QueryParamTestCase) {
(0, _emberBabel.inherits)(_class, _QueryParamTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _QueryParamTestCase.apply(this, arguments));
}
_class.prototype.setupBase = function setupBase() {
this.router.map(function () {
this.route('parent', function () {
this.route('child');
});
});
return this.visit('/parent/child');
};
_class.prototype['@test can remap same-named qp props'] = function testCanRemapSameNamedQpProps(assert) {
var _this2 = this;
assert.expect(7);
this.setMappedQPController('parent');
this.setMappedQPController('parent.child', 'page', 'childPage');
return this.setupBase().then(function () {
_this2.assertCurrentPath('/parent/child');
var parentController = _this2.getController('parent');
var parentChildController = _this2.getController('parent.child');
_this2.setAndFlush(parentController, 'page', 2);
_this2.assertCurrentPath('/parent/child?parentPage=2');
_this2.setAndFlush(parentController, 'page', 1);
_this2.assertCurrentPath('/parent/child');
_this2.setAndFlush(parentChildController, 'page', 2);
_this2.assertCurrentPath('/parent/child?childPage=2');
_this2.setAndFlush(parentChildController, 'page', 1);
_this2.assertCurrentPath('/parent/child');
(0, _emberMetal.run)(function () {
parentController.set('page', 2);
parentChildController.set('page', 2);
});
_this2.assertCurrentPath('/parent/child?childPage=2&parentPage=2');
(0, _emberMetal.run)(function () {
parentController.set('page', 1);
parentChildController.set('page', 1);
});
_this2.assertCurrentPath('/parent/child');
});
};
_class.prototype['@test query params can be either controller property or url key'] = function testQueryParamsCanBeEitherControllerPropertyOrUrlKey(assert) {
var _this3 = this;
assert.expect(3);
this.setMappedQPController('parent');
return this.setupBase().then(function () {
_this3.assertCurrentPath('/parent/child');
_this3.transitionTo('parent.child', { queryParams: { page: 2 } });
_this3.assertCurrentPath('/parent/child?parentPage=2');
_this3.transitionTo('parent.child', { queryParams: { parentPage: 3 } });
_this3.assertCurrentPath('/parent/child?parentPage=3');
});
};
_class.prototype['@test query param matching a url key and controller property'] = function testQueryParamMatchingAUrlKeyAndControllerProperty(assert) {
var _this4 = this;
assert.expect(3);
this.setMappedQPController('parent', 'page', 'parentPage');
this.setMappedQPController('parent.child', 'index', 'page');
return this.setupBase().then(function () {
_this4.transitionTo('parent.child', { queryParams: { page: 2 } });
_this4.assertCurrentPath('/parent/child?parentPage=2');
_this4.transitionTo('parent.child', { queryParams: { parentPage: 3 } });
_this4.assertCurrentPath('/parent/child?parentPage=3');
_this4.transitionTo('parent.child', { queryParams: { index: 2, page: 2 } });
_this4.assertCurrentPath('/parent/child?page=2&parentPage=2');
});
};
_class.prototype['@test query param matching same property on two controllers use the urlKey higher in the chain'] = function testQueryParamMatchingSamePropertyOnTwoControllersUseTheUrlKeyHigherInTheChain(assert) {
var _this5 = this;
assert.expect(4);
this.setMappedQPController('parent', 'page', 'parentPage');
this.setMappedQPController('parent.child', 'page', 'childPage');
return this.setupBase().then(function () {
_this5.transitionTo('parent.child', { queryParams: { page: 2 } });
_this5.assertCurrentPath('/parent/child?parentPage=2');
_this5.transitionTo('parent.child', { queryParams: { parentPage: 3 } });
_this5.assertCurrentPath('/parent/child?parentPage=3');
_this5.transitionTo('parent.child', { queryParams: { childPage: 2, page: 2 } });
_this5.assertCurrentPath('/parent/child?childPage=2&parentPage=2');
_this5.transitionTo('parent.child', { queryParams: { childPage: 3, parentPage: 4 } });
_this5.assertCurrentPath('/parent/child?childPage=3&parentPage=4');
});
};
_class.prototype['@test query params does not error when a query parameter exists for route instances that share a controller'] = function testQueryParamsDoesNotErrorWhenAQueryParameterExistsForRouteInstancesThatShareAController(assert) {
var _this6 = this;
assert.expect(1);
var parentController = _emberRuntime.Controller.extend({
queryParams: { page: 'page' }
});
this.add('controller:parent', parentController);
this.add('route:parent.child', _emberRouting.Route.extend({ controllerName: 'parent' }));
return this.setupBase('/parent').then(function () {
_this6.transitionTo('parent.child', { queryParams: { page: 2 } });
_this6.assertCurrentPath('/parent/child?page=2');
});
};
_class.prototype['@test query params in the same route hierarchy with the same url key get auto-scoped'] = function testQueryParamsInTheSameRouteHierarchyWithTheSameUrlKeyGetAutoScoped(assert) {
var _this7 = this;
assert.expect(1);
this.setMappedQPController('parent');
this.setMappedQPController('parent.child');
expectAssertion(function () {
_this7.setupBase();
}, 'You\'re not allowed to have more than one controller property map to the same query param key, but both `parent:page` and `parent.child:page` map to `parentPage`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `page: { as: \'other-page\' }`');
};
_class.prototype['@test Support shared but overridable mixin pattern'] = function testSupportSharedButOverridableMixinPattern(assert) {
var _this8 = this;
assert.expect(7);
var HasPage = _emberMetal.Mixin.create({
queryParams: 'page',
page: 1
});
this.add('controller:parent', _emberRuntime.Controller.extend(HasPage, {
queryParams: { page: 'yespage' }
}));
this.add('controller:parent.child', _emberRuntime.Controller.extend(HasPage));
return this.setupBase().then(function () {
_this8.assertCurrentPath('/parent/child');
var parentController = _this8.getController('parent');
var parentChildController = _this8.getController('parent.child');
_this8.setAndFlush(parentChildController, 'page', 2);
_this8.assertCurrentPath('/parent/child?page=2');
assert.equal(parentController.get('page'), 1);
assert.equal(parentChildController.get('page'), 2);
_this8.setAndFlush(parentController, 'page', 2);
_this8.assertCurrentPath('/parent/child?page=2&yespage=2');
assert.equal(parentController.get('page'), 2);
assert.equal(parentChildController.get('page'), 2);
});
};
return _class;
}(_internalTestHelpers.QueryParamTestCase));
});
QUnit.module('ESLint | ember/tests/routing/query_params_test/overlapping_query_params_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/query_params_test/overlapping_query_params_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/query_params_test/query_param_async_get_handler_test', ['ember-babel', 'ember-metal', 'ember-runtime', 'ember-routing', 'internal-test-helpers'], function (_emberBabel, _emberMetal, _emberRuntime, _emberRouting, _internalTestHelpers) {
'use strict';
// These tests mimic what happens with lazily loaded Engines.
(0, _internalTestHelpers.moduleFor)('Query Params - async get handler', function (_QueryParamTestCase) {
(0, _emberBabel.inherits)(_class, _QueryParamTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _QueryParamTestCase.apply(this, arguments));
}
_class.prototype['@test can render a link to an asynchronously loaded route without fetching the route'] = function testCanRenderALinkToAnAsynchronouslyLoadedRouteWithoutFetchingTheRoute(assert) {
var _this2 = this;
assert.expect(4);
this.router.map(function () {
this.route('post', { path: '/post/:id' });
});
this.setSingleQPController('post');
var setupAppTemplate = function () {
_this2.addTemplate('application', '\n {{link-to \'Post\' \'post\' 1337 (query-params foo=\'bar\') class=\'post-link\'}}\n {{link-to \'Post\' \'post\' 7331 (query-params foo=\'boo\') class=\'post-link\'}}\n {{outlet}}\n ');
};
setupAppTemplate();
return this.visitAndAssert('/').then(function () {
assert.equal(_this2.$('.post-link').eq(0).attr('href'), '/post/1337?foo=bar', 'renders correctly with default QP value');
assert.equal(_this2.$('.post-link').eq(1).attr('href'), '/post/7331?foo=boo', 'renders correctly with non-default QP value');
assert.deepEqual(_this2.fetchedHandlers, ['application', 'index'], 'only fetched the handlers for the route we\'re on');
});
};
_class.prototype['@test can transitionTo to an asynchronously loaded route with simple query params'] = function testCanTransitionToToAnAsynchronouslyLoadedRouteWithSimpleQueryParams(assert) {
var _this3 = this;
assert.expect(6);
this.router.map(function () {
this.route('post', { path: '/post/:id' });
this.route('posts');
});
this.setSingleQPController('post');
var postController = void 0;
return this.visitAndAssert('/').then(function () {
postController = _this3.getController('post');
return _this3.transitionTo('posts').then(function () {
_this3.assertCurrentPath('/posts');
});
}).then(function () {
return _this3.transitionTo('post', 1337, { queryParams: { foo: 'boo' } }).then(function () {
assert.equal(postController.get('foo'), 'boo', 'simple QP is correctly set on controller');
_this3.assertCurrentPath('/post/1337?foo=boo');
});
}).then(function () {
return _this3.transitionTo('post', 1337, { queryParams: { foo: 'bar' } }).then(function () {
assert.equal(postController.get('foo'), 'bar', 'simple QP is correctly set with default value');
_this3.assertCurrentPath('/post/1337');
});
});
};
_class.prototype['@test can transitionTo to an asynchronously loaded route with array query params'] = function testCanTransitionToToAnAsynchronouslyLoadedRouteWithArrayQueryParams(assert) {
var _this4 = this;
assert.expect(5);
this.router.map(function () {
this.route('post', { path: '/post/:id' });
});
this.setSingleQPController('post', 'comments', []);
var postController = void 0;
return this.visitAndAssert('/').then(function () {
postController = _this4.getController('post');
return _this4.transitionTo('post', 1337, { queryParams: { comments: [1, 2] } }).then(function () {
assert.deepEqual(postController.get('comments'), [1, 2], 'array QP is correctly set with default value');
_this4.assertCurrentPath('/post/1337?comments=%5B1%2C2%5D');
});
}).then(function () {
return _this4.transitionTo('post', 1338).then(function () {
assert.deepEqual(postController.get('comments'), [], 'array QP is correctly set on controller');
_this4.assertCurrentPath('/post/1338');
});
});
};
_class.prototype['@test can transitionTo to an asynchronously loaded route with mapped query params'] = function testCanTransitionToToAnAsynchronouslyLoadedRouteWithMappedQueryParams(assert) {
var _this5 = this;
assert.expect(7);
this.router.map(function () {
this.route('post', { path: '/post/:id' }, function () {
this.route('index', { path: '/' });
});
});
this.setSingleQPController('post');
this.setMappedQPController('post.index', 'comment', 'note');
var postController = void 0;
var postIndexController = void 0;
return this.visitAndAssert('/').then(function () {
postController = _this5.getController('post');
postIndexController = _this5.getController('post.index');
return _this5.transitionTo('post.index', 1337, { queryParams: { note: 6, foo: 'boo' } }).then(function () {
assert.equal(postController.get('foo'), 'boo', 'simple QP is correctly set on controller');
assert.equal(postIndexController.get('comment'), 6, 'mapped QP is correctly set on controller');
_this5.assertCurrentPath('/post/1337?foo=boo¬e=6');
});
}).then(function () {
return _this5.transitionTo('post', 1337, { queryParams: { foo: 'bar' } }).then(function () {
assert.equal(postController.get('foo'), 'bar', 'simple QP is correctly set with default value');
assert.equal(postIndexController.get('comment'), 6, 'mapped QP retains value scoped to model');
_this5.assertCurrentPath('/post/1337?note=6');
});
});
};
_class.prototype['@test can transitionTo with a URL'] = function testCanTransitionToWithAURL(assert) {
var _this6 = this;
assert.expect(7);
this.router.map(function () {
this.route('post', { path: '/post/:id' }, function () {
this.route('index', { path: '/' });
});
});
this.setSingleQPController('post');
this.setMappedQPController('post.index', 'comment', 'note');
var postController = void 0;
var postIndexController = void 0;
return this.visitAndAssert('/').then(function () {
postController = _this6.getController('post');
postIndexController = _this6.getController('post.index');
return _this6.transitionTo('/post/1337?foo=boo¬e=6').then(function () {
assert.equal(postController.get('foo'), 'boo', 'simple QP is correctly deserialized on controller');
assert.equal(postIndexController.get('comment'), 6, 'mapped QP is correctly deserialized on controller');
_this6.assertCurrentPath('/post/1337?foo=boo¬e=6');
});
}).then(function () {
return _this6.transitionTo('/post/1337?note=6').then(function () {
assert.equal(postController.get('foo'), 'bar', 'simple QP is correctly deserialized with default value');
assert.equal(postIndexController.get('comment'), 6, 'mapped QP retains value scoped to model');
_this6.assertCurrentPath('/post/1337?note=6');
});
});
};
_class.prototype['@test undefined isn\'t serialized or deserialized into a string'] = function testUndefinedIsnTSerializedOrDeserializedIntoAString(assert) {
var _this7 = this;
assert.expect(4);
this.router.map(function () {
this.route('example');
});
this.addTemplate('application', '{{link-to \'Example\' \'example\' (query-params foo=undefined) id=\'the-link\'}}');
this.setSingleQPController('example', 'foo', undefined, {
foo: undefined
});
this.add('route:example', _emberRouting.Route.extend({
model: function (params) {
assert.deepEqual(params, { foo: undefined });
}
}));
return this.visitAndAssert('/').then(function () {
assert.equal(_this7.$('#the-link').attr('href'), '/example', 'renders without undefined qp serialized');
return _this7.transitionTo('example', { queryParams: { foo: undefined } }).then(function () {
_this7.assertCurrentPath('/example');
});
});
};
(0, _emberBabel.createClass)(_class, [{
key: 'routerOptions',
get: function () {
var fetchedHandlers = this.fetchedHandlers = [];
return {
location: 'test',
init: function () {
this._super.apply(this, arguments);
this._seenHandlers = Object.create(null);
this._handlerPromises = Object.create(null);
},
_getQPMeta: function (handlerInfo) {
var handler = this._seenHandlers[handlerInfo.name];
if (handler) {
return (0, _emberMetal.get)(handler, '_qp');
}
},
_getHandlerFunction: function () {
var getHandler = this._super.apply(this, arguments);
var handlerPromises = this._handlerPromises;
var seenHandlers = this._seenHandlers;
return function (routeName) {
fetchedHandlers.push(routeName);
// Cache the returns so we don't have more than one Promise for a
// given handler.
return handlerPromises[routeName] || (handlerPromises[routeName] = new _emberRuntime.RSVP.Promise(function (resolve) {
setTimeout(function () {
var handler = getHandler(routeName);
seenHandlers[routeName] = handler;
resolve(handler);
}, 10);
}));
};
}
};
}
}]);
return _class;
}(_internalTestHelpers.QueryParamTestCase));
});
QUnit.module('ESLint | ember/tests/routing/query_params_test/query_param_async_get_handler_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/query_params_test/query_param_async_get_handler_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/query_params_test/query_params_paramless_link_to_test', ['ember-babel', 'ember-runtime', 'ember-views', 'internal-test-helpers'], function (_emberBabel, _emberRuntime, _emberViews, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Query Params - paramless link-to', function (_QueryParamTestCase) {
(0, _emberBabel.inherits)(_class, _QueryParamTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _QueryParamTestCase.apply(this, arguments));
}
_class.prototype.testParamlessLinks = function testParamlessLinks(assert, routeName) {
assert.expect(1);
this.addTemplate(routeName, '{{link-to \'index\' \'index\' id=\'index-link\'}}');
this.add('controller:' + routeName, _emberRuntime.Controller.extend({
queryParams: ['foo'],
foo: 'wat'
}));
return this.visit('/?foo=YEAH').then(function () {
assert.equal((0, _emberViews.jQuery)('#index-link').attr('href'), '/?foo=YEAH');
});
};
_class.prototype['@test param-less links in an app booted with query params in the URL don\'t reset the query params: application'] = function testParamLessLinksInAnAppBootedWithQueryParamsInTheURLDonTResetTheQueryParamsApplication(assert) {
return this.testParamlessLinks(assert, 'application');
};
_class.prototype['@test param-less links in an app booted with query params in the URL don\'t reset the query params: index'] = function testParamLessLinksInAnAppBootedWithQueryParamsInTheURLDonTResetTheQueryParamsIndex(assert) {
return this.testParamlessLinks(assert, 'index');
};
return _class;
}(_internalTestHelpers.QueryParamTestCase));
});
QUnit.module('ESLint | ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/query_params_test/query_params_paramless_link_to_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/query_params_test/shared_state_test', ['ember-babel', 'ember-runtime', 'ember', 'ember-metal', 'ember-views', 'internal-test-helpers'], function (_emberBabel, _emberRuntime, _ember, _emberMetal, _emberViews, _internalTestHelpers) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Query Params - shared service state', function (_QueryParamTestCase) {
(0, _emberBabel.inherits)(_class, _QueryParamTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _QueryParamTestCase.apply(this, arguments));
}
_class.prototype.boot = function boot() {
this.setupApplication();
return this.visitApplication();
};
_class.prototype.setupApplication = function setupApplication() {
this.router.map(function () {
this.route('home', { path: '/' });
this.route('dashboard');
});
this.add('service:filters', _emberRuntime.Service.extend({
shared: true
}));
this.add('controller:home', _emberRuntime.Controller.extend({
filters: _ember.default.inject.service()
}));
this.add('controller:dashboard', _emberRuntime.Controller.extend({
filters: _ember.default.inject.service(),
queryParams: [{ 'filters.shared': 'shared' }]
}));
this.addTemplate('application', '{{link-to \'Home\' \'home\' }}
{{outlet}}
');
this.addTemplate('home', '{{link-to \'Dashboard\' \'dashboard\' }}{{input type="checkbox" id=\'filters-checkbox\' checked=(mut filters.shared) }}');
this.addTemplate('dashboard', '{{link-to \'Home\' \'home\' }}');
};
_class.prototype.visitApplication = function visitApplication() {
return this.visit('/');
};
_class.prototype['@test can modify shared state before transition'] = function testCanModifySharedStateBeforeTransition(assert) {
var _this2 = this;
assert.expect(1);
return this.boot().then(function () {
_this2.$input = (0, _emberViews.jQuery)('#filters-checkbox');
// click the checkbox once to set filters.shared to false
(0, _emberMetal.run)(_this2.$input, 'click');
return _this2.visit('/dashboard').then(function () {
assert.ok(true, 'expecting navigating to dashboard to succeed');
});
});
};
_class.prototype['@test can modify shared state back to the default value before transition'] = function testCanModifySharedStateBackToTheDefaultValueBeforeTransition(assert) {
var _this3 = this;
assert.expect(1);
return this.boot().then(function () {
_this3.$input = (0, _emberViews.jQuery)('#filters-checkbox');
// click the checkbox twice to set filters.shared to false and back to true
(0, _emberMetal.run)(_this3.$input, 'click');
(0, _emberMetal.run)(_this3.$input, 'click');
return _this3.visit('/dashboard').then(function () {
assert.ok(true, 'expecting navigating to dashboard to succeed');
});
});
};
return _class;
}(_internalTestHelpers.QueryParamTestCase));
});
QUnit.module('ESLint | ember/tests/routing/query_params_test/shared_state_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/query_params_test/shared_state_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/router_map_test', ['ember-babel', 'internal-test-helpers', 'ember-metal', 'ember-routing'], function (_emberBabel, _internalTestHelpers, _emberMetal, _emberRouting) {
'use strict';
(0, _internalTestHelpers.moduleFor)('Router.map', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.apply(this, arguments));
}
_class.prototype['@test Router.map returns an Ember Router class'] = function testRouterMapReturnsAnEmberRouterClass(assert) {
assert.expect(1);
var ret = this.router.map(function () {
this.route('hello');
});
assert.ok(_emberRouting.Router.detect(ret));
};
_class.prototype['@test Router.map can be called multiple times'] = function testRouterMapCanBeCalledMultipleTimes(assert) {
var _this2 = this;
assert.expect(2);
this.addTemplate('hello', 'Hello!');
this.addTemplate('goodbye', 'Goodbye!');
this.router.map(function () {
this.route('hello');
});
this.router.map(function () {
this.route('goodbye');
});
return (0, _emberMetal.run)(function () {
return _this2.visit('/hello').then(function () {
_this2.assertText('Hello!');
}).then(function () {
return _this2.visit('/goodbye');
}).then(function () {
_this2.assertText('Goodbye!');
});
});
};
return _class;
}(_internalTestHelpers.ApplicationTestCase));
});
QUnit.module('ESLint | ember/tests/routing/router_map_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/router_map_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/router_service_test/basic_test', ['ember-babel', 'ember-runtime', 'ember-glimmer', 'ember-routing', 'ember-metal', 'internal-test-helpers', 'ember/features'], function (_emberBabel, _emberRuntime, _emberGlimmer, _emberRouting, _emberMetal, _internalTestHelpers, _features) {
'use strict';
if (_features.EMBER_ROUTING_ROUTER_SERVICE) {
(0, _internalTestHelpers.moduleFor)('Router Service - main', function (_RouterTestCase) {
(0, _emberBabel.inherits)(_class, _RouterTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _RouterTestCase.apply(this, arguments));
}
_class.prototype['@test RouterService#currentRouteName is correctly set for top level route'] = function testRouterServiceCurrentRouteNameIsCorrectlySetForTopLevelRoute(assert) {
var _this2 = this;
assert.expect(1);
return this.visit('/').then(function () {
assert.equal(_this2.routerService.get('currentRouteName'), 'parent.index');
});
};
_class.prototype['@test RouterService#currentRouteName is correctly set for child route'] = function testRouterServiceCurrentRouteNameIsCorrectlySetForChildRoute(assert) {
var _this3 = this;
assert.expect(1);
return this.visit('/child').then(function () {
assert.equal(_this3.routerService.get('currentRouteName'), 'parent.child');
});
};
_class.prototype['@test RouterService#currentRouteName is correctly set after transition'] = function testRouterServiceCurrentRouteNameIsCorrectlySetAfterTransition(assert) {
var _this4 = this;
assert.expect(1);
return this.visit('/child').then(function () {
return _this4.routerService.transitionTo('parent.sister');
}).then(function () {
assert.equal(_this4.routerService.get('currentRouteName'), 'parent.sister');
});
};
_class.prototype['@test RouterService#currentRouteName is correctly set on each transition'] = function testRouterServiceCurrentRouteNameIsCorrectlySetOnEachTransition(assert) {
var _this5 = this;
assert.expect(3);
return this.visit('/child').then(function () {
assert.equal(_this5.routerService.get('currentRouteName'), 'parent.child');
return _this5.visit('/sister');
}).then(function () {
assert.equal(_this5.routerService.get('currentRouteName'), 'parent.sister');
return _this5.visit('/brother');
}).then(function () {
assert.equal(_this5.routerService.get('currentRouteName'), 'parent.brother');
});
};
_class.prototype['@test RouterService#rootURL is correctly set to the default value'] = function testRouterServiceRootURLIsCorrectlySetToTheDefaultValue(assert) {
var _this6 = this;
assert.expect(1);
return this.visit('/').then(function () {
assert.equal(_this6.routerService.get('rootURL'), '/');
});
};
_class.prototype['@test RouterService#rootURL is correctly set to a custom value'] = function testRouterServiceRootURLIsCorrectlySetToACustomValue(assert) {
var _this7 = this;
assert.expect(1);
this.add('route:parent.index', _emberRouting.Route.extend({
init: function () {
this._super();
(0, _emberMetal.set)(this.router, 'rootURL', '/homepage');
}
}));
return this.visit('/').then(function () {
assert.equal(_this7.routerService.get('rootURL'), '/homepage');
});
};
_class.prototype['@test RouterService#location is correctly delegated from router:main'] = function testRouterServiceLocationIsCorrectlyDelegatedFromRouterMain(assert) {
var _this8 = this;
assert.expect(2);
return this.visit('/').then(function () {
var location = _this8.routerService.get('location');
assert.ok(location);
assert.ok(location instanceof _emberRouting.NoneLocation);
});
};
return _class;
}(_internalTestHelpers.RouterTestCase));
}
});
QUnit.module('ESLint | ember/tests/routing/router_service_test/basic_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/router_service_test/basic_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/router_service_test/currenturl_lifecycle_test', ['ember-babel', 'ember-runtime', 'ember-glimmer', 'ember-routing', 'ember-metal', 'internal-test-helpers', 'ember/features'], function (_emberBabel, _emberRuntime, _emberGlimmer, _emberRouting, _emberMetal, _internalTestHelpers, _features) {
'use strict';
if (_features.EMBER_ROUTING_ROUTER_SERVICE) {
var results = [];
var ROUTE_NAMES = ['index', 'child', 'sister', 'brother'];
var InstrumentedRoute = _emberRouting.Route.extend({
routerService: _emberRuntime.inject.service('router'),
beforeModel: function () {
var service = (0, _emberMetal.get)(this, 'routerService');
results.push([service.get('currentRouteName'), 'beforeModel', service.get('currentURL')]);
},
model: function () {
var service = (0, _emberMetal.get)(this, 'routerService');
results.push([service.get('currentRouteName'), 'model', service.get('currentURL')]);
},
afterModel: function () {
var service = (0, _emberMetal.get)(this, 'routerService');
results.push([service.get('currentRouteName'), 'afterModel', service.get('currentURL')]);
}
});
(0, _internalTestHelpers.moduleFor)('Router Service - currentURL', function (_RouterTestCase) {
(0, _emberBabel.inherits)(_class, _RouterTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _RouterTestCase.call(this));
results = [];
ROUTE_NAMES.forEach(function (name) {
var routeName = 'parent.' + name;
_this.add('route:' + routeName, InstrumentedRoute.extend());
_this.addTemplate(routeName, '{{current-url}}');
});
_this.addComponent('current-url', {
ComponentClass: _emberGlimmer.Component.extend({
routerService: _emberRuntime.inject.service('router'),
currentURL: (0, _emberRuntime.readOnly)('routerService.currentURL')
}),
template: '{{currentURL}}'
});
return _this;
}
_class.prototype['@test RouterService#currentURL is correctly set for top level route'] = function testRouterServiceCurrentURLIsCorrectlySetForTopLevelRoute(assert) {
var _this2 = this;
assert.expect(1);
return this.visit('/').then(function () {
assert.equal(_this2.routerService.get('currentURL'), '/');
});
};
_class.prototype['@test RouterService#currentURL is correctly set for child route'] = function testRouterServiceCurrentURLIsCorrectlySetForChildRoute(assert) {
var _this3 = this;
assert.expect(1);
return this.visit('/child').then(function () {
assert.equal(_this3.routerService.get('currentURL'), '/child');
});
};
_class.prototype['@test RouterService#currentURL is correctly set after transition'] = function testRouterServiceCurrentURLIsCorrectlySetAfterTransition(assert) {
var _this4 = this;
assert.expect(1);
return this.visit('/child').then(function () {
return _this4.routerService.transitionTo('parent.sister');
}).then(function () {
assert.equal(_this4.routerService.get('currentURL'), '/sister');
});
};
_class.prototype['@test RouterService#currentURL is correctly set on each transition'] = function testRouterServiceCurrentURLIsCorrectlySetOnEachTransition(assert) {
var _this5 = this;
assert.expect(3);
return this.visit('/child').then(function () {
assert.equal(_this5.routerService.get('currentURL'), '/child');
return _this5.visit('/sister');
}).then(function () {
assert.equal(_this5.routerService.get('currentURL'), '/sister');
return _this5.visit('/brother');
}).then(function () {
assert.equal(_this5.routerService.get('currentURL'), '/brother');
});
};
_class.prototype['@test RouterService#currentURL is not set during lifecycle hooks'] = function testRouterServiceCurrentURLIsNotSetDuringLifecycleHooks(assert) {
var _this6 = this;
assert.expect(2);
return this.visit('/').then(function () {
assert.deepEqual(results, [[null, 'beforeModel', null], [null, 'model', null], [null, 'afterModel', null]]);
results = [];
return _this6.visit('/child');
}).then(function () {
assert.deepEqual(results, [['parent.index', 'beforeModel', '/'], ['parent.index', 'model', '/'], ['parent.index', 'afterModel', '/']]);
});
};
_class.prototype['@test RouterService#currentURL is correctly set with component after consecutive visits'] = function testRouterServiceCurrentURLIsCorrectlySetWithComponentAfterConsecutiveVisits(assert) {
var _this7 = this;
assert.expect(3);
return this.visit('/').then(function () {
_this7.assertText('/');
return _this7.visit('/child');
}).then(function () {
_this7.assertText('/child');
return _this7.visit('/');
}).then(function () {
_this7.assertText('/');
});
};
return _class;
}(_internalTestHelpers.RouterTestCase));
}
});
QUnit.module('ESLint | ember/tests/routing/router_service_test/currenturl_lifecycle_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/router_service_test/currenturl_lifecycle_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/router_service_test/isActive_test', ['ember-babel', 'ember-runtime', 'ember-glimmer', 'ember-routing', 'ember-metal', 'internal-test-helpers', 'ember/features'], function (_emberBabel, _emberRuntime, _emberGlimmer, _emberRouting, _emberMetal, _internalTestHelpers, _features) {
'use strict';
if (_features.EMBER_ROUTING_ROUTER_SERVICE) {
(0, _internalTestHelpers.moduleFor)('Router Service - isActive', function (_RouterTestCase) {
(0, _emberBabel.inherits)(_class, _RouterTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _RouterTestCase.apply(this, arguments));
}
_class.prototype['@test RouterService#isActive returns true for simple route'] = function testRouterServiceIsActiveReturnsTrueForSimpleRoute(assert) {
var _this2 = this;
assert.expect(1);
return this.visit('/').then(function () {
return _this2.routerService.transitionTo('parent.child');
}).then(function () {
return _this2.routerService.transitionTo('parent.sister');
}).then(function () {
assert.ok(_this2.routerService.isActive('parent.sister'));
});
};
_class.prototype['@test RouterService#isActive returns true for simple route with dynamic segments'] = function testRouterServiceIsActiveReturnsTrueForSimpleRouteWithDynamicSegments(assert) {
var _this3 = this;
assert.expect(1);
var dynamicModel = { id: 1 };
return this.visit('/').then(function () {
return _this3.routerService.transitionTo('dynamic', dynamicModel);
}).then(function () {
assert.ok(_this3.routerService.isActive('dynamic', dynamicModel));
});
};
_class.prototype['@test RouterService#isActive does not eagerly instantiate controller for query params'] = function testRouterServiceIsActiveDoesNotEagerlyInstantiateControllerForQueryParams(assert) {
var _this4 = this;
assert.expect(1);
var queryParams = this.buildQueryParams({ sort: 'ASC' });
this.add('controller:parent.sister', _emberRuntime.Controller.extend({
queryParams: ['sort'],
sort: 'ASC',
init: function () {
assert.ok(false, 'should never create');
this._super.apply(this, arguments);
}
}));
return this.visit('/').then(function () {
return _this4.routerService.transitionTo('parent.brother');
}).then(function () {
assert.notOk(_this4.routerService.isActive('parent.sister', queryParams));
});
};
_class.prototype['@test RouterService#isActive is correct for simple route with basic query params'] = function testRouterServiceIsActiveIsCorrectForSimpleRouteWithBasicQueryParams(assert) {
var _this5 = this;
assert.expect(2);
var queryParams = this.buildQueryParams({ sort: 'ASC' });
this.add('controller:parent.child', _emberRuntime.Controller.extend({
queryParams: ['sort'],
sort: 'ASC'
}));
return this.visit('/').then(function () {
return _this5.routerService.transitionTo('parent.child', queryParams);
}).then(function () {
assert.ok(_this5.routerService.isActive('parent.child', queryParams));
assert.notOk(_this5.routerService.isActive('parent.child', _this5.buildQueryParams({ sort: 'DESC' })));
});
};
_class.prototype['@test RouterService#isActive for simple route with array as query params'] = function testRouterServiceIsActiveForSimpleRouteWithArrayAsQueryParams(assert) {
var _this6 = this;
assert.expect(1);
var queryParams = this.buildQueryParams({ sort: ['ascending'] });
return this.visit('/').then(function () {
return _this6.routerService.transitionTo('parent.child', queryParams);
}).then(function () {
assert.notOk(_this6.routerService.isActive('parent.child', _this6.buildQueryParams({ sort: 'descending' })));
});
};
return _class;
}(_internalTestHelpers.RouterTestCase));
}
});
QUnit.module('ESLint | ember/tests/routing/router_service_test/isActive_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/router_service_test/isActive_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/router_service_test/replaceWith_test', ['ember-babel', 'ember-routing', 'internal-test-helpers', 'router', 'ember-runtime', 'ember/features'], function (_emberBabel, _emberRouting, _internalTestHelpers, _router, _emberRuntime, _features) {
'use strict';
if (_features.EMBER_ROUTING_ROUTER_SERVICE) {
(0, _internalTestHelpers.moduleFor)('Router Service - replaceWith', function (_RouterTestCase) {
(0, _emberBabel.inherits)(_class, _RouterTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _RouterTestCase.call(this));
var testCase = _this;
testCase.state = [];
_this.add('location:test', _emberRouting.NoneLocation.extend({
setURL: function (path) {
testCase.state.push(path);
this.set('path', path);
},
replaceURL: function (path) {
testCase.state.splice(testCase.state.length - 1, 1, path);
this.set('path', path);
}
}));
return _this;
}
_class.prototype['@test RouterService#replaceWith returns a Transition'] = function testRouterServiceReplaceWithReturnsATransition(assert) {
var _this2 = this;
assert.expect(1);
var transition = void 0;
return this.visit('/').then(function () {
transition = _this2.routerService.replaceWith('parent.child');
assert.ok(transition instanceof _router.Transition);
return transition;
});
};
_class.prototype['@test RouterService#replaceWith with basic route replaces location'] = function testRouterServiceReplaceWithWithBasicRouteReplacesLocation(assert) {
var _this3 = this;
assert.expect(1);
return this.visit('/').then(function () {
return _this3.routerService.transitionTo('parent.child');
}).then(function () {
return _this3.routerService.transitionTo('parent.sister');
}).then(function () {
return _this3.routerService.replaceWith('parent.brother');
}).then(function () {
assert.deepEqual(_this3.state, ['/', '/child', '/brother']);
});
};
_class.prototype['@test RouterService#replaceWith with basic route using URLs replaces location'] = function testRouterServiceReplaceWithWithBasicRouteUsingURLsReplacesLocation(assert) {
var _this4 = this;
assert.expect(1);
return this.visit('/').then(function () {
return _this4.routerService.transitionTo('/child');
}).then(function () {
return _this4.routerService.transitionTo('/sister');
}).then(function () {
return _this4.routerService.replaceWith('/brother');
}).then(function () {
assert.deepEqual(_this4.state, ['/', '/child', '/brother']);
});
};
_class.prototype['@test RouterService#replaceWith transitioning back to previously visited route replaces location'] = function testRouterServiceReplaceWithTransitioningBackToPreviouslyVisitedRouteReplacesLocation(assert) {
var _this5 = this;
assert.expect(1);
return this.visit('/').then(function () {
return _this5.routerService.transitionTo('parent.child');
}).then(function () {
return _this5.routerService.transitionTo('parent.sister');
}).then(function () {
return _this5.routerService.transitionTo('parent.brother');
}).then(function () {
return _this5.routerService.replaceWith('parent.sister');
}).then(function () {
assert.deepEqual(_this5.state, ['/', '/child', '/sister', '/sister']);
});
};
_class.prototype['@test RouterService#replaceWith with basic query params does not remove query param defaults'] = function testRouterServiceReplaceWithWithBasicQueryParamsDoesNotRemoveQueryParamDefaults(assert) {
var _this6 = this;
assert.expect(1);
this.add('controller:parent.child', _emberRuntime.Controller.extend({
queryParams: ['sort'],
sort: 'ASC'
}));
var queryParams = this.buildQueryParams({ sort: 'ASC' });
return this.visit('/').then(function () {
return _this6.routerService.transitionTo('parent.brother');
}).then(function () {
return _this6.routerService.replaceWith('parent.sister');
}).then(function () {
return _this6.routerService.replaceWith('parent.child', queryParams);
}).then(function () {
assert.deepEqual(_this6.state, ['/', '/child?sort=ASC']);
});
};
(0, _emberBabel.createClass)(_class, [{
key: 'routerOptions',
get: function () {
return {
location: 'test'
};
}
}]);
return _class;
}(_internalTestHelpers.RouterTestCase));
}
});
QUnit.module('ESLint | ember/tests/routing/router_service_test/replaceWith_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/router_service_test/replaceWith_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/router_service_test/transitionTo_test', ['ember-babel', 'ember-runtime', 'ember-glimmer', 'ember-routing', 'ember-metal', 'internal-test-helpers', 'router', 'ember/features'], function (_emberBabel, _emberRuntime, _emberGlimmer, _emberRouting, _emberMetal, _internalTestHelpers, _router, _features) {
'use strict';
if (_features.EMBER_ROUTING_ROUTER_SERVICE) {
(0, _internalTestHelpers.moduleFor)('Router Service - transitionTo', function (_RouterTestCase) {
(0, _emberBabel.inherits)(_class, _RouterTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _RouterTestCase.call(this));
var testCase = _this;
testCase.state = [];
_this.add('location:test', _emberRouting.NoneLocation.extend({
setURL: function (path) {
testCase.state.push(path);
this.set('path', path);
},
replaceURL: function (path) {
testCase.state.splice(testCase.state.length - 1, 1, path);
this.set('path', path);
}
}));
return _this;
}
_class.prototype['@test RouterService#transitionTo returns a Transition'] = function testRouterServiceTransitionToReturnsATransition(assert) {
var _this2 = this;
assert.expect(1);
var transition = void 0;
return this.visit('/').then(function () {
transition = _this2.routerService.transitionTo('parent.child');
assert.ok(transition instanceof _router.Transition);
return transition;
});
};
_class.prototype['@test RouterService#transitionTo with basic route updates location'] = function testRouterServiceTransitionToWithBasicRouteUpdatesLocation(assert) {
var _this3 = this;
assert.expect(1);
return this.visit('/').then(function () {
return _this3.routerService.transitionTo('parent.child');
}).then(function () {
return _this3.routerService.transitionTo('parent.sister');
}).then(function () {
return _this3.routerService.transitionTo('parent.brother');
}).then(function () {
assert.deepEqual(_this3.state, ['/', '/child', '/sister', '/brother']);
});
};
_class.prototype['@test RouterService#transitionTo transitioning back to previously visited route updates location'] = function testRouterServiceTransitionToTransitioningBackToPreviouslyVisitedRouteUpdatesLocation(assert) {
var _this4 = this;
assert.expect(1);
return this.visit('/').then(function () {
return _this4.routerService.transitionTo('parent.child');
}).then(function () {
return _this4.routerService.transitionTo('parent.sister');
}).then(function () {
return _this4.routerService.transitionTo('parent.brother');
}).then(function () {
return _this4.routerService.transitionTo('parent.sister');
}).then(function () {
assert.deepEqual(_this4.state, ['/', '/child', '/sister', '/brother', '/sister']);
});
};
_class.prototype['@test RouterService#transitionTo with basic route'] = function testRouterServiceTransitionToWithBasicRoute(assert) {
var _this5 = this;
assert.expect(1);
var componentInstance = void 0;
this.addTemplate('parent.index', '{{foo-bar}}');
this.addComponent('foo-bar', {
ComponentClass: _emberGlimmer.Component.extend({
routerService: _emberRuntime.inject.service('router'),
init: function () {
this._super();
componentInstance = this;
},
actions: {
transitionToSister: function () {
(0, _emberMetal.get)(this, 'routerService').transitionTo('parent.sister');
}
}
}),
template: 'foo-bar'
});
return this.visit('/').then(function () {
(0, _emberMetal.run)(function () {
componentInstance.send('transitionToSister');
});
assert.equal(_this5.routerService.get('currentRouteName'), 'parent.sister');
});
};
_class.prototype['@test RouterService#transitionTo with basic route using URL'] = function testRouterServiceTransitionToWithBasicRouteUsingURL(assert) {
var _this6 = this;
assert.expect(1);
var componentInstance = void 0;
this.addTemplate('parent.index', '{{foo-bar}}');
this.addComponent('foo-bar', {
ComponentClass: _emberGlimmer.Component.extend({
routerService: _emberRuntime.inject.service('router'),
init: function () {
this._super();
componentInstance = this;
},
actions: {
transitionToSister: function () {
(0, _emberMetal.get)(this, 'routerService').transitionTo('/sister');
}
}
}),
template: 'foo-bar'
});
return this.visit('/').then(function () {
(0, _emberMetal.run)(function () {
componentInstance.send('transitionToSister');
});
assert.equal(_this6.routerService.get('currentRouteName'), 'parent.sister');
});
};
_class.prototype['@test RouterService#transitionTo with dynamic segment'] = function testRouterServiceTransitionToWithDynamicSegment(assert) {
var _this7 = this;
assert.expect(3);
var componentInstance = void 0;
var dynamicModel = { id: 1, contents: 'much dynamicism' };
this.addTemplate('parent.index', '{{foo-bar}}');
this.addTemplate('dynamic', '{{model.contents}}');
this.addComponent('foo-bar', {
ComponentClass: _emberGlimmer.Component.extend({
routerService: _emberRuntime.inject.service('router'),
init: function () {
this._super();
componentInstance = this;
},
actions: {
transitionToDynamic: function () {
(0, _emberMetal.get)(this, 'routerService').transitionTo('dynamic', dynamicModel);
}
}
}),
template: 'foo-bar'
});
return this.visit('/').then(function () {
(0, _emberMetal.run)(function () {
componentInstance.send('transitionToDynamic');
});
assert.equal(_this7.routerService.get('currentRouteName'), 'dynamic');
assert.equal(_this7.routerService.get('currentURL'), '/dynamic/1');
_this7.assertText('much dynamicism');
});
};
_class.prototype['@test RouterService#transitionTo with dynamic segment and model hook'] = function testRouterServiceTransitionToWithDynamicSegmentAndModelHook(assert) {
var _this8 = this;
assert.expect(3);
var componentInstance = void 0;
var dynamicModel = { id: 1, contents: 'much dynamicism' };
this.add('route:dynamic', _emberRouting.Route.extend({
model: function () {
return dynamicModel;
}
}));
this.addTemplate('parent.index', '{{foo-bar}}');
this.addTemplate('dynamic', '{{model.contents}}');
this.addComponent('foo-bar', {
ComponentClass: _emberGlimmer.Component.extend({
routerService: _emberRuntime.inject.service('router'),
init: function () {
this._super();
componentInstance = this;
},
actions: {
transitionToDynamic: function () {
(0, _emberMetal.get)(this, 'routerService').transitionTo('dynamic', 1);
}
}
}),
template: 'foo-bar'
});
return this.visit('/').then(function () {
(0, _emberMetal.run)(function () {
componentInstance.send('transitionToDynamic');
});
assert.equal(_this8.routerService.get('currentRouteName'), 'dynamic');
assert.equal(_this8.routerService.get('currentURL'), '/dynamic/1');
_this8.assertText('much dynamicism');
});
};
_class.prototype['@test RouterService#transitionTo with basic query params does not remove query param defaults'] = function testRouterServiceTransitionToWithBasicQueryParamsDoesNotRemoveQueryParamDefaults(assert) {
var _this9 = this;
assert.expect(1);
this.add('controller:parent.child', _emberRuntime.Controller.extend({
queryParams: ['sort'],
sort: 'ASC'
}));
var queryParams = this.buildQueryParams({ sort: 'ASC' });
return this.visit('/').then(function () {
return _this9.routerService.transitionTo('parent.child', queryParams);
}).then(function () {
assert.equal(_this9.routerService.get('currentURL'), '/child?sort=ASC');
});
};
_class.prototype['@test RouterService#transitionTo with unspecified query params'] = function testRouterServiceTransitionToWithUnspecifiedQueryParams(assert) {
var _this10 = this;
assert.expect(1);
this.add('controller:parent.child', _emberRuntime.Controller.extend({
queryParams: ['sort', 'page', 'category', 'extra'],
sort: 'ASC',
page: null,
category: undefined
}));
var queryParams = this.buildQueryParams({ sort: 'ASC' });
return this.visit('/').then(function () {
return _this10.routerService.transitionTo('parent.child', queryParams);
}).then(function () {
assert.equal(_this10.routerService.get('currentURL'), '/child?sort=ASC');
});
};
_class.prototype['@test RouterService#transitionTo with aliased query params uses the original provided key'] = function testRouterServiceTransitionToWithAliasedQueryParamsUsesTheOriginalProvidedKey(assert) {
var _this11 = this;
assert.expect(1);
this.add('controller:parent.child', _emberRuntime.Controller.extend({
queryParams: {
'cont_sort': 'url_sort'
},
cont_sort: 'ASC'
}));
var queryParams = this.buildQueryParams({ url_sort: 'ASC' });
return this.visit('/').then(function () {
return _this11.routerService.transitionTo('parent.child', queryParams);
}).then(function () {
assert.equal(_this11.routerService.get('currentURL'), '/child?url_sort=ASC');
});
};
_class.prototype['@test RouterService#transitionTo with aliased query params uses the original provided key when controller property name'] = function testRouterServiceTransitionToWithAliasedQueryParamsUsesTheOriginalProvidedKeyWhenControllerPropertyName(assert) {
var _this12 = this;
assert.expect(1);
this.add('controller:parent.child', _emberRuntime.Controller.extend({
queryParams: {
'cont_sort': 'url_sort'
},
cont_sort: 'ASC'
}));
var queryParams = this.buildQueryParams({ cont_sort: 'ASC' });
return this.visit('/').then(function () {
expectAssertion(function () {
return _this12.routerService.transitionTo('parent.child', queryParams);
}, 'You passed the `cont_sort` query parameter during a transition into parent.child, please update to url_sort');
});
};
(0, _emberBabel.createClass)(_class, [{
key: 'routerOptions',
get: function () {
return {
location: 'test'
};
}
}]);
return _class;
}(_internalTestHelpers.RouterTestCase));
}
});
QUnit.module('ESLint | ember/tests/routing/router_service_test/transitionTo_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/router_service_test/transitionTo_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/router_service_test/urlFor_test', ['ember-babel', 'ember-runtime', 'ember-routing', 'ember-metal', 'internal-test-helpers', 'ember/features'], function (_emberBabel, _emberRuntime, _emberRouting, _emberMetal, _internalTestHelpers, _features) {
'use strict';
function setupController(app, name) {
var controllerName = _emberRuntime.String.capitalize(name) + 'Controller';
Object.defineProperty(app, controllerName, {
get: function () {
throw new Error('Generating a URL should not require instantiation of a ' + controllerName + '.');
}
});
}
if (_features.EMBER_ROUTING_ROUTER_SERVICE) {
(0, _internalTestHelpers.moduleFor)('Router Service - urlFor', function (_RouterTestCase) {
(0, _emberBabel.inherits)(_class, _RouterTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _RouterTestCase.apply(this, arguments));
}
_class.prototype['@test RouterService#urlFor returns URL for simple route'] = function testRouterServiceUrlForReturnsURLForSimpleRoute(assert) {
var _this2 = this;
assert.expect(1);
return this.visit('/').then(function () {
var expectedURL = _this2.routerService.urlFor('parent.child');
assert.equal('/child', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with dynamic segments'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithDynamicSegments(assert) {
var _this3 = this;
assert.expect(1);
setupController(this.application, 'dynamic');
var dynamicModel = { id: 1, contents: 'much dynamicism' };
return this.visit('/').then(function () {
var expectedURL = _this3.routerService.urlFor('dynamic', dynamicModel);
assert.equal('/dynamic/1', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with basic query params'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithBasicQueryParams(assert) {
var _this4 = this;
assert.expect(1);
var queryParams = this.buildQueryParams({ foo: 'bar' });
return this.visit('/').then(function () {
var expectedURL = _this4.routerService.urlFor('parent.child', queryParams);
assert.equal('/child?foo=bar', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with basic query params and default value'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithBasicQueryParamsAndDefaultValue(assert) {
var _this5 = this;
assert.expect(1);
this.add('controller:parent.child', _emberRuntime.Controller.extend({
queryParams: ['sort'],
sort: 'ASC'
}));
var queryParams = this.buildQueryParams({ sort: 'ASC' });
return this.visit('/').then(function () {
var expectedURL = _this5.routerService.urlFor('parent.child', queryParams);
assert.equal('/child?sort=ASC', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with basic query params and default value with stickyness'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithBasicQueryParamsAndDefaultValueWithStickyness(assert) {
var _this6 = this;
assert.expect(2);
this.add('controller:parent.child', _emberRuntime.Controller.extend({
queryParams: ['sort', 'foo'],
sort: 'ASC'
}));
var queryParams = this.buildQueryParams({ sort: 'DESC' });
return this.visit('/child/?sort=DESC').then(function () {
var controller = _this6.applicationInstance.lookup('controller:parent.child');
assert.equal((0, _emberMetal.get)(controller, 'sort'), 'DESC', 'sticky is set');
var queryParams = _this6.buildQueryParams({ foo: 'derp' });
var actual = _this6.routerService.urlFor('parent.child', queryParams);
assert.equal(actual, '/child?foo=derp', 'does not use "stickiness"');
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with array as query params'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithArrayAsQueryParams(assert) {
var _this7 = this;
assert.expect(1);
var queryParams = this.buildQueryParams({ selectedItems: ['a', 'b', 'c'] });
return this.visit('/').then(function () {
var expectedURL = _this7.routerService.urlFor('parent.child', queryParams);
assert.equal('/child?selectedItems[]=a&selectedItems[]=b&selectedItems[]=c', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with null query params'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithNullQueryParams(assert) {
var _this8 = this;
assert.expect(1);
var queryParams = this.buildQueryParams({ foo: null });
return this.visit('/').then(function () {
var expectedURL = _this8.routerService.urlFor('parent.child', queryParams);
assert.equal('/child', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with undefined query params'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithUndefinedQueryParams(assert) {
var _this9 = this;
assert.expect(1);
var queryParams = this.buildQueryParams({ foo: undefined });
return this.visit('/').then(function () {
var expectedURL = _this9.routerService.urlFor('parent.child', queryParams);
assert.equal('/child', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with dynamic segments and basic query params'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithDynamicSegmentsAndBasicQueryParams(assert) {
var _this10 = this;
assert.expect(1);
var queryParams = this.buildQueryParams({ foo: 'bar' });
return this.visit('/').then(function () {
var expectedURL = _this10.routerService.urlFor('dynamic', { id: 1 }, queryParams);
assert.equal('/dynamic/1?foo=bar', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with dynamic segments and array as query params'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithDynamicSegmentsAndArrayAsQueryParams(assert) {
var _this11 = this;
assert.expect(1);
var queryParams = this.buildQueryParams({ selectedItems: ['a', 'b', 'c'] });
return this.visit('/').then(function () {
var expectedURL = _this11.routerService.urlFor('dynamic', { id: 1 }, queryParams);
assert.equal('/dynamic/1?selectedItems[]=a&selectedItems[]=b&selectedItems[]=c', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with dynamic segments and null query params'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithDynamicSegmentsAndNullQueryParams(assert) {
var _this12 = this;
assert.expect(1);
var queryParams = this.buildQueryParams({ foo: null });
return this.visit('/').then(function () {
var expectedURL = _this12.routerService.urlFor('dynamic', { id: 1 }, queryParams);
assert.equal('/dynamic/1', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor returns URL for simple route with dynamic segments and undefined query params'] = function testRouterServiceUrlForReturnsURLForSimpleRouteWithDynamicSegmentsAndUndefinedQueryParams(assert) {
var _this13 = this;
assert.expect(1);
var queryParams = this.buildQueryParams({ foo: undefined });
return this.visit('/').then(function () {
var expectedURL = _this13.routerService.urlFor('dynamic', { id: 1 }, queryParams);
assert.equal('/dynamic/1', expectedURL);
});
};
_class.prototype['@test RouterService#urlFor correctly transitions to route via generated path'] = function testRouterServiceUrlForCorrectlyTransitionsToRouteViaGeneratedPath(assert) {
var _this14 = this;
assert.expect(1);
var expectedURL = void 0;
return this.visit('/').then(function () {
expectedURL = _this14.routerService.urlFor('parent.child');
return _this14.routerService.transitionTo(expectedURL);
}).then(function () {
assert.equal(expectedURL, _this14.routerService.get('currentURL'));
});
};
_class.prototype['@test RouterService#urlFor correctly transitions to route via generated path with dynamic segments'] = function testRouterServiceUrlForCorrectlyTransitionsToRouteViaGeneratedPathWithDynamicSegments(assert) {
var _this15 = this;
assert.expect(1);
var expectedURL = void 0;
var dynamicModel = { id: 1 };
this.add('route:dynamic', _emberRouting.Route.extend({
model: function () {
return dynamicModel;
}
}));
return this.visit('/').then(function () {
expectedURL = _this15.routerService.urlFor('dynamic', dynamicModel);
return _this15.routerService.transitionTo(expectedURL);
}).then(function () {
assert.equal(expectedURL, _this15.routerService.get('currentURL'));
});
};
_class.prototype['@test RouterService#urlFor correctly transitions to route via generated path with query params'] = function testRouterServiceUrlForCorrectlyTransitionsToRouteViaGeneratedPathWithQueryParams(assert) {
var _this16 = this;
assert.expect(1);
var expectedURL = void 0;
var actualURL = void 0;
var queryParams = this.buildQueryParams({ foo: 'bar' });
return this.visit('/').then(function () {
expectedURL = _this16.routerService.urlFor('parent.child', queryParams);
return _this16.routerService.transitionTo(expectedURL);
}).then(function () {
actualURL = _this16.routerService.get('currentURL') + '?foo=bar';
assert.equal(expectedURL, actualURL);
});
};
_class.prototype['@test RouterService#urlFor correctly transitions to route via generated path with dynamic segments and query params'] = function testRouterServiceUrlForCorrectlyTransitionsToRouteViaGeneratedPathWithDynamicSegmentsAndQueryParams(assert) {
var _this17 = this;
assert.expect(1);
var expectedURL = void 0;
var actualURL = void 0;
var queryParams = this.buildQueryParams({ foo: 'bar' });
var dynamicModel = { id: 1 };
this.add('route:dynamic', _emberRouting.Route.extend({
model: function () {
return dynamicModel;
}
}));
return this.visit('/').then(function () {
expectedURL = _this17.routerService.urlFor('dynamic', dynamicModel, queryParams);
return _this17.routerService.transitionTo(expectedURL);
}).then(function () {
actualURL = _this17.routerService.get('currentURL') + '?foo=bar';
assert.equal(expectedURL, actualURL);
});
};
return _class;
}(_internalTestHelpers.RouterTestCase));
}
});
QUnit.module('ESLint | ember/tests/routing/router_service_test/urlFor_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember/tests/routing/router_service_test/urlFor_test.js should pass ESLint\n\n');
});
enifed('ember/tests/routing/substates_test', ['ember-babel', 'ember-runtime', 'ember-routing', 'internal-test-helpers'], function (_emberBabel, _emberRuntime, _emberRouting, _internalTestHelpers) {
'use strict';
var counter = void 0;
function step(expectedValue, description) {
equal(counter, expectedValue, 'Step ' + expectedValue + ': ' + description);
counter++;
}
(0, _internalTestHelpers.moduleFor)('Loading/Error Substates', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.call(this));
counter = 1;
_this.addTemplate('application', '
{{outlet}}
');
_this.addTemplate('index', 'INDEX');
return _this;
}
_class.prototype.getController = function getController(name) {
return this.applicationInstance.lookup('controller:' + name);
};
_class.prototype['@test Slow promise from a child route of application enters nested loading state'] = function testSlowPromiseFromAChildRouteOfApplicationEntersNestedLoadingState(assert) {
var _this2 = this;
var turtleDeferred = _emberRuntime.RSVP.defer();
this.router.map(function () {
this.route('turtle');
});
this.add('route:application', _emberRouting.Route.extend({
setupController: function () {
step(2, 'ApplicationRoute#setupController');
}
}));
this.add('route:turtle', _emberRouting.Route.extend({
model: function () {
step(1, 'TurtleRoute#model');
return turtleDeferred.promise;
}
}));
this.addTemplate('turtle', 'TURTLE');
this.addTemplate('loading', 'LOADING');
var promise = this.visit('/turtle').then(function () {
text = _this2.$('#app').text();
assert.equal(text, 'TURTLE', 'turtle template has loaded and replaced the loading template');
});
var text = this.$('#app').text();
assert.equal(text, 'LOADING', 'The Loading template is nested in application template\'s outlet');
turtleDeferred.resolve();
return promise;
};
_class.prototype['@test Slow promises returned from ApplicationRoute#model don\'t enter LoadingRoute'] = function (assert) {
var _this3 = this;
var appDeferred = _emberRuntime.RSVP.defer();
this.add('route:application', _emberRouting.Route.extend({
model: function () {
return appDeferred.promise;
}
}));
this.add('route:loading', _emberRouting.Route.extend({
setupController: function () {
ok(false, 'shouldn\'t get here');
}
}));
var promise = this.visit('/').then(function () {
text = _this3.$('#app').text();
assert.equal(text, 'INDEX', 'index template has been rendered');
});
var text = this.$('#app').text();
assert.equal(text, '', 'nothing has been rendered yet');
appDeferred.resolve();
return promise;
};
_class.prototype['@test Don\'t enter loading route unless either route or template defined'] = function (assert) {
var _this4 = this;
var deferred = _emberRuntime.RSVP.defer();
this.router.map(function () {
this.route('dummy');
});
this.add('route:dummy', _emberRouting.Route.extend({
model: function () {
return deferred.promise;
}
}));
this.addTemplate('dummy', 'DUMMY');
return this.visit('/').then(function () {
var promise = _this4.visit('/dummy').then(function () {
var text = _this4.$('#app').text();
assert.equal(text, 'DUMMY', 'dummy template has been rendered');
});
assert.ok(_this4.currentPath !== 'loading', '\n loading state not entered\n ');
deferred.resolve();
return promise;
});
};
_class.prototype['@test Enter loading route only if loadingRoute is defined'] = function testEnterLoadingRouteOnlyIfLoadingRouteIsDefined(assert) {
var _this5 = this;
var deferred = _emberRuntime.RSVP.defer();
this.router.map(function () {
this.route('dummy');
});
this.add('route:dummy', _emberRouting.Route.extend({
model: function () {
step(1, 'DummyRoute#model');
return deferred.promise;
}
}));
this.add('route:loading', _emberRouting.Route.extend({
setupController: function () {
step(2, 'LoadingRoute#setupController');
}
}));
this.addTemplate('dummy', 'DUMMY');
return this.visit('/').then(function () {
var promise = _this5.visit('/dummy').then(function () {
var text = _this5.$('#app').text();
assert.equal(text, 'DUMMY', 'dummy template has been rendered');
});
assert.equal(_this5.currentPath, 'loading', 'loading state entered');
deferred.resolve();
return promise;
});
};
_class.prototype['@test Slow promises returned from ApplicationRoute#model enter ApplicationLoadingRoute if present'] = function testSlowPromisesReturnedFromApplicationRouteModelEnterApplicationLoadingRouteIfPresent(assert) {
var _this6 = this;
var appDeferred = _emberRuntime.RSVP.defer();
this.add('route:application', _emberRouting.Route.extend({
model: function () {
return appDeferred.promise;
}
}));
var loadingRouteEntered = false;
this.add('route:application_loading', _emberRouting.Route.extend({
setupController: function () {
loadingRouteEntered = true;
}
}));
var promise = this.visit('/').then(function () {
assert.equal(_this6.$('#app').text(), 'INDEX', 'index route loaded');
});
assert.ok(loadingRouteEntered, 'ApplicationLoadingRoute was entered');
appDeferred.resolve();
return promise;
};
_class.prototype['@test Slow promises returned from ApplicationRoute#model enter application_loading if template present'] = function testSlowPromisesReturnedFromApplicationRouteModelEnterApplication_loadingIfTemplatePresent(assert) {
var _this7 = this;
var appDeferred = _emberRuntime.RSVP.defer();
this.addTemplate('application_loading', '\n
TOPLEVEL LOADING
\n ');
this.add('route:application', _emberRouting.Route.extend({
model: function () {
return appDeferred.promise;
}
}));
var promise = this.visit('/').then(function () {
var length = _this7.$('#toplevel-loading').length;
text = _this7.$('#app').text();
assert.equal(length, 0, 'top-level loading view has been entirely removed from the DOM');
assert.equal(text, 'INDEX', 'index has fully rendered');
});
var text = this.$('#toplevel-loading').text();
assert.equal(text, 'TOPLEVEL LOADING', 'still loading the top level');
appDeferred.resolve();
return promise;
};
_class.prototype['@test Prioritized substate entry works with preserved-namespace nested routes'] = function testPrioritizedSubstateEntryWorksWithPreservedNamespaceNestedRoutes(assert) {
var _this8 = this;
var deferred = _emberRuntime.RSVP.defer();
this.addTemplate('foo.bar_loading', 'FOOBAR LOADING');
this.addTemplate('foo.bar.index', 'YAY');
this.router.map(function () {
this.route('foo', function () {
this.route('bar', { path: '/bar' }, function () {});
});
});
this.add('route:foo.bar', _emberRouting.Route.extend({
model: function () {
return deferred.promise;
}
}));
return this.visit('/').then(function () {
var promise = _this8.visit('/foo/bar').then(function () {
text = _this8.$('#app').text();
assert.equal(text, 'YAY', 'foo.bar.index fully loaded');
});
var text = _this8.$('#app').text();
assert.equal(text, 'FOOBAR LOADING', 'foo.bar_loading was entered (as opposed to something like foo/foo/bar_loading)');
deferred.resolve();
return promise;
});
};
_class.prototype['@test Prioritized substate entry works with reset-namespace nested routes'] = function testPrioritizedSubstateEntryWorksWithResetNamespaceNestedRoutes(assert) {
var _this9 = this;
var deferred = _emberRuntime.RSVP.defer();
this.addTemplate('bar_loading', 'BAR LOADING');
this.addTemplate('bar.index', 'YAY');
this.router.map(function () {
this.route('foo', function () {
this.route('bar', { path: '/bar', resetNamespace: true }, function () {});
});
});
this.add('route:bar', _emberRouting.Route.extend({
model: function () {
return deferred.promise;
}
}));
return this.visit('/').then(function () {
var promise = _this9.visit('/foo/bar').then(function () {
text = _this9.$('#app').text();
assert.equal(text, 'YAY', 'bar.index fully loaded');
});
var text = _this9.$('#app').text();
assert.equal(text, 'BAR LOADING', 'foo.bar_loading was entered (as opposed to something likefoo/foo/bar_loading)');
deferred.resolve();
return promise;
});
};
_class.prototype['@test Prioritized loading substate entry works with preserved-namespace nested routes'] = function testPrioritizedLoadingSubstateEntryWorksWithPreservedNamespaceNestedRoutes(assert) {
var _this10 = this;
var deferred = _emberRuntime.RSVP.defer();
this.addTemplate('foo.bar_loading', 'FOOBAR LOADING');
this.addTemplate('foo.bar', 'YAY');
this.router.map(function () {
this.route('foo', function () {
this.route('bar');
});
});
this.add('route:foo.bar', _emberRouting.Route.extend({
model: function () {
return deferred.promise;
}
}));
var promise = this.visit('/foo/bar').then(function () {
text = _this10.$('#app').text();
assert.equal(text, 'YAY', 'foo.bar has rendered');
});
var text = this.$('#app').text();
assert.equal(text, 'FOOBAR LOADING', 'foo.bar_loading was entered (as opposed to something like foo/foo/bar_loading)');
deferred.resolve();
return promise;
};
_class.prototype['@test Prioritized error substate entry works with preserved-namespaec nested routes'] = function testPrioritizedErrorSubstateEntryWorksWithPreservedNamespaecNestedRoutes(assert) {
var _this11 = this;
this.addTemplate('foo.bar_error', 'FOOBAR ERROR: {{model.msg}}');
this.addTemplate('foo.bar', 'YAY');
this.router.map(function () {
this.route('foo', function () {
this.route('bar');
});
});
this.add('route:foo.bar', _emberRouting.Route.extend({
model: function () {
return _emberRuntime.RSVP.reject({
msg: 'did it broke?'
});
}
}));
return this.visit('/').then(function () {
return _this11.visit('/foo/bar').then(function () {
var text = _this11.$('#app').text();
assert.equal(text, 'FOOBAR ERROR: did it broke?', 'foo.bar_error was entered (as opposed to something like foo/foo/bar_error)');
});
});
};
_class.prototype['@test Prioritized loading substate entry works with auto-generated index routes'] = function testPrioritizedLoadingSubstateEntryWorksWithAutoGeneratedIndexRoutes(assert) {
var _this12 = this;
var deferred = _emberRuntime.RSVP.defer();
this.addTemplate('foo.index_loading', 'FOO LOADING');
this.addTemplate('foo.index', 'YAY');
this.addTemplate('foo', '{{outlet}}');
this.router.map(function () {
this.route('foo', function () {
this.route('bar');
});
});
this.add('route:foo.index', _emberRouting.Route.extend({
model: function () {
return deferred.promise;
}
}));
this.add('route:foo', _emberRouting.Route.extend({
model: function () {
return true;
}
}));
var promise = this.visit('/foo').then(function () {
text = _this12.$('#app').text();
assert.equal(text, 'YAY', 'foo.index was rendered');
});
var text = this.$('#app').text();
assert.equal(text, 'FOO LOADING', 'foo.index_loading was entered');
deferred.resolve();
return promise;
};
_class.prototype['@test Prioritized error substate entry works with auto-generated index routes'] = function testPrioritizedErrorSubstateEntryWorksWithAutoGeneratedIndexRoutes(assert) {
var _this13 = this;
this.addTemplate('foo.index_error', 'FOO ERROR: {{model.msg}}');
this.addTemplate('foo.index', 'YAY');
this.addTemplate('foo', '{{outlet}}');
this.router.map(function () {
this.route('foo', function () {
this.route('bar');
});
});
this.add('route:foo.index', _emberRouting.Route.extend({
model: function () {
return _emberRuntime.RSVP.reject({
msg: 'did it broke?'
});
}
}));
this.add('route:foo', _emberRouting.Route.extend({
model: function () {
return true;
}
}));
return this.visit('/').then(function () {
return _this13.visit('/foo').then(function () {
var text = _this13.$('#app').text();
assert.equal(text, 'FOO ERROR: did it broke?', 'foo.index_error was entered');
});
});
};
(0, _emberBabel.createClass)(_class, [{
key: 'currentPath',
get: function () {
return this.getController('application').get('currentPath');
}
}]);
return _class;
}(_internalTestHelpers.ApplicationTestCase));
(0, _internalTestHelpers.moduleFor)('Loading/Error Substates - globals mode app', function (_AutobootApplicationT) {
(0, _emberBabel.inherits)(_class2, _AutobootApplicationT);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _AutobootApplicationT.apply(this, arguments));
}
_class2.prototype['@test Rejected promises returned from ApplicationRoute transition into top-level application_error'] = function testRejectedPromisesReturnedFromApplicationRouteTransitionIntoTopLevelApplication_error(assert) {
var _this15 = this;
var reject = true;
this.runTask(function () {
_this15.createApplication();
_this15.addTemplate('index', '