Files larger than 1 MB are truncated. Click
here to display the full file (may cause the browser to become unresponsive) or use the
Open button to view outside of Swarm.
(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.18.0
*/
/*global process */
var enifed, requireModule, Ember;
var mainContext = this; // Used in ember-environment/lib/global.js
(function() {
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;
}
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'];
};
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');
});
QUnit.module('ESLint | container/lib/container.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'container/lib/container.js should pass ESLint\n\n');
});
QUnit.module('ESLint | container/lib/index.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'container/lib/index.js should pass ESLint\n\n');
});
QUnit.module('ESLint | container/lib/registry.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'container/lib/registry.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();
expectAssertion(function () {
container.factoryFor('chad-bar');
}, /fullName must be a proper full name/);
});
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);
expectAssertion(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('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);
expectAssertion(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/lib/index.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/lib/index.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/lib/initializers/dom-templates.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/lib/initializers/dom-templates.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/lib/system/application-instance.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/lib/system/application-instance.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/lib/system/application.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/lib/system/application.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/lib/system/engine-instance.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/lib/system/engine-instance.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/lib/system/engine-parent.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/lib/system/engine-parent.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/lib/system/engine.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/lib/system/engine.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/lib/system/resolver.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/lib/system/resolver.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-application/lib/utils/validate-type.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/lib/utils/validate-type.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('<div id=\'one\'><div id=\'one-child\'>HI</div></div><div id=\'two\'>HI</div>');
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 <div id="one">\n <div id="one-child">HI</div>\n </div>\n <div id="two">HI</div>\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('<script type="text/x-handlebars">Hello World</script>');
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', '<h1>Hi from index</h1>');
});
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', '<h1>Hello!</h1>');
});
// 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', '<h1>{{greeting}}</h1>');
_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 <div id="app"></div>\n\n <script type="text/x-handlebars">Hello {{outlet}}</script>\n <script type="text/x-handlebars" id="index">World!</script>\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('<h1>Fallback</h1>');
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;
expectAssertion(function () {
_this3.applicationInstance.resolveRegistration(undefined);
}, /fullName must be a proper full name/);
expectAssertion(function () {
_this3.applicationInstance.resolveRegistration(null);
}, /fullName must be a proper full name/);
expectAssertion(function () {
_this3.applicationInstance.resolveRegistration('');
}, /fullName must be a proper full name/);
expectAssertion(function () {
_this3.applicationInstance.resolveRegistration('');
}, /fullName must be a proper full name/);
expectAssertion(function () {
_this3.applicationInstance.resolveRegistration(':');
}, /fullName must be a proper full name/);
expectAssertion(function () {
_this3.applicationInstance.resolveRegistration('model');
}, /fullName must be a proper full name/);
expectAssertion(function () {
_this3.applicationInstance.resolveRegistration('model:');
}, /fullName must be a proper full name/);
expectAssertion(function () {
_this3.applicationInstance.resolveRegistration(':type');
}, /fullName must be a proper full name/);
};
_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(), '<model:peter:' + guid + '>', '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 <div id="one">ONE</div>\n <div id="two">TWO</div>\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 <div id="one">ONE</div>\n <div id="two">TWO</div>\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', '<h1>Hello world</h1>');
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', '<h1>Hello world</h1>');
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', '<h1>Hello world</h1>');
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', '<h1>Hello world</h1>');
// 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', '<h1>Hello world</h1>{{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 <p>Dis cache money</p>\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 <p>Dis cache money</p>\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 <h1>X-Foo</h1>\n <p>Hello {{model.name}}, I have been clicked {{isolatedCounter.value}} times ({{sharedCounter.value}} times combined)!</p>\n ');
this.add('component:x-foo', _emberGlimmer.Component.extend({
tagName: 'x-foo',
isolatedCounter: _emberRuntime.inject.service(),
sharedCounter: _emberRuntime.inject.service(),
init: function () {
this._super();
xFooInitCalled = true;
},
didInsertElement: function () {
xFooDidInsertElementCalled = true;
},
click: function () {
this.get('isolatedCounter').increment();
this.get('sharedCounter').increment();
}
}));
this.addTemplate('components/x-bar', '\n <h1>X-Bar</h1>\n <button {{action "incrementCounter"}}>Join {{counter.value}} others in clicking me!</button>\n ');
this.add('component:x-bar', _emberGlimmer.Component.extend({
counter: _emberRuntime.inject.service('sharedCounter'),
actions: {
incrementCounter: function () {
this.get('counter').increment();
}
},
init: function () {
this._super();
xBarInitCalled = true;
},
didInsertElement: function () {
xBarDidInsertElementCalled = true;
}
}));
var $foo = (0, _emberViews.jQuery)('<div />').appendTo(this.$());
var $bar = (0, _emberViews.jQuery)('<div />').appendTo(this.$());
var data = encodeURIComponent(JSON.stringify({ name: 'Godfrey' }));
var instances = [];
return _emberRuntime.RSVP.all([this.runTask(function () {
return _this11.application.visit('/x-foo?data=' + data, { rootElement: $foo[0] });
}), this.runTask(function () {
return _this11.application.visit('/x-bar', { rootElement: $bar[0] });
})]).then(function (_instances) {
instances = _instances;
assert.ok(xFooInitCalled);
assert.ok(xFooDidInsertElementCalled);
assert.ok(xBarInitCalled);
assert.ok(xBarDidInsertElementCalled);
assert.equal($foo.find('h1').text(), 'X-Foo');
assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 0 times (0 times combined)!');
assert.ok($foo.text().indexOf('X-Bar') === -1);
assert.equal($bar.find('h1').text(), 'X-Bar');
assert.equal($bar.find('button').text(), 'Join 0 others in clicking me!');
assert.ok($bar.text().indexOf('X-Foo') === -1);
_this11.runTask(function () {
$foo.find('x-foo').click();
});
assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (1 times combined)!');
assert.equal($bar.find('button').text(), 'Join 1 others in clicking me!');
_this11.runTask(function () {
$bar.find('button').click();
$bar.find('button').click();
});
assert.equal($foo.find('p').text(), 'Hello Godfrey, I have been clicked 1 times (3 times combined)!');
assert.equal($bar.find('button').text(), 'Join 3 others in clicking me!');
}).finally(function () {
_this11.runTask(function () {
instances.forEach(function (instance) {
instance.destroy();
});
});
});
};
return _class;
}(_internalTestHelpers.ApplicationTestCase));
});
QUnit.module('ESLint | ember-application/tests/system/visit_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/system/visit_test.js should pass ESLint\n\n');
});
enifed('ember-application/tests/test-helpers/registry-check', ['exports'], function (exports) {
'use strict';
exports.verifyRegistration = verifyRegistration;
exports.verifyInjection = verifyInjection;
function verifyRegistration(owner, fullName) {
ok(owner.resolveRegistration(fullName), 'has registration: ' + fullName);
}
function verifyInjection(owner, fullName, property, injectionName) {
var registry = owner.__registry__;
var injections = void 0;
if (fullName.indexOf(':') === -1) {
injections = registry.getTypeInjections(fullName);
} else {
injections = registry.getInjections(registry.normalize(fullName));
}
var normalizedName = registry.normalize(injectionName);
var hasInjection = false;
var injection = void 0;
for (var i = 0, l = injections.length; i < l; i++) {
injection = injections[i];
if (injection.property === property && injection.fullName === normalizedName) {
hasInjection = true;
break;
}
}
ok(hasInjection, 'has injection: ' + fullName + '.' + property + ' = ' + injectionName);
}
});
QUnit.module('ESLint | ember-application/tests/test-helpers/registry-check.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-application/tests/test-helpers/registry-check.js should pass ESLint\n\n');
});
enifed('ember-babel', ['exports'], function (exports) {
'use strict';
exports.classCallCheck = classCallCheck;
exports.inherits = inherits;
exports.taggedTemplateLiteralLoose = taggedTemplateLiteralLoose;
exports.createClass = createClass;
exports.defaults = defaults;
function classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
function inherits(subClass, superClass) {
if (typeof superClass !== 'function' && superClass !== null) {
throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : defaults(subClass, superClass);
}
function taggedTemplateLiteralLoose(strings, raw) {
strings.raw = raw;
return strings;
}
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ('value' in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function createClass(Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
}
function defaults(obj, defaults) {
var keys = Object.getOwnPropertyNames(defaults);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = Object.getOwnPropertyDescriptor(defaults, key);
if (value && value.configurable && obj[key] === undefined) {
Object.defineProperty(obj, key, value);
}
}
return obj;
}
var possibleConstructorReturn = exports.possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError('this hasn\'t been initialized - super() hasn\'t been called');
}
return call && (typeof call === 'object' || typeof call === 'function') ? call : self;
};
var slice = exports.slice = Array.prototype.slice;
});
QUnit.module('ESLint | ember-console.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-console.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-console/lib/index.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-console/lib/index.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/deprecate.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/deprecate.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/error.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/error.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/features.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/features.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/handlers.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/handlers.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/index.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/index.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/lib/deprecate.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/lib/deprecate.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/lib/error.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/lib/error.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/lib/features.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/lib/features.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/lib/handlers.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/lib/handlers.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/lib/index.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/lib/index.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/lib/testing.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/lib/testing.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/lib/warn.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/lib/warn.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/testing.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/testing.js should pass ESLint\n\n');
});
enifed('ember-debug/tests/error_test', ['ember-debug/error'], function (_error) {
'use strict';
QUnit.module('Ember Error Throwing');
QUnit.test('new Ember.Error displays provided message', function () {
throws(function () {
throw new _error.default('A Message');
}, function (e) {
return e.message === 'A Message';
}, 'the assigned message was displayed');
});
});
QUnit.module('ESLint | ember-debug/tests/error_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/tests/error_test.js should pass ESLint\n\n');
});
enifed('ember-debug/tests/handlers-test', ['ember-debug/handlers'], function (_handlers) {
'use strict';
QUnit.module('ember-debug/handlers', {
teardown: function () {
delete _handlers.HANDLERS.blarz;
}
});
QUnit.test('calls handler on `invoke` when `falsey`', function (assert) {
assert.expect(2);
function handler(message) {
assert.ok(true, 'called handler');
assert.equal(message, 'Foo bar');
}
(0, _handlers.registerHandler)('blarz', handler);
(0, _handlers.invoke)('blarz', 'Foo bar', false);
});
QUnit.test('does not call handler on `invoke` when `truthy`', function (assert) {
assert.expect(0);
function handler() {
assert.ok(false, 'called handler');
}
(0, _handlers.registerHandler)('blarz', handler);
(0, _handlers.invoke)('blarz', 'Foo bar', true);
});
QUnit.test('calling `invoke` without handlers does not throw an error', function (assert) {
assert.expect(0);
(0, _handlers.invoke)('blarz', 'Foo bar', false);
});
QUnit.test('invoking `next` argument calls the next handler', function (assert) {
assert.expect(2);
function handler1(message, options, next) {
assert.ok(true, 'called handler1');
}
function handler2(message, options, next) {
assert.ok(true, 'called handler2');
next(message, options);
}
(0, _handlers.registerHandler)('blarz', handler1);
(0, _handlers.registerHandler)('blarz', handler2);
(0, _handlers.invoke)('blarz', 'Foo', false);
});
QUnit.test('invoking `next` when no other handlers exists does not error', function (assert) {
assert.expect(1);
function handler(message, options, next) {
assert.ok(true, 'called handler1');
next(message, options);
}
(0, _handlers.registerHandler)('blarz', handler);
(0, _handlers.invoke)('blarz', 'Foo', false);
});
QUnit.test('handlers are called in the proper order', function (assert) {
assert.expect(11);
var expectedMessage = 'This is the message';
var expectedOptions = { id: 'foo-bar' };
var expected = ['first', 'second', 'third', 'fourth', 'fifth'];
var actualCalls = [];
function generateHandler(item) {
return function (message, options, next) {
assert.equal(message, expectedMessage, 'message supplied to ' + item + ' handler is correct');
assert.equal(options, expectedOptions, 'options supplied to ' + item + ' handler is correct');
actualCalls.push(item);
next(message, options);
};
}
expected.forEach(function (item) {
return (0, _handlers.registerHandler)('blarz', generateHandler(item));
});
(0, _handlers.invoke)('blarz', expectedMessage, false, expectedOptions);
assert.deepEqual(actualCalls, expected.reverse(), 'handlers were called in proper order');
});
QUnit.test('not invoking `next` prevents further handlers from being called', function (assert) {
assert.expect(1);
function handler1(message, options, next) {
assert.ok(false, 'called handler1');
}
function handler2(message, options, next) {
assert.ok(true, 'called handler2');
}
(0, _handlers.registerHandler)('blarz', handler1);
(0, _handlers.registerHandler)('blarz', handler2);
(0, _handlers.invoke)('blarz', 'Foo', false);
});
QUnit.test('handlers can call `next` with custom message and/or options', function (assert) {
assert.expect(4);
var initialMessage = 'initial message';
var initialOptions = { id: 'initial-options' };
var handler2Message = 'Handler2 Message';
var handler2Options = { id: 'handler-2' };
function handler1(message, options, next) {
assert.equal(message, handler2Message, 'handler2 message provided to handler1');
assert.equal(options, handler2Options, 'handler2 options provided to handler1');
}
function handler2(message, options, next) {
assert.equal(message, initialMessage, 'initial message provided to handler2');
assert.equal(options, initialOptions, 'initial options proivided to handler2');
next(handler2Message, handler2Options);
}
(0, _handlers.registerHandler)('blarz', handler1);
(0, _handlers.registerHandler)('blarz', handler2);
(0, _handlers.invoke)('blarz', initialMessage, false, initialOptions);
});
});
QUnit.module('ESLint | ember-debug/tests/handlers-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/tests/handlers-test.js should pass ESLint\n\n');
});
enifed('ember-debug/tests/main_test', ['ember-environment', 'ember-runtime', 'ember-debug/handlers', 'ember-debug/deprecate', 'ember-debug/warn', 'ember-debug/index'], function (_emberEnvironment, _emberRuntime, _handlers, _deprecate, _warn, _index) {
'use strict';
var originalEnvValue = void 0;
var originalDeprecateHandler = void 0;
QUnit.module('ember-debug', {
setup: function () {
originalEnvValue = _emberEnvironment.ENV.RAISE_ON_DEPRECATION;
originalDeprecateHandler = _handlers.HANDLERS.deprecate;
_emberEnvironment.ENV.RAISE_ON_DEPRECATION = true;
},
teardown: function () {
_handlers.HANDLERS.deprecate = originalDeprecateHandler;
_emberEnvironment.ENV.RAISE_ON_DEPRECATION = originalEnvValue;
}
});
QUnit.test('Ember.deprecate does not throw if RAISE_ON_DEPRECATION is false', function (assert) {
assert.expect(1);
_emberEnvironment.ENV.RAISE_ON_DEPRECATION = false;
try {
(0, _index.deprecate)('Should not throw', false, { id: 'test', until: 'forever' });
assert.ok(true, 'Ember.deprecate did not throw');
} catch (e) {
assert.ok(false, 'Expected deprecate not to throw but it did: ' + e.message);
}
});
QUnit.test('Ember.deprecate resets deprecation level to RAISE if ENV.RAISE_ON_DEPRECATION is set', function (assert) {
assert.expect(2);
_emberEnvironment.ENV.RAISE_ON_DEPRECATION = false;
try {
(0, _index.deprecate)('Should not throw', false, { id: 'test', until: 'forever' });
assert.ok(true, 'Ember.deprecate did not throw');
} catch (e) {
assert.ok(false, 'Expected deprecate not to throw but it did: ' + e.message);
}
_emberEnvironment.ENV.RAISE_ON_DEPRECATION = true;
assert.throws(function () {
(0, _index.deprecate)('Should throw', false, { id: 'test', until: 'forever' });
}, /Should throw/);
});
QUnit.test('When ENV.RAISE_ON_DEPRECATION is true, it is still possible to silence a deprecation by id', function (assert) {
assert.expect(3);
_emberEnvironment.ENV.RAISE_ON_DEPRECATION = true;
(0, _deprecate.registerHandler)(function (message, options, next) {
if (!options || options.id !== 'my-deprecation') {
next.apply(undefined, arguments);
}
});
try {
(0, _index.deprecate)('should be silenced with matching id', false, { id: 'my-deprecation', until: 'forever' });
assert.ok(true, 'Did not throw when level is set by id');
} catch (e) {
assert.ok(false, 'Expected deprecate not to throw but it did: ' + e.message);
}
assert.throws(function () {
(0, _index.deprecate)('Should throw with no matching id', false, { id: 'test', until: 'forever' });
}, /Should throw with no matching id/);
assert.throws(function () {
(0, _index.deprecate)('Should throw with non-matching id', false, { id: 'other-id', until: 'forever' });
}, /Should throw with non-matching id/);
});
QUnit.test('Ember.deprecate throws deprecation if second argument is falsy', function () {
expect(3);
throws(function () {
return (0, _index.deprecate)('Deprecation is thrown', false, { id: 'test', until: 'forever' });
});
throws(function () {
return (0, _index.deprecate)('Deprecation is thrown', '', { id: 'test', until: 'forever' });
});
throws(function () {
return (0, _index.deprecate)('Deprecation is thrown', 0, { id: 'test', until: 'forever' });
});
});
QUnit.test('Ember.deprecate does not invoke a function as the second argument', function () {
expect(1);
(0, _index.deprecate)('Deprecation is thrown', function () {
ok(false, 'this function should not be invoked');
}, { id: 'test', until: 'forever' });
ok(true, 'deprecations were not thrown');
});
QUnit.test('Ember.deprecate does not throw deprecations if second argument is truthy', function () {
expect(1);
(0, _index.deprecate)('Deprecation is thrown', true, { id: 'test', until: 'forever' });
(0, _index.deprecate)('Deprecation is thrown', '1', { id: 'test', until: 'forever' });
(0, _index.deprecate)('Deprecation is thrown', 1, { id: 'test', until: 'forever' });
ok(true, 'deprecations were not thrown');
});
QUnit.test('Ember.assert throws if second argument is falsy', function () {
expect(3);
throws(function () {
return (0, _index.assert)('Assertion is thrown', false);
});
throws(function () {
return (0, _index.assert)('Assertion is thrown', '');
});
throws(function () {
return (0, _index.assert)('Assertion is thrown', 0);
});
});
QUnit.test('Ember.assert does not throw if second argument is a function', function (assert) {
assert.expect(1);
(0, _index.assert)('Assertion is thrown', function () {
return true;
});
ok(true, 'assertions were not thrown');
});
QUnit.test('Ember.assert does not throw if second argument is truthy', function () {
expect(1);
(0, _index.assert)('Assertion is thrown', true);
(0, _index.assert)('Assertion is thrown', '1');
(0, _index.assert)('Assertion is thrown', 1);
ok(true, 'assertions were not thrown');
});
QUnit.test('Ember.assert does not throw if second argument is an object', function () {
expect(1);
var Igor = _emberRuntime.Object.extend();
(0, _index.assert)('is truthy', Igor);
(0, _index.assert)('is truthy', Igor.create());
ok(true, 'assertions were not thrown');
});
QUnit.test('Ember.deprecate does not throw a deprecation at log and silence levels', function () {
expect(4);
var id = 'ABC';
var until = 'forever';
var shouldThrow = false;
(0, _deprecate.registerHandler)(function (message, options, next) {
if (options && options.id === id) {
if (shouldThrow) {
throw new Error(message);
}
}
});
try {
(0, _index.deprecate)('Deprecation for testing purposes', false, { id: id, until: until });
ok(true, 'Deprecation did not throw');
} catch (e) {
ok(false, 'Deprecation was thrown despite being added to blacklist');
}
try {
(0, _index.deprecate)('Deprecation for testing purposes', false, { id: id, until: until });
ok(true, 'Deprecation did not throw');
} catch (e) {
ok(false, 'Deprecation was thrown despite being added to blacklist');
}
shouldThrow = true;
throws(function () {
(0, _index.deprecate)('Deprecation is thrown', false, { id: id, until: until });
});
throws(function () {
(0, _index.deprecate)('Deprecation is thrown', false, { id: id, until: until });
});
});
QUnit.test('Ember.deprecate without options triggers a deprecation', function (assert) {
assert.expect(4);
(0, _deprecate.registerHandler)(function (message) {
if (message === _deprecate.missingOptionsDeprecation) {
assert.ok(true, 'proper deprecation is triggered when options is missing');
} else if (message === 'foo') {
assert.ok(true, 'original deprecation is still triggered');
}
});
(0, _index.deprecate)('foo');
(0, _index.deprecate)('foo', false, {});
});
QUnit.test('Ember.deprecate without options.id triggers a deprecation', function (assert) {
assert.expect(2);
(0, _deprecate.registerHandler)(function (message) {
if (message === _deprecate.missingOptionsIdDeprecation) {
assert.ok(true, 'proper deprecation is triggered when options.id is missing');
} else if (message === 'foo') {
assert.ok(true, 'original deprecation is still triggered');
}
});
(0, _index.deprecate)('foo', false, { until: 'forever' });
});
QUnit.test('Ember.deprecate without options.until triggers a deprecation', function (assert) {
assert.expect(2);
(0, _deprecate.registerHandler)(function (message) {
if (message === _deprecate.missingOptionsUntilDeprecation) {
assert.ok(true, 'proper deprecation is triggered when options.until is missing');
} else if (message === 'foo') {
assert.ok(true, 'original deprecation is still triggered');
}
});
(0, _index.deprecate)('foo', false, { id: 'test' });
});
QUnit.test('warn without options triggers a deprecation', function (assert) {
assert.expect(2);
(0, _deprecate.registerHandler)(function (message) {
assert.equal(message, _warn.missingOptionsDeprecation, 'deprecation is triggered when options is missing');
});
(0, _warn.registerHandler)(function (message) {
assert.equal(message, 'foo', 'original warning is triggered');
});
(0, _index.warn)('foo');
});
QUnit.test('warn without options.id triggers a deprecation', function (assert) {
assert.expect(2);
(0, _deprecate.registerHandler)(function (message) {
assert.equal(message, _warn.missingOptionsIdDeprecation, 'deprecation is triggered when options is missing');
});
(0, _warn.registerHandler)(function (message) {
assert.equal(message, 'foo', 'original warning is triggered');
});
(0, _index.warn)('foo', false, {});
});
QUnit.test('warn without options.id nor test triggers a deprecation', function (assert) {
assert.expect(2);
(0, _deprecate.registerHandler)(function (message) {
assert.equal(message, _warn.missingOptionsIdDeprecation, 'deprecation is triggered when options is missing');
});
(0, _warn.registerHandler)(function (message) {
assert.equal(message, 'foo', 'original warning is triggered');
});
(0, _index.warn)('foo', {});
});
QUnit.test('warn without test but with options does not trigger a deprecation', function (assert) {
assert.expect(1);
(0, _deprecate.registerHandler)(function (message) {
assert.ok(false, 'there should be no deprecation ' + message);
});
(0, _warn.registerHandler)(function (message) {
assert.equal(message, 'foo', 'warning was triggered');
});
(0, _index.warn)('foo', { id: 'ember-debug.do-not-raise' });
});
});
QUnit.module('ESLint | ember-debug/tests/main_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/tests/main_test.js should pass ESLint\n\n');
});
enifed('ember-debug/tests/warn_if_using_stripped_feature_flags_test', ['ember-environment', 'ember-debug', 'ember-debug/index'], function (_emberEnvironment, _emberDebug, _index) {
'use strict';
var oldWarn = void 0,
oldRunInDebug = void 0,
origEnvFeatures = void 0,
origEnableOptional = void 0,
features = void 0,
knownFeatures = void 0;
function confirmWarns(expectedMsg) {
var featuresWereStripped = true;
(0, _emberDebug.setDebugFunction)('warn', function (msg, test) {
if (!test) {
equal(msg, expectedMsg);
}
});
(0, _emberDebug.setDebugFunction)('runInDebug', function (func) {
func();
});
// Should trigger our 1 warning
(0, _index._warnIfUsingStrippedFeatureFlags)(features, knownFeatures, featuresWereStripped);
// Shouldn't trigger any warnings now that we're "in canary"
featuresWereStripped = false;
(0, _index._warnIfUsingStrippedFeatureFlags)(features, knownFeatures, featuresWereStripped);
}
QUnit.module('ember-debug - _warnIfUsingStrippedFeatureFlags', {
setup: function () {
oldWarn = (0, _emberDebug.getDebugFunction)('warn');
oldRunInDebug = (0, _emberDebug.getDebugFunction)('runInDebug');
origEnvFeatures = _emberEnvironment.ENV.FEATURES;
origEnableOptional = _emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES;
knownFeatures = {
'fred': null,
'barney': null,
'wilma': null
};
},
teardown: function () {
(0, _emberDebug.setDebugFunction)('warn', oldWarn);
(0, _emberDebug.setDebugFunction)('runInDebug', oldRunInDebug);
_emberEnvironment.ENV.FEATURES = origEnvFeatures;
_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = origEnableOptional;
}
});
QUnit.test('Setting Ember.ENV.ENABLE_OPTIONAL_FEATURES truthy in non-canary, debug build causes a warning', function () {
expect(1);
_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = true;
features = {};
confirmWarns('Ember.ENV.ENABLE_OPTIONAL_FEATURES is only available in canary builds.');
});
QUnit.test('Enabling a known FEATURE flag in non-canary, debug build causes a warning', function () {
expect(1);
_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = false;
features = {
'fred': true,
'barney': false,
'wilma': null
};
confirmWarns('FEATURE["fred"] is set as enabled, but FEATURE flags are only available in canary builds.');
});
QUnit.test('Enabling an unknown FEATURE flag in non-canary debug build does not cause a warning', function () {
expect(0);
_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = false;
features = {
'some-ember-data-feature-flag': true
};
confirmWarns('FEATURE["fred"] is set as enabled, but FEATURE flags are only available in canary builds.');
});
QUnit.test('`ENV.FEATURES` being undefined does not cause an error', function () {
expect(0);
_emberEnvironment.ENV.ENABLE_OPTIONAL_FEATURES = false;
features = undefined;
confirmWarns();
});
});
QUnit.module('ESLint | ember-debug/tests/warn_if_using_stripped_feature_flags_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/tests/warn_if_using_stripped_feature_flags_test.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-debug/warn.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-debug/warn.js should pass ESLint\n\n');
});
enifed('ember-dev/test-helper/assertion', ['exports', 'ember-dev/test-helper/utils'], function (exports, _utils) {
'use strict';
exports.default = AssertionAssert;
var BREAK = {};
/**
This assertion class is used to test assertions made using Ember.assert.
It injects two helpers onto `window`:
- expectAssertion(func: Function, [expectedMessage: String | RegExp])
This function calls `func` and asserts that `Ember.assert` is invoked during
the execution. Moreover, it takes a String or a RegExp as a second optional
argument that can be used to test if a specific assertion message was
generated.
- ignoreAssertion(func: Function)
This function calls `func` and disables `Ember.assert` during the execution.
In particular, this prevents `Ember.assert` from throw errors that would
disrupt the control flow.
*/
function AssertionAssert(env) {
this.env = env;
}
AssertionAssert.prototype = {
reset: function reset() {},
assert: function assert() {},
inject: function inject() {
var _this = this;
var expectAssertion = function expectAssertion(func, expectedMessage) {
if (_this.env.runningProdBuild) {
QUnit.ok(true, 'Assertions disabled in production builds.');
return;
}
var sawCall = undefined;
var actualMessage = undefined;
// The try-catch statement is used to "exit" `func` as soon as
// the first useful assertion has been produced.
try {
(0, _utils.callWithStub)(_this.env, 'assert', func, function (message, test) {
sawCall = true;
if ((0, _utils.checkTest)(test)) {
return;
}
actualMessage = message;
throw BREAK;
});
} catch (e) {
if (e !== BREAK) {
throw e;
}
}
assert(sawCall, actualMessage, expectedMessage);
};
var ignoreAssertion = function ignoreAssertion(func) {
(0, _utils.callWithStub)(_this.env, 'assert', func);
};
window.expectAssertion = expectAssertion;
window.ignoreAssertion = ignoreAssertion;
},
restore: function restore() {
window.expectAssertion = null;
window.ignoreAssertion = null;
}
};
function assert(sawCall, actualMessage, expectedMessage) {
// Run assertions in an order that is useful when debugging a test failure.
if (!sawCall) {
QUnit.ok(false, 'Expected Ember.assert to be called (Not called with any value).');
} else if (!actualMessage) {
QUnit.ok(false, 'Expected a failing Ember.assert (Ember.assert called, but without a failing test).');
} else {
if (expectedMessage) {
if (expectedMessage instanceof RegExp) {
QUnit.ok(expectedMessage.test(actualMessage), 'Expected failing Ember.assert: \'' + expectedMessage + '\', but got \'' + actualMessage + '\'.');
} else {
QUnit.equal(actualMessage, expectedMessage, 'Expected failing Ember.assert: \'' + expectedMessage + '\', but got \'' + actualMessage + '\'.');
}
} else {
// Positive assertion that assert was called
QUnit.ok(true, 'Expected a failing Ember.assert.');
}
}
}
});
enifed('ember-dev/test-helper/debug', ['exports', 'ember-dev/test-helper/method-call-tracker'], function (exports, _methodCallTracker) {
'use strict';
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ('value' in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
}
}return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
};
}();
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
var DebugAssert = function () {
function DebugAssert(methodName, env) {
_classCallCheck(this, DebugAssert);
this.methodName = methodName;
this.env = env;
}
_createClass(DebugAssert, [{
key: 'inject',
value: function inject() {}
}, {
key: 'restore',
value: function restore() {
this.reset();
}
}, {
key: 'reset',
value: function reset() {
if (this.tracker) {
this.tracker.restoreMethod();
}
this.tracker = null;
}
}, {
key: 'assert',
value: function assert() {
if (this.tracker) {
this.tracker.assert();
}
}
// Run an expectation callback within the context of a new tracker, optionally
// accepting a function to run, which asserts immediately
}, {
key: 'runExpectation',
value: function runExpectation(func, callback) {
var originalTracker = undefined;
// When helpers are passed a callback, they get a new tracker context
if (func) {
originalTracker = this.tracker;
this.tracker = null;
}
if (!this.tracker) {
this.tracker = new _methodCallTracker.default(this.env, this.methodName);
}
// Yield to caller with tracker instance
callback(this.tracker);
// Once the given callback is invoked, the pending assertions should be
// flushed immediately
if (func) {
func();
this.assert();
this.reset();
this.tracker = originalTracker;
}
}
}]);
return DebugAssert;
}();
exports.default = DebugAssert;
});
enifed('ember-dev/test-helper/deprecation', ['exports', 'ember-babel', 'ember-dev/test-helper/debug', 'ember-dev/test-helper/utils'], function (exports, _emberBabel, _debug, _utils) {
'use strict';
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ('value' in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
}
}return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
};
}();
var _get = function get(_x, _x2, _x3) {
var _again = true;_function: while (_again) {
var object = _x,
property = _x2,
receiver = _x3;_again = false;if (object === null) object = Function.prototype;var desc = Object.getOwnPropertyDescriptor(object, property);if (desc === undefined) {
var parent = Object.getPrototypeOf(object);if (parent === null) {
return undefined;
} else {
_x = parent;_x2 = property;_x3 = receiver;_again = true;desc = parent = undefined;continue _function;
}
} else if ('value' in desc) {
return desc.value;
} else {
var getter = desc.get;if (getter === undefined) {
return undefined;
}return getter.call(receiver);
}
}
};
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
function _inherits(subClass, superClass) {
if (typeof superClass !== 'function' && superClass !== null) {
throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : (0, _emberBabel.defaults)(subClass, superClass);
}
var DeprecationAssert = function (_DebugAssert) {
_inherits(DeprecationAssert, _DebugAssert);
function DeprecationAssert(env) {
_classCallCheck(this, DeprecationAssert);
_get(Object.getPrototypeOf(DeprecationAssert.prototype), 'constructor', this).call(this, 'deprecate', env);
}
_createClass(DeprecationAssert, [{
key: 'inject',
value: function inject() {
var _this = this;
// Expects no deprecation to happen within a function, or if no function is
// passed, from the time of calling until the end of the test.
//
// expectNoDeprecation(function() {
// fancyNewThing();
// });
//
// expectNoDeprecation();
// Ember.deprecate("Old And Busted");
//
var expectNoDeprecation = function expectNoDeprecation(func) {
if (typeof func !== 'function') {
func = null;
}
_this.runExpectation(func, function (tracker) {
if (tracker.isExpectingCalls()) {
throw new Error("expectNoDeprecation was called after expectDeprecation was called!");
}
tracker.expectNoCalls();
});
};
// Expect a deprecation to happen within a function, or if no function
// is pass, from the time of calling until the end of the test. Can be called
// multiple times to assert deprecations with different specific messages
// were fired.
//
// expectDeprecation(function() {
// Ember.deprecate("Old And Busted");
// }, /* optionalStringOrRegex */);
//
// expectDeprecation(/* optionalStringOrRegex */);
// Ember.deprecate("Old And Busted");
//
var expectDeprecation = function expectDeprecation(func, message) {
if (typeof func !== 'function') {
message = func;
func = null;
}
_this.runExpectation(func, function (tracker) {
if (tracker.isExpectingNoCalls()) {
throw new Error("expectDeprecation was called after expectNoDeprecation was called!");
}
tracker.expectCall(message);
});
};
var ignoreDeprecation = function ignoreDeprecation(func) {
(0, _utils.callWithStub)(_this.env, 'deprecate', func);
};
window.expectNoDeprecation = expectNoDeprecation;
window.expectDeprecation = expectDeprecation;
window.ignoreDeprecation = ignoreDeprecation;
}
}, {
key: 'restore',
value: function restore() {
_get(Object.getPrototypeOf(DeprecationAssert.prototype), 'restore', this).call(this);
window.expectDeprecation = null;
window.expectNoDeprecation = null;
window.ignoreDeprecation = null;
}
}]);
return DeprecationAssert;
}(_debug.default);
exports.default = DeprecationAssert;
});
enifed("ember-dev/test-helper/index", ["exports", "ember-dev/test-helper/deprecation", "ember-dev/test-helper/warning", "ember-dev/test-helper/remaining-view", "ember-dev/test-helper/remaining-template", "ember-dev/test-helper/assertion", "ember-dev/test-helper/run-loop", "ember-dev/test-helper/utils"], function (exports, _deprecation, _warning, _remainingView, _remainingTemplate, _assertion, _runLoop, _utils) {
"use strict";
var EmberDevTestHelperAssert = (0, _utils.buildCompositeAssert)([_deprecation.default, _warning.default, _remainingView.default, _remainingTemplate.default, _assertion.default, _runLoop.default]);
exports.default = EmberDevTestHelperAssert;
});
enifed('ember-dev/test-helper/method-call-tracker', ['exports', 'ember-dev/test-helper/utils'], function (exports, _utils) {
'use strict';
var MethodCallTracker = function MethodCallTracker(env, methodName) {
this._env = env;
this._methodName = methodName;
this._isExpectingNoCalls = false;
this._expecteds = [];
this._actuals = [];
}; /* globals QUnit */
MethodCallTracker.prototype = {
stubMethod: function stubMethod() {
var _this = this;
if (this._originalMethod) {
// Method is already stubbed
return;
}
var env = this._env;
var methodName = this._methodName;
this._originalMethod = env.getDebugFunction(methodName);
env.setDebugFunction(methodName, function (message, test) {
var resultOfTest = (0, _utils.checkTest)(test);
_this._actuals.push([message, resultOfTest]);
});
},
restoreMethod: function restoreMethod() {
if (this._originalMethod) {
this._env.setDebugFunction(this._methodName, this._originalMethod);
}
},
expectCall: function expectCall(message) {
this.stubMethod();
this._expecteds.push(message || /.*/);
},
expectNoCalls: function expectNoCalls() {
this.stubMethod();
this._isExpectingNoCalls = true;
},
isExpectingNoCalls: function isExpectingNoCalls() {
return this._isExpectingNoCalls;
},
isExpectingCalls: function isExpectingCalls() {
return !this._isExpectingNoCalls && this._expecteds.length;
},
assert: function assert() {
var env = this._env;
var methodName = this._methodName;
var isExpectingNoCalls = this._isExpectingNoCalls;
var expecteds = this._expecteds;
var actuals = this._actuals;
var o = undefined,
i = undefined;
if (!isExpectingNoCalls && expecteds.length === 0 && actuals.length === 0) {
return;
}
if (env.runningProdBuild) {
QUnit.ok(true, 'calls to Ember.' + methodName + ' disabled in production builds.');
return;
}
if (isExpectingNoCalls) {
var actualMessages = [];
for (i = 0; i < actuals.length; i++) {
if (!actuals[i][1]) {
actualMessages.push(actuals[i][0]);
}
}
QUnit.ok(actualMessages.length === 0, 'Expected no Ember.' + methodName + ' calls, got ' + actuals.length + ': ' + actualMessages.join(', '));
return;
}
var expected = undefined,
actual = undefined,
match = undefined;
for (o = 0; o < expecteds.length; o++) {
expected = expecteds[o];
for (i = 0; i < actuals.length; i++) {
actual = actuals[i];
if (!actual[1]) {
if (expected instanceof RegExp) {
if (expected.test(actual[0])) {
match = actual;
break;
}
} else {
if (expected === actual[0]) {
match = actual;
break;
}
}
}
}
if (!actual) {
QUnit.ok(false, 'Recieved no Ember.' + methodName + ' calls at all, expecting: ' + expected);
} else if (match && !match[1]) {
QUnit.ok(true, 'Recieved failing Ember.' + methodName + ' call with message: ' + match[0]);
} else if (match && match[1]) {
QUnit.ok(false, 'Expected failing Ember.' + methodName + ' call, got succeeding with message: ' + match[0]);
} else if (actual[1]) {
QUnit.ok(false, 'Did not receive failing Ember.' + methodName + ' call matching \'' + expected + '\', last was success with \'' + actual[0] + '\'');
} else if (!actual[1]) {
QUnit.ok(false, 'Did not receive failing Ember.' + methodName + ' call matching \'' + expected + '\', last was failure with \'' + actual[0] + '\'');
}
}
}
};
exports.default = MethodCallTracker;
});
enifed("ember-dev/test-helper/remaining-template", ["exports"], function (exports) {
"use strict";
/* globals QUnit */
var RemainingTemplateAssert = function RemainingTemplateAssert(env) {
this.env = env;
};
RemainingTemplateAssert.prototype = {
reset: function reset() {},
inject: function inject() {},
assert: function assert() {
if (this.env.Ember && this.env.Ember.TEMPLATES) {
var templateNames = [],
name;
for (name in this.env.Ember.TEMPLATES) {
if (this.env.Ember.TEMPLATES[name] != null) {
templateNames.push(name);
}
}
if (templateNames.length > 0) {
QUnit.deepEqual(templateNames, [], "Ember.TEMPLATES should be empty");
this.env.Ember.TEMPLATES = {};
}
}
},
restore: function restore() {}
};
exports.default = RemainingTemplateAssert;
});
enifed("ember-dev/test-helper/remaining-view", ["exports"], function (exports) {
"use strict";
/* globals QUnit */
var RemainingViewAssert = function RemainingViewAssert(env) {
this.env = env;
};
RemainingViewAssert.prototype = {
reset: function reset() {},
inject: function inject() {},
assert: function assert() {
if (this.env.Ember && this.env.Ember.View) {
var viewIds = [],
id;
for (id in this.env.Ember.View.views) {
if (this.env.Ember.View.views[id] != null) {
viewIds.push(id);
}
}
if (viewIds.length > 0) {
QUnit.deepEqual(viewIds, [], "Ember.View.views should be empty");
this.env.Ember.View.views = [];
}
}
},
restore: function restore() {}
};
exports.default = RemainingViewAssert;
});
enifed("ember-dev/test-helper/run-loop", ["exports"], function (exports) {
"use strict";
/* globals QUnit */
function RunLoopAssertion(env) {
this.env = env;
}
RunLoopAssertion.prototype = {
reset: function reset() {},
inject: function inject() {},
assert: function assert() {
var run = this.env.Ember.run;
if (run.currentRunLoop) {
QUnit.ok(false, "Should not be in a run loop at end of test");
while (run.currentRunLoop) {
run.end();
}
}
if (run.hasScheduledTimers()) {
QUnit.ok(false, "Ember run should not have scheduled timers at end of test");
run.cancelTimers();
}
},
restore: function restore() {}
};
exports.default = RunLoopAssertion;
});
enifed("ember-dev/test-helper/setup-qunit", ["exports"], function (exports) {
"use strict";
exports.default = setupQUnit;
/* globals QUnit */
function setupQUnit(assertion, _qunitGlobal) {
var qunitGlobal = QUnit;
if (_qunitGlobal) {
qunitGlobal = _qunitGlobal;
}
var originalModule = qunitGlobal.module;
qunitGlobal.module = function (name, _options) {
var options = _options || {};
var originalSetup = options.setup || function () {};
var originalTeardown = options.teardown || function () {};
options.setup = function () {
assertion.reset();
assertion.inject();
originalSetup.call(this);
};
options.teardown = function () {
originalTeardown.call(this);
assertion.assert();
assertion.restore();
};
return originalModule(name, options);
};
}
});
enifed('ember-dev/test-helper/utils', ['exports'], function (exports) {
'use strict';
exports.buildCompositeAssert = buildCompositeAssert;
exports.callWithStub = callWithStub;
exports.checkTest = checkTest;
function callForEach(prop, func) {
return function () {
for (var i = 0, l = this[prop].length; i < l; i++) {
this[prop][i][func]();
}
};
}
function buildCompositeAssert(assertClasses) {
function Composite(env) {
this.asserts = assertClasses.map(function (Assert) {
return new Assert(env);
});
}
Composite.prototype = {
reset: callForEach('asserts', 'reset'),
inject: callForEach('asserts', 'inject'),
assert: callForEach('asserts', 'assert'),
restore: callForEach('asserts', 'restore')
};
return Composite;
}
function noop() {}
function callWithStub(env, name, func) {
var debugStub = arguments.length <= 3 || arguments[3] === undefined ? noop : arguments[3];
var originalFunc = env.getDebugFunction(name);
try {
env.setDebugFunction(name, debugStub);
func();
} finally {
env.setDebugFunction(name, originalFunc);
}
}
function checkTest(test) {
return typeof test === 'function' ? test() : test;
}
});
enifed('ember-dev/test-helper/warning', ['exports', 'ember-babel', 'ember-dev/test-helper/debug', 'ember-dev/test-helper/utils'], function (exports, _emberBabel, _debug, _utils) {
'use strict';
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if ('value' in descriptor) descriptor.writable = true;Object.defineProperty(target, descriptor.key, descriptor);
}
}return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);if (staticProps) defineProperties(Constructor, staticProps);return Constructor;
};
}();
var _get = function get(_x, _x2, _x3) {
var _again = true;_function: while (_again) {
var object = _x,
property = _x2,
receiver = _x3;_again = false;if (object === null) object = Function.prototype;var desc = Object.getOwnPropertyDescriptor(object, property);if (desc === undefined) {
var parent = Object.getPrototypeOf(object);if (parent === null) {
return undefined;
} else {
_x = parent;_x2 = property;_x3 = receiver;_again = true;desc = parent = undefined;continue _function;
}
} else if ('value' in desc) {
return desc.value;
} else {
var getter = desc.get;if (getter === undefined) {
return undefined;
}return getter.call(receiver);
}
}
};
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError('Cannot call a class as a function');
}
}
function _inherits(subClass, superClass) {
if (typeof superClass !== 'function' && superClass !== null) {
throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass);
}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : (0, _emberBabel.defaults)(subClass, superClass);
}
var WarningAssert = function (_DebugAssert) {
_inherits(WarningAssert, _DebugAssert);
function WarningAssert(env) {
_classCallCheck(this, WarningAssert);
_get(Object.getPrototypeOf(WarningAssert.prototype), 'constructor', this).call(this, 'warn', env);
}
_createClass(WarningAssert, [{
key: 'inject',
value: function inject() {
var _this = this;
// Expects no warning to happen within a function, or if no function is
// passed, from the time of calling until the end of the test.
//
// expectNoWarning(function() {
// fancyNewThing();
// });
//
// expectNoWarning();
// Ember.warn("Oh snap, didn't expect that");
//
var expectNoWarning = function expectNoWarning(func) {
if (typeof func !== 'function') {
func = null;
}
_this.runExpectation(func, function (tracker) {
if (tracker.isExpectingCalls()) {
throw new Error("expectNoWarning was called after expectWarning was called!");
}
tracker.expectNoCalls();
});
};
// Expect a warning to happen within a function, or if no function is
// passed, from the time of calling until the end of the test. Can be called
// multiple times to assert warnings with different specific messages
// happened.
//
// expectWarning(function() {
// Ember.warn("Times they are a-changin'");
// }, /* optionalStringOrRegex */);
//
// expectWarning(/* optionalStringOrRegex */);
// Ember.warn("Times definitely be changin'");
//
var expectWarning = function expectWarning(fn, message) {
if (typeof fn !== 'function') {
message = fn;
fn = null;
}
_this.runExpectation(fn, function (tracker) {
if (tracker.isExpectingNoCalls()) {
throw new Error("expectWarning was called after expectNoWarning was called!");
}
tracker.expectCall(message);
});
};
var ignoreWarning = function ignoreWarning(func) {
(0, _utils.callWithStub)(_this.env, 'warn', func);
};
window.expectNoWarning = expectNoWarning;
window.expectWarning = expectWarning;
window.ignoreWarning = ignoreWarning;
}
}, {
key: 'restore',
value: function restore() {
_get(Object.getPrototypeOf(WarningAssert.prototype), 'restore', this).call(this);
window.expectWarning = null;
window.expectNoWarning = null;
window.ignoreWarning = null;
}
}]);
return WarningAssert;
}(_debug.default);
exports.default = WarningAssert;
});
QUnit.module('ESLint | ember-environment.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-environment.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-environment/lib/global.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-environment/lib/global.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-environment/lib/index.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-environment/lib/index.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-environment/lib/utils.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-environment/lib/utils.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-extension-support/lib/container_debug_adapter.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-extension-support/lib/container_debug_adapter.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-extension-support/lib/data_adapter.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-extension-support/lib/data_adapter.js should pass ESLint\n\n');
});
QUnit.module('ESLint | ember-extension-support/lib/index.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-extension-support/lib/index.js should pass ESLint\n\n');
});
enifed('ember-extension-support/tests/container_debug_adapter_test', ['ember-babel', 'internal-test-helpers', 'ember-utils', 'ember-metal', 'ember-runtime', 'ember-extension-support/index'], function (_emberBabel, _internalTestHelpers, _emberUtils, _emberMetal, _emberRuntime) {
'use strict';
// Must be required to export Ember.ContainerDebugAdapter.
var adapter = void 0;
(0, _internalTestHelpers.moduleFor)('Container Debug Adapter', function (_ApplicationTestCase) {
(0, _emberBabel.inherits)(_class, _ApplicationTestCase);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTestCase.call(this));
adapter = _this.application.__deprecatedInstance__.lookup('container-debug-adapter:main');
return _this;
}
_class.prototype.teardown = function teardown() {
(0, _emberMetal.run)(function () {
adapter.destroy();
});
_ApplicationTestCase.prototype.teardown.call(this);
};
_class.prototype['@test default ContainerDebugAdapter cannot catalog certain entries by type'] = function testDefaultContainerDebugAdapterCannotCatalogCertainEntriesByType(assert) {
assert.equal(adapter.canCatalogEntriesByType('model'), false, 'canCatalogEntriesByType should return false for model');
assert.equal(adapter.canCatalogEntriesByType('template'), false, 'canCatalogEntriesByType should return false for template');
};
_class.prototype['@test default ContainerDebugAdapter can catalog typical entries by type'] = function testDefaultContainerDebugAdapterCanCatalogTypicalEntriesByType(assert) {
assert.equal(adapter.canCatalogEntriesByType('controller'), true, 'canCatalogEntriesByType should return true for controller');
assert.equal(adapter.canCatalogEntriesByType('route'), true, 'canCatalogEntriesByType should return true for route');
assert.equal(adapter.canCatalogEntriesByType('view'), true, 'canCatalogEntriesByType should return true for view');
};
_class.prototype['@test default ContainerDebugAdapter catalogs controller entries'] = function testDefaultContainerDebugAdapterCatalogsControllerEntries(assert) {
this.application.PostController = _emberRuntime.Controller.extend();
var controllerClasses = adapter.catalogEntriesByType('controller');
assert.equal(controllerClasses.length, 1, 'found 1 class');
assert.equal(controllerClasses[0], 'post', 'found the right class');
};
(0, _emberBabel.createClass)(_class, [{
key: 'applicationOptions',
get: function () {
return (0, _emberUtils.assign)(_ApplicationTestCase.prototype.applicationOptions, {
autoboot: true
});
}
}]);
return _class;
}(_internalTestHelpers.ApplicationTestCase));
});
QUnit.module('ESLint | ember-extension-support/tests/container_debug_adapter_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-extension-support/tests/container_debug_adapter_test.js should pass ESLint\n\n');
});
enifed('ember-extension-support/tests/data_adapter_test', ['ember-babel', 'ember-metal', 'ember-runtime', 'ember-extension-support/data_adapter', 'internal-test-helpers'], function (_emberBabel, _emberMetal, _emberRuntime, _data_adapter, _internalTestHelpers) {
'use strict';
var adapter = void 0,
App = void 0;
var Model = _emberRuntime.Object.extend();
var PostClass = Model.extend();
var DataAdapter = _data_adapter.default.extend({
detect: function (klass) {
return klass !== Model && Model.detect(klass);
},
init: function () {
this._super.apply(this, arguments);
this.set('containerDebugAdapter', {
canCatalogEntriesByType: function (type) {
return true;
},
catalogEntriesByType: function (type) {
return (0, _emberRuntime.A)(['post']);
}
});
}
});
(0, _internalTestHelpers.moduleFor)('Data Adapter', 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 Model types added'] = function testModelTypesAdded() {
var _this2 = this;
this.add('data-adapter:main', DataAdapter.extend({
getRecords: function () {
return (0, _emberRuntime.A)([1, 2, 3]);
},
columnsForType: function () {
return [{ name: 'title', desc: 'Title' }];
}
}));
this.add('model:post', PostClass);
return this.visit('/').then(function () {
var adapter = _this2.applicationInstance.lookup('data-adapter:main');
function modelTypesAdded(types) {
equal(types.length, 1);
var postType = types[0];
equal(postType.name, 'post', 'Correctly sets the name');
equal(postType.count, 3, 'Correctly sets the record count');
strictEqual(postType.object, PostClass, 'Correctly sets the object');
deepEqual(postType.columns, [{ name: 'title', desc: 'Title' }], 'Correctly sets the columns');
}
adapter.watchModelTypes(modelTypesAdded);
});
};
_class.prototype['@test getRecords gets a model name as second argument'] = function testGetRecordsGetsAModelNameAsSecondArgument() {
var _this3 = this;
this.add('data-adapter:main', DataAdapter.extend({
getRecords: function (klass, name) {
equal(name, 'post');
return (0, _emberRuntime.A)();
}
}));
this.add('model:post', PostClass);
return this.visit('/').then(function () {
adapter = _this3.applicationInstance.lookup('data-adapter:main');
adapter.watchModelTypes(function () {});
});
};
_class.prototype['@test Model types added with custom container-debug-adapter'] = function testModelTypesAddedWithCustomContainerDebugAdapter() {
var _this4 = this;
var StubContainerDebugAdapter = _emberRuntime.Object.extend({
canCatalogEntriesByType: function (type) {
return true;
},
catalogEntriesByType: function (type) {
return (0, _emberRuntime.A)(['post']);
}
});
this.add('container-debug-adapter:main', StubContainerDebugAdapter);
this.add('data-adapter:main', DataAdapter.extend({
getRecords: function () {
return (0, _emberRuntime.A)([1, 2, 3]);
},
columnsForType: function () {
return [{ name: 'title', desc: 'Title' }];
}
}));
this.add('model:post', PostClass);
return this.visit('/').then(function () {
var adapter = _this4.applicationInstance.lookup('data-adapter:main');
function modelTypesAdded(types) {
equal(types.length, 1);
var postType = types[0];
equal(postType.name, 'post', 'Correctly sets the name');
equal(postType.count, 3, 'Correctly sets the record count');
strictEqual(postType.object, PostClass, 'Correctly sets the object');
deepEqual(postType.columns, [{ name: 'title', desc: 'Title' }], 'Correctly sets the columns');
}
adapter.watchModelTypes(modelTypesAdded);
});
};
_class.prototype['@test Model Types Updated'] = function testModelTypesUpdated() {
var _this5 = this;
var records = (0, _emberRuntime.A)([1, 2, 3]);
this.add('data-adapter:main', DataAdapter.extend({
getRecords: function (klass, name) {
return records;
}
}));
this.add('model:post', PostClass);
return this.visit('/').then(function () {
adapter = _this5.applicationInstance.lookup('data-adapter:main');
function modelTypesAdded(types) {
(0, _emberMetal.run)(function () {
records.pushObject(4);
});
}
function modelTypesUpdated(types) {
var postType = types[0];
equal(postType.count, 4, 'Correctly updates the count');
}
adapter.watchModelTypes(modelTypesAdded, modelTypesUpdated);
});
};
_class.prototype['@test Model Types Updated but Unchanged Do not Trigger Callbacks'] = function testModelTypesUpdatedButUnchangedDoNotTriggerCallbacks() {
var _this6 = this;
expect(0);
var records = (0, _emberRuntime.A)([1, 2, 3]);
this.add('data-adapter:main', DataAdapter.extend({
getRecords: function (klass, name) {
return records;
}
}));
this.add('model:post', PostClass);
return this.visit('/').then(function () {
adapter = _this6.applicationInstance.lookup('data-adapter:main');
function modelTypesAdded(types) {
(0, _emberMetal.run)(function () {
records.arrayContentDidChange(0, 0, 0);
});
}
function modelTypesUpdated(types) {
ok(false, "modelTypesUpdated should not be triggered if the array didn't change");
}
adapter.watchModelTypes(modelTypesAdded, modelTypesUpdated);
});
};
_class.prototype['@test Records Added'] = function testRecordsAdded() {
var _this7 = this;
var countAdded = 1;
var post = PostClass.create();
var recordList = (0, _emberRuntime.A)([post]);
this.add('data-adapter:main', DataAdapter.extend({
getRecords: function (klass, name) {
return recordList;
},
getRecordColor: function () {
return 'blue';
},
getRecordColumnValues: function () {
return { title: 'Post ' + countAdded };
},
getRecordKeywords: function () {
return ['Post ' + countAdded];
}
}));
this.add('model:post', PostClass);
return this.visit('/').then(function () {
adapter = _this7.applicationInstance.lookup('data-adapter:main');
function recordsAdded(records) {
var record = records[0];
equal(record.color, 'blue', 'Sets the color correctly');
deepEqual(record.columnValues, { title: 'Post ' + countAdded }, 'Sets the column values correctly');
deepEqual(record.searchKeywords, ['Post ' + countAdded], 'Sets search keywords correctly');
strictEqual(record.object, post, 'Sets the object to the record instance');
}
adapter.watchRecords('post', recordsAdded);
countAdded++;
post = PostClass.create();
recordList.pushObject(post);
});
};
_class.prototype['@test Observes and releases a record correctly'] = function testObservesAndReleasesARecordCorrectly() {
var _this8 = this;
var updatesCalled = 0;
var post = PostClass.create({ title: 'Post' });
var recordList = (0, _emberRuntime.A)([post]);
this.add('data-adapter:main', DataAdapter.extend({
getRecords: function () {
return recordList;
},
observeRecord: function (record, recordUpdated) {
var self = this;
function callback() {
recordUpdated(self.wrapRecord(record));
}
(0, _emberMetal.addObserver)(record, 'title', callback);
return function () {
(0, _emberMetal.removeObserver)(record, 'title', callback);
};
},
getRecordColumnValues: function (record) {
return { title: (0, _emberMetal.get)(record, 'title') };
}
}));
this.add('model:post', PostClass);
return this.visit('/').then(function () {
adapter = _this8.applicationInstance.lookup('data-adapter:main');
function recordsAdded() {
(0, _emberMetal.set)(post, 'title', 'Post Modified');
}
function recordsUpdated(records) {
updatesCalled++;
equal(records[0].columnValues.title, 'Post Modified');
}
var release = adapter.watchRecords('post', recordsAdded, recordsUpdated);
release();
(0, _emberMetal.set)(post, 'title', 'New Title');
equal(updatesCalled, 1, 'Release function removes observers');
});
};
_class.prototype['@test _nameToClass does not error when not found'] = function test_nameToClassDoesNotErrorWhenNotFound() {
var _this9 = this;
this.add('data-adapter:main', DataAdapter);
return this.visit('/').then(function () {
adapter = _this9.applicationInstance.lookup('data-adapter:main');
var klass = adapter._nameToClass('foo');
equal(klass, undefined, 'returns undefined');
});
};
return _class;
}(_internalTestHelpers.ApplicationTestCase));
});
QUnit.module('ESLint | ember-extension-support/tests/data_adapter_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-extension-support/tests/data_adapter_test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/application/actions-test', ['ember-babel', 'ember-runtime', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers'], function (_emberBabel, _emberRuntime, _testCase, _helpers) {
'use strict';
(0, _testCase.moduleFor)('Application test: actions', function (_ApplicationTest) {
(0, _emberBabel.inherits)(_class, _ApplicationTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTest.apply(this, arguments));
}
_class.prototype['@test actions in top level template application template target application controller'] = function testActionsInTopLevelTemplateApplicationTemplateTargetApplicationController(assert) {
var _this2 = this;
assert.expect(1);
this.add('controller:application', _emberRuntime.Controller.extend({
actions: {
handleIt: function (arg) {
assert.ok(true, 'controller received action properly');
}
}
}));
this.addTemplate('application', '<button id="handle-it" {{action "handleIt"}}>Click!</button>');
return this.visit('/').then(function () {
_this2.runTask(function () {
return _this2.$('#handle-it').click();
});
});
};
_class.prototype['@test actions in nested outlet template target their controller'] = function testActionsInNestedOutletTemplateTargetTheirController(assert) {
var _this3 = this;
assert.expect(1);
this.add('controller:application', _emberRuntime.Controller.extend({
actions: {
handleIt: function (arg) {
assert.ok(false, 'application controller should not have received action!');
}
}
}));
this.add('controller:index', _emberRuntime.Controller.extend({
actions: {
handleIt: function (arg) {
assert.ok(true, 'controller received action properly');
}
}
}));
this.addTemplate('index', '<button id="handle-it" {{action "handleIt"}}>Click!</button>');
return this.visit('/').then(function () {
_this3.runTask(function () {
return _this3.$('#handle-it').click();
});
});
};
return _class;
}(_testCase.ApplicationTest));
(0, _testCase.moduleFor)('Rendering test: non-interactive actions', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class2, _RenderingTest);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.apply(this, arguments));
}
_class2.prototype.getBootOptions = function getBootOptions() {
return { isInteractive: false };
};
_class2.prototype['@test doesn\'t attatch actions'] = function (assert) {
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
actions: {
fire: function () {
assert.ok(false);
}
}
}),
template: '<button {{action \'fire\'}}>Fire!</button>'
});
this.render('{{foo-bar tagName=""}}');
this.assertHTML('<button>Fire!</button>');
this.$('button').click();
};
return _class2;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/application/actions-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/application/actions-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/application/engine-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers', 'ember-runtime', 'ember-glimmer', 'ember-application', 'ember-routing', 'ember-metal'], function (_emberBabel, _testCase, _abstractTestCase, _helpers, _emberRuntime, _emberGlimmer, _emberApplication, _emberRouting, _emberMetal) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <h1>{{contextType}}</h1>\n {{ambiguous-curlies}}\n\n {{outlet}}\n '], ['\n <h1>{{contextType}}</h1>\n {{ambiguous-curlies}}\n\n {{outlet}}\n ']),
_templateObject2 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <p>Component!</p>\n '], ['\n <p>Component!</p>\n ']),
_templateObject3 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{ambiguous-curlies}}\n '], ['\n {{ambiguous-curlies}}\n ']),
_templateObject4 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <h1>Application</h1>\n {{my-component ambiguous-curlies="Local Data!"}}\n {{outlet}}\n '], ['\n <h1>Application</h1>\n {{my-component ambiguous-curlies="Local Data!"}}\n {{outlet}}\n ']),
_templateObject5 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <h1>Engine</h1>\n {{my-component}}\n {{outlet}}\n '], ['\n <h1>Engine</h1>\n {{my-component}}\n {{outlet}}\n ']),
_templateObject6 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <p>Component!</p>\n '], ['\n <p>Component!</p>\n ']);
(0, _testCase.moduleFor)('Application test: engine rendering', function (_ApplicationTest) {
(0, _emberBabel.inherits)(_class, _ApplicationTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTest.apply(this, arguments));
}
_class.prototype.setupAppAndRoutableEngine = function setupAppAndRoutableEngine() {
var hooks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var self = this;
this.addTemplate('application', 'Application{{outlet}}');
this.router.map(function () {
this.mount('blog');
});
this.add('route-map:blog', function () {
this.route('post', function () {
this.route('comments');
this.route('likes');
});
this.route('category', { path: 'category/:id' });
this.route('author', { path: 'author/:id' });
});
this.add('route:application', _emberRouting.Route.extend({
model: function () {
hooks.push('application - application');
}
}));
this.add('engine:blog', _emberApplication.Engine.extend({
init: function () {
this._super.apply(this, arguments);
this.register('controller:application', _emberRuntime.Controller.extend({
queryParams: ['lang'],
lang: ''
}));
this.register('controller:category', _emberRuntime.Controller.extend({
queryParams: ['type']
}));
this.register('controller:authorKtrl', _emberRuntime.Controller.extend({
queryParams: ['official']
}));
this.register('template:application', (0, _helpers.compile)('Engine{{lang}}{{outlet}}'));
this.register('route:application', _emberRouting.Route.extend({
model: function () {
hooks.push('engine - application');
}
}));
this.register('route:author', _emberRouting.Route.extend({
controllerName: 'authorKtrl'
}));
if (self._additionalEngineRegistrations) {
self._additionalEngineRegistrations.call(this);
}
}
}));
};
_class.prototype.setupAppAndRoutelessEngine = function setupAppAndRoutelessEngine(hooks) {
this.setupRoutelessEngine(hooks);
this.add('engine:chat-engine', _emberApplication.Engine.extend({
init: function () {
this._super.apply(this, arguments);
this.register('template:application', (0, _helpers.compile)('Engine'));
this.register('controller:application', _emberRuntime.Controller.extend({
init: function () {
this._super.apply(this, arguments);
hooks.push('engine - application');
}
}));
}
}));
};
_class.prototype.setupAppAndRoutableEngineWithPartial = function setupAppAndRoutableEngineWithPartial(hooks) {
this.addTemplate('application', 'Application{{outlet}}');
this.router.map(function () {
this.mount('blog');
});
this.add('route-map:blog', function () {});
this.add('route:application', _emberRouting.Route.extend({
model: function () {
hooks.push('application - application');
}
}));
this.add('engine:blog', _emberApplication.Engine.extend({
init: function () {
this._super.apply(this, arguments);
this.register('template:foo', (0, _helpers.compile)('foo partial'));
this.register('template:application', (0, _helpers.compile)('Engine{{outlet}} {{partial "foo"}}'));
this.register('route:application', _emberRouting.Route.extend({
model: function () {
hooks.push('engine - application');
}
}));
}
}));
};
_class.prototype.setupRoutelessEngine = function setupRoutelessEngine(hooks) {
this.addTemplate('application', 'Application{{mount "chat-engine"}}');
this.add('route:application', _emberRouting.Route.extend({
model: function () {
hooks.push('application - application');
}
}));
};
_class.prototype.setupAppAndRoutlessEngineWithPartial = function setupAppAndRoutlessEngineWithPartial(hooks) {
this.setupRoutelessEngine(hooks);
this.add('engine:chat-engine', _emberApplication.Engine.extend({
init: function () {
this._super.apply(this, arguments);
this.register('template:foo', (0, _helpers.compile)('foo partial'));
this.register('template:application', (0, _helpers.compile)('Engine {{partial "foo"}}'));
this.register('controller:application', _emberRuntime.Controller.extend({
init: function () {
this._super.apply(this, arguments);
hooks.push('engine - application');
}
}));
}
}));
};
_class.prototype.additionalEngineRegistrations = function additionalEngineRegistrations(callback) {
this._additionalEngineRegistrations = callback;
};
_class.prototype.setupEngineWithAttrs = function setupEngineWithAttrs(hooks) {
this.addTemplate('application', 'Application{{mount "chat-engine"}}');
this.add('engine:chat-engine', _emberApplication.Engine.extend({
init: function () {
this._super.apply(this, arguments);
this.register('template:components/foo-bar', (0, _helpers.compile)('{{partial "troll"}}'));
this.register('template:troll', (0, _helpers.compile)('{{attrs.wat}}'));
this.register('controller:application', _emberRuntime.Controller.extend({
contextType: 'Engine'
}));
this.register('template:application', (0, _helpers.compile)('Engine {{foo-bar wat=contextType}}'));
}
}));
};
_class.prototype.stringsEndWith = function stringsEndWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
};
_class.prototype['@test attrs in an engine'] = function testAttrsInAnEngine() {
var _this2 = this;
this.setupEngineWithAttrs([]);
return this.visit('/').then(function () {
_this2.assertText('ApplicationEngine Engine');
});
};
_class.prototype['@test sharing a template between engine and application has separate refinements'] = function testSharingATemplateBetweenEngineAndApplicationHasSeparateRefinements() {
var _this3 = this;
this.assert.expect(1);
var sharedTemplate = (0, _helpers.compile)((0, _abstractTestCase.strip)(_templateObject));
this.add('template:application', sharedTemplate);
this.add('controller:application', _emberRuntime.Controller.extend({
contextType: 'Application',
'ambiguous-curlies': 'Controller Data!'
}));
this.router.map(function () {
this.mount('blog');
});
this.add('route-map:blog', function () {});
this.add('engine:blog', _emberApplication.Engine.extend({
init: function () {
this._super.apply(this, arguments);
this.register('controller:application', _emberRuntime.Controller.extend({
contextType: 'Engine'
}));
this.register('template:application', sharedTemplate);
this.register('template:components/ambiguous-curlies', (0, _helpers.compile)((0, _abstractTestCase.strip)(_templateObject2)));
}
}));
return this.visit('/blog').then(function () {
_this3.assertText('ApplicationController Data!EngineComponent!');
});
};
_class.prototype['@test sharing a layout between engine and application has separate refinements'] = function testSharingALayoutBetweenEngineAndApplicationHasSeparateRefinements() {
var _this4 = this;
this.assert.expect(1);
var sharedLayout = (0, _helpers.compile)((0, _abstractTestCase.strip)(_templateObject3));
var sharedComponent = _emberGlimmer.Component.extend({
layout: sharedLayout
});
this.addTemplate('application', (0, _abstractTestCase.strip)(_templateObject4));
this.add('component:my-component', sharedComponent);
this.router.map(function () {
this.mount('blog');
});
this.add('route-map:blog', function () {});
this.add('engine:blog', _emberApplication.Engine.extend({
init: function () {
this._super.apply(this, arguments);
this.register('template:application', (0, _helpers.compile)((0, _abstractTestCase.strip)(_templateObject5)));
this.register('component:my-component', sharedComponent);
this.register('template:components/ambiguous-curlies', (0, _helpers.compile)((0, _abstractTestCase.strip)(_templateObject6)));
}
}));
return this.visit('/blog').then(function () {
_this4.assertText('ApplicationLocal Data!EngineComponent!');
});
};
_class.prototype['@test visit() with `shouldRender: true` returns a promise that resolves when application and engine templates have rendered'] = function testVisitWithShouldRenderTrueReturnsAPromiseThatResolvesWhenApplicationAndEngineTemplatesHaveRendered(assert) {
var _this5 = this;
assert.expect(2);
var hooks = [];
this.setupAppAndRoutableEngine(hooks);
return this.visit('/blog', { shouldRender: true }).then(function () {
_this5.assertText('ApplicationEngine');
_this5.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected model hooks were fired');
});
};
_class.prototype['@test visit() with `shouldRender: false` returns a promise that resolves without rendering'] = function testVisitWithShouldRenderFalseReturnsAPromiseThatResolvesWithoutRendering(assert) {
var _this6 = this;
assert.expect(2);
var hooks = [];
this.setupAppAndRoutableEngine(hooks);
return this.visit('/blog', { shouldRender: false }).then(function () {
_this6.assertText('');
_this6.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected model hooks were fired');
});
};
_class.prototype['@test visit() with `shouldRender: true` returns a promise that resolves when application and routeless engine templates have rendered'] = function testVisitWithShouldRenderTrueReturnsAPromiseThatResolvesWhenApplicationAndRoutelessEngineTemplatesHaveRendered(assert) {
var _this7 = this;
assert.expect(2);
var hooks = [];
this.setupAppAndRoutelessEngine(hooks);
return this.visit('/', { shouldRender: true }).then(function () {
_this7.assertText('ApplicationEngine');
_this7.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired');
});
};
_class.prototype['@test visit() with partials in routable engine'] = function testVisitWithPartialsInRoutableEngine(assert) {
var _this8 = this;
assert.expect(2);
var hooks = [];
this.setupAppAndRoutableEngineWithPartial(hooks);
return this.visit('/blog', { shouldRender: true }).then(function () {
_this8.assertText('ApplicationEngine foo partial');
_this8.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired');
});
};
_class.prototype['@test visit() with partials in non-routable engine'] = function testVisitWithPartialsInNonRoutableEngine(assert) {
var _this9 = this;
assert.expect(2);
var hooks = [];
this.setupAppAndRoutlessEngineWithPartial(hooks);
return this.visit('/', { shouldRender: true }).then(function () {
_this9.assertText('ApplicationEngine foo partial');
_this9.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired');
});
};
_class.prototype['@test deactivate should be called on Engine Routes before destruction'] = function testDeactivateShouldBeCalledOnEngineRoutesBeforeDestruction(assert) {
var _this10 = this;
assert.expect(3);
this.setupAppAndRoutableEngine();
this.add('engine:blog', _emberApplication.Engine.extend({
init: function () {
this._super.apply(this, arguments);
this.register('template:application', (0, _helpers.compile)('Engine{{outlet}}'));
this.register('route:application', _emberRouting.Route.extend({
deactivate: function () {
assert.notOk(this.isDestroyed, 'Route is not destroyed');
assert.notOk(this.isDestroying, 'Route is not being destroyed');
}
}));
}
}));
return this.visit('/blog').then(function () {
_this10.assertText('ApplicationEngine');
});
};
_class.prototype['@test engine should lookup and use correct controller'] = function testEngineShouldLookupAndUseCorrectController(assert) {
var _this11 = this;
this.setupAppAndRoutableEngine();
return this.visit('/blog?lang=English').then(function () {
_this11.assertText('ApplicationEngineEnglish');
});
};
_class.prototype['@test error substate route works for the application route of an Engine'] = function testErrorSubstateRouteWorksForTheApplicationRouteOfAnEngine(assert) {
var _this12 = this;
assert.expect(2);
var errorEntered = _emberRuntime.RSVP.defer();
this.setupAppAndRoutableEngine();
this.additionalEngineRegistrations(function () {
this.register('route:application_error', _emberRouting.Route.extend({
activate: function () {
_emberMetal.run.next(errorEntered.resolve);
}
}));
this.register('template:application_error', (0, _helpers.compile)('Error! {{model.message}}'));
this.register('route:post', _emberRouting.Route.extend({
model: function () {
return _emberRuntime.RSVP.reject(new Error('Oh, noes!'));
}
}));
});
return this.visit('/').then(function () {
_this12.assertText('Application');
return _this12.transitionTo('blog.post');
}).then(function () {
return errorEntered.promise;
}).then(function () {
_this12.assertText('ApplicationError! Oh, noes!');
});
};
_class.prototype['@test error route works for the application route of an Engine'] = function testErrorRouteWorksForTheApplicationRouteOfAnEngine(assert) {
var _this13 = this;
assert.expect(2);
var errorEntered = _emberRuntime.RSVP.defer();
this.setupAppAndRoutableEngine();
this.additionalEngineRegistrations(function () {
this.register('route:error', _emberRouting.Route.extend({
activate: function () {
_emberMetal.run.next(errorEntered.resolve);
}
}));
this.register('template:error', (0, _helpers.compile)('Error! {{model.message}}'));
this.register('route:post', _emberRouting.Route.extend({
model: function () {
return _emberRuntime.RSVP.reject(new Error('Oh, noes!'));
}
}));
});
return this.visit('/').then(function () {
_this13.assertText('Application');
return _this13.transitionTo('blog.post');
}).then(function () {
return errorEntered.promise;
}).then(function () {
_this13.assertText('ApplicationEngineError! Oh, noes!');
});
};
_class.prototype['@test error substate route works for a child route of an Engine'] = function testErrorSubstateRouteWorksForAChildRouteOfAnEngine(assert) {
var _this14 = this;
assert.expect(2);
var errorEntered = _emberRuntime.RSVP.defer();
this.setupAppAndRoutableEngine();
this.additionalEngineRegistrations(function () {
this.register('route:post_error', _emberRouting.Route.extend({
activate: function () {
_emberMetal.run.next(errorEntered.resolve);
}
}));
this.register('template:post_error', (0, _helpers.compile)('Error! {{model.message}}'));
this.register('route:post', _emberRouting.Route.extend({
model: function () {
return _emberRuntime.RSVP.reject(new Error('Oh, noes!'));
}
}));
});
return this.visit('/').then(function () {
_this14.assertText('Application');
return _this14.transitionTo('blog.post');
}).then(function () {
return errorEntered.promise;
}).then(function () {
_this14.assertText('ApplicationEngineError! Oh, noes!');
});
};
_class.prototype['@test error route works for a child route of an Engine'] = function testErrorRouteWorksForAChildRouteOfAnEngine(assert) {
var _this15 = this;
assert.expect(2);
var errorEntered = _emberRuntime.RSVP.defer();
this.setupAppAndRoutableEngine();
this.additionalEngineRegistrations(function () {
this.register('route:post.error', _emberRouting.Route.extend({
activate: function () {
_emberMetal.run.next(errorEntered.resolve);
}
}));
this.register('template:post.error', (0, _helpers.compile)('Error! {{model.message}}'));
this.register('route:post.comments', _emberRouting.Route.extend({
model: function () {
return _emberRuntime.RSVP.reject(new Error('Oh, noes!'));
}
}));
});
return this.visit('/').then(function () {
_this15.assertText('Application');
return _this15.transitionTo('blog.post.comments');
}).then(function () {
return errorEntered.promise;
}).then(function () {
_this15.assertText('ApplicationEngineError! Oh, noes!');
});
};
_class.prototype['@test loading substate route works for the application route of an Engine'] = function testLoadingSubstateRouteWorksForTheApplicationRouteOfAnEngine(assert) {
var _this16 = this;
assert.expect(3);
var done = assert.async();
var loadingEntered = _emberRuntime.RSVP.defer();
var resolveLoading = _emberRuntime.RSVP.defer();
this.setupAppAndRoutableEngine();
this.additionalEngineRegistrations(function () {
this.register('route:application_loading', _emberRouting.Route.extend({
activate: function () {
_emberMetal.run.next(loadingEntered.resolve);
}
}));
this.register('template:application_loading', (0, _helpers.compile)('Loading'));
this.register('template:post', (0, _helpers.compile)('Post'));
this.register('route:post', _emberRouting.Route.extend({
model: function () {
return resolveLoading.promise;
}
}));
});
return this.visit('/').then(function () {
_this16.assertText('Application');
var transition = _this16.transitionTo('blog.post');
loadingEntered.promise.then(function () {
_this16.assertText('ApplicationLoading');
resolveLoading.resolve();
_this16.runTaskNext(function () {
_this16.assertText('ApplicationEnginePost');
done();
});
});
return transition;
});
};
_class.prototype['@test loading route works for the application route of an Engine'] = function testLoadingRouteWorksForTheApplicationRouteOfAnEngine(assert) {
var _this17 = this;
assert.expect(3);
var done = assert.async();
var loadingEntered = _emberRuntime.RSVP.defer();
var resolveLoading = _emberRuntime.RSVP.defer();
this.setupAppAndRoutableEngine();
this.additionalEngineRegistrations(function () {
this.register('route:loading', _emberRouting.Route.extend({
activate: function () {
_emberMetal.run.next(loadingEntered.resolve);
}
}));
this.register('template:loading', (0, _helpers.compile)('Loading'));
this.register('template:post', (0, _helpers.compile)('Post'));
this.register('route:post', _emberRouting.Route.extend({
model: function () {
return resolveLoading.promise;
}
}));
});
return this.visit('/').then(function () {
_this17.assertText('Application');
var transition = _this17.transitionTo('blog.post');
loadingEntered.promise.then(function () {
_this17.assertText('ApplicationEngineLoading');
resolveLoading.resolve();
_this17.runTaskNext(function () {
_this17.assertText('ApplicationEnginePost');
done();
});
});
return transition;
});
};
_class.prototype['@test loading substate route works for a child route of an Engine'] = function testLoadingSubstateRouteWorksForAChildRouteOfAnEngine(assert) {
var _this18 = this;
assert.expect(3);
var resolveLoading = void 0;
this.setupAppAndRoutableEngine();
this.additionalEngineRegistrations(function () {
this.register('template:post', (0, _helpers.compile)('{{outlet}}'));
this.register('template:post.comments', (0, _helpers.compile)('Comments'));
this.register('template:post.likes_loading', (0, _helpers.compile)('Loading'));
this.register('template:post.likes', (0, _helpers.compile)('Likes'));
this.register('route:post.likes', _emberRouting.Route.extend({
model: function () {
return new _emberRuntime.RSVP.Promise(function (resolve) {
resolveLoading = resolve;
});
}
}));
});
return this.visit('/blog/post/comments').then(function () {
_this18.assertText('ApplicationEngineComments');
var transition = _this18.transitionTo('blog.post.likes');
_this18.runTaskNext(function () {
_this18.assertText('ApplicationEngineLoading');
resolveLoading();
});
return transition.then(function () {
_this18.runTaskNext(function () {
return _this18.assertText('ApplicationEngineLikes');
});
});
});
};
_class.prototype['@test loading route works for a child route of an Engine'] = function testLoadingRouteWorksForAChildRouteOfAnEngine(assert) {
var _this19 = this;
assert.expect(3);
var done = assert.async();
var loadingEntered = _emberRuntime.RSVP.defer();
var resolveLoading = _emberRuntime.RSVP.defer();
this.setupAppAndRoutableEngine();
this.additionalEngineRegistrations(function () {
this.register('template:post', (0, _helpers.compile)('{{outlet}}'));
this.register('template:post.comments', (0, _helpers.compile)('Comments'));
this.register('route:post.loading', _emberRouting.Route.extend({
activate: function () {
_emberMetal.run.next(loadingEntered.resolve);
}
}));
this.register('template:post.loading', (0, _helpers.compile)('Loading'));
this.register('template:post.likes', (0, _helpers.compile)('Likes'));
this.register('route:post.likes', _emberRouting.Route.extend({
model: function () {
return resolveLoading.promise;
}
}));
});
return this.visit('/blog/post/comments').then(function () {
_this19.assertText('ApplicationEngineComments');
var transition = _this19.transitionTo('blog.post.likes');
loadingEntered.promise.then(function () {
_this19.assertText('ApplicationEngineLoading');
resolveLoading.resolve();
_this19.runTaskNext(function () {
_this19.assertText('ApplicationEngineLikes');
done();
});
});
return transition;
});
};
_class.prototype['@test query params don\'t have stickiness by default between model'] = function testQueryParamsDonTHaveStickinessByDefaultBetweenModel(assert) {
var _this20 = this;
assert.expect(1);
var tmpl = '{{#link-to "blog.category" 1337}}Category 1337{{/link-to}}';
this.setupAppAndRoutableEngine();
this.additionalEngineRegistrations(function () {
this.register('template:category', (0, _helpers.compile)(tmpl));
});
return this.visit('/blog/category/1?type=news').then(function () {
var suffix = '/blog/category/1337';
var href = _this20.element.querySelector('a').href;
// check if link ends with the suffix
assert.ok(_this20.stringsEndWith(href, suffix));
});
};
_class.prototype['@test query params in customized controllerName have stickiness by default between model'] = function testQueryParamsInCustomizedControllerNameHaveStickinessByDefaultBetweenModel(assert) {
var _this21 = this;
assert.expect(2);
var tmpl = '{{#link-to "blog.author" 1337 class="author-1337"}}Author 1337{{/link-to}}{{#link-to "blog.author" 1 class="author-1"}}Author 1{{/link-to}}';
this.setupAppAndRoutableEngine();
this.additionalEngineRegistrations(function () {
this.register('template:author', (0, _helpers.compile)(tmpl));
});
return this.visit('/blog/author/1?official=true').then(function () {
var suffix1 = '/blog/author/1?official=true';
var href1 = _this21.element.querySelector('.author-1').href;
var suffix1337 = '/blog/author/1337';
var href1337 = _this21.element.querySelector('.author-1337').href;
// check if link ends with the suffix
assert.ok(_this21.stringsEndWith(href1, suffix1));
assert.ok(_this21.stringsEndWith(href1337, suffix1337));
});
};
_class.prototype['@test visit() routable engine which errors on init'] = function testVisitRoutableEngineWhichErrorsOnInit(assert) {
var _this22 = this;
assert.expect(1);
var hooks = [];
this.additionalEngineRegistrations(function () {
this.register('route:application', _emberRouting.Route.extend({
init: function () {
throw new Error('Whoops! Something went wrong...');
}
}));
});
this.setupAppAndRoutableEngine(hooks);
return this.visit('/', { shouldRender: true }).then(function () {
return _this22.visit('/blog');
}).catch(function (error) {
assert.equal(error.message, 'Whoops! Something went wrong...');
});
};
(0, _emberBabel.createClass)(_class, [{
key: 'routerOptions',
get: function () {
var assert = this.assert;
return {
location: 'none',
_getHandlerFunction: function () {
var _this23 = this;
var syncHandler = this._super.apply(this, arguments);
this._enginePromises = Object.create(null);
this._resolvedEngines = Object.create(null);
return function (name) {
var engineInfo = _this23._engineInfoByRoute[name];
if (!engineInfo) {
return syncHandler(name);
}
var engineName = engineInfo.name;
if (_this23._resolvedEngines[engineName]) {
return syncHandler(name);
}
var enginePromise = _this23._enginePromises[engineName];
if (!enginePromise) {
enginePromise = new _emberRuntime.RSVP.Promise(function (resolve) {
setTimeout(function () {
_this23._resolvedEngines[engineName] = true;
resolve();
}, 1);
});
_this23._enginePromises[engineName] = enginePromise;
}
return enginePromise.then(function () {
return syncHandler(name);
});
};
}
};
}
}]);
return _class;
}(_testCase.ApplicationTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/application/engine-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/application/engine-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/application/rendering-test', ['ember-babel', 'ember-runtime', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-routing', 'ember-glimmer', 'ember/features'], function (_emberBabel, _emberRuntime, _testCase, _abstractTestCase, _emberRouting, _emberGlimmer, _features) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <ul>\n {{#each model as |item|}}\n <li>{{item}}</li>\n {{/each}}\n </ul>\n '], ['\n <ul>\n {{#each model as |item|}}\n <li>{{item}}</li>\n {{/each}}\n </ul>\n ']),
_templateObject2 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <ul>\n <li>red</li>\n <li>yellow</li>\n <li>blue</li>\n </ul>\n '], ['\n <ul>\n <li>red</li>\n <li>yellow</li>\n <li>blue</li>\n </ul>\n ']),
_templateObject3 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <nav>{{outlet "nav"}}</nav>\n <main>{{outlet}}</main>\n '], ['\n <nav>{{outlet "nav"}}</nav>\n <main>{{outlet}}</main>\n ']),
_templateObject4 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <a href="https://emberjs.com/">Ember</a>\n '], ['\n <a href="https://emberjs.com/">Ember</a>\n ']),
_templateObject5 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <nav>\n <a href="https://emberjs.com/">Ember</a>\n </nav>\n <main>\n <ul>\n <li>red</li>\n <li>yellow</li>\n <li>blue</li>\n </ul>\n </main>\n '], ['\n <nav>\n <a href="https://emberjs.com/">Ember</a>\n </nav>\n <main>\n <ul>\n <li>red</li>\n <li>yellow</li>\n <li>blue</li>\n </ul>\n </main>\n ']);
(0, _testCase.moduleFor)('Application test: rendering', function (_ApplicationTest) {
(0, _emberBabel.inherits)(_class, _ApplicationTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTest.apply(this, arguments));
}
_class.prototype['@test it can render the application template'] = function testItCanRenderTheApplicationTemplate(assert) {
var _this2 = this;
this.addTemplate('application', 'Hello world!');
return this.visit('/').then(function () {
_this2.assertText('Hello world!');
});
};
_class.prototype['@test it can access the model provided by the route'] = function testItCanAccessTheModelProvidedByTheRoute(assert) {
var _this3 = this;
this.add('route:application', _emberRouting.Route.extend({
model: function () {
return ['red', 'yellow', 'blue'];
}
}));
this.addTemplate('application', (0, _abstractTestCase.strip)(_templateObject));
return this.visit('/').then(function () {
_this3.assertComponentElement(_this3.firstChild, {
content: (0, _abstractTestCase.strip)(_templateObject2)
});
});
};
_class.prototype['@test it can render a nested route'] = function testItCanRenderANestedRoute(assert) {
var _this4 = this;
this.router.map(function () {
this.route('lists', function () {
this.route('colors', function () {
this.route('favorite');
});
});
});
// The "favorite" route will inherit the model
this.add('route:lists.colors', _emberRouting.Route.extend({
model: function () {
return ['red', 'yellow', 'blue'];
}
}));
this.addTemplate('lists.colors.favorite', (0, _abstractTestCase.strip)(_templateObject));
return this.visit('/lists/colors/favorite').then(function () {
_this4.assertComponentElement(_this4.firstChild, {
content: (0, _abstractTestCase.strip)(_templateObject2)
});
});
};
_class.prototype['@test it can render into named outlets'] = function testItCanRenderIntoNamedOutlets(assert) {
var _this5 = this;
this.router.map(function () {
this.route('colors');
});
this.addTemplate('application', (0, _abstractTestCase.strip)(_templateObject3));
this.addTemplate('nav', (0, _abstractTestCase.strip)(_templateObject4));
this.add('route:application', _emberRouting.Route.extend({
renderTemplate: function () {
this.render();
this.render('nav', {
into: 'application',
outlet: 'nav'
});
}
}));
this.add('route:colors', _emberRouting.Route.extend({
model: function () {
return ['red', 'yellow', 'blue'];
}
}));
this.addTemplate('colors', (0, _abstractTestCase.strip)(_templateObject));
return this.visit('/colors').then(function () {
_this5.assertComponentElement(_this5.firstChild, {
content: (0, _abstractTestCase.strip)(_templateObject5)
});
});
};
_class.prototype['@test it can render into named outlets'] = function testItCanRenderIntoNamedOutlets(assert) {
var _this6 = this;
this.router.map(function () {
this.route('colors');
});
this.addTemplate('application', (0, _abstractTestCase.strip)(_templateObject3));
this.addTemplate('nav', (0, _abstractTestCase.strip)(_templateObject4));
this.add('route:application', _emberRouting.Route.extend({
renderTemplate: function () {
this.render();
this.render('nav', {
into: 'application',
outlet: 'nav'
});
}
}));
this.add('route:colors', _emberRouting.Route.extend({
model: function () {
return ['red', 'yellow', 'blue'];
}
}));
this.addTemplate('colors', (0, _abstractTestCase.strip)(_templateObject));
return this.visit('/colors').then(function () {
_this6.assertComponentElement(_this6.firstChild, {
content: (0, _abstractTestCase.strip)(_templateObject5)
});
});
};
_class.prototype['@test it should update the outlets when switching between routes'] = function testItShouldUpdateTheOutletsWhenSwitchingBetweenRoutes(assert) {
var _this7 = this;
this.router.map(function () {
this.route('a');
this.route('b', function () {
this.route('c');
this.route('d');
});
});
this.addTemplate('a', 'A{{outlet}}');
this.addTemplate('b', 'B{{outlet}}');
this.addTemplate('b.c', 'C');
this.addTemplate('b.d', 'D');
return this.visit('/b/c').then(function () {
// this.assertComponentElement(this.firstChild, { content: 'BC' });
_this7.assertText('BC');
return _this7.visit('/a');
}).then(function () {
// this.assertComponentElement(this.firstChild, { content: 'A' });
_this7.assertText('A');
return _this7.visit('/b/d');
}).then(function () {
_this7.assertText('BD');
// this.assertComponentElement(this.firstChild, { content: 'BD' });
});
};
_class.prototype['@test it should produce a stable DOM when the model changes'] = function testItShouldProduceAStableDOMWhenTheModelChanges(assert) {
var _this8 = this;
this.router.map(function () {
this.route('color', { path: '/colors/:color' });
});
this.add('route:color', _emberRouting.Route.extend({
model: function (params) {
return params.color;
}
}));
this.addTemplate('color', 'color: {{model}}');
return this.visit('/colors/red').then(function () {
_this8.assertComponentElement(_this8.firstChild, { content: 'color: red' });
_this8.takeSnapshot();
return _this8.visit('/colors/green');
}).then(function () {
_this8.assertComponentElement(_this8.firstChild, { content: 'color: green' });
_this8.assertInvariants();
});
};
_class.prototype['@test it should have the right controller in scope for the route template'] = function testItShouldHaveTheRightControllerInScopeForTheRouteTemplate() {
var _this9 = this;
this.router.map(function () {
this.route('a');
this.route('b');
});
this.add('controller:a', _emberRuntime.Controller.extend({
value: 'a'
}));
this.add('controller:b', _emberRuntime.Controller.extend({
value: 'b'
}));
this.addTemplate('a', '{{value}}');
this.addTemplate('b', '{{value}}');
return this.visit('/a').then(function () {
_this9.assertText('a');
return _this9.visit('/b');
}).then(function () {
return _this9.assertText('b');
});
};
_class.prototype['@test it should update correctly when the controller changes'] = function testItShouldUpdateCorrectlyWhenTheControllerChanges(assert) {
var _this10 = this;
this.router.map(function () {
this.route('color', { path: '/colors/:color' });
});
this.add('route:color', _emberRouting.Route.extend({
model: function (params) {
return { color: params.color };
},
renderTemplate: function (controller, model) {
this.render({ controller: model.color, model: model });
}
}));
this.add('controller:red', _emberRuntime.Controller.extend({
color: 'red'
}));
this.add('controller:green', _emberRuntime.Controller.extend({
color: 'green'
}));
this.addTemplate('color', 'model color: {{model.color}}, controller color: {{color}}');
return this.visit('/colors/red').then(function () {
_this10.assertComponentElement(_this10.firstChild, { content: 'model color: red, controller color: red' });
_this10.takeSnapshot();
return _this10.visit('/colors/green');
}).then(function () {
_this10.assertComponentElement(_this10.firstChild, { content: 'model color: green, controller color: green' });
_this10.assertInvariants();
});
};
_class.prototype['@test it should produce a stable DOM when two routes render the same template'] = function testItShouldProduceAStableDOMWhenTwoRoutesRenderTheSameTemplate(assert) {
var _this11 = this;
this.router.map(function () {
this.route('a');
this.route('b');
});
this.add('route:a', _emberRouting.Route.extend({
model: function () {
return 'A';
},
renderTemplate: function (controller, model) {
this.render('common', { controller: 'common', model: model });
}
}));
this.add('route:b', _emberRouting.Route.extend({
model: function () {
return 'B';
},
renderTemplate: function (controller, model) {
this.render('common', { controller: 'common', model: model });
}
}));
this.add('controller:common', _emberRuntime.Controller.extend({
prefix: 'common'
}));
this.addTemplate('common', '{{prefix}} {{model}}');
return this.visit('/a').then(function () {
_this11.assertComponentElement(_this11.firstChild, { content: 'common A' });
_this11.takeSnapshot();
return _this11.visit('/b');
}).then(function () {
_this11.assertComponentElement(_this11.firstChild, { content: 'common B' });
_this11.assertInvariants();
});
};
_class.prototype['@test a child outlet is always a fragment'] = function testAChildOutletIsAlwaysAFragment() {
var _this12 = this;
this.addTemplate('application', '{{outlet}}');
this.addTemplate('index', '{{#if true}}1{{/if}}<div>2</div>');
return this.visit('/').then(function () {
_this12.assertComponentElement(_this12.firstChild, { content: '1<div>2</div>' });
});
};
_class.prototype['@test it allows a transition during route activate'] = function testItAllowsATransitionDuringRouteActivate(assert) {
var _this13 = this;
this.router.map(function () {
this.route('a');
});
this.add('route:index', _emberRouting.Route.extend({
activate: function () {
this.transitionTo('a');
}
}));
this.addTemplate('a', 'Hello from A!');
return this.visit('/').then(function () {
_this13.assertComponentElement(_this13.firstChild, {
content: 'Hello from A!'
});
});
};
_class.prototype['@test it emits a useful backtracking re-render assertion message'] = function testItEmitsAUsefulBacktrackingReRenderAssertionMessage(assert) {
var _this14 = this;
this.router.map(function () {
this.route('routeWithError');
});
this.add('route:routeWithError', _emberRouting.Route.extend({
model: function () {
return { name: 'Alex' };
}
}));
this.addTemplate('routeWithError', 'Hi {{model.name}} {{x-foo person=model}}');
this.addComponent('x-foo', {
ComponentClass: _emberGlimmer.Component.extend({
init: function () {
this._super.apply(this, arguments);
this.set('person.name', 'Ben');
}
}),
template: 'Hi {{person.name}} from component'
});
var expectedBacktrackingMessage = /modified "model\.name" twice on \[object Object\] in a single render\. It was rendered in "template:routeWithError" and modified in "component:x-foo"/;
if (_features.EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER) {
expectDeprecation(expectedBacktrackingMessage);
return this.visit('/routeWithError');
} else {
return this.visit('/').then(function () {
expectAssertion(function () {
_this14.visit('/routeWithError');
}, expectedBacktrackingMessage);
});
}
};
return _class;
}(_testCase.ApplicationTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/application/rendering-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/application/rendering-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/binding_integration_test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (_emberBabel, _testCase, _helpers, _emberMetal) {
'use strict';
(0, _testCase.moduleFor)('Binding integration 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 should accept bindings as a string or an Ember.binding'] = function testShouldAcceptBindingsAsAStringOrAnEmberBinding() {
var _this2 = this;
var FooBarComponent = _helpers.Component.extend({
twoWayTestBinding: _emberMetal.Binding.from('direction'),
stringTestBinding: 'direction',
twoWayObjectTestBinding: _emberMetal.Binding.from('displacement.distance'),
stringObjectTestBinding: 'displacement.distance'
});
this.registerComponent('foo-bar', {
ComponentClass: FooBarComponent,
template: 'two way: {{twoWayTest}}, string: {{stringTest}}, object: {{twoWayObjectTest}}, string object: {{stringObjectTest}}'
});
expectDeprecation(function () {
_this2.render('{{foo-bar direction=direction displacement=displacement}}', {
direction: 'down',
displacement: {
distance: 10
}
});
}, /`Ember\.Binding` is deprecated/);
this.assertText('two way: down, string: down, object: 10, string object: 10');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'direction', 'up');
});
this.assertText('two way: up, string: up, object: 10, string object: 10');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'displacement.distance', 20);
});
this.assertText('two way: up, string: up, object: 20, string object: 20');
this.runTask(function () {
(0, _emberMetal.set)(_this2.context, 'direction', 'right');
(0, _emberMetal.set)(_this2.context, 'displacement.distance', 30);
});
this.assertText('two way: right, string: right, object: 30, string object: 30');
this.runTask(function () {
(0, _emberMetal.set)(_this2.context, 'direction', 'down');
(0, _emberMetal.set)(_this2.context, 'displacement', { distance: 10 });
});
this.assertText('two way: down, string: down, object: 10, string object: 10');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/binding_integration_test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/binding_integration_test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/append-test', ['ember-babel', 'ember-metal', 'ember-views', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case'], function (_emberBabel, _emberMetal, _emberViews, _testCase, _helpers, _abstractTestCase) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if showFooBar}}\n {{foo-bar}}\n {{else}}\n {{baz-qux}}\n {{/if}}\n '], ['\n {{#if showFooBar}}\n {{foo-bar}}\n {{else}}\n {{baz-qux}}\n {{/if}}\n ']);
var AbstractAppendTest = function (_RenderingTest) {
(0, _emberBabel.inherits)(AbstractAppendTest, _RenderingTest);
function AbstractAppendTest() {
(0, _emberBabel.classCallCheck)(this, AbstractAppendTest);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.call(this));
_this.components = [];
_this.ids = [];
return _this;
}
AbstractAppendTest.prototype.teardown = function teardown() {
var _this2 = this;
this.component = null;
this.components.forEach(function (component) {
_this2.runTask(function () {
return component.destroy();
});
});
this.ids.forEach(function (id) {
var $element = (0, _emberViews.jQuery)(id).remove();
_this2.assert.strictEqual($element.length, 0, 'Should not leak element: #' + id);
});
_RenderingTest.prototype.teardown.call(this);
};
AbstractAppendTest.prototype.didAppend = function didAppend(component) {
this.components.push(component);
this.ids.push(component.elementId);
};
AbstractAppendTest.prototype['@test lifecycle hooks during component append'] = function testLifecycleHooksDuringComponentAppend(assert) {
var _this4 = this;
var hooks = [];
var oldRegisterComponent = this.registerComponent;
var componentsByName = {};
// TODO: refactor/combine with other life-cycle tests
this.registerComponent = function (name, _options) {
function pushHook(hookName) {
hooks.push([name, hookName]);
}
var options = {
ComponentClass: _options.ComponentClass.extend({
init: function () {
var _this3 = this,
_arguments = arguments;
expectDeprecation(function () {
_this3._super.apply(_this3, _arguments);
}, /didInitAttrs called/);
if (name in componentsByName) {
throw new TypeError('Component named: ` ' + name + ' ` already registered');
}
componentsByName[name] = this;
pushHook('init');
this.on('init', function () {
return pushHook('on(init)');
});
},
didInitAttrs: function (options) {
pushHook('didInitAttrs', options);
},
didReceiveAttrs: function () {
pushHook('didReceiveAttrs');
},
willInsertElement: function () {
pushHook('willInsertElement');
},
willRender: function () {
pushHook('willRender');
},
didInsertElement: function () {
pushHook('didInsertElement');
},
didRender: function () {
pushHook('didRender');
},
didUpdateAttrs: function () {
pushHook('didUpdateAttrs');
},
willUpdate: function () {
pushHook('willUpdate');
},
didUpdate: function () {
pushHook('didUpdate');
},
willDestroyElement: function () {
pushHook('willDestroyElement');
},
willClearRender: function () {
pushHook('willClearRender');
},
didDestroyElement: function () {
pushHook('didDestroyElement');
},
willDestroy: function () {
pushHook('willDestroy');
this._super.apply(this, arguments);
}
}),
template: _options.template
};
oldRegisterComponent.call(this, name, options);
};
this.registerComponent('x-parent', {
ComponentClass: _helpers.Component.extend({
layoutName: 'components/x-parent'
}),
template: '[parent: {{foo}}]{{#x-child bar=foo}}[yielded: {{foo}}]{{/x-child}}'
});
this.registerComponent('x-child', {
ComponentClass: _helpers.Component.extend({
tagName: ''
}),
template: '[child: {{bar}}]{{yield}}'
});
var XParent = void 0;
XParent = this.owner.factoryFor('component:x-parent');
this.component = XParent.create({ foo: 'zomg' });
assert.deepEqual(hooks, [['x-parent', 'init'], ['x-parent', 'didInitAttrs'], ['x-parent', 'didReceiveAttrs'], ['x-parent', 'on(init)']], 'creation of x-parent');
hooks.length = 0;
this.element = this.append(this.component);
assert.deepEqual(hooks, [['x-parent', 'willInsertElement'], ['x-child', 'init'], ['x-child', 'didInitAttrs'], ['x-child', 'didReceiveAttrs'], ['x-child', 'on(init)'], ['x-child', 'willRender'], ['x-child', 'willInsertElement'], ['x-child', 'didInsertElement'], ['x-child', 'didRender'], ['x-parent', 'didInsertElement'], ['x-parent', 'didRender']], 'appending of x-parent');
hooks.length = 0;
this.runTask(function () {
return componentsByName['x-parent'].rerender();
});
assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'rerender x-parent');
hooks.length = 0;
this.runTask(function () {
return componentsByName['x-child'].rerender();
});
assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-child', 'willUpdate'], ['x-child', 'willRender'], ['x-child', 'didUpdate'], ['x-child', 'didRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'rerender x-child');
hooks.length = 0;
this.runTask(function () {
return (0, _emberMetal.set)(_this4.component, 'foo', 'wow');
});
assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-child', 'didUpdateAttrs'], ['x-child', 'didReceiveAttrs'], ['x-child', 'willUpdate'], ['x-child', 'willRender'], ['x-child', 'didUpdate'], ['x-child', 'didRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'set foo = wow');
hooks.length = 0;
this.runTask(function () {
return (0, _emberMetal.set)(_this4.component, 'foo', 'zomg');
});
assert.deepEqual(hooks, [['x-parent', 'willUpdate'], ['x-parent', 'willRender'], ['x-child', 'didUpdateAttrs'], ['x-child', 'didReceiveAttrs'], ['x-child', 'willUpdate'], ['x-child', 'willRender'], ['x-child', 'didUpdate'], ['x-child', 'didRender'], ['x-parent', 'didUpdate'], ['x-parent', 'didRender']], 'set foo = zomg');
hooks.length = 0;
this.runTask(function () {
return _this4.component.destroy();
});
assert.deepEqual(hooks, [['x-parent', 'willDestroyElement'], ['x-parent', 'willClearRender'], ['x-child', 'willDestroyElement'], ['x-child', 'willClearRender'], ['x-child', 'didDestroyElement'], ['x-parent', 'didDestroyElement'], ['x-parent', 'willDestroy'], ['x-child', 'willDestroy']], 'destroy');
};
AbstractAppendTest.prototype['@test appending, updating and destroying a single component'] = function testAppendingUpdatingAndDestroyingASingleComponent(assert) {
var _this5 = this;
var willDestroyCalled = 0;
this.registerComponent('x-parent', {
ComponentClass: _helpers.Component.extend({
layoutName: 'components/x-parent',
willDestroyElement: function () {
willDestroyCalled++;
}
}),
template: '[parent: {{foo}}]{{#x-child bar=foo}}[yielded: {{foo}}]{{/x-child}}'
});
this.registerComponent('x-child', {
ComponentClass: _helpers.Component.extend({
tagName: ''
}),
template: '[child: {{bar}}]{{yield}}'
});
var XParent = void 0;
XParent = this.owner.factoryFor('component:x-parent');
this.component = XParent.create({ foo: 'zomg' });
assert.ok(!this.component.element, 'precond - should not have an element');
this.element = this.append(this.component);
var componentElement = this.component.element;
this.assertComponentElement(componentElement, { content: '[parent: zomg][child: zomg][yielded: zomg]' });
assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target');
this.runTask(function () {
return _this5.rerender();
});
this.assertComponentElement(componentElement, { content: '[parent: zomg][child: zomg][yielded: zomg]' });
assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target');
this.runTask(function () {
return (0, _emberMetal.set)(_this5.component, 'foo', 'wow');
});
this.assertComponentElement(componentElement, { content: '[parent: wow][child: wow][yielded: wow]' });
assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target');
this.runTask(function () {
return (0, _emberMetal.set)(_this5.component, 'foo', 'zomg');
});
this.assertComponentElement(componentElement, { content: '[parent: zomg][child: zomg][yielded: zomg]' });
assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target');
this.runTask(function () {
return _this5.component.destroy();
});
assert.ok(!this.component.element, 'It should not have an element');
assert.ok(!componentElement.parentElement, 'The component element should be detached');
this.assert.equal(willDestroyCalled, 1);
};
AbstractAppendTest.prototype['@test releasing a root component after it has been destroy'] = function testReleasingARootComponentAfterItHasBeenDestroy(assert) {
var _this6 = this;
var renderer = this.owner.lookup('renderer:-dom');
this.registerComponent('x-component', {
ComponentClass: _helpers.Component.extend()
});
this.component = this.owner.factoryFor('component:x-component').create();
this.append(this.component);
assert.equal(renderer._roots.length, 1, 'added a root component');
this.runTask(function () {
return _this6.component.destroy();
});
assert.equal(renderer._roots.length, 0, 'released the root component');
};
AbstractAppendTest.prototype['@test appending, updating and destroying multiple components'] = function testAppendingUpdatingAndDestroyingMultipleComponents(assert) {
var _this7 = this;
var willDestroyCalled = 0;
this.registerComponent('x-first', {
ComponentClass: _helpers.Component.extend({
layoutName: 'components/x-first',
willDestroyElement: function () {
willDestroyCalled++;
}
}),
template: 'x-first {{foo}}!'
});
this.registerComponent('x-second', {
ComponentClass: _helpers.Component.extend({
layoutName: 'components/x-second',
willDestroyElement: function () {
willDestroyCalled++;
}
}),
template: 'x-second {{bar}}!'
});
var First = void 0,
Second = void 0;
First = this.owner.factoryFor('component:x-first');
Second = this.owner.factoryFor('component:x-second');
var first = First.create({ foo: 'foo' });
var second = Second.create({ bar: 'bar' });
this.assert.ok(!first.element, 'precond - should not have an element');
this.assert.ok(!second.element, 'precond - should not have an element');
var wrapper1 = void 0,
wrapper2 = void 0;
this.runTask(function () {
return wrapper1 = _this7.append(first);
});
this.runTask(function () {
return wrapper2 = _this7.append(second);
});
var componentElement1 = first.element;
var componentElement2 = second.element;
this.assertComponentElement(componentElement1, { content: 'x-first foo!' });
this.assertComponentElement(componentElement2, { content: 'x-second bar!' });
assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target');
assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target');
this.runTask(function () {
return (0, _emberMetal.set)(first, 'foo', 'FOO');
});
this.assertComponentElement(componentElement1, { content: 'x-first FOO!' });
this.assertComponentElement(componentElement2, { content: 'x-second bar!' });
assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target');
assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target');
this.runTask(function () {
return (0, _emberMetal.set)(second, 'bar', 'BAR');
});
this.assertComponentElement(componentElement1, { content: 'x-first FOO!' });
this.assertComponentElement(componentElement2, { content: 'x-second BAR!' });
assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target');
assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target');
this.runTask(function () {
(0, _emberMetal.set)(first, 'foo', 'foo');
(0, _emberMetal.set)(second, 'bar', 'bar');
});
this.assertComponentElement(componentElement1, { content: 'x-first foo!' });
this.assertComponentElement(componentElement2, { content: 'x-second bar!' });
assert.equal(componentElement1.parentElement, wrapper1, 'The first component should be attached to the target');
assert.equal(componentElement2.parentElement, wrapper2, 'The second component should be attached to the target');
this.runTask(function () {
first.destroy();
second.destroy();
});
assert.ok(!first.element, 'The first component should not have an element');
assert.ok(!second.element, 'The second component should not have an element');
assert.ok(!componentElement1.parentElement, 'The first component element should be detached');
assert.ok(!componentElement2.parentElement, 'The second component element should be detached');
this.assert.equal(willDestroyCalled, 2);
};
AbstractAppendTest.prototype['@test can appendTo while rendering'] = function testCanAppendToWhileRendering(assert) {
var _this8 = this;
var owner = this.owner;
var append = function (component) {
return _this8.append(component);
};
var element1 = void 0,
element2 = void 0;
this.registerComponent('first-component', {
ComponentClass: _helpers.Component.extend({
layout: (0, _helpers.compile)('component-one'),
didInsertElement: function () {
element1 = this.element;
var SecondComponent = owner.factoryFor('component:second-component');
append(SecondComponent.create());
}
})
});
this.registerComponent('second-component', {
ComponentClass: _helpers.Component.extend({
layout: (0, _helpers.compile)('component-two'),
didInsertElement: function () {
element2 = this.element;
}
})
});
var FirstComponent = this.owner.factoryFor('component:first-component');
this.runTask(function () {
return append(FirstComponent.create());
});
this.assertComponentElement(element1, { content: 'component-one' });
this.assertComponentElement(element2, { content: 'component-two' });
};
AbstractAppendTest.prototype['@test can appendTo and remove while rendering'] = function testCanAppendToAndRemoveWhileRendering(assert) {
var _this9 = this;
var owner = this.owner;
var append = function (component) {
return _this9.append(component);
};
var element1 = void 0,
element2 = void 0,
element3 = void 0,
element4 = void 0,
component1 = void 0,
component2 = void 0;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
layout: (0, _helpers.compile)('foo-bar'),
init: function () {
this._super.apply(this, arguments);
component1 = this;
},
didInsertElement: function () {
element1 = this.element;
var OtherRoot = owner.factoryFor('component:other-root');
this._instance = OtherRoot.create({
didInsertElement: function () {
element2 = this.element;
}
});
append(this._instance);
},
willDestroy: function () {
this._instance.destroy();
}
})
});
this.registerComponent('baz-qux', {
ComponentClass: _helpers.Component.extend({
layout: (0, _helpers.compile)('baz-qux'),
init: function () {
this._super.apply(this, arguments);
component2 = this;
},
didInsertElement: function () {
element3 = this.element;
var OtherRoot = owner.factoryFor('component:other-root');
this._instance = OtherRoot.create({
didInsertElement: function () {
element4 = this.element;
}
});
append(this._instance);
},
willDestroy: function () {
this._instance.destroy();
}
})
});
var instantiatedRoots = 0;
var destroyedRoots = 0;
this.registerComponent('other-root', {
ComponentClass: _helpers.Component.extend({
layout: (0, _helpers.compile)('fake-thing: {{counter}}'),
init: function () {
this._super.apply(this, arguments);
this.counter = instantiatedRoots++;
},
willDestroy: function () {
destroyedRoots++;
this._super.apply(this, arguments);
}
})
});
this.render((0, _abstractTestCase.strip)(_templateObject), { showFooBar: true });
this.assertComponentElement(element1, {});
this.assertComponentElement(element2, { content: 'fake-thing: 0' });
assert.equal(instantiatedRoots, 1);
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this9.context, 'showFooBar', false);
});
assert.equal(instantiatedRoots, 2);
assert.equal(destroyedRoots, 1);
this.assertComponentElement(element3, {});
this.assertComponentElement(element4, { content: 'fake-thing: 1' });
this.runTask(function () {
component1.destroy();
component2.destroy();
});
assert.equal(instantiatedRoots, 2);
assert.equal(destroyedRoots, 2);
};
return AbstractAppendTest;
}(_testCase.RenderingTest);
(0, _testCase.moduleFor)('append: no arguments (attaching to document.body)', function (_AbstractAppendTest) {
(0, _emberBabel.inherits)(_class, _AbstractAppendTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _AbstractAppendTest.apply(this, arguments));
}
_class.prototype.append = function append(component) {
this.runTask(function () {
return component.append();
});
this.didAppend(component);
return document.body;
};
return _class;
}(AbstractAppendTest));
(0, _testCase.moduleFor)('appendTo: a selector', function (_AbstractAppendTest2) {
(0, _emberBabel.inherits)(_class2, _AbstractAppendTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _AbstractAppendTest2.apply(this, arguments));
}
_class2.prototype.append = function append(component) {
this.runTask(function () {
return component.appendTo('#qunit-fixture');
});
this.didAppend(component);
return (0, _emberViews.jQuery)('#qunit-fixture')[0];
};
_class2.prototype['@test raises an assertion when the target does not exist in the DOM'] = function testRaisesAnAssertionWhenTheTargetDoesNotExistInTheDOM(assert) {
var _this12 = this;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
layoutName: 'components/foo-bar'
}),
template: 'FOO BAR!'
});
var FooBar = this.owner.factoryFor('component:foo-bar');
this.component = FooBar.create();
assert.ok(!this.component.element, 'precond - should not have an element');
this.runTask(function () {
expectAssertion(function () {
_this12.component.appendTo('#does-not-exist-in-dom');
}, /You tried to append to \(#does-not-exist-in-dom\) but that isn't in the DOM/);
});
assert.ok(!this.component.element, 'component should not have an element');
};
return _class2;
}(AbstractAppendTest));
(0, _testCase.moduleFor)('appendTo: an element', function (_AbstractAppendTest3) {
(0, _emberBabel.inherits)(_class3, _AbstractAppendTest3);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
return (0, _emberBabel.possibleConstructorReturn)(this, _AbstractAppendTest3.apply(this, arguments));
}
_class3.prototype.append = function append(component) {
var element = (0, _emberViews.jQuery)('#qunit-fixture')[0];
this.runTask(function () {
return component.appendTo(element);
});
this.didAppend(component);
return element;
};
return _class3;
}(AbstractAppendTest));
(0, _testCase.moduleFor)('appendTo: with multiple components', function (_AbstractAppendTest4) {
(0, _emberBabel.inherits)(_class4, _AbstractAppendTest4);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
return (0, _emberBabel.possibleConstructorReturn)(this, _AbstractAppendTest4.apply(this, arguments));
}
_class4.prototype.append = function append(component) {
this.runTask(function () {
return component.appendTo('#qunit-fixture');
});
this.didAppend(component);
return (0, _emberViews.jQuery)('#qunit-fixture')[0];
};
return _class4;
}(AbstractAppendTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/append-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/append-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/attribute-bindings-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal'], function (_emberBabel, _testCase, _helpers, _abstractTestCase, _emberMetal) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{foo-bar hasFoo=true foo=foo hasBar=false bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=true foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=false bar=bar}}\n '], ['\n {{foo-bar hasFoo=true foo=foo hasBar=false bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=true foo=foo hasBar=true bar=bar}}\n {{foo-bar hasFoo=false foo=foo hasBar=false bar=bar}}\n ']);
(0, _testCase.moduleFor)('Attribute bindings integration', 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 have attribute bindings'] = function testItCanHaveAttributeBindings() {
var _this2 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['foo:data-foo', 'bar:data-bar']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', bar: 'bar' });
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' });
this.runTask(function () {
return _this2.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this2.context, 'foo', 'FOO');
(0, _emberMetal.set)(_this2.context, 'bar', undefined);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this2.context, 'foo', 'foo');
(0, _emberMetal.set)(_this2.context, 'bar', 'bar');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' });
};
_class.prototype['@test it can have attribute bindings with attrs'] = function testItCanHaveAttributeBindingsWithAttrs() {
var _this3 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['attrs.foo:data-foo', 'attrs.baz.bar:data-bar']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar foo=model.foo baz=model.baz}}', {
model: { foo: undefined, baz: { bar: 'bar' } }
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } });
this.runTask(function () {
return _this3.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } });
this.runTask(function () {
(0, _emberMetal.set)(_this3.context, 'model.foo', 'foo');
(0, _emberMetal.set)(_this3.context, 'model.baz.bar', undefined);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'model', {
foo: undefined, baz: { bar: 'bar' }
});
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } });
};
_class.prototype['@test it can have attribute bindings with a nested path'] = function testItCanHaveAttributeBindingsWithANestedPath() {
var _this4 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['foo.bar:data-foo-bar']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar foo=foo}}', { foo: { bar: 'foo-bar' } });
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' });
this.runTask(function () {
return _this4.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'foo.bar', 'FOO-BAR');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'FOO-BAR' }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'foo.bar', undefined);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'foo', undefined);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'foo', { bar: 'foo-bar' });
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' });
};
_class.prototype['@test handles non-microsyntax attributeBindings'] = function testHandlesNonMicrosyntaxAttributeBindings() {
var _this5 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['type']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar type=submit}}', {
submit: 'submit'
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' });
this.runTask(function () {
return _this5.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this5.context, 'submit', 'password');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this5.context, 'submit', null);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this5.context, 'submit', 'submit');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' });
};
_class.prototype['@test non-microsyntax attributeBindings cannot contain nested paths'] = function testNonMicrosyntaxAttributeBindingsCannotContainNestedPaths() {
var _this6 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['foo.bar']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
expectAssertion(function () {
_this6.render('{{foo-bar foo=foo}}', { foo: { bar: 'foo-bar' } });
}, /Illegal attributeBinding: 'foo.bar' is not a valid attribute name./);
};
_class.prototype['@test normalizes attributeBindings for property names'] = function testNormalizesAttributeBindingsForPropertyNames() {
var _this7 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['tiTLe']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar tiTLe=name}}', {
name: 'qux'
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { title: 'qux' }, content: 'hello' });
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'name', null);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'name', 'qux');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { title: 'qux' }, content: 'hello' });
};
_class.prototype['@test normalizes attributeBindings for attribute names'] = function testNormalizesAttributeBindingsForAttributeNames() {
var _this8 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['foo:data-FOO']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar foo=foo}}', {
foo: 'qux'
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'qux' }, content: 'hello' });
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'foo', null);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'foo', 'qux');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'qux' }, content: 'hello' });
};
_class.prototype['@test attributeBindings handles null/undefined'] = function testAttributeBindingsHandlesNullUndefined() {
var _this9 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['fizz', 'bar']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar fizz=fizz bar=bar}}', {
fizz: null,
bar: undefined
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
return _this9.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this9.context, 'fizz', 'fizz');
(0, _emberMetal.set)(_this9.context, 'bar', 'bar');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { fizz: 'fizz', bar: 'bar' }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this9.context, 'fizz', null);
(0, _emberMetal.set)(_this9.context, 'bar', undefined);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' });
};
_class.prototype['@test attributeBindings handles number value'] = function testAttributeBindingsHandlesNumberValue() {
var _this10 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['size']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar size=size}}', {
size: 21
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' });
this.runTask(function () {
return _this10.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'size', 0);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '0' }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'size', 21);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' });
};
_class.prototype['@test handles internal and external changes'] = function testHandlesInternalAndExternalChanges() {
var _this11 = this;
var component = void 0;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['type'],
type: 'password',
init: function () {
this._super.apply(this, arguments);
component = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' });
this.runTask(function () {
return _this11.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(component, 'type', 'checkbox');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'checkbox' }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(component, 'type', 'password');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' });
};
_class.prototype['@test can set attributeBindings on component with a different tagName'] = function testCanSetAttributeBindingsOnComponentWithADifferentTagName() {
var _this12 = this;
var FooBarComponent = _helpers.Component.extend({
tagName: 'input',
attributeBindings: ['type', 'isDisabled:disabled']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar type=type isDisabled=disabled}}', {
type: 'password',
disabled: false
});
this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } });
this.runTask(function () {
return _this12.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } });
this.runTask(function () {
(0, _emberMetal.set)(_this12.context, 'type', 'checkbox');
(0, _emberMetal.set)(_this12.context, 'disabled', true);
});
this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'checkbox', disabled: '' } });
this.runTask(function () {
(0, _emberMetal.set)(_this12.context, 'type', 'password');
(0, _emberMetal.set)(_this12.context, 'disabled', false);
});
this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } });
};
_class.prototype['@test should allow namespaced attributes in micro syntax'] = function testShouldAllowNamespacedAttributesInMicroSyntax() {
var _this13 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['xlinkHref:xlink:href']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar type=type xlinkHref=xlinkHref}}', {
xlinkHref: '/foo.png'
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } });
this.runTask(function () {
return _this13.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'xlinkHref', '/lol.png');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/lol.png' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'xlinkHref', '/foo.png');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } });
};
_class.prototype['@test should allow for String objects'] = function testShouldAllowForStringObjects() {
var _this14 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['foo']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar foo=foo}}', {
foo: function () {
return this;
}.call('bar')
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'bar' } });
this.runTask(function () {
return _this14.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'bar' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'foo', function () {
return this;
}.call('baz'));
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'baz' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'foo', function () {
return this;
}.call('bar'));
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'foo': 'bar' } });
};
_class.prototype['@test can set id initially via attributeBindings '] = function testCanSetIdInitiallyViaAttributeBindings() {
var _this15 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['specialSauce:id']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar specialSauce=sauce}}', {
sauce: 'special-sauce'
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } });
this.runTask(function () {
return _this15.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'sauce', 'foo');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'sauce', 'special-sauce');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'id': 'special-sauce' } });
};
_class.prototype['@test attributeBindings are overwritten'] = function testAttributeBindingsAreOverwritten() {
var _this16 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['href'],
href: 'a href'
});
var FizzBarComponent = FooBarComponent.extend({
attributeBindings: ['newHref:href']
});
this.registerComponent('fizz-bar', { ComponentClass: FizzBarComponent });
this.render('{{fizz-bar newHref=href}}', {
href: 'dog.html'
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'dog.html' } });
this.runTask(function () {
return _this16.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'dog.html' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'href', 'cat.html');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'cat.html' } });
};
_class.prototype['@test it can set attribute bindings in the constructor'] = function testItCanSetAttributeBindingsInTheConstructor() {
var _this17 = this;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
var bindings = [];
if (this.get('hasFoo')) {
bindings.push('foo:data-foo');
}
if (this.get('hasBar')) {
bindings.push('bar:data-bar');
}
this.attributeBindings = bindings;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render((0, _abstractTestCase.strip)(_templateObject), { foo: 'foo', bar: 'bar' });
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' });
this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
return _this17.rerender();
});
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' });
this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this17.context, 'foo', 'FOO');
(0, _emberMetal.set)(_this17.context, 'bar', undefined);
});
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: {}, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' });
this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'bar', 'BAR');
});
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'BAR' }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'FOO', 'data-bar': 'BAR' }, content: 'hello' });
this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this17.context, 'foo', 'foo');
(0, _emberMetal.set)(_this17.context, 'bar', 'bar');
});
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'data-bar': 'bar' }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' });
this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: {}, content: 'hello' });
};
_class.prototype['@test it should not allow attributeBindings to be set'] = function testItShouldNotAllowAttributeBindingsToBeSet() {
var _this18 = this;
this.registerComponent('foo-bar', { template: 'hello' });
expectAssertion(function () {
_this18.render('{{foo-bar attributeBindings="one two"}}');
}, /Setting 'attributeBindings' via template helpers is not allowed/);
};
_class.prototype['@test asserts if an attributeBinding is setup on class'] = function testAssertsIfAnAttributeBindingIsSetupOnClass() {
var _this19 = this;
var FooBarComponent = _helpers.Component.extend({
attributeBindings: ['class']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
expectAssertion(function () {
_this19.render('{{foo-bar}}');
}, /You cannot use class as an attributeBinding, use classNameBindings instead./i);
};
_class.prototype['@test blacklists href bindings based on protocol'] = function testBlacklistsHrefBindingsBasedOnProtocol() {
/* jshint scripturl:true */
var FooBarComponent = _helpers.Component.extend({
tagName: 'a',
attributeBindings: ['href']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar href=xss}}', {
xss: 'javascript:alert(\'foo\')'
});
this.assertComponentElement(this.firstChild, { tagName: 'a', attrs: { href: 'unsafe:javascript:alert(\'foo\')' } });
};
_class.prototype['@test it can bind the role attribute (issue #14007)'] = function testItCanBindTheRoleAttributeIssue14007() {
var _this20 = this;
var FooBarComponent = _helpers.Component.extend({ attributeBindings: ['role'] });
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar role=role}}', { role: 'button' });
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'button' } });
this.runTask(function () {
return _this20.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'button' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this20.context, 'role', 'combobox');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'combobox' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this20.context, 'role', null);
});
this.assertComponentElement(this.firstChild, { tagName: 'div' });
};
_class.prototype['@test component with an `id` attribute binding of undefined'] = function testComponentWithAnIdAttributeBindingOfUndefined() {
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
attributeBindings: ['id'],
id: undefined
})
});
this.registerComponent('baz-qux', {
ComponentClass: _helpers.Component.extend({
attributeBindings: ['somethingUndefined:id'],
somethingUndefined: undefined
})
});
this.render('{{foo-bar}}{{baz-qux}}');
this.assertComponentElement(this.nthChild(0), { content: '' });
this.assertComponentElement(this.nthChild(1), { content: '' });
this.assert.ok(this.nthChild(0).id.match(/ember\d+/), 'a valid `id` was used');
this.assert.ok(this.nthChild(1).id.match(/ember\d+/), 'a valid `id` was used');
};
_class.prototype['@test component with an `id` attribute binding of null'] = function testComponentWithAnIdAttributeBindingOfNull() {
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
attributeBindings: ['id'],
id: null
})
});
this.registerComponent('baz-qux', {
ComponentClass: _helpers.Component.extend({
attributeBindings: ['somethingNull:id'],
somethingNull: null
})
});
this.render('{{foo-bar}}{{baz-qux}}');
this.assertComponentElement(this.nthChild(0), { content: '' });
this.assertComponentElement(this.nthChild(1), { content: '' });
this.assert.ok(this.nthChild(0).id.match(/ember\d+/), 'a valid `id` was used');
this.assert.ok(this.nthChild(1).id.match(/ember\d+/), 'a valid `id` was used');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/attribute-bindings-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/attribute-bindings-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/attrs-lookup-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal', 'ember-glimmer/tests/utils/test-helpers'], function (_emberBabel, _testCase, _helpers, _emberMetal, _testHelpers) {
'use strict';
(0, _testCase.moduleFor)('Components test: attrs lookup', 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 should be able to lookup attrs without `attrs.` - template access'] = function testItShouldBeAbleToLookupAttrsWithoutAttrsTemplateAccess() {
var _this2 = this;
this.registerComponent('foo-bar', { template: '{{first}}' });
this.render('{{foo-bar first=firstAttr}}', {
firstAttr: 'first attr'
});
this.assertText('first attr');
this.runTask(function () {
return _this2.rerender();
});
this.assertText('first attr');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'firstAttr', 'second attr');
});
this.assertText('second attr');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'firstAttr', 'first attr');
});
this.assertText('first attr');
};
_class.prototype['@test it should be able to lookup attrs without `attrs.` - component access'] = function testItShouldBeAbleToLookupAttrsWithoutAttrsComponentAccess(assert) {
var _this3 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
instance = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{first}}' });
this.render('{{foo-bar first=firstAttr}}', {
firstAttr: 'first attr'
});
assert.equal(instance.get('first'), 'first attr');
this.runTask(function () {
return _this3.rerender();
});
assert.equal(instance.get('first'), 'first attr');
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'firstAttr', 'second attr');
});
assert.equal(instance.get('first'), 'second attr');
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'firstAttr', 'first attr');
});
this.assertText('first attr');
};
_class.prototype['@test should be able to modify a provided attr into local state #11571 / #11559'] = function testShouldBeAbleToModifyAProvidedAttrIntoLocalState1157111559(assert) {
var _this4 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
instance = this;
},
didReceiveAttrs: function () {
this.set('first', this.get('first').toUpperCase());
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{first}}' });
this.render('{{foo-bar first="first attr"}}');
assert.equal(instance.get('first'), 'FIRST ATTR', 'component lookup uses local state');
this.assertText('FIRST ATTR');
this.runTask(function () {
return _this4.rerender();
});
assert.equal(instance.get('first'), 'FIRST ATTR', 'component lookup uses local state during rerender');
this.assertText('FIRST ATTR');
// This is testing that passing string literals for use as initial values,
// so there is no update step
};
_class.prototype['@test should be able to access unspecified attr #12035'] = function testShouldBeAbleToAccessUnspecifiedAttr12035(assert) {
var _this5 = this;
var instance = void 0;
var wootVal = 'yes';
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
instance = this;
},
didReceiveAttrs: function () {
assert.equal(this.get('woot'), wootVal, 'found attr in didReceiveAttrs');
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar woot=woot}}', {
woot: wootVal
});
assert.equal(instance.get('woot'), 'yes', 'component found attr');
this.runTask(function () {
return _this5.rerender();
});
assert.equal(instance.get('woot'), 'yes', 'component found attr after rerender');
this.runTask(function () {
wootVal = 'nope';
(0, _emberMetal.set)(_this5.context, 'woot', wootVal);
});
assert.equal(instance.get('woot'), 'nope', 'component found attr after attr change');
this.runTask(function () {
wootVal = 'yes';
(0, _emberMetal.set)(_this5.context, 'woot', wootVal);
});
assert.equal(instance.get('woot'), 'yes', 'component found attr after reset');
};
_class.prototype['@test getAttr() should return the same value as get()'] = function testGetAttrShouldReturnTheSameValueAsGet(assert) {
var _this6 = this;
assert.expect(33);
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
instance = this;
},
didReceiveAttrs: function () {
var rootFirstPositional = this.get('firstPositional');
var rootFirst = this.get('first');
var rootSecond = this.get('second');
var attrFirstPositional = this.getAttr('firstPositional');
var attrFirst = this.getAttr('first');
var attrSecond = this.getAttr('second');
equal(rootFirstPositional, attrFirstPositional, 'root property matches attrs value');
equal(rootFirst, attrFirst, 'root property matches attrs value');
equal(rootSecond, attrSecond, 'root property matches attrs value');
}
});
FooBarComponent.reopenClass({
positionalParams: ['firstPositional']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar firstPositional first=first second=second}}', {
firstPositional: 'firstPositional',
first: 'first',
second: 'second'
});
assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value');
assert.equal(instance.get('first'), 'first', 'matches known value');
assert.equal(instance.get('second'), 'second', 'matches known value');
this.runTask(function () {
return _this6.rerender();
});
assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value');
assert.equal(instance.get('first'), 'first', 'matches known value');
assert.equal(instance.get('second'), 'second', 'matches known value');
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'first', 'third');
});
assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value');
assert.equal(instance.get('first'), 'third', 'matches known value');
assert.equal(instance.get('second'), 'second', 'matches known value');
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'second', 'fourth');
});
assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value');
assert.equal(instance.get('first'), 'third', 'matches known value');
assert.equal(instance.get('second'), 'fourth', 'matches known value');
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'firstPositional', 'fifth');
});
assert.equal(instance.get('firstPositional'), 'fifth', 'matches known value');
assert.equal(instance.get('first'), 'third', 'matches known value');
assert.equal(instance.get('second'), 'fourth', 'matches known value');
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'firstPositional', 'firstPositional');
(0, _emberMetal.set)(_this6.context, 'first', 'first');
(0, _emberMetal.set)(_this6.context, 'second', 'second');
});
assert.equal(instance.get('firstPositional'), 'firstPositional', 'matches known value');
assert.equal(instance.get('first'), 'first', 'matches known value');
assert.equal(instance.get('second'), 'second', 'matches known value');
};
_class.prototype['@test bound computed properties can be overridden in extensions, set during init, and passed in as attrs'] = function testBoundComputedPropertiesCanBeOverriddenInExtensionsSetDuringInitAndPassedInAsAttrs() {
var FooClass = _helpers.Component.extend({
attributeBindings: ['style'],
style: (0, _emberMetal.computed)('height', 'color', function () {
var height = this.get('height');
var color = this.get('color');
return 'height: ' + height + 'px; background-color: ' + color + ';';
}),
color: 'red',
height: 20
});
var BarClass = FooClass.extend({
init: function () {
this._super.apply(this, arguments);
this.height = 150;
},
color: 'yellow'
});
this.registerComponent('x-foo', { ComponentClass: FooClass });
this.registerComponent('x-bar', { ComponentClass: BarClass });
this.render('{{x-foo}}{{x-bar}}{{x-bar color="green"}}');
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { style: (0, _testHelpers.styles)('height: 20px; background-color: red;') } });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { style: (0, _testHelpers.styles)('height: 150px; background-color: yellow;') } });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { style: (0, _testHelpers.styles)('height: 150px; background-color: green;') } });
this.assertStableRerender();
// No U-R
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/attrs-lookup-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/attrs-lookup-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/class-bindings-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-helpers', 'ember-metal', 'ember-glimmer/tests/utils/abstract-test-case'], function (_emberBabel, _testCase, _helpers, _testHelpers, _emberMetal, _abstractTestCase) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n '], ['\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=true isEnabled=isEnabled bindIsHappy=true isHappy=isHappy}}\n {{foo-bar foo=foo bindIsEnabled=false isEnabled=isEnabled bindIsHappy=false isHappy=isHappy}}\n ']);
(0, _testCase.moduleFor)('ClassNameBindings integration', 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 have class name bindings on the class definition'] = function testItCanHaveClassNameBindingsOnTheClassDefinition() {
var _this2 = this;
var FooBarComponent = _helpers.Component.extend({
classNameBindings: ['foo', 'isEnabled:enabled', 'isHappy:happy:sad']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar foo=foo isEnabled=isEnabled isHappy=isHappy}}', { foo: 'foo', isEnabled: true, isHappy: false });
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' });
this.runTask(function () {
return _this2.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this2.context, 'foo', 'FOO');
(0, _emberMetal.set)(_this2.context, 'isEnabled', false);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view FOO sad') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this2.context, 'foo', undefined);
(0, _emberMetal.set)(_this2.context, 'isHappy', true);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view happy') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this2.context, 'foo', 'foo');
(0, _emberMetal.set)(_this2.context, 'isEnabled', true);
(0, _emberMetal.set)(_this2.context, 'isHappy', false);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' });
};
_class.prototype['@test attrs in classNameBindings'] = function testAttrsInClassNameBindings() {
var _this3 = this;
var FooBarComponent = _helpers.Component.extend({
classNameBindings: ['attrs.joker:purple:green', 'attrs.batman.robin:black:red']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar joker=model.wat batman=model.super}}', {
model: { wat: false, super: { robin: true } }
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view green black') }, content: 'hello' });
this.runTask(function () {
return _this3.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view green black') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this3.context, 'model.wat', true);
(0, _emberMetal.set)(_this3.context, 'model.super.robin', false);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view purple red') }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'model', {
wat: false, super: { robin: true }
});
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view green black') }, content: 'hello' });
};
_class.prototype['@test it can have class name bindings in the template'] = function testItCanHaveClassNameBindingsInTheTemplate() {
var _this4 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar classNameBindings="model.someInitiallyTrueProperty model.someInitiallyFalseProperty model.someInitiallyUndefinedProperty :static model.isBig:big model.isOpen:open:closed model.isUp::down model.bar:isTruthy:isFalsy"}}', {
model: {
someInitiallyTrueProperty: true,
someInitiallyFalseProperty: false,
isBig: true,
isOpen: false,
isUp: true,
bar: true
}
});
this.assertComponentElement(this.firstChild, {
attrs: { 'class': (0, _testHelpers.classes)('ember-view some-initially-true-property static big closed isTruthy') },
content: 'hello'
});
this.runTask(function () {
return _this4.rerender();
});
this.assertComponentElement(this.firstChild, {
attrs: { 'class': (0, _testHelpers.classes)('ember-view some-initially-true-property static big closed isTruthy') },
content: 'hello'
});
this.runTask(function () {
(0, _emberMetal.set)(_this4.context, 'model.someInitiallyTrueProperty', false);
(0, _emberMetal.set)(_this4.context, 'model.someInitiallyFalseProperty', true);
(0, _emberMetal.set)(_this4.context, 'model.someInitiallyUndefinedProperty', true);
(0, _emberMetal.set)(_this4.context, 'model.isBig', false);
(0, _emberMetal.set)(_this4.context, 'model.isOpen', true);
(0, _emberMetal.set)(_this4.context, 'model.isUp', false);
(0, _emberMetal.set)(_this4.context, 'model.bar', false);
});
this.assertComponentElement(this.firstChild, {
attrs: { 'class': (0, _testHelpers.classes)('ember-view some-initially-false-property some-initially-undefined-property static open down isFalsy') },
content: 'hello'
});
this.runTask(function () {
(0, _emberMetal.set)(_this4.context, 'model', {
someInitiallyTrueProperty: true,
someInitiallyFalseProperty: false,
someInitiallyUndefinedProperty: undefined,
isBig: true,
isOpen: false,
isUp: true,
bar: true
});
});
this.assertComponentElement(this.firstChild, {
attrs: { 'class': (0, _testHelpers.classes)('ember-view some-initially-true-property static big closed isTruthy') },
content: 'hello'
});
};
_class.prototype['@test it can have class name bindings with nested paths'] = function testItCanHaveClassNameBindingsWithNestedPaths() {
var _this5 = this;
var FooBarComponent = _helpers.Component.extend({
classNameBindings: ['foo.bar', 'is.enabled:enabled', 'is.happy:happy:sad']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar foo=foo is=is}}', { foo: { bar: 'foo-bar' }, is: { enabled: true, happy: false } });
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo-bar enabled sad') }, content: 'hello' });
this.runTask(function () {
return _this5.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo-bar enabled sad') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this5.context, 'foo.bar', 'FOO-BAR');
(0, _emberMetal.set)(_this5.context, 'is.enabled', false);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view FOO-BAR sad') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this5.context, 'foo.bar', null);
(0, _emberMetal.set)(_this5.context, 'is.happy', true);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view happy') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this5.context, 'foo', null);
(0, _emberMetal.set)(_this5.context, 'is', null);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view sad') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this5.context, 'foo', { bar: 'foo-bar' });
(0, _emberMetal.set)(_this5.context, 'is', { enabled: true, happy: false });
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo-bar enabled sad') }, content: 'hello' });
};
_class.prototype['@test it should dasherize the path when the it resolves to true'] = function testItShouldDasherizeThePathWhenTheItResolvesToTrue() {
var _this6 = this;
var FooBarComponent = _helpers.Component.extend({
classNameBindings: ['fooBar', 'nested.fooBarBaz']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar fooBar=fooBar nested=nested}}', { fooBar: true, nested: { fooBarBaz: false } });
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo-bar') }, content: 'hello' });
this.runTask(function () {
return _this6.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo-bar') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'fooBar', false);
(0, _emberMetal.set)(_this6.context, 'nested.fooBarBaz', true);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo-bar-baz') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'fooBar', 'FOO-BAR');
(0, _emberMetal.set)(_this6.context, 'nested.fooBarBaz', null);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view FOO-BAR') }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this6.context, 'nested', null);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view FOO-BAR') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'fooBar', true);
(0, _emberMetal.set)(_this6.context, 'nested', { fooBarBaz: false });
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo-bar') }, content: 'hello' });
};
_class.prototype['@test const bindings can be set as attrs'] = function testConstBindingsCanBeSetAsAttrs() {
var _this7 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar classNameBindings="foo:enabled:disabled"}}', {
foo: true
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view enabled') }, content: 'hello' });
this.runTask(function () {
return _this7.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view enabled') }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'foo', false);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view disabled') }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'foo', true);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view enabled') }, content: 'hello' });
};
_class.prototype['@test :: class name syntax works with an empty true class'] = function testClassNameSyntaxWorksWithAnEmptyTrueClass() {
var _this8 = this;
var FooBarComponent = _helpers.Component.extend({
classNameBindings: ['isEnabled::not-enabled']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar isEnabled=enabled}}', {
enabled: false
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view not-enabled') }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'enabled', true);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view') }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'enabled', false);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view not-enabled') }, content: 'hello' });
};
_class.prototype['@test uses all provided static class names (issue #11193)'] = function testUsesAllProvidedStaticClassNamesIssue11193() {
var _this9 = this;
var FooBarComponent = _helpers.Component.extend({
classNameBindings: [':class-one', ':class-two']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar}}', {
enabled: false
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view class-one class-two') }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this9.context, 'enabled', true);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view class-one class-two') }, content: 'hello' });
};
_class.prototype['@test Providing a binding with a space in it asserts'] = function testProvidingABindingWithASpaceInItAsserts() {
var _this10 = this;
var FooBarComponent = _helpers.Component.extend({
classNameBindings: 'i:think:i am:so:clever'
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
expectAssertion(function () {
_this10.render('{{foo-bar}}');
}, /classNameBindings must not have spaces in them/i);
};
_class.prototype['@test it asserts that items must be strings'] = function testItAssertsThatItemsMustBeStrings() {
var _this11 = this;
var FooBarComponent = _helpers.Component.extend({
foo: 'foo',
bar: 'bar',
classNameBindings: ['foo',, 'bar'] // eslint-disable-line no-sparse-arrays
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
expectAssertion(function () {
_this11.render('{{foo-bar}}');
}, /classNameBindings must be non-empty strings/);
};
_class.prototype['@test it asserts that items must be non-empty strings'] = function testItAssertsThatItemsMustBeNonEmptyStrings() {
var _this12 = this;
var FooBarComponent = _helpers.Component.extend({
foo: 'foo',
bar: 'bar',
classNameBindings: ['foo', '', 'bar']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
expectAssertion(function () {
_this12.render('{{foo-bar}}');
}, /classNameBindings must be non-empty strings/);
};
_class.prototype['@test it can set class name bindings in the constructor'] = function testItCanSetClassNameBindingsInTheConstructor() {
var _this13 = this;
var FooBarComponent = _helpers.Component.extend({
classNameBindings: ['foo'],
init: function () {
this._super();
var bindings = this.classNameBindings = this.classNameBindings.slice();
if (this.get('bindIsEnabled')) {
bindings.push('isEnabled:enabled');
}
if (this.get('bindIsHappy')) {
bindings.push('isHappy:happy:sad');
}
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render((0, _abstractTestCase.strip)(_templateObject), { foo: 'foo', isEnabled: true, isHappy: false });
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo enabled') }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo sad') }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' });
this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo') }, content: 'hello' });
this.runTask(function () {
return _this13.rerender();
});
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo enabled') }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo sad') }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' });
this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this13.context, 'foo', 'FOO');
(0, _emberMetal.set)(_this13.context, 'isEnabled', false);
});
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view FOO') }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view FOO sad') }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view FOO sad') }, content: 'hello' });
this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view FOO') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this13.context, 'foo', undefined);
(0, _emberMetal.set)(_this13.context, 'isHappy', true);
});
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view') }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view happy') }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view happy') }, content: 'hello' });
this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view') }, content: 'hello' });
this.runTask(function () {
(0, _emberMetal.set)(_this13.context, 'foo', 'foo');
(0, _emberMetal.set)(_this13.context, 'isEnabled', true);
(0, _emberMetal.set)(_this13.context, 'isHappy', false);
});
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo enabled') }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo sad') }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' });
this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo') }, content: 'hello' });
};
_class.prototype['@test using a computed property for classNameBindings triggers an assertion'] = function testUsingAComputedPropertyForClassNameBindingsTriggersAnAssertion() {
var _this14 = this;
var FooBarComponent = _helpers.Component.extend({
classNameBindings: (0, _emberMetal.computed)(function () {
return ['isHappy:happy:sad'];
})
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
expectAssertion(function () {
_this14.render('{{foo-bar}}');
}, /Only arrays are allowed/);
};
return _class;
}(_testCase.RenderingTest));
(0, _testCase.moduleFor)('ClassBinding integration', function (_RenderingTest2) {
(0, _emberBabel.inherits)(_class2, _RenderingTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest2.apply(this, arguments));
}
_class2.prototype['@test it should apply classBinding without condition always'] = function testItShouldApplyClassBindingWithoutConditionAlways() {
var _this16 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar classBinding=":foo"}}');
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo ember-view') } });
this.runTask(function () {
return _this16.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo ember-view') } });
};
_class2.prototype['@test it should merge classBinding with class'] = function testItShouldMergeClassBindingWithClass() {
var _this17 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar classBinding="birdman:respeck" class="myName"}}', { birdman: true });
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('respeck myName ember-view') } });
this.runTask(function () {
return _this17.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('respeck myName ember-view') } });
};
_class2.prototype['@test it should apply classBinding with only truthy condition'] = function testItShouldApplyClassBindingWithOnlyTruthyCondition() {
var _this18 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar classBinding="myName:respeck"}}', { myName: true });
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('respeck ember-view') } });
this.runTask(function () {
return _this18.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('respeck ember-view') } });
};
_class2.prototype['@test it should apply classBinding with only falsy condition'] = function testItShouldApplyClassBindingWithOnlyFalsyCondition() {
var _this19 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar classBinding="myName::shade"}}', { myName: false });
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('shade ember-view') } });
this.runTask(function () {
return _this19.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('shade ember-view') } });
};
_class2.prototype['@test it should apply nothing when classBinding is falsy but only supplies truthy class'] = function testItShouldApplyNothingWhenClassBindingIsFalsyButOnlySuppliesTruthyClass() {
var _this20 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar classBinding="myName:respeck"}}', { myName: false });
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('ember-view') } });
this.runTask(function () {
return _this20.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('ember-view') } });
};
_class2.prototype['@test it should apply nothing when classBinding is truthy but only supplies falsy class'] = function testItShouldApplyNothingWhenClassBindingIsTruthyButOnlySuppliesFalsyClass() {
var _this21 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar classBinding="myName::shade"}}', { myName: true });
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('ember-view') } });
this.runTask(function () {
return _this21.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('ember-view') } });
};
_class2.prototype['@test it should apply classBinding with falsy condition'] = function testItShouldApplyClassBindingWithFalsyCondition() {
var _this22 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar classBinding="swag:fresh:scrub"}}', { swag: false });
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('scrub ember-view') } });
this.runTask(function () {
return _this22.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('scrub ember-view') } });
};
_class2.prototype['@test it should apply classBinding with truthy condition'] = function testItShouldApplyClassBindingWithTruthyCondition() {
var _this23 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar classBinding="swag:fresh:scrub"}}', { swag: true });
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('fresh ember-view') } });
this.runTask(function () {
return _this23.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('fresh ember-view') } });
};
return _class2;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/class-bindings-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/class-bindings-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/contextual-components-test', ['ember-babel', 'ember-utils', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember-runtime/system/native_array'], function (_emberBabel, _emberUtils, _helpers, _abstractTestCase, _testCase, _emberMetal, _native_array) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{component (component "-looked-up") "Hodari" greeting="Hodi"}}'], ['\n {{component (component "-looked-up") "Hodari" greeting="Hodi"}}']),
_templateObject2 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{component (component "-looked-up" "Hodari" greeting="Hodi")\n greeting="Hola"}}'], ['\n {{component (component "-looked-up" "Hodari" greeting="Hodi")\n greeting="Hola"}}']),
_templateObject3 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with (hash comp=(component "-looked-up" greeting=model.greeting)) as |my|}}\n {{#my.comp}}{{/my.comp}}\n {{/with}}'], ['\n {{#with (hash comp=(component "-looked-up" greeting=model.greeting)) as |my|}}\n {{#my.comp}}{{/my.comp}}\n {{/with}}']),
_templateObject4 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}\n {{#with (component first greeting="Hej" name="Sigmundur") as |second|}}\n {{component second greeting=model.greeting}}\n {{/with}}\n {{/with}}'], ['\n {{#with (component "-looked-up" greeting="Hola" name="Dolores" age=33) as |first|}}\n {{#with (component first greeting="Hej" name="Sigmundur") as |second|}}\n {{component second greeting=model.greeting}}\n {{/with}}\n {{/with}}']),
_templateObject5 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup}}\n {{/with}}']),
_templateObject6 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup expectedText=model.expectedText}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup expectedText=model.expectedText}}\n {{/with}}']),
_templateObject7 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with (hash lookedup=(component "-looked-up" expectedText=model.expectedText)) as |object|}}\n {{object.lookedup}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up" expectedText=model.expectedText)) as |object|}}\n {{object.lookedup}}\n {{/with}}']),
_templateObject8 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup model.expectedText "Hola"}}\n {{/with}}'], ['\n {{#with (hash lookedup=(component "-looked-up")) as |object|}}\n {{object.lookedup model.expectedText "Hola"}}\n {{/with}}']),
_templateObject9 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with (hash my-component=(component \'my-component\' first)) as |c|}}\n {{c.my-component}}\n {{/with}}'], ['\n {{#with (hash my-component=(component \'my-component\' first)) as |c|}}\n {{c.my-component}}\n {{/with}}']),
_templateObject10 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#my-component my-attr=myProp as |api|}}\n {{api.my-nested-component}}\n {{/my-component}}\n <br>\n <button onclick={{action \'changeValue\'}}>Change value</button>'], ['\n {{#my-component my-attr=myProp as |api|}}\n {{api.my-nested-component}}\n {{/my-component}}\n <br>\n <button onclick={{action \'changeValue\'}}>Change value</button>']),
_templateObject11 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#select-box as |sb|}}\n {{sb.option label="Foo"}}\n {{sb.option}}\n {{/select-box}}'], ['\n {{#select-box as |sb|}}\n {{sb.option label="Foo"}}\n {{sb.option}}\n {{/select-box}}']),
_templateObject12 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <button {{action (action (mut val) 10)}} class="my-button">\n Change to 10\n </button>'], ['\n <button {{action (action (mut val) 10)}} class="my-button">\n Change to 10\n </button>']),
_templateObject13 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{component (component "change-button" model.val2)}}\n <span class="value">{{model.val2}}</span>'], ['\n {{component (component "change-button" model.val2)}}\n <span class="value">{{model.val2}}</span>']),
_templateObject14 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n message: {{message}}{{inner-component message=message}}\n <button onclick={{action "change"}} />'], ['\n message: {{message}}{{inner-component message=message}}\n <button onclick={{action "change"}} />']),
_templateObject15 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with (hash ctxCmp=(component "my-comp" isOpen=isOpen)) as |thing|}}\n {{#thing.ctxCmp}}This is a contextual component{{/thing.ctxCmp}}\n {{/with}}\n '], ['\n {{#with (hash ctxCmp=(component "my-comp" isOpen=isOpen)) as |thing|}}\n {{#thing.ctxCmp}}This is a contextual component{{/thing.ctxCmp}}\n {{/with}}\n ']),
_templateObject16 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with (hash ctxCmp=(component compName isOpen=isOpen)) as |thing|}}\n {{#thing.ctxCmp}}This is a contextual component{{/thing.ctxCmp}}\n {{/with}}\n '], ['\n {{#with (hash ctxCmp=(component compName isOpen=isOpen)) as |thing|}}\n {{#thing.ctxCmp}}This is a contextual component{{/thing.ctxCmp}}\n {{/with}}\n ']),
_templateObject17 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <button {{action (action (mut val) 10)}} class="my-button">\n Change to 10\n </button>'], ['\n <button {{action (action (mut val) 10)}} class="my-button">\n Change to 10\n </button>']);
(0, _testCase.moduleFor)('Components test: contextual components', 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 renders with component helper'] = function testRendersWithComponentHelper() {
var _this2 = this;
var expectedText = 'Hodi';
this.registerComponent('-looked-up', {
template: expectedText
});
this.render('{{component (component "-looked-up")}}');
this.assertText(expectedText);
this.runTask(function () {
return _this2.rerender();
});
this.assertText(expectedText);
};
_class.prototype['@test renders with component helper with invocation params, hash'] = function testRendersWithComponentHelperWithInvocationParamsHash() {
var _this3 = this;
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name']
}),
template: '{{greeting}} {{name}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject));
this.assertText('Hodi Hodari');
this.runTask(function () {
return _this3.rerender();
});
this.assertText('Hodi Hodari');
};
_class.prototype['@test GH#13742 keeps nested rest positional parameters if rendered with no positional parameters'] = function testGH13742KeepsNestedRestPositionalParametersIfRenderedWithNoPositionalParameters() {
var _this4 = this;
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'params'
}),
template: '{{#each params as |p|}}{{p}}{{/each}}'
});
this.render('{{component (component "-looked-up" model.greeting model.name)}}', {
model: {
greeting: 'Gabon ',
name: 'Zack'
}
});
this.assertText('Gabon Zack');
this.runTask(function () {
return _this4.rerender();
});
this.assertText('Gabon Zack');
this.runTask(function () {
return _this4.context.set('model.greeting', 'Good morning ');
});
this.assertText('Good morning Zack');
this.runTask(function () {
return _this4.context.set('model.name', 'Matthew');
});
this.assertText('Good morning Matthew');
this.runTask(function () {
return _this4.context.set('model', { greeting: 'Gabon ', name: 'Zack' });
});
this.assertText('Gabon Zack');
};
_class.prototype['@test overwrites nested rest positional parameters if rendered with positional parameters'] = function testOverwritesNestedRestPositionalParametersIfRenderedWithPositionalParameters() {
var _this5 = this;
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'params'
}),
template: '{{#each params as |p|}}{{p}}{{/each}}'
});
this.render('{{component (component "-looked-up" model.greeting model.name) model.name model.greeting}}', {
model: {
greeting: 'Gabon ',
name: 'Zack'
}
});
this.assertText('ZackGabon ');
this.runTask(function () {
return _this5.rerender();
});
this.assertText('ZackGabon ');
this.runTask(function () {
return _this5.context.set('model.greeting', 'Good morning ');
});
this.assertText('ZackGood morning ');
this.runTask(function () {
return _this5.context.set('model.name', 'Matthew');
});
this.assertText('MatthewGood morning ');
this.runTask(function () {
return _this5.context.set('model', { greeting: 'Gabon ', name: 'Zack' });
});
this.assertText('ZackGabon ');
};
_class.prototype['@test GH#13742 keeps nested rest positional parameters if nested and rendered with no positional parameters'] = function testGH13742KeepsNestedRestPositionalParametersIfNestedAndRenderedWithNoPositionalParameters() {
var _this6 = this;
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'params'
}),
template: '{{#each params as |p|}}{{p}}{{/each}}'
});
this.render('{{component (component (component "-looked-up" model.greeting model.name))}}', {
model: {
greeting: 'Gabon ',
name: 'Zack'
}
});
this.assertText('Gabon Zack');
this.runTask(function () {
return _this6.rerender();
});
this.assertText('Gabon Zack');
this.runTask(function () {
return _this6.context.set('model.greeting', 'Good morning ');
});
this.assertText('Good morning Zack');
this.runTask(function () {
return _this6.context.set('model.name', 'Matthew');
});
this.assertText('Good morning Matthew');
this.runTask(function () {
return _this6.context.set('model', { greeting: 'Gabon ', name: 'Zack' });
});
this.assertText('Gabon Zack');
};
_class.prototype['@test overwrites nested rest positional parameters if nested with new pos params and rendered with no positional parameters'] = function testOverwritesNestedRestPositionalParametersIfNestedWithNewPosParamsAndRenderedWithNoPositionalParameters() {
var _this7 = this;
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'params'
}),
template: '{{#each params as |p|}}{{p}}{{/each}}'
});
this.render('{{component (component (component "-looked-up" model.greeting model.name) model.name model.greeting)}}', {
model: {
greeting: 'Gabon ',
name: 'Zack'
}
});
this.assertText('ZackGabon ');
this.runTask(function () {
return _this7.rerender();
});
this.assertText('ZackGabon ');
this.runTask(function () {
return _this7.context.set('model.greeting', 'Good morning ');
});
this.assertText('ZackGood morning ');
this.runTask(function () {
return _this7.context.set('model.name', 'Matthew');
});
this.assertText('MatthewGood morning ');
this.runTask(function () {
return _this7.context.set('model', { greeting: 'Gabon ', name: 'Zack' });
});
this.assertText('ZackGabon ');
};
_class.prototype['@test renders with component helper with curried params, hash'] = function testRendersWithComponentHelperWithCurriedParamsHash() {
var _this8 = this;
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name']
}),
template: '{{greeting}} {{name}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject2));
this.assertText('Hola Hodari');
this.runTask(function () {
return _this8.rerender();
});
this.assertText('Hola Hodari');
};
_class.prototype['@test updates when component path is bound'] = function testUpdatesWhenComponentPathIsBound() {
var _this9 = this;
this.registerComponent('-mandarin', {
template: 'ni hao'
});
this.registerComponent('-hindi', {
template: 'Namaste'
});
this.render('{{component (component model.lookupComponent)}}', {
model: {
lookupComponent: '-mandarin'
}
});
this.assertText('ni hao');
this.runTask(function () {
return _this9.rerender();
});
this.assertText('ni hao');
this.runTask(function () {
return _this9.context.set('model.lookupComponent', '-hindi');
});
this.assertText('Namaste');
this.runTask(function () {
return _this9.context.set('model', { lookupComponent: '-mandarin' });
});
this.assertText('ni hao');
};
_class.prototype['@test updates when curried hash argument is bound'] = function testUpdatesWhenCurriedHashArgumentIsBound() {
var _this10 = this;
this.registerComponent('-looked-up', {
template: '{{greeting}}'
});
this.render('{{component (component "-looked-up" greeting=model.greeting)}}', {
model: {
greeting: 'Hodi'
}
});
this.assertText('Hodi');
this.runTask(function () {
return _this10.rerender();
});
this.assertText('Hodi');
this.runTask(function () {
return _this10.context.set('model.greeting', 'Hola');
});
this.assertText('Hola');
this.runTask(function () {
return _this10.context.set('model', { greeting: 'Hodi' });
});
this.assertText('Hodi');
};
_class.prototype['@test updates when curried hash arguments is bound in block form'] = function testUpdatesWhenCurriedHashArgumentsIsBoundInBlockForm() {
var _this11 = this;
this.registerComponent('-looked-up', {
template: '{{greeting}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject3), {
model: {
greeting: 'Hodi'
}
});
this.assertText('Hodi');
this.runTask(function () {
return _this11.rerender();
});
this.assertText('Hodi');
this.runTask(function () {
return _this11.context.set('model.greeting', 'Hola');
});
this.assertText('Hola');
this.runTask(function () {
return _this11.context.set('model', { greeting: 'Hodi' });
});
this.assertText('Hodi');
};
_class.prototype['@test nested components overwrite named positional parameters'] = function testNestedComponentsOverwriteNamedPositionalParameters() {
var _this12 = this;
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name', 'age']
}),
template: '{{name}} {{age}}'
});
this.render('{{component (component (component "-looked-up" "Sergio" 29) "Marvin" 21) "Hodari"}}');
this.assertText('Hodari 21');
this.runTask(function () {
return _this12.rerender();
});
this.assertText('Hodari 21');
};
_class.prototype['@test nested components overwrite hash parameters'] = function testNestedComponentsOverwriteHashParameters() {
var _this13 = this;
this.registerComponent('-looked-up', {
template: '{{greeting}} {{name}} {{age}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject4), {
model: {
greeting: 'Hodi'
}
});
this.assertText('Hodi Sigmundur 33');
this.runTask(function () {
return _this13.rerender();
});
this.assertText('Hodi Sigmundur 33');
this.runTask(function () {
return _this13.context.set('model.greeting', 'Kaixo');
});
this.assertText('Kaixo Sigmundur 33');
this.runTask(function () {
return _this13.context.set('model', { greeting: 'Hodi' });
});
this.assertText('Hodi Sigmundur 33');
};
_class.prototype['@test bound outer named parameters get updated in the right scope'] = function testBoundOuterNamedParametersGetUpdatedInTheRightScope() {
var _this14 = this;
this.registerComponent('-inner-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['comp']
}),
template: '{{component comp "Inner"}}'
});
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name', 'age']
}),
template: '{{name}} {{age}}'
});
this.render('{{component "-inner-component" (component "-looked-up" model.outerName model.outerAge)}}', {
model: {
outerName: 'Outer',
outerAge: 28
}
});
this.assertText('Inner 28');
this.runTask(function () {
return _this14.rerender();
});
this.assertText('Inner 28');
this.runTask(function () {
return _this14.context.set('model.outerAge', 29);
});
this.assertText('Inner 29');
this.runTask(function () {
return _this14.context.set('model.outerName', 'Not outer');
});
this.assertText('Inner 29');
this.runTask(function () {
_this14.context.set('model', {
outerName: 'Outer',
outerAge: 28
});
});
this.assertText('Inner 28');
};
_class.prototype['@test bound outer hash parameters get updated in the right scope'] = function testBoundOuterHashParametersGetUpdatedInTheRightScope() {
var _this15 = this;
this.registerComponent('-inner-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['comp']
}),
template: '{{component comp name="Inner"}}'
});
this.registerComponent('-looked-up', {
template: '{{name}} {{age}}'
});
this.render('{{component "-inner-component" (component "-looked-up" name=model.outerName age=model.outerAge)}}', {
model: {
outerName: 'Outer',
outerAge: 28
}
});
this.assertText('Inner 28');
this.runTask(function () {
return _this15.rerender();
});
this.assertText('Inner 28');
this.runTask(function () {
return _this15.context.set('model.outerAge', 29);
});
this.assertText('Inner 29');
this.runTask(function () {
return _this15.context.set('model.outerName', 'Not outer');
});
this.assertText('Inner 29');
this.runTask(function () {
_this15.context.set('model', {
outerName: 'Outer',
outerAge: 28
});
});
this.assertText('Inner 28');
};
_class.prototype['@test conflicting positional and hash parameters raise and assertion if in the same component context'] = function testConflictingPositionalAndHashParametersRaiseAndAssertionIfInTheSameComponentContext() {
var _this16 = this;
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name']
}),
template: '{{greeting}} {{name}}'
});
expectAssertion(function () {
_this16.render('{{component (component "-looked-up" "Hodari" name="Sergio") "Hodari" greeting="Hodi"}}');
}, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.');
};
_class.prototype['@test conflicting positional and hash parameters does not raise an assertion if rerendered'] = function testConflictingPositionalAndHashParametersDoesNotRaiseAnAssertionIfRerendered() {
var _this17 = this;
// In some cases, rerendering with a positional param used to cause an
// assertion. This test checks it does not.
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name']
}),
template: '{{greeting}} {{name}}'
});
this.render('{{component (component "-looked-up" model.name greeting="Hodi")}}', {
model: {
name: 'Hodari'
}
});
this.assertText('Hodi Hodari');
this.runTask(function () {
return _this17.rerender();
});
this.assertText('Hodi Hodari');
this.runTask(function () {
return _this17.context.set('model.name', 'Sergio');
});
this.assertText('Hodi Sergio');
this.runTask(function () {
return _this17.context.set('model', { name: 'Hodari' });
});
this.assertText('Hodi Hodari');
};
_class.prototype['@test conflicting positional and hash parameters does not raise an assertion if in different component context'] = function testConflictingPositionalAndHashParametersDoesNotRaiseAnAssertionIfInDifferentComponentContext() {
var _this18 = this;
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name']
}),
template: '{{greeting}} {{name}}'
});
this.render('{{component (component "-looked-up" "Hodari") name="Sergio" greeting="Hodi"}}');
this.assertText('Hodi Sergio');
this.runTask(function () {
return _this18.rerender();
});
this.assertText('Hodi Sergio');
};
_class.prototype['@test raises an asserton when component path is null'] = function testRaisesAnAssertonWhenComponentPathIsNull() {
var _this19 = this;
expectAssertion(function () {
_this19.render('{{component (component lookupComponent)}}');
});
};
_class.prototype['@test raises an assertion when component path is not a component name (static)'] = function testRaisesAnAssertionWhenComponentPathIsNotAComponentNameStatic() {
var _this20 = this;
expectAssertion(function () {
_this20.render('{{component (component "not-a-component")}}');
}, 'The component helper cannot be used without a valid component name. You used "not-a-component" via (component "not-a-component")');
};
_class.prototype['@test raises an assertion when component path is not a component name (dynamic)'] = function testRaisesAnAssertionWhenComponentPathIsNotAComponentNameDynamic() {
var _this21 = this;
expectAssertion(function () {
_this21.render('{{component (component compName)}}', {
compName: 'not-a-component'
});
}, /The component helper cannot be used without a valid component name. You used "not-a-component" via \(component .*\)/);
};
_class.prototype['@test renders with dot path'] = function testRendersWithDotPath() {
var _this22 = this;
var expectedText = 'Hodi';
this.registerComponent('-looked-up', {
template: expectedText
});
this.render((0, _abstractTestCase.strip)(_templateObject5));
this.assertText(expectedText);
this.runTask(function () {
return _this22.rerender();
});
this.assertText(expectedText);
};
_class.prototype['@test renders with dot path and attr'] = function testRendersWithDotPathAndAttr() {
var _this23 = this;
var expectedText = 'Hodi';
this.registerComponent('-looked-up', {
template: '{{expectedText}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject6), {
model: {
expectedText: expectedText
}
});
this.assertText(expectedText);
this.runTask(function () {
return _this23.rerender();
});
this.assertText(expectedText);
this.runTask(function () {
return _this23.context.set('model.expectedText', 'Hola');
});
this.assertText('Hola');
this.runTask(function () {
return _this23.context.set('model', { expectedText: expectedText });
});
this.assertText(expectedText);
};
_class.prototype['@test renders with dot path and curried over attr'] = function testRendersWithDotPathAndCurriedOverAttr() {
var _this24 = this;
var expectedText = 'Hodi';
this.registerComponent('-looked-up', {
template: '{{expectedText}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject7), {
model: {
expectedText: expectedText
}
});
this.assertText(expectedText);
this.runTask(function () {
return _this24.rerender();
});
this.assertText(expectedText);
this.runTask(function () {
return _this24.context.set('model.expectedText', 'Hola');
});
this.assertText('Hola');
this.runTask(function () {
return _this24.context.set('model', { expectedText: expectedText });
});
this.assertText(expectedText);
};
_class.prototype['@test renders with dot path and with rest positional parameters'] = function testRendersWithDotPathAndWithRestPositionalParameters() {
var _this25 = this;
this.registerComponent('-looked-up', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'params'
}),
template: '{{params}}'
});
var expectedText = 'Hodi';
this.render((0, _abstractTestCase.strip)(_templateObject8), {
model: {
expectedText: expectedText
}
});
this.assertText(expectedText + ',Hola');
this.runTask(function () {
return _this25.rerender();
});
this.assertText(expectedText + ',Hola');
this.runTask(function () {
return _this25.context.set('model.expectedText', 'Kaixo');
});
this.assertText('Kaixo,Hola');
this.runTask(function () {
return _this25.context.set('model', { expectedText: expectedText });
});
this.assertText(expectedText + ',Hola');
};
_class.prototype['@test renders with dot path and rest parameter does not leak'] = function testRendersWithDotPathAndRestParameterDoesNotLeak(assert) {
// In the original implementation, positional parameters were not handled
// correctly causing the first positional parameter to be the contextual
// component itself.
var value = false;
this.registerComponent('my-component', {
ComponentClass: _helpers.Component.extend({
didReceiveAttrs: function () {
value = this.getAttr('value');
}
}).reopenClass({
positionalParams: ['value']
})
});
this.render((0, _abstractTestCase.strip)(_templateObject9), { first: 'first' });
assert.equal(value, 'first', 'value is the expected parameter');
};
_class.prototype['@test renders with dot path and updates attributes'] = function testRendersWithDotPathAndUpdatesAttributes(assert) {
var _this26 = this;
this.registerComponent('my-nested-component', {
ComponentClass: _helpers.Component.extend({
didReceiveAttrs: function () {
this.set('myProp', this.getAttr('my-parent-attr'));
}
}),
template: '<span id="nested-prop">{{myProp}}</span>'
});
this.registerComponent('my-component', {
template: '{{yield (hash my-nested-component=(component "my-nested-component" my-parent-attr=my-attr))}}'
});
this.registerComponent('my-action-component', {
ComponentClass: _helpers.Component.extend({
actions: {
changeValue: function () {
this.incrementProperty('myProp');
}
}
}),
template: (0, _abstractTestCase.strip)(_templateObject10)
});
this.render('{{my-action-component myProp=model.myProp}}', {
model: {
myProp: 1
}
});
assert.equal(this.$('#nested-prop').text(), '1');
this.runTask(function () {
return _this26.rerender();
});
assert.equal(this.$('#nested-prop').text(), '1');
this.runTask(function () {
return _this26.$('button').click();
});
assert.equal(this.$('#nested-prop').text(), '2');
this.runTask(function () {
return _this26.$('button').click();
});
assert.equal(this.$('#nested-prop').text(), '3');
this.runTask(function () {
return _this26.context.set('model', { myProp: 1 });
});
assert.equal(this.$('#nested-prop').text(), '1');
};
_class.prototype['@test adding parameters to a contextual component\'s instance does not add it to other instances'] = function testAddingParametersToAContextualComponentSInstanceDoesNotAddItToOtherInstances() {
var _this27 = this;
// If parameters and attributes are not handled correctly, setting a value
// in an invokation can leak to others invocation.
this.registerComponent('select-box', {
template: '{{yield (hash option=(component "select-box-option"))}}'
});
this.registerComponent('select-box-option', {
template: '{{label}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject11));
this.assertText('Foo');
this.runTask(function () {
return _this27.rerender();
});
this.assertText('Foo');
};
_class.prototype['@test parameters in a contextual component are mutable when value is a param'] = function testParametersInAContextualComponentAreMutableWhenValueIsAParam(assert) {
var _this28 = this;
// This checks that a `(mut)` is added to parameters and attributes to
// contextual components when it is a param.
this.registerComponent('change-button', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['val']
}),
template: (0, _abstractTestCase.strip)(_templateObject12)
});
this.render((0, _abstractTestCase.strip)(_templateObject13), {
model: {
val2: 8
}
});
assert.equal(this.$('.value').text(), '8');
this.runTask(function () {
return _this28.rerender();
});
assert.equal(this.$('.value').text(), '8');
this.runTask(function () {
return _this28.$('.my-button').click();
});
assert.equal(this.$('.value').text(), '10');
this.runTask(function () {
return _this28.context.set('model', { val2: 8 });
});
assert.equal(this.$('.value').text(), '8');
};
_class.prototype['@test tagless blockless components render'] = function testTaglessBlocklessComponentsRender(assert) {
var _this29 = this;
this.registerComponent('my-comp', {
ComponentClass: _helpers.Component.extend({ tagName: '' })
});
this.render('{{my-comp}}');
this.runTask(function () {
return _this29.rerender();
});
assert.equal(this.$().text(), '');
};
_class.prototype['@test GH#13494 tagless blockless component with property binding'] = function testGH13494TaglessBlocklessComponentWithPropertyBinding(assert) {
var _this30 = this;
this.registerComponent('outer-component', {
ComponentClass: _helpers.Component.extend({
message: 'hello',
actions: {
change: function () {
this.set('message', 'goodbye');
}
}
}),
template: (0, _abstractTestCase.strip)(_templateObject14)
});
this.registerComponent('inner-component', {
ComponentClass: _helpers.Component.extend({
tagName: ''
})
});
this.render('{{outer-component}}');
assert.equal(this.$().text(), 'message: hello');
this.runTask(function () {
return _this30.rerender();
});
assert.equal(this.$().text(), 'message: hello');
this.runTask(function () {
return _this30.$('button').click();
});
assert.equal(this.$().text(), 'message: goodbye');
this.runTask(function () {
return _this30.rerender();
});
assert.equal(this.$().text(), 'message: goodbye');
};
_class.prototype['@test GH#13982 contextual component ref is stable even when bound params change'] = function testGH13982ContextualComponentRefIsStableEvenWhenBoundParamsChange(assert) {
var _this31 = this;
var instance = void 0,
previousInstance = void 0;
var initCount = 0;
this.registerComponent('my-comp', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super();
previousInstance = instance;
instance = this;
initCount++;
},
isOpen: undefined
}),
template: '{{if isOpen "open" "closed"}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject15), {
isOpen: true
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'a instance was created');
assert.equal(previousInstance, undefined, 'no previous component exists');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'open', 'the components text is "open"');
this.runTask(function () {
return _this31.rerender();
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'the component instance exists');
assert.equal(previousInstance, undefined, 'no previous component exists');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'open', 'the components text is "open"');
this.runTask(function () {
return _this31.context.set('isOpen', false);
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'the component instance exists');
assert.equal(previousInstance, undefined, 'no previous component exists');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'closed', 'the component text is "closed"');
this.runTask(function () {
return _this31.rerender();
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'the component instance exists');
assert.equal(previousInstance, undefined, 'no previous component exists');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'closed', 'the component text is "closed"');
this.runTask(function () {
return _this31.context.set('isOpen', true);
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'the component instance exists');
assert.equal(previousInstance, undefined, 'no previous component exists');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'open', 'the components text is "open"');
};
_class.prototype['@test GH#13982 contextual component ref is stable even when bound params change (bound name param)'] = function testGH13982ContextualComponentRefIsStableEvenWhenBoundParamsChangeBoundNameParam(assert) {
var _this32 = this;
var instance = void 0,
previousInstance = void 0;
var initCount = 0;
this.registerComponent('my-comp', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super();
previousInstance = instance;
instance = this;
initCount++;
},
isOpen: undefined
}),
template: '{{if isOpen "open" "closed"}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject16), {
compName: 'my-comp',
isOpen: true
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'a instance was created');
assert.equal(previousInstance, undefined, 'no previous component exists');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'open', 'the components text is "open"');
this.runTask(function () {
return _this32.rerender();
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'the component instance exists');
assert.equal(previousInstance, undefined, 'no previous component exists');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'open', 'the components text is "open"');
this.runTask(function () {
return _this32.context.set('isOpen', false);
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'the component instance exists');
assert.equal(previousInstance, undefined, 'no previous component exists');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'closed', 'the component text is "closed"');
this.runTask(function () {
return _this32.rerender();
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'the component instance exists');
assert.equal(previousInstance, undefined, 'no previous component exists');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'closed', 'the component text is "closed"');
this.runTask(function () {
return _this32.context.set('isOpen', true);
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'the component instance exists');
assert.equal(previousInstance, undefined, 'no previous component exists');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'open', 'the components text is "open"');
};
_class.prototype['@test GH#13982 contextual component ref is recomputed when component name param changes'] = function testGH13982ContextualComponentRefIsRecomputedWhenComponentNameParamChanges(assert) {
var _this33 = this;
var instance = void 0,
previousInstance = void 0;
var initCount = 0;
this.registerComponent('my-comp', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super();
previousInstance = instance;
instance = this;
initCount++;
},
isOpen: undefined
}),
template: 'my-comp: {{if isOpen "open" "closed"}}'
});
this.registerComponent('your-comp', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super();
previousInstance = instance;
instance = this;
initCount++;
},
isOpen: undefined
}),
template: 'your-comp: {{if isOpen "open" "closed"}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject16), {
compName: 'my-comp',
isOpen: true
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'a instance was created');
assert.equal(previousInstance, undefined, 'there is no previous instance');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'my-comp: open');
this.runTask(function () {
return _this33.rerender();
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'a instance exists after rerender');
assert.equal(previousInstance, undefined, 'there is no previous instance after rerender');
assert.equal(initCount, 1, 'the component was constructed exactly 1 time');
assert.equal(this.$().text(), 'my-comp: open');
this.runTask(function () {
return _this33.context.set('compName', 'your-comp');
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'an instance was created after component name changed');
assert.ok(!(0, _emberMetal.isEmpty)(previousInstance), 'a previous instance now exists');
assert.notEqual(instance, previousInstance, 'the instance and previous instance are not the same object');
assert.equal(initCount, 2, 'the component was constructed exactly 2 times');
assert.equal(this.$().text(), 'your-comp: open');
this.runTask(function () {
return _this33.rerender();
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'an instance was created after component name changed (rerender)');
assert.ok(!(0, _emberMetal.isEmpty)(previousInstance), 'a previous instance now exists (rerender)');
assert.notEqual(instance, previousInstance, 'the instance and previous instance are not the same object (rerender)');
assert.equal(initCount, 2, 'the component was constructed exactly 2 times (rerender)');
assert.equal(this.$().text(), 'your-comp: open');
this.runTask(function () {
return _this33.context.set('compName', 'my-comp');
});
assert.ok(!(0, _emberMetal.isEmpty)(instance), 'an instance was created after component name changed');
assert.ok(!(0, _emberMetal.isEmpty)(previousInstance), 'a previous instance still exists');
assert.notEqual(instance, previousInstance, 'the instance and previous instance are not the same object');
assert.equal(initCount, 3, 'the component was constructed exactly 3 times (rerender)');
assert.equal(this.$().text(), 'my-comp: open');
};
_class.prototype['@test GH#14508 rest positional params are received when passed as named parameter'] = function testGH14508RestPositionalParamsAreReceivedWhenPassedAsNamedParameter() {
var _this34 = this;
this.registerComponent('my-link', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'params'
}),
template: '{{#each params as |p|}}{{p}}{{/each}}'
});
this.render('{{component (component "my-link") params=allParams}}', {
allParams: (0, _native_array.A)(['a', 'b'])
});
this.assertText('ab');
this.runTask(function () {
return _this34.rerender();
});
this.assertText('ab');
this.runTask(function () {
return _this34.context.get('allParams').pushObject('c');
});
this.assertText('abc');
this.runTask(function () {
return _this34.context.get('allParams').popObject();
});
this.assertText('ab');
this.runTask(function () {
return _this34.context.get('allParams').clear();
});
this.assertText('');
this.runTask(function () {
return _this34.context.set('allParams', (0, _native_array.A)(['1', '2']));
});
this.assertText('12');
this.runTask(function () {
return _this34.context.set('allParams', (0, _native_array.A)(['a', 'b']));
});
this.assertText('ab');
};
_class.prototype['@test GH#14508 rest positional params are received when passed as named parameter with dot notation'] = function testGH14508RestPositionalParamsAreReceivedWhenPassedAsNamedParameterWithDotNotation() {
var _this35 = this;
this.registerComponent('my-link', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'params'
}),
template: '{{#each params as |p|}}{{p}}{{/each}}'
});
this.render('{{#with (hash link=(component "my-link")) as |c|}}{{c.link params=allParams}}{{/with}}', {
allParams: (0, _native_array.A)(['a', 'b'])
});
this.assertText('ab');
this.runTask(function () {
return _this35.rerender();
});
this.assertText('ab');
this.runTask(function () {
return _this35.context.get('allParams').pushObject('c');
});
this.assertText('abc');
this.runTask(function () {
return _this35.context.get('allParams').popObject();
});
this.assertText('ab');
this.runTask(function () {
return _this35.context.get('allParams').clear();
});
this.assertText('');
this.runTask(function () {
return _this35.context.set('allParams', (0, _native_array.A)(['1', '2']));
});
this.assertText('12');
this.runTask(function () {
return _this35.context.set('allParams', (0, _native_array.A)(['a', 'b']));
});
this.assertText('ab');
};
_class.prototype['@test GH#14632 give useful warning when calling contextual components with input as a name'] = function testGH14632GiveUsefulWarningWhenCallingContextualComponentsWithInputAsAName() {
var _this36 = this;
expectAssertion(function () {
_this36.render('{{component (component "input" type="text")}}');
}, 'You cannot use the input helper as a contextual helper. Please extend TextField or Checkbox to use it as a contextual component.');
};
_class.prototype['@test GH#14632 give useful warning when calling contextual components with textarea as a name'] = function testGH14632GiveUsefulWarningWhenCallingContextualComponentsWithTextareaAsAName() {
var _this37 = this;
expectAssertion(function () {
_this37.render('{{component (component "textarea" type="text")}}');
}, 'You cannot use the textarea helper as a contextual helper. Please extend TextArea to use it as a contextual component.');
};
return _class;
}(_testCase.RenderingTest));
var ContextualComponentMutableParamsTest = function (_RenderingTest2) {
(0, _emberBabel.inherits)(ContextualComponentMutableParamsTest, _RenderingTest2);
function ContextualComponentMutableParamsTest() {
(0, _emberBabel.classCallCheck)(this, ContextualComponentMutableParamsTest);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest2.apply(this, arguments));
}
ContextualComponentMutableParamsTest.prototype.render = function render(templateStr) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_RenderingTest2.prototype.render.call(this, templateStr + '<span class="value">{{model.val2}}</span>', (0, _emberUtils.assign)(context, { model: { val2: 8 } }));
};
return ContextualComponentMutableParamsTest;
}(_testCase.RenderingTest);
var MutableParamTestGenerator = function () {
function MutableParamTestGenerator(cases) {
(0, _emberBabel.classCallCheck)(this, MutableParamTestGenerator);
this.cases = cases;
}
MutableParamTestGenerator.prototype.generate = function generate(_ref) {
var _ref2;
var title = _ref.title,
setup = _ref.setup;
return _ref2 = {}, _ref2['@test parameters in a contextual component are mutable when value is a ' + title] = function (assert) {
var _this39 = this;
this.registerComponent('change-button', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['val']
}),
template: (0, _abstractTestCase.strip)(_templateObject17)
});
setup.call(this, assert);
assert.equal(this.$('.value').text(), '8');
this.runTask(function () {
return _this39.rerender();
});
assert.equal(this.$('.value').text(), '8');
this.runTask(function () {
return _this39.$('.my-button').click();
});
assert.equal(this.$('.value').text(), '10');
this.runTask(function () {
return _this39.context.set('model', { val2: 8 });
});
assert.equal(this.$('.value').text(), '8');
}, _ref2;
};
return MutableParamTestGenerator;
}();
(0, _abstractTestCase.applyMixins)(ContextualComponentMutableParamsTest, new MutableParamTestGenerator([{
title: 'param',
setup: function () {
this.render('{{component (component "change-button" model.val2)}}');
}
}, {
title: 'nested param',
setup: function () {
this.registerComponent('my-comp', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['components']
}),
template: '{{component components.comp}}'
});
this.render('{{my-comp (hash comp=(component "change-button" model.val2))}}');
}
}, {
title: 'hash value',
setup: function () {
this.registerComponent('my-comp', {
template: '{{component component}}'
});
this.render('{{my-comp component=(component "change-button" val=model.val2)}}');
}
}, {
title: 'nested hash value',
setup: function () {
this.registerComponent('my-comp', {
template: '{{component components.button}}'
});
this.render('{{my-comp components=(hash button=(component "change-button" val=model.val2))}}');
}
}]));
(0, _testCase.moduleFor)('Components test: contextual components -- mutable params', ContextualComponentMutableParamsTest);
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/contextual-components-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/contextual-components-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/curly-components-test', ['ember-babel', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/test-helpers', 'ember/features'], function (_emberBabel, _emberMetal, _emberRuntime, _helpers, _abstractTestCase, _testCase, _testHelpers, _features) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{foo-bar class="bar baz"}}\n {{foo-bar classNames="bar baz"}}\n {{foo-bar}}\n '], ['\n {{foo-bar class="bar baz"}}\n {{foo-bar classNames="bar baz"}}\n {{foo-bar}}\n ']),
_templateObject2 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if cond1}}\n {{#foo-bar id=1}}\n {{#if cond2}}\n {{#foo-bar id=2}}{{/foo-bar}}\n {{#if cond3}}\n {{#foo-bar id=3}}\n {{#if cond4}}\n {{#foo-bar id=4}}\n {{#if cond5}}\n {{#foo-bar id=5}}{{/foo-bar}}\n {{#foo-bar id=6}}{{/foo-bar}}\n {{#foo-bar id=7}}{{/foo-bar}}\n {{/if}}\n {{#foo-bar id=8}}{{/foo-bar}}\n {{/foo-bar}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}'], ['\n {{#if cond1}}\n {{#foo-bar id=1}}\n {{#if cond2}}\n {{#foo-bar id=2}}{{/foo-bar}}\n {{#if cond3}}\n {{#foo-bar id=3}}\n {{#if cond4}}\n {{#foo-bar id=4}}\n {{#if cond5}}\n {{#foo-bar id=5}}{{/foo-bar}}\n {{#foo-bar id=6}}{{/foo-bar}}\n {{#foo-bar id=7}}{{/foo-bar}}\n {{/if}}\n {{#foo-bar id=8}}{{/foo-bar}}\n {{/foo-bar}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}\n {{/if}}\n {{/foo-bar}}\n {{/if}}']),
_templateObject3 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if isStream}}\n true\n {{else}}\n false\n {{/if}}\n '], ['\n {{#if isStream}}\n true\n {{else}}\n false\n {{/if}}\n ']),
_templateObject4 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n Args: {{this.attrs.value}} | {{attrs.value}} | {{value}}\n {{#each this.attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each items as |item|}}\n {{item}}\n {{/each}}\n '], ['\n Args: {{this.attrs.value}} | {{attrs.value}} | {{value}}\n {{#each this.attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each attrs.items as |item|}}\n {{item}}\n {{/each}}\n {{#each items as |item|}}\n {{item}}\n {{/each}}\n ']),
_templateObject5 = (0, _emberBabel.taggedTemplateLiteralLoose)(['Args: lul | lul | lul111'], ['Args: lul | lul | lul111']),
_templateObject6 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with-block someProp=prop}}\n In template\n {{/with-block}}'], ['\n {{#with-block someProp=prop}}\n In template\n {{/with-block}}']),
_templateObject7 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#each names as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each names as |name|}}\n {{name}}\n {{/each}}']),
_templateObject8 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{sample-component "Foo" 4 "Bar" elementId="args-3"}}\n {{sample-component "Foo" 4 "Bar" 5 "Baz" elementId="args-5"}}'], ['\n {{sample-component "Foo" 4 "Bar" elementId="args-3"}}\n {{sample-component "Foo" 4 "Bar" 5 "Baz" elementId="args-5"}}']),
_templateObject9 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{sample-component "one" "two" elementId="two-positional"}}\n {{sample-component "one" second="two" elementId="one-positional"}}\n {{sample-component first="one" second="two" elementId="no-positional"}}'], ['\n {{sample-component "one" "two" elementId="two-positional"}}\n {{sample-component "one" second="two" elementId="one-positional"}}\n {{sample-component first="one" second="two" elementId="no-positional"}}']),
_templateObject10 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#each n as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each n as |name|}}\n {{name}}\n {{/each}}']),
_templateObject11 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with-template name="with-block"}}\n [In block - {{name}}]\n {{/with-template}}\n {{with-template name="without-block"}}'], ['\n {{#with-template name="with-block"}}\n [In block - {{name}}]\n {{/with-template}}\n {{with-template name="without-block"}}']),
_templateObject12 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if hasBlock}}\n {{yield}}\n {{else}}\n No Block!\n {{/if}}'], ['\n {{#if hasBlock}}\n {{yield}}\n {{else}}\n No Block!\n {{/if}}']),
_templateObject13 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with-block}}\n In template\n {{/with-block}}'], ['\n {{#with-block}}\n In template\n {{/with-block}}']),
_templateObject14 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if hasBlockParams}}\n {{yield this}} - In Component\n {{else}}\n {{yield}} No Block!\n {{/if}}'], ['\n {{#if hasBlockParams}}\n {{yield this}} - In Component\n {{else}}\n {{yield}} No Block!\n {{/if}}']),
_templateObject15 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with-block as |something|}}\n In template\n {{/with-block}}'], ['\n {{#with-block as |something|}}\n In template\n {{/with-block}}']),
_templateObject16 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if hasBlockParams}}\n {{yield this}}\n {{else}}\n {{yield}} No Block Param!\n {{/if}}'], ['\n {{#if hasBlockParams}}\n {{yield this}}\n {{else}}\n {{yield}} No Block Param!\n {{/if}}']),
_templateObject17 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#with-block}}\n In block\n {{/with-block}}'], ['\n {{#with-block}}\n In block\n {{/with-block}}']),
_templateObject18 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if predicate}}\n Yes:{{yield someValue}}\n {{else}}\n No:{{yield to="inverse"}}\n {{/if}}'], ['\n {{#if predicate}}\n Yes:{{yield someValue}}\n {{else}}\n No:{{yield to="inverse"}}\n {{/if}}']),
_templateObject19 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#my-if predicate=activated someValue=42 as |result|}}\n Hello{{result}}\n {{else}}\n Goodbye\n {{/my-if}}'], ['\n {{#my-if predicate=activated someValue=42 as |result|}}\n Hello{{result}}\n {{else}}\n Goodbye\n {{/my-if}}']),
_templateObject20 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if (hasBlock "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlock "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}']),
_templateObject21 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse}}{{else}}{{/check-inverse}}'], ['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse}}{{else}}{{/check-inverse}}']),
_templateObject22 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if (hasBlock)}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlock)}}\n Yes\n {{else}}\n No\n {{/if}}']),
_templateObject23 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{check-block}}\n {{#check-block}}{{/check-block}}'], ['\n {{check-block}}\n {{#check-block}}{{/check-block}}']),
_templateObject24 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if (hasBlockParams "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlockParams "inverse")}}\n Yes\n {{else}}\n No\n {{/if}}']),
_templateObject25 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse as |something|}}{{/check-inverse}}'], ['\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse as |something|}}{{/check-inverse}}']),
_templateObject26 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if (hasBlockParams)}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if (hasBlockParams)}}\n Yes\n {{else}}\n No\n {{/if}}']),
_templateObject27 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#check-block}}{{/check-block}}\n {{#check-block as |something|}}{{/check-block}}'], ['\n {{#check-block}}{{/check-block}}\n {{#check-block as |something|}}{{/check-block}}']),
_templateObject28 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if hasBlock}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if hasBlock}}\n Yes\n {{else}}\n No\n {{/if}}']),
_templateObject29 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#check-params}}{{/check-params}}\n {{#check-params as |foo|}}{{/check-params}}'], ['\n {{#check-params}}{{/check-params}}\n {{#check-params as |foo|}}{{/check-params}}']),
_templateObject30 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if hasBlockParams}}\n Yes\n {{else}}\n No\n {{/if}}'], ['\n {{#if hasBlockParams}}\n Yes\n {{else}}\n No\n {{/if}}']),
_templateObject31 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{check-attr}}\n {{#check-attr}}{{/check-attr}}'], ['\n {{check-attr}}\n {{#check-attr}}{{/check-attr}}']),
_templateObject32 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr}}{{else}}{{/check-attr}}'], ['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr}}{{else}}{{/check-attr}}']),
_templateObject33 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr as |something|}}{{/check-attr}}'], ['\n {{#check-attr}}{{/check-attr}}\n {{#check-attr as |something|}}{{/check-attr}}']),
_templateObject34 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{check-helper}}\n {{#check-helper}}{{/check-helper}}'], ['\n {{check-helper}}\n {{#check-helper}}{{/check-helper}}']),
_templateObject35 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper}}{{else}}{{/check-helper}}'], ['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper}}{{else}}{{/check-helper}}']),
_templateObject36 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper as |something|}}{{/check-helper}}'], ['\n {{#check-helper}}{{/check-helper}}\n {{#check-helper as |something|}}{{/check-helper}}']),
_templateObject37 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#x-outer}}\n {{#if showInner}}\n {{x-inner}}\n {{/if}}\n {{/x-outer}}'], ['\n {{#x-outer}}\n {{#if showInner}}\n {{x-inner}}\n {{/if}}\n {{/x-outer}}']),
_templateObject38 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n In layout. {{#each items as |item|}}\n [{{child-non-block item=item}}]\n {{/each}}'], ['\n In layout. {{#each items as |item|}}\n [{{child-non-block item=item}}]\n {{/each}}']),
_templateObject39 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#some-clicky-thing classNames="baz"}}\n Click Me\n {{/some-clicky-thing}}'], ['\n {{#some-clicky-thing classNames="baz"}}\n Click Me\n {{/some-clicky-thing}}']),
_templateObject40 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#each blahzz as |p|}}\n {{p}}\n {{/each}}\n - {{yield}}'], ['\n {{#each blahzz as |p|}}\n {{p}}\n {{/each}}\n - {{yield}}']),
_templateObject41 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#some-clicky-thing blahzz="baz"}}\n Click Me\n {{/some-clicky-thing}}'], ['\n {{#some-clicky-thing blahzz="baz"}}\n Click Me\n {{/some-clicky-thing}}']),
_templateObject42 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#x-select value=value as |select|}}\n {{#x-option value="1" select=select}}1{{/x-option}}\n {{#x-option value="2" select=select}}2{{/x-option}}\n {{/x-select}}\n '], ['\n {{#x-select value=value as |select|}}\n {{#x-option value="1" select=select}}1{{/x-option}}\n {{#x-option value="2" select=select}}2{{/x-option}}\n {{/x-select}}\n ']),
_templateObject43 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#list-items items=items as |thing|}}\n |{{thing}}|\n\n {{#if editMode}}\n Remove {{thing}}\n {{/if}}\n {{/list-items}}\n '], ['\n {{#list-items items=items as |thing|}}\n |{{thing}}|\n\n {{#if editMode}}\n Remove {{thing}}\n {{/if}}\n {{/list-items}}\n ']);
(0, _testCase.moduleFor)('Components test: curly components', 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'] = function testItCanRenderABasicComponent() {
var _this2 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return _this2.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
};
_class.prototype['@test it can render a template only component'] = function testItCanRenderATemplateOnlyComponent() {
var _this3 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return _this3.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
};
_class.prototype['@test it can have a custom id and it is not bound'] = function testItCanHaveACustomIdAndItIsNotBound() {
var _this4 = this;
this.registerComponent('foo-bar', { template: '{{id}} {{elementId}}' });
this.render('{{foo-bar id=customId}}', {
customId: 'bizz'
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' });
this.runTask(function () {
return _this4.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' });
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'customId', 'bar');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bar bizz' });
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'customId', 'bizz');
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' });
};
_class.prototype['@test elementId cannot change'] = function testElementIdCannotChange(assert) {
var component = void 0;
var FooBarComponent = _helpers.Component.extend({
elementId: 'blahzorz',
init: function () {
this._super.apply(this, arguments);
component = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{elementId}}' });
this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'blahzorz' }, content: 'blahzorz' });
if (EmberDev && !EmberDev.runningProdBuild) {
var willThrow = function () {
return (0, _emberMetal.run)(null, _emberMetal.set, component, 'elementId', 'herpyderpy');
};
assert.throws(willThrow, /Changing a view's elementId after creation is not allowed/);
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'blahzorz' }, content: 'blahzorz' });
}
};
_class.prototype['@test can specify template with `layoutName` property'] = function testCanSpecifyTemplateWithLayoutNameProperty() {
var FooBarComponent = _helpers.Component.extend({
elementId: 'blahzorz',
layoutName: 'fizz-bar',
init: function () {
this._super.apply(this, arguments);
this.local = 'hey';
}
});
this.registerTemplate('fizz-bar', 'FIZZ BAR {{local}}');
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar}}');
this.assertText('FIZZ BAR hey');
};
_class.prototype['@test can specify template with `defaultLayout` property [DEPRECATED]'] = function testCanSpecifyTemplateWithDefaultLayoutPropertyDEPRECATED() {
expectDeprecation(/Specifying `defaultLayout` to .* is deprecated. Please use `layout` instead/);
var FooBarComponent = _helpers.Component.extend({
elementId: 'blahzorz',
defaultLayout: (0, _helpers.compile)('much wat {{lulz}}'),
init: function () {
this._super.apply(this, arguments);
this.lulz = 'hey';
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar}}');
this.assertText('much wat hey');
};
_class.prototype['@test layout takes precedence over defaultLayout'] = function testLayoutTakesPrecedenceOverDefaultLayout() {
var FooBarComponent = _helpers.Component.extend({
elementId: 'blahzorz',
layout: (0, _helpers.compile)('so much layout wat {{lulz}}'),
defaultLayout: (0, _helpers.compile)('much wat {{lulz}}'),
init: function () {
this._super.apply(this, arguments);
this.lulz = 'hey';
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar}}');
this.assertText('so much layout wat hey');
};
_class.prototype['@test layout supports computed property'] = function testLayoutSupportsComputedProperty() {
var FooBarComponent = _helpers.Component.extend({
elementId: 'blahzorz',
layout: (0, _emberMetal.computed)(function () {
return (0, _helpers.compile)('so much layout wat {{lulz}}');
}),
init: function () {
this._super.apply(this, arguments);
this.lulz = 'heyo';
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar}}');
this.assertText('so much layout wat heyo');
};
_class.prototype['@test passing undefined elementId results in a default elementId'] = function testPassingUndefinedElementIdResultsInADefaultElementId(assert) {
var _this5 = this;
var FooBarComponent = _helpers.Component.extend({
tagName: 'h1'
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'something' });
this.render('{{foo-bar id=somethingUndefined}}');
var foundId = this.$('h1').attr('id');
assert.ok(/^ember/.test(foundId), 'Has a reasonable id attribute (found id=' + foundId + ').');
this.runTask(function () {
return _this5.rerender();
});
var newFoundId = this.$('h1').attr('id');
assert.ok(/^ember/.test(newFoundId), 'Has a reasonable id attribute (found id=' + newFoundId + ').');
assert.equal(foundId, newFoundId);
};
_class.prototype['@test id is an alias for elementId'] = function testIdIsAnAliasForElementId(assert) {
var _this6 = this;
var FooBarComponent = _helpers.Component.extend({
tagName: 'h1'
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'something' });
this.render('{{foo-bar id="custom-id"}}');
var foundId = this.$('h1').attr('id');
assert.equal(foundId, 'custom-id');
this.runTask(function () {
return _this6.rerender();
});
var newFoundId = this.$('h1').attr('id');
assert.equal(newFoundId, 'custom-id');
assert.equal(foundId, newFoundId);
};
_class.prototype['@test cannot pass both id and elementId at the same time'] = function testCannotPassBothIdAndElementIdAtTheSameTime(assert) {
var _this7 = this;
this.registerComponent('foo-bar', { template: '' });
expectAssertion(function () {
_this7.render('{{foo-bar id="zomg" elementId="lol"}}');
}, /You cannot invoke a component with both 'id' and 'elementId' at the same time./);
};
_class.prototype['@test it can have a custom tagName'] = function testItCanHaveACustomTagName() {
var _this8 = this;
var FooBarComponent = _helpers.Component.extend({
tagName: 'foo-bar'
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' });
this.runTask(function () {
return _this8.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' });
};
_class.prototype['@test it can have a custom tagName set in the constructor'] = function testItCanHaveACustomTagNameSetInTheConstructor() {
var _this9 = this;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
this.tagName = 'foo-bar';
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' });
this.runTask(function () {
return _this9.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' });
};
_class.prototype['@test it can have a custom tagName from the invocation'] = function testItCanHaveACustomTagNameFromTheInvocation() {
var _this10 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar tagName="foo-bar"}}');
this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' });
this.runTask(function () {
return _this10.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' });
};
_class.prototype['@test tagName can not be a computed property'] = function testTagNameCanNotBeAComputedProperty(assert) {
var _this11 = this;
var FooBarComponent = _helpers.Component.extend({
tagName: (0, _emberMetal.computed)(function () {
return 'foo-bar';
})
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
expectAssertion(function () {
_this11.render('{{foo-bar}}');
}, /You cannot use a computed property for the component's `tagName` \(<\(.+>\)\./);
};
_class.prototype['@test class is applied before didInsertElement'] = function testClassIsAppliedBeforeDidInsertElement(assert) {
var componentClass = void 0;
var FooBarComponent = _helpers.Component.extend({
didInsertElement: function () {
componentClass = this.element.className;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar class="foo-bar"}}');
assert.equal(componentClass, 'foo-bar ember-view');
};
_class.prototype['@test it can have custom classNames'] = function testItCanHaveCustomClassNames() {
var _this12 = this;
var FooBarComponent = _helpers.Component.extend({
classNames: ['foo', 'bar']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo bar') }, content: 'hello' });
this.runTask(function () {
return _this12.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo bar') }, content: 'hello' });
};
_class.prototype['@test should not apply falsy class name'] = function testShouldNotApplyFalsyClassName() {
var _this13 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar class=somethingFalsy}}', {
somethingFalsy: false
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, content: 'hello' });
this.runTask(function () {
return _this13.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, content: 'hello' });
};
_class.prototype['@test should apply classes of the dasherized property name when bound property specified is true'] = function testShouldApplyClassesOfTheDasherizedPropertyNameWhenBoundPropertySpecifiedIsTrue() {
var _this14 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar class=model.someTruth}}', {
model: { someTruth: true }
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('ember-view some-truth') }, content: 'hello' });
this.runTask(function () {
return _this14.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('ember-view some-truth') }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'model.someTruth', false);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('ember-view') }, content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'model', { someTruth: true });
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('ember-view some-truth') }, content: 'hello' });
};
_class.prototype['@test class property on components can be dynamic'] = function testClassPropertyOnComponentsCanBeDynamic() {
var _this15 = this;
this.registerComponent('foo-bar', { template: 'hello' });
this.render('{{foo-bar class=(if fooBar "foo-bar")}}', {
fooBar: true
});
this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo-bar') } });
this.runTask(function () {
return _this15.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo-bar') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'fooBar', false);
});
this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('ember-view') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'fooBar', true);
});
this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo-bar') } });
};
_class.prototype['@test it can have custom classNames from constructor'] = function testItCanHaveCustomClassNamesFromConstructor() {
var _this16 = this;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
this.classNames = this.classNames.slice();
this.classNames.push('foo', 'bar', 'outside-' + this.get('extraClass'));
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar extraClass="baz"}}');
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo bar outside-baz') }, content: 'hello' });
this.runTask(function () {
return _this16.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo bar outside-baz') }, content: 'hello' });
};
_class.prototype['@test it can set custom classNames from the invocation'] = function testItCanSetCustomClassNamesFromTheInvocation() {
var _this17 = this;
var FooBarComponent = _helpers.Component.extend({
classNames: ['foo']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render((0, _abstractTestCase.strip)(_templateObject));
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo bar baz') }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo bar baz') }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo') }, content: 'hello' });
this.runTask(function () {
return _this17.rerender();
});
this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo bar baz') }, content: 'hello' });
this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo bar baz') }, content: 'hello' });
this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { 'class': (0, _testHelpers.classes)('ember-view foo') }, content: 'hello' });
};
_class.prototype['@test it has an element'] = function testItHasAnElement() {
var _this18 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
instance = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar}}');
var element1 = instance.element;
this.assertComponentElement(element1, { content: 'hello' });
this.runTask(function () {
return _this18.rerender();
});
var element2 = instance.element;
this.assertComponentElement(element2, { content: 'hello' });
this.assertSameNode(element2, element1);
};
_class.prototype['@test it has a jQuery proxy to the element'] = function testItHasAJQueryProxyToTheElement(assert) {
var _this19 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
instance = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{foo-bar}}');
var element1 = instance.$()[0];
this.assertComponentElement(element1, { content: 'hello' });
this.runTask(function () {
return _this19.rerender();
});
var element2 = instance.$()[0];
this.assertComponentElement(element2, { content: 'hello' });
this.assertSameNode(element2, element1);
};
_class.prototype['@test it scopes the jQuery proxy to the component element'] = function testItScopesTheJQueryProxyToTheComponentElement(assert) {
var _this20 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
instance = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '<span class="inner">inner</span>' });
this.render('<span class="outer">outer</span>{{foo-bar}}');
var $span = instance.$('span');
assert.equal($span.length, 1);
assert.equal($span.attr('class'), 'inner');
this.runTask(function () {
return _this20.rerender();
});
$span = instance.$('span');
assert.equal($span.length, 1);
assert.equal($span.attr('class'), 'inner');
};
_class.prototype['@test an empty component does not have childNodes'] = function testAnEmptyComponentDoesNotHaveChildNodes(assert) {
var _this21 = this;
var fooBarInstance = void 0;
var FooBarComponent = _helpers.Component.extend({
tagName: 'input',
init: function () {
this._super();
fooBarInstance = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '' });
this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild, { tagName: 'input' });
assert.strictEqual(fooBarInstance.element.childNodes.length, 0);
this.runTask(function () {
return _this21.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'input' });
assert.strictEqual(fooBarInstance.element.childNodes.length, 0);
};
_class.prototype['@test it has the right parentView and childViews'] = function testItHasTheRightParentViewAndChildViews(assert) {
var _this22 = this;
var fooBarInstance = void 0,
fooBarBazInstance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
fooBarInstance = this;
}
});
var FooBarBazComponent = _helpers.Component.extend({
init: function () {
this._super();
fooBarBazInstance = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'foo-bar {{foo-bar-baz}}' });
this.registerComponent('foo-bar-baz', { ComponentClass: FooBarBazComponent, template: 'foo-bar-baz' });
this.render('{{foo-bar}}');
this.assertText('foo-bar foo-bar-baz');
assert.equal(fooBarInstance.parentView, this.component);
assert.equal(fooBarBazInstance.parentView, fooBarInstance);
assert.deepEqual(this.component.childViews, [fooBarInstance]);
assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]);
this.runTask(function () {
return _this22.rerender();
});
this.assertText('foo-bar foo-bar-baz');
assert.equal(fooBarInstance.parentView, this.component);
assert.equal(fooBarBazInstance.parentView, fooBarInstance);
assert.deepEqual(this.component.childViews, [fooBarInstance]);
assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]);
};
_class.prototype['@test it renders passed named arguments'] = function testItRendersPassedNamedArguments() {
var _this23 = this;
this.registerComponent('foo-bar', {
template: '{{foo}}'
});
this.render('{{foo-bar foo=model.bar}}', {
model: {
bar: 'Hola'
}
});
this.assertText('Hola');
this.runTask(function () {
return _this23.rerender();
});
this.assertText('Hola');
this.runTask(function () {
return _this23.context.set('model.bar', 'Hello');
});
this.assertText('Hello');
this.runTask(function () {
return _this23.context.set('model', { bar: 'Hola' });
});
this.assertText('Hola');
};
_class.prototype['@test it can render a basic component with a block'] = function testItCanRenderABasicComponentWithABlock() {
var _this24 = this;
this.registerComponent('foo-bar', { template: '{{yield}} - In component' });
this.render('{{#foo-bar}}hello{{/foo-bar}}');
this.assertComponentElement(this.firstChild, { content: 'hello - In component' });
this.runTask(function () {
return _this24.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello - In component' });
};
_class.prototype['@test it can render a basic component with a block when the yield is in a partial'] = function testItCanRenderABasicComponentWithABlockWhenTheYieldIsInAPartial() {
var _this25 = this;
this.registerPartial('_partialWithYield', 'yielded: [{{yield}}]');
this.registerComponent('foo-bar', { template: '{{partial "partialWithYield"}} - In component' });
this.render('{{#foo-bar}}hello{{/foo-bar}}');
this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' });
this.runTask(function () {
return _this25.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' });
};
_class.prototype['@test it can render a basic component with a block param when the yield is in a partial'] = function testItCanRenderABasicComponentWithABlockParamWhenTheYieldIsInAPartial() {
var _this26 = this;
this.registerPartial('_partialWithYield', 'yielded: [{{yield "hello"}}]');
this.registerComponent('foo-bar', { template: '{{partial "partialWithYield"}} - In component' });
this.render('{{#foo-bar as |value|}}{{value}}{{/foo-bar}}');
this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' });
this.runTask(function () {
return _this26.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' });
};
_class.prototype['@test it renders the layout with the component instance as the context'] = function testItRendersTheLayoutWithTheComponentInstanceAsTheContext() {
var _this27 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
instance = this;
this.set('message', 'hello');
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{message}}' });
this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return _this27.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'message', 'goodbye');
});
this.assertComponentElement(this.firstChild, { content: 'goodbye' });
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'message', 'hello');
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
};
_class.prototype['@test it preserves the outer context when yielding'] = function testItPreservesTheOuterContextWhenYielding() {
var _this28 = this;
this.registerComponent('foo-bar', { template: '{{yield}}' });
this.render('{{#foo-bar}}{{message}}{{/foo-bar}}', { message: 'hello' });
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return _this28.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this28.context, 'message', 'goodbye');
});
this.assertComponentElement(this.firstChild, { content: 'goodbye' });
this.runTask(function () {
return (0, _emberMetal.set)(_this28.context, 'message', 'hello');
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
};
_class.prototype['@test it can yield a block param named for reserved words [GH#14096]'] = function testItCanYieldABlockParamNamedForReservedWordsGH14096() {
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
instance = this;
},
name: 'foo-bar'
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{yield this}}' });
this.render('{{#foo-bar as |component|}}{{component.name}}{{/foo-bar}}');
this.assertComponentElement(this.firstChild, { content: 'foo-bar' });
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'name', 'derp-qux');
});
this.assertComponentElement(this.firstChild, { content: 'derp-qux' });
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'name', 'foo-bar');
});
this.assertComponentElement(this.firstChild, { content: 'foo-bar' });
};
_class.prototype['@test it can yield internal and external properties positionally'] = function testItCanYieldInternalAndExternalPropertiesPositionally() {
var _this29 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
instance = this;
},
greeting: 'hello'
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{yield greeting greetee.firstName}}' });
this.render('{{#foo-bar greetee=person as |greeting name|}}{{name}} {{person.lastName}}, {{greeting}}{{/foo-bar}}', {
person: {
firstName: 'Joel',
lastName: 'Kang'
}
});
this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' });
this.runTask(function () {
return _this29.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this29.context, 'person', { firstName: 'Dora', lastName: 'the Explorer' });
});
this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hello' });
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'greeting', 'hola');
});
this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hola' });
this.runTask(function () {
(0, _emberMetal.set)(instance, 'greeting', 'hello');
(0, _emberMetal.set)(_this29.context, 'person', {
firstName: 'Joel',
lastName: 'Kang'
});
});
this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' });
};
_class.prototype['@test #11519 - block param infinite loop'] = function test11519BlockParamInfiniteLoop() {
var _this30 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
instance = this;
},
danger: 0
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{danger}}{{yield danger}}' });
// On initial render, create streams. The bug will not have manifested yet, but at this point
// we have created streams that create a circular invalidation.
this.render('{{#foo-bar as |dangerBlockParam|}}{{/foo-bar}}');
this.assertText('0');
// Trigger a non-revalidating re-render. The yielded block will not be dirtied
// nor will block param streams, and thus no infinite loop will occur.
this.runTask(function () {
return _this30.rerender();
});
this.assertText('0');
// Trigger a revalidation, which will cause an infinite loop without the fix
// in place. Note that we do not see the infinite loop is in testing mode,
// because a deprecation warning about re-renders is issued, which Ember
// treats as an exception.
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'danger', 1);
});
this.assertText('1');
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'danger', 0);
});
this.assertText('0');
};
_class.prototype['@test the component and its child components are destroyed'] = function testTheComponentAndItsChildComponentsAreDestroyed(assert) {
var _this31 = this;
var destroyed = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 };
this.registerComponent('foo-bar', {
template: '{{id}} {{yield}}',
ComponentClass: _helpers.Component.extend({
willDestroy: function () {
this._super();
destroyed[this.get('id')]++;
}
})
});
this.render((0, _abstractTestCase.strip)(_templateObject2), {
cond1: true,
cond2: true,
cond3: true,
cond4: true,
cond5: true
});
this.assertText('1 2 3 4 5 6 7 8 ');
this.runTask(function () {
return _this31.rerender();
});
assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 });
this.runTask(function () {
return (0, _emberMetal.set)(_this31.context, 'cond5', false);
});
this.assertText('1 2 3 4 8 ');
assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 1, 7: 1, 8: 0 });
this.runTask(function () {
(0, _emberMetal.set)(_this31.context, 'cond3', false);
(0, _emberMetal.set)(_this31.context, 'cond5', true);
(0, _emberMetal.set)(_this31.context, 'cond4', false);
});
assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 });
this.runTask(function () {
(0, _emberMetal.set)(_this31.context, 'cond2', false);
(0, _emberMetal.set)(_this31.context, 'cond1', false);
});
assert.deepEqual(destroyed, { 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 });
};
_class.prototype['@test should escape HTML in normal mustaches'] = function testShouldEscapeHTMLInNormalMustaches() {
var _this32 = this;
var component = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
output: 'you need to be more <b>bold</b>'
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{output}}' });
this.render('{{foo-bar}}');
this.assertText('you need to be more <b>bold</b>');
this.runTask(function () {
return _this32.rerender();
});
this.assertText('you need to be more <b>bold</b>');
this.runTask(function () {
return (0, _emberMetal.set)(component, 'output', 'you are so <i>super</i>');
});
this.assertText('you are so <i>super</i>');
this.runTask(function () {
return (0, _emberMetal.set)(component, 'output', 'you need to be more <b>bold</b>');
});
};
_class.prototype['@test should not escape HTML in triple mustaches'] = function testShouldNotEscapeHTMLInTripleMustaches(assert) {
var _this33 = this;
var expectedHtmlBold = 'you need to be more <b>bold</b>';
var expectedHtmlItalic = 'you are so <i>super</i>';
var component = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
output: expectedHtmlBold
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{{output}}}' });
this.render('{{foo-bar}}');
(0, _testHelpers.equalTokens)(this.firstChild, expectedHtmlBold);
this.runTask(function () {
return _this33.rerender();
});
(0, _testHelpers.equalTokens)(this.firstChild, expectedHtmlBold);
this.runTask(function () {
return (0, _emberMetal.set)(component, 'output', expectedHtmlItalic);
});
(0, _testHelpers.equalTokens)(this.firstChild, expectedHtmlItalic);
this.runTask(function () {
return (0, _emberMetal.set)(component, 'output', expectedHtmlBold);
});
(0, _testHelpers.equalTokens)(this.firstChild, expectedHtmlBold);
};
_class.prototype['@test should not escape HTML if string is a htmlSafe'] = function testShouldNotEscapeHTMLIfStringIsAHtmlSafe(assert) {
var _this34 = this;
var expectedHtmlBold = 'you need to be more <b>bold</b>';
var expectedHtmlItalic = 'you are so <i>super</i>';
var component = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
output: (0, _helpers.htmlSafe)(expectedHtmlBold)
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{output}}' });
this.render('{{foo-bar}}');
(0, _testHelpers.equalTokens)(this.firstChild, expectedHtmlBold);
this.runTask(function () {
return _this34.rerender();
});
(0, _testHelpers.equalTokens)(this.firstChild, expectedHtmlBold);
this.runTask(function () {
return (0, _emberMetal.set)(component, 'output', (0, _helpers.htmlSafe)(expectedHtmlItalic));
});
(0, _testHelpers.equalTokens)(this.firstChild, expectedHtmlItalic);
this.runTask(function () {
return (0, _emberMetal.set)(component, 'output', (0, _helpers.htmlSafe)(expectedHtmlBold));
});
(0, _testHelpers.equalTokens)(this.firstChild, expectedHtmlBold);
};
_class.prototype['@test late bound layouts return the same definition'] = function testLateBoundLayoutsReturnTheSameDefinition(assert) {
var templateIds = [];
// This is testing the scenario where you import a template and
// set it to the layout property:
//
// import layout from './template';
//
// export default Ember.Component.extend({
// layout
// });
var hello = (0, _helpers.compile)('Hello');
var bye = (0, _helpers.compile)('Bye');
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
this.layout = this.cond ? hello : bye;
templateIds.push(this.layout.id);
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent });
this.render('{{foo-bar cond=true}}{{foo-bar cond=false}}{{foo-bar cond=true}}{{foo-bar cond=false}}');
var t1 = templateIds[0],
t2 = templateIds[1],
t3 = templateIds[2],
t4 = templateIds[3];
assert.equal(t1, t3);
assert.equal(t2, t4);
};
_class.prototype['@test can use isStream property without conflict (#13271)'] = function testCanUseIsStreamPropertyWithoutConflict13271() {
var _this35 = this;
var component = void 0;
var FooBarComponent = _helpers.Component.extend({
isStream: true,
init: function () {
this._super.apply(this, arguments);
component = this;
}
});
this.registerComponent('foo-bar', {
ComponentClass: FooBarComponent,
template: (0, _abstractTestCase.strip)(_templateObject3)
});
this.render('{{foo-bar}}');
this.assertComponentElement(this.firstChild, { content: 'true' });
this.runTask(function () {
return _this35.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'true' });
this.runTask(function () {
return (0, _emberMetal.set)(component, 'isStream', false);
});
this.assertComponentElement(this.firstChild, { content: 'false' });
this.runTask(function () {
return (0, _emberMetal.set)(component, 'isStream', true);
});
this.assertComponentElement(this.firstChild, { content: 'true' });
};
_class.prototype['@test lookup of component takes priority over property'] = function testLookupOfComponentTakesPriorityOverProperty() {
var _this36 = this;
this.registerComponent('some-component', {
template: 'some-component'
});
this.render('{{some-prop}} {{some-component}}', {
'some-component': 'not-some-component',
'some-prop': 'some-prop'
});
this.assertText('some-prop some-component');
this.runTask(function () {
return _this36.rerender();
});
this.assertText('some-prop some-component');
};
_class.prototype['@test component without dash is not looked up'] = function testComponentWithoutDashIsNotLookedUp() {
var _this37 = this;
this.registerComponent('somecomponent', {
template: 'somecomponent'
});
this.render('{{somecomponent}}', {
'somecomponent': 'notsomecomponent'
});
this.assertText('notsomecomponent');
this.runTask(function () {
return _this37.rerender();
});
this.assertText('notsomecomponent');
this.runTask(function () {
return _this37.context.set('somecomponent', 'not not notsomecomponent');
});
this.assertText('not not notsomecomponent');
this.runTask(function () {
return _this37.context.set('somecomponent', 'notsomecomponent');
});
this.assertText('notsomecomponent');
};
_class.prototype['@test non-block with properties on attrs'] = function testNonBlockWithPropertiesOnAttrs() {
var _this38 = this;
this.registerComponent('non-block', {
template: 'In layout - someProp: {{attrs.someProp}}'
});
this.render('{{non-block someProp=prop}}', {
prop: 'something here'
});
this.assertText('In layout - someProp: something here');
this.runTask(function () {
return _this38.rerender();
});
this.assertText('In layout - someProp: something here');
this.runTask(function () {
return _this38.context.set('prop', 'other thing there');
});
this.assertText('In layout - someProp: other thing there');
this.runTask(function () {
return _this38.context.set('prop', 'something here');
});
this.assertText('In layout - someProp: something here');
};
_class.prototype['@test non-block with properties overridden in init'] = function testNonBlockWithPropertiesOverriddenInInit() {
var _this39 = this;
var instance = void 0;
this.registerComponent('non-block', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
instance = this;
this.someProp = 'value set in instance';
}
}),
template: 'In layout - someProp: {{someProp}}'
});
this.render('{{non-block someProp=prop}}', {
prop: 'something passed when invoked'
});
this.assertText('In layout - someProp: value set in instance');
this.runTask(function () {
return _this39.rerender();
});
this.assertText('In layout - someProp: value set in instance');
this.runTask(function () {
return _this39.context.set('prop', 'updated something passed when invoked');
});
this.assertText('In layout - someProp: updated something passed when invoked');
this.runTask(function () {
return instance.set('someProp', 'update value set in instance');
});
this.assertText('In layout - someProp: update value set in instance');
this.runTask(function () {
return _this39.context.set('prop', 'something passed when invoked');
});
this.runTask(function () {
return instance.set('someProp', 'value set in instance');
});
this.assertText('In layout - someProp: value set in instance');
};
_class.prototype['@test rerendering component with attrs from parent'] = function testRerenderingComponentWithAttrsFromParent(assert) {
var _this40 = this;
var willUpdateCount = 0;
var didReceiveAttrsCount = 0;
function expectHooks(_ref, callback) {
var willUpdate = _ref.willUpdate,
didReceiveAttrs = _ref.didReceiveAttrs;
willUpdateCount = 0;
didReceiveAttrsCount = 0;
callback();
if (willUpdate) {
assert.strictEqual(willUpdateCount, 1, 'The willUpdate hook was fired');
} else {
assert.strictEqual(willUpdateCount, 0, 'The willUpdate hook was not fired');
}
if (didReceiveAttrs) {
assert.strictEqual(didReceiveAttrsCount, 1, 'The didReceiveAttrs hook was fired');
} else {
assert.strictEqual(didReceiveAttrsCount, 0, 'The didReceiveAttrs hook was not fired');
}
}
this.registerComponent('non-block', {
ComponentClass: _helpers.Component.extend({
didReceiveAttrs: function () {
didReceiveAttrsCount++;
},
willUpdate: function () {
willUpdateCount++;
}
}),
template: 'In layout - someProp: {{someProp}}'
});
expectHooks({ willUpdate: false, didReceiveAttrs: true }, function () {
_this40.render('{{non-block someProp=someProp}}', {
someProp: 'wycats'
});
});
this.assertText('In layout - someProp: wycats');
// Note: Hooks are not fired in Glimmer for idempotent re-renders
expectHooks({ willUpdate: false, didReceiveAttrs: false }, function () {
_this40.runTask(function () {
return _this40.rerender();
});
});
this.assertText('In layout - someProp: wycats');
expectHooks({ willUpdate: true, didReceiveAttrs: true }, function () {
_this40.runTask(function () {
return _this40.context.set('someProp', 'tomdale');
});
});
this.assertText('In layout - someProp: tomdale');
// Note: Hooks are not fired in Glimmer for idempotent re-renders
expectHooks({ willUpdate: false, didReceiveAttrs: false }, function () {
_this40.runTask(function () {
return _this40.rerender();
});
});
this.assertText('In layout - someProp: tomdale');
expectHooks({ willUpdate: true, didReceiveAttrs: true }, function () {
_this40.runTask(function () {
return _this40.context.set('someProp', 'wycats');
});
});
this.assertText('In layout - someProp: wycats');
};
_class.prototype['@test this.attrs.foo === attrs.foo === foo'] = function testThisAttrsFooAttrsFooFoo() {
var _this41 = this;
this.registerComponent('foo-bar', {
template: (0, _abstractTestCase.strip)(_templateObject4)
});
this.render('{{foo-bar value=model.value items=model.items}}', {
model: {
value: 'wat',
items: [1, 2, 3]
}
});
this.assertStableRerender();
this.runTask(function () {
_this41.context.set('model.value', 'lul');
_this41.context.set('model.items', [1]);
});
this.assertText((0, _abstractTestCase.strip)(_templateObject5));
this.runTask(function () {
return _this41.context.set('model', { value: 'wat', items: [1, 2, 3] });
});
this.assertText('Args: wat | wat | wat123123123');
};
_class.prototype['@test non-block with properties on self'] = function testNonBlockWithPropertiesOnSelf() {
var _this42 = this;
this.registerComponent('non-block', {
template: 'In layout - someProp: {{someProp}}'
});
this.render('{{non-block someProp=prop}}', {
prop: 'something here'
});
this.assertText('In layout - someProp: something here');
this.runTask(function () {
return _this42.rerender();
});
this.assertText('In layout - someProp: something here');
this.runTask(function () {
return _this42.context.set('prop', 'something else');
});
this.assertText('In layout - someProp: something else');
this.runTask(function () {
return _this42.context.set('prop', 'something here');
});
this.assertText('In layout - someProp: something here');
};
_class.prototype['@test block with properties on self'] = function testBlockWithPropertiesOnSelf() {
var _this43 = this;
this.registerComponent('with-block', {
template: 'In layout - someProp: {{someProp}} - {{yield}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject6), {
prop: 'something here'
});
this.assertText('In layout - someProp: something here - In template');
this.runTask(function () {
return _this43.rerender();
});
this.assertText('In layout - someProp: something here - In template');
this.runTask(function () {
return _this43.context.set('prop', 'something else');
});
this.assertText('In layout - someProp: something else - In template');
this.runTask(function () {
return _this43.context.set('prop', 'something here');
});
this.assertText('In layout - someProp: something here - In template');
};
_class.prototype['@test block with properties on attrs'] = function testBlockWithPropertiesOnAttrs() {
var _this44 = this;
this.registerComponent('with-block', {
template: 'In layout - someProp: {{attrs.someProp}} - {{yield}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject6), {
prop: 'something here'
});
this.assertText('In layout - someProp: something here - In template');
this.runTask(function () {
return _this44.rerender();
});
this.assertText('In layout - someProp: something here - In template');
this.runTask(function () {
return _this44.context.set('prop', 'something else');
});
this.assertText('In layout - someProp: something else - In template');
this.runTask(function () {
return _this44.context.set('prop', 'something here');
});
this.assertText('In layout - someProp: something here - In template');
};
_class.prototype['@test static arbitrary number of positional parameters'] = function testStaticArbitraryNumberOfPositionalParameters(assert) {
var _this45 = this;
this.registerComponent('sample-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'names'
}),
template: (0, _abstractTestCase.strip)(_templateObject7)
});
this.render((0, _abstractTestCase.strip)(_templateObject8));
assert.equal(this.$('#args-3').text(), 'Foo4Bar');
assert.equal(this.$('#args-5').text(), 'Foo4Bar5Baz');
this.runTask(function () {
return _this45.rerender();
});
assert.equal(this.$('#args-3').text(), 'Foo4Bar');
assert.equal(this.$('#args-5').text(), 'Foo4Bar5Baz');
};
_class.prototype['@test arbitrary positional parameter conflict with hash parameter is reported'] = function testArbitraryPositionalParameterConflictWithHashParameterIsReported() {
var _this46 = this;
this.registerComponent('sample-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'names'
}),
template: (0, _abstractTestCase.strip)(_templateObject7)
});
expectAssertion(function () {
_this46.render('{{sample-component "Foo" 4 "Bar" names=numbers id="args-3"}}', {
numbers: [1, 2, 3]
});
}, 'You cannot specify positional parameters and the hash argument `names`.');
};
_class.prototype['@test can use hash parameter instead of arbitrary positional param [GH #12444]'] = function testCanUseHashParameterInsteadOfArbitraryPositionalParamGH12444(assert) {
var _this47 = this;
this.registerComponent('sample-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'names'
}),
template: (0, _abstractTestCase.strip)(_templateObject7)
});
this.render('{{sample-component names=things}}', {
things: (0, _emberRuntime.A)(['Foo', 4, 'Bar'])
});
this.assertText('Foo4Bar');
this.runTask(function () {
return _this47.rerender();
});
this.assertText('Foo4Bar');
this.runTask(function () {
return _this47.context.get('things').pushObject(5);
});
this.assertText('Foo4Bar5');
this.runTask(function () {
return _this47.context.get('things').shiftObject();
});
this.assertText('4Bar5');
this.runTask(function () {
return _this47.context.get('things').clear();
});
this.assertText('');
this.runTask(function () {
return _this47.context.set('things', (0, _emberRuntime.A)(['Foo', 4, 'Bar']));
});
this.assertText('Foo4Bar');
};
_class.prototype['@test can use hash parameter instead of positional param'] = function testCanUseHashParameterInsteadOfPositionalParam(assert) {
var _this48 = this;
this.registerComponent('sample-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['first', 'second']
}),
template: '{{first}} - {{second}}'
});
// TODO: Fix when id is implemented
this.render((0, _abstractTestCase.strip)(_templateObject9));
assert.equal(this.$('#two-positional').text(), 'one - two');
assert.equal(this.$('#one-positional').text(), 'one - two');
assert.equal(this.$('#no-positional').text(), 'one - two');
this.runTask(function () {
return _this48.rerender();
});
assert.equal(this.$('#two-positional').text(), 'one - two');
assert.equal(this.$('#one-positional').text(), 'one - two');
assert.equal(this.$('#no-positional').text(), 'one - two');
};
_class.prototype['@test dynamic arbitrary number of positional parameters'] = function testDynamicArbitraryNumberOfPositionalParameters(assert) {
var _this49 = this;
this.registerComponent('sample-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'n'
}),
template: (0, _abstractTestCase.strip)(_templateObject10)
});
this.render('{{sample-component user1 user2}}', {
user1: 'Foo',
user2: 4
});
this.assertText('Foo4');
this.runTask(function () {
return _this49.rerender();
});
this.assertText('Foo4');
this.runTask(function () {
return _this49.context.set('user1', 'Bar');
});
this.assertText('Bar4');
this.runTask(function () {
return _this49.context.set('user2', '5');
});
this.assertText('Bar5');
this.runTask(function () {
_this49.context.set('user1', 'Foo');
_this49.context.set('user2', 4);
});
this.assertText('Foo4');
};
_class.prototype['@test with ariaRole specified'] = function testWithAriaRoleSpecified() {
var _this50 = this;
this.registerComponent('aria-test', {
template: 'Here!'
});
this.render('{{aria-test ariaRole=role}}', {
role: 'main'
});
this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } });
this.runTask(function () {
return _this50.rerender();
});
this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } });
this.runTask(function () {
return _this50.context.set('role', 'input');
});
this.assertComponentElement(this.firstChild, { attrs: { role: 'input' } });
this.runTask(function () {
return _this50.context.set('role', 'main');
});
this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } });
};
_class.prototype['@test `template` specified in component is overridden by block'] = function testTemplateSpecifiedInComponentIsOverriddenByBlock() {
var _this51 = this;
this.registerComponent('with-template', {
ComponentClass: _helpers.Component.extend({
template: (0, _helpers.compile)('Should not be used')
}),
template: '[In layout - {{name}}] {{yield}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject11), {
name: 'Whoop, whoop!'
});
this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] ');
this.runTask(function () {
return _this51.rerender();
});
this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] ');
this.runTask(function () {
return _this51.context.set('name', 'Ole, ole');
});
this.assertText('[In layout - with-block] [In block - Ole, ole][In layout - without-block] ');
this.runTask(function () {
return _this51.context.set('name', 'Whoop, whoop!');
});
this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] ');
};
_class.prototype['@test hasBlock is true when block supplied'] = function testHasBlockIsTrueWhenBlockSupplied() {
var _this52 = this;
this.registerComponent('with-block', {
template: (0, _abstractTestCase.strip)(_templateObject12)
});
this.render((0, _abstractTestCase.strip)(_templateObject13));
this.assertText('In template');
this.runTask(function () {
return _this52.rerender();
});
this.assertText('In template');
};
_class.prototype['@test hasBlock is false when no block supplied'] = function testHasBlockIsFalseWhenNoBlockSupplied() {
var _this53 = this;
this.registerComponent('with-block', {
template: (0, _abstractTestCase.strip)(_templateObject12)
});
this.render('{{with-block}}');
this.assertText('No Block!');
this.runTask(function () {
return _this53.rerender();
});
this.assertText('No Block!');
};
_class.prototype['@test hasBlockParams is true when block param supplied'] = function testHasBlockParamsIsTrueWhenBlockParamSupplied() {
var _this54 = this;
this.registerComponent('with-block', {
template: (0, _abstractTestCase.strip)(_templateObject14)
});
this.render((0, _abstractTestCase.strip)(_templateObject15));
this.assertText('In template - In Component');
this.runTask(function () {
return _this54.rerender();
});
this.assertText('In template - In Component');
};
_class.prototype['@test hasBlockParams is false when no block param supplied'] = function testHasBlockParamsIsFalseWhenNoBlockParamSupplied() {
var _this55 = this;
this.registerComponent('with-block', {
template: (0, _abstractTestCase.strip)(_templateObject16)
});
this.render((0, _abstractTestCase.strip)(_templateObject17));
this.assertText('In block No Block Param!');
this.runTask(function () {
return _this55.rerender();
});
this.assertText('In block No Block Param!');
};
_class.prototype['@test static named positional parameters'] = function testStaticNamedPositionalParameters() {
var _this56 = this;
this.registerComponent('sample-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name', 'age']
}),
template: '{{name}}{{age}}'
});
this.render('{{sample-component "Quint" 4}}');
this.assertText('Quint4');
this.runTask(function () {
return _this56.rerender();
});
this.assertText('Quint4');
};
_class.prototype['@test dynamic named positional parameters'] = function testDynamicNamedPositionalParameters() {
var _this57 = this;
this.registerComponent('sample-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name', 'age']
}),
template: '{{name}}{{age}}'
});
this.render('{{sample-component myName myAge}}', {
myName: 'Quint',
myAge: 4
});
this.assertText('Quint4');
this.runTask(function () {
return _this57.rerender();
});
this.assertText('Quint4');
this.runTask(function () {
return _this57.context.set('myName', 'Sergio');
});
this.assertText('Sergio4');
this.runTask(function () {
return _this57.context.set('myAge', 2);
});
this.assertText('Sergio2');
this.runTask(function () {
_this57.context.set('myName', 'Quint');
_this57.context.set('myAge', 4);
});
this.assertText('Quint4');
};
_class.prototype['@test if a value is passed as a non-positional parameter, it raises an assertion'] = function testIfAValueIsPassedAsANonPositionalParameterItRaisesAnAssertion() {
var _this58 = this;
this.registerComponent('sample-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name']
}),
template: '{{name}}'
});
expectAssertion(function () {
_this58.render('{{sample-component notMyName name=myName}}', {
myName: 'Quint',
notMyName: 'Sergio'
});
}, 'You cannot specify both a positional param (at position 0) and the hash argument `name`.');
};
_class.prototype['@test yield to inverse'] = function testYieldToInverse() {
var _this59 = this;
this.registerComponent('my-if', {
template: (0, _abstractTestCase.strip)(_templateObject18)
});
this.render((0, _abstractTestCase.strip)(_templateObject19), {
activated: true
});
this.assertText('Yes:Hello42');
this.runTask(function () {
return _this59.rerender();
});
this.assertText('Yes:Hello42');
this.runTask(function () {
return _this59.context.set('activated', false);
});
this.assertText('No:Goodbye');
this.runTask(function () {
return _this59.context.set('activated', true);
});
this.assertText('Yes:Hello42');
};
_class.prototype['@test expression hasBlock inverse'] = function testExpressionHasBlockInverse(assert) {
this.registerComponent('check-inverse', {
template: (0, _abstractTestCase.strip)(_templateObject20)
});
this.render((0, _abstractTestCase.strip)(_templateObject21));
this.assertComponentElement(this.firstChild, { content: 'No' });
this.assertComponentElement(this.nthChild(1), { content: 'Yes' });
this.assertStableRerender();
};
_class.prototype['@test expression hasBlock default'] = function testExpressionHasBlockDefault(assert) {
this.registerComponent('check-block', {
template: (0, _abstractTestCase.strip)(_templateObject22)
});
this.render((0, _abstractTestCase.strip)(_templateObject23));
this.assertComponentElement(this.firstChild, { content: 'No' });
this.assertComponentElement(this.nthChild(1), { content: 'Yes' });
this.assertStableRerender();
};
_class.prototype['@test expression hasBlockParams inverse'] = function testExpressionHasBlockParamsInverse(assert) {
this.registerComponent('check-inverse', {
template: (0, _abstractTestCase.strip)(_templateObject24)
});
this.render((0, _abstractTestCase.strip)(_templateObject25));
this.assertComponentElement(this.firstChild, { content: 'No' });
this.assertComponentElement(this.nthChild(1), { content: 'No' });
this.assertStableRerender();
};
_class.prototype['@test expression hasBlockParams default'] = function testExpressionHasBlockParamsDefault(assert) {
this.registerComponent('check-block', {
template: (0, _abstractTestCase.strip)(_templateObject26)
});
this.render((0, _abstractTestCase.strip)(_templateObject27));
this.assertComponentElement(this.firstChild, { content: 'No' });
this.assertComponentElement(this.nthChild(1), { content: 'Yes' });
this.assertStableRerender();
};
_class.prototype['@test non-expression hasBlock'] = function testNonExpressionHasBlock(assert) {
this.registerComponent('check-block', {
template: (0, _abstractTestCase.strip)(_templateObject28)
});
this.render((0, _abstractTestCase.strip)(_templateObject23));
this.assertComponentElement(this.firstChild, { content: 'No' });
this.assertComponentElement(this.nthChild(1), { content: 'Yes' });
this.assertStableRerender();
};
_class.prototype['@test expression hasBlockParams'] = function testExpressionHasBlockParams(assert) {
this.registerComponent('check-params', {
template: (0, _abstractTestCase.strip)(_templateObject26)
});
this.render((0, _abstractTestCase.strip)(_templateObject29));
this.assertComponentElement(this.firstChild, { content: 'No' });
this.assertComponentElement(this.nthChild(1), { content: 'Yes' });
this.assertStableRerender();
};
_class.prototype['@test non-expression hasBlockParams'] = function testNonExpressionHasBlockParams(assert) {
this.registerComponent('check-params', {
template: (0, _abstractTestCase.strip)(_templateObject30)
});
this.render((0, _abstractTestCase.strip)(_templateObject29));
this.assertComponentElement(this.firstChild, { content: 'No' });
this.assertComponentElement(this.nthChild(1), { content: 'Yes' });
this.assertStableRerender();
};
_class.prototype['@test hasBlock expression in an attribute'] = function testHasBlockExpressionInAnAttribute(assert) {
this.registerComponent('check-attr', {
template: '<button name={{hasBlock}}></button>'
});
this.render((0, _abstractTestCase.strip)(_templateObject31));
(0, _testHelpers.equalsElement)(this.$('button')[0], 'button', { name: 'false' }, '');
(0, _testHelpers.equalsElement)(this.$('button')[1], 'button', { name: 'true' }, '');
this.assertStableRerender();
};
_class.prototype['@test hasBlock inverse expression in an attribute'] = function testHasBlockInverseExpressionInAnAttribute(assert) {
this.registerComponent('check-attr', {
template: '<button name={{hasBlock "inverse"}}></button>'
}, '');
this.render((0, _abstractTestCase.strip)(_templateObject32));
(0, _testHelpers.equalsElement)(this.$('button')[0], 'button', { name: 'false' }, '');
(0, _testHelpers.equalsElement)(this.$('button')[1], 'button', { name: 'true' }, '');
this.assertStableRerender();
};
_class.prototype['@test hasBlockParams expression in an attribute'] = function testHasBlockParamsExpressionInAnAttribute(assert) {
this.registerComponent('check-attr', {
template: '<button name={{hasBlockParams}}></button>'
});
this.render((0, _abstractTestCase.strip)(_templateObject33));
(0, _testHelpers.equalsElement)(this.$('button')[0], 'button', { name: 'false' }, '');
(0, _testHelpers.equalsElement)(this.$('button')[1], 'button', { name: 'true' }, '');
this.assertStableRerender();
};
_class.prototype['@test hasBlockParams inverse expression in an attribute'] = function testHasBlockParamsInverseExpressionInAnAttribute(assert) {
this.registerComponent('check-attr', {
template: '<button name={{hasBlockParams "inverse"}}></button>'
}, '');
this.render((0, _abstractTestCase.strip)(_templateObject33));
(0, _testHelpers.equalsElement)(this.$('button')[0], 'button', { name: 'false' }, '');
(0, _testHelpers.equalsElement)(this.$('button')[1], 'button', { name: 'false' }, '');
this.assertStableRerender();
};
_class.prototype['@test hasBlock as a param to a helper'] = function testHasBlockAsAParamToAHelper(assert) {
this.registerComponent('check-helper', {
template: '{{if hasBlock "true" "false"}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject34));
this.assertComponentElement(this.firstChild, { content: 'false' });
this.assertComponentElement(this.nthChild(1), { content: 'true' });
this.assertStableRerender();
};
_class.prototype['@test hasBlock as an expression param to a helper'] = function testHasBlockAsAnExpressionParamToAHelper(assert) {
this.registerComponent('check-helper', {
template: '{{if (hasBlock) "true" "false"}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject34));
this.assertComponentElement(this.firstChild, { content: 'false' });
this.assertComponentElement(this.nthChild(1), { content: 'true' });
this.assertStableRerender();
};
_class.prototype['@test hasBlock inverse as a param to a helper'] = function testHasBlockInverseAsAParamToAHelper(assert) {
this.registerComponent('check-helper', {
template: '{{if (hasBlock "inverse") "true" "false"}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject35));
this.assertComponentElement(this.firstChild, { content: 'false' });
this.assertComponentElement(this.nthChild(1), { content: 'true' });
this.assertStableRerender();
};
_class.prototype['@test hasBlockParams as a param to a helper'] = function testHasBlockParamsAsAParamToAHelper(assert) {
this.registerComponent('check-helper', {
template: '{{if hasBlockParams "true" "false"}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject36));
this.assertComponentElement(this.firstChild, { content: 'false' });
this.assertComponentElement(this.nthChild(1), { content: 'true' });
this.assertStableRerender();
};
_class.prototype['@test hasBlockParams as an expression param to a helper'] = function testHasBlockParamsAsAnExpressionParamToAHelper(assert) {
this.registerComponent('check-helper', {
template: '{{if (hasBlockParams) "true" "false"}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject36));
this.assertComponentElement(this.firstChild, { content: 'false' });
this.assertComponentElement(this.nthChild(1), { content: 'true' });
this.assertStableRerender();
};
_class.prototype['@test hasBlockParams inverse as a param to a helper'] = function testHasBlockParamsInverseAsAParamToAHelper(assert) {
this.registerComponent('check-helper', {
template: '{{if (hasBlockParams "inverse") "true" "false"}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject36));
this.assertComponentElement(this.firstChild, { content: 'false' });
this.assertComponentElement(this.nthChild(1), { content: 'false' });
this.assertStableRerender();
};
_class.prototype['@test component in template of a yielding component should have the proper parentView'] = function testComponentInTemplateOfAYieldingComponentShouldHaveTheProperParentView(assert) {
var _this60 = this;
var outer = void 0,
innerTemplate = void 0,
innerLayout = void 0;
this.registerComponent('x-outer', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
outer = this;
}
}),
template: '{{x-inner-in-layout}}{{yield}}'
});
this.registerComponent('x-inner-in-template', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerTemplate = this;
}
})
});
this.registerComponent('x-inner-in-layout', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerLayout = this;
}
})
});
this.render('{{#x-outer}}{{x-inner-in-template}}{{/x-outer}}');
assert.equal(innerTemplate.parentView, outer, 'receives the wrapping component as its parentView in template blocks');
assert.equal(innerLayout.parentView, outer, 'receives the wrapping component as its parentView in layout');
assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView');
this.runTask(function () {
return _this60.rerender();
});
assert.equal(innerTemplate.parentView, outer, 'receives the wrapping component as its parentView in template blocks');
assert.equal(innerLayout.parentView, outer, 'receives the wrapping component as its parentView in layout');
assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView');
};
_class.prototype['@test newly-added sub-components get correct parentView'] = function testNewlyAddedSubComponentsGetCorrectParentView(assert) {
var _this61 = this;
var outer = void 0,
inner = void 0;
this.registerComponent('x-outer', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
outer = this;
}
})
});
this.registerComponent('x-inner', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
inner = this;
}
})
});
this.render((0, _abstractTestCase.strip)(_templateObject37), {
showInner: false
});
assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView');
this.runTask(function () {
return _this61.rerender();
});
assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView (after rerender)');
this.runTask(function () {
return _this61.context.set('showInner', true);
});
assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView');
assert.equal(inner.parentView, outer, 'receives the wrapping component as its parentView in template blocks');
this.runTask(function () {
return _this61.context.set('showInner', false);
});
assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView');
};
_class.prototype['@test when a property is changed during children\'s rendering'] = function testWhenAPropertyIsChangedDuringChildrenSRendering(assert) {
var _this62 = this;
var outer = void 0,
middle = void 0;
this.registerComponent('x-outer', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
outer = this;
},
value: 1
}),
template: '{{#x-middle}}{{x-inner value=value}}{{/x-middle}}'
});
this.registerComponent('x-middle', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
middle = this;
},
value: null
}),
template: '<div id="middle-value">{{value}}</div>{{yield}}'
});
this.registerComponent('x-inner', {
ComponentClass: _helpers.Component.extend({
value: null,
pushDataUp: (0, _emberMetal.observer)('value', function () {
middle.set('value', this.get('value'));
})
}),
template: '<div id="inner-value">{{value}}</div>'
});
this.render('{{x-outer}}');
assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner');
assert.equal(this.$('#middle-value').text(), '', 'initial render of middle (observers do not run during init)');
this.runTask(function () {
return _this62.rerender();
});
assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner');
assert.equal(this.$('#middle-value').text(), '', 'initial render of middle (observers do not run during init)');
var expectedBacktrackingMessage = /modified "value" twice on <\(.+> in a single render\. It was rendered in "component:x-middle" and modified in "component:x-inner"/;
if (_features.EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER) {
expectDeprecation(expectedBacktrackingMessage);
this.runTask(function () {
return outer.set('value', 2);
});
} else {
expectAssertion(function () {
_this62.runTask(function () {
return outer.set('value', 2);
});
}, expectedBacktrackingMessage);
return;
}
assert.equal(this.$('#inner-value').text(), '2', 'second render of inner');
assert.equal(this.$('#middle-value').text(), '2', 'second render of middle');
this.runTask(function () {
return outer.set('value', 3);
});
assert.equal(this.$('#inner-value').text(), '3', 'third render of inner');
assert.equal(this.$('#middle-value').text(), '3', 'third render of middle');
this.runTask(function () {
return outer.set('value', 1);
});
assert.equal(this.$('#inner-value').text(), '1', 'reset render of inner');
assert.equal(this.$('#middle-value').text(), '1', 'reset render of middle');
};
_class.prototype['@test when a shared dependency is changed during children\'s rendering'] = function testWhenASharedDependencyIsChangedDuringChildrenSRendering(assert) {
var _this63 = this;
var outer = void 0;
this.registerComponent('x-outer', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
outer = this;
},
value: 1,
wrapper: _emberRuntime.Object.create({ content: null })
}),
template: '<div id="outer-value">{{wrapper.content}}</div> {{x-inner value=value wrapper=wrapper}}'
});
this.registerComponent('x-inner', {
ComponentClass: _helpers.Component.extend({
didReceiveAttrs: function () {
this.get('wrapper').set('content', this.get('value'));
},
value: null
}),
template: '<div id="inner-value">{{wrapper.content}}</div>'
});
var expectedBacktrackingMessage = /modified "wrapper\.content" twice on <Ember\.Object.+> in a single render\. It was rendered in "component:x-outer" and modified in "component:x-inner"/;
if (_features.EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER) {
expectDeprecation(expectedBacktrackingMessage);
this.render('{{x-outer}}');
} else {
expectAssertion(function () {
_this63.render('{{x-outer}}');
}, expectedBacktrackingMessage);
return;
}
assert.equal(this.$('#inner-value').text(), '1', 'initial render of inner');
assert.equal(this.$('#outer-value').text(), '1', 'initial render of outer');
this.runTask(function () {
return _this63.rerender();
});
assert.equal(this.$('#inner-value').text(), '1', 're-render of inner');
assert.equal(this.$('#outer-value').text(), '1', 're-render of outer');
this.runTask(function () {
return outer.set('value', 2);
});
assert.equal(this.$('#inner-value').text(), '2', 'second render of inner');
assert.equal(this.$('#outer-value').text(), '2', 'second render of outer');
this.runTask(function () {
return outer.set('value', 3);
});
assert.equal(this.$('#inner-value').text(), '3', 'third render of inner');
assert.equal(this.$('#outer-value').text(), '3', 'third render of outer');
this.runTask(function () {
return outer.set('value', 1);
});
assert.equal(this.$('#inner-value').text(), '1', 'reset render of inner');
assert.equal(this.$('#outer-value').text(), '1', 'reset render of outer');
};
_class.prototype['@test non-block with each rendering child components'] = function testNonBlockWithEachRenderingChildComponents() {
var _this64 = this;
this.registerComponent('non-block', {
template: (0, _abstractTestCase.strip)(_templateObject38)
});
this.registerComponent('child-non-block', {
template: 'Child: {{item}}.'
});
var items = (0, _emberRuntime.A)(['Tom', 'Dick', 'Harry']);
this.render('{{non-block items=items}}', { items: items });
this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]');
this.runTask(function () {
return _this64.rerender();
});
this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]');
this.runTask(function () {
return _this64.context.get('items').pushObject('Sergio');
});
this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.][Child: Sergio.]');
this.runTask(function () {
return _this64.context.get('items').shiftObject();
});
this.assertText('In layout. [Child: Dick.][Child: Harry.][Child: Sergio.]');
this.runTask(function () {
return _this64.context.set('items', (0, _emberRuntime.A)(['Tom', 'Dick', 'Harry']));
});
this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]');
};
_class.prototype['@test specifying classNames results in correct class'] = function testSpecifyingClassNamesResultsInCorrectClass(assert) {
var _this65 = this;
this.registerComponent('some-clicky-thing', {
ComponentClass: _helpers.Component.extend({
tagName: 'button',
classNames: ['foo', 'bar']
})
});
this.render((0, _abstractTestCase.strip)(_templateObject39));
// TODO: ember-view is no longer viewable in the classNames array. Bug or
// feature?
var expectedClassNames = ['ember-view', 'foo', 'bar', 'baz'];
assert.ok(this.$('button').is('.foo.bar.baz.ember-view'), 'the element has the correct classes: ' + this.$('button').attr('class'));
// `ember-view` is no longer in classNames.
// assert.deepEqual(clickyThing.get('classNames'), expectedClassNames, 'classNames are properly combined');
this.assertComponentElement(this.firstChild, { tagName: 'button', attrs: { 'class': (0, _testHelpers.classes)(expectedClassNames.join(' ')) } });
this.runTask(function () {
return _this65.rerender();
});
assert.ok(this.$('button').is('.foo.bar.baz.ember-view'), 'the element has the correct classes: ' + this.$('button').attr('class') + ' (rerender)');
// `ember-view` is no longer in classNames.
// assert.deepEqual(clickyThing.get('classNames'), expectedClassNames, 'classNames are properly combined (rerender)');
this.assertComponentElement(this.firstChild, { tagName: 'button', attrs: { 'class': (0, _testHelpers.classes)(expectedClassNames.join(' ')) } });
};
_class.prototype['@test specifying custom concatenatedProperties avoids clobbering'] = function testSpecifyingCustomConcatenatedPropertiesAvoidsClobbering(assert) {
var _this66 = this;
this.registerComponent('some-clicky-thing', {
ComponentClass: _helpers.Component.extend({
concatenatedProperties: ['blahzz'],
blahzz: ['blark', 'pory']
}),
template: (0, _abstractTestCase.strip)(_templateObject40)
});
this.render((0, _abstractTestCase.strip)(_templateObject41));
this.assertText('blarkporybaz- Click Me');
this.runTask(function () {
return _this66.rerender();
});
this.assertText('blarkporybaz- Click Me');
};
_class.prototype['@test a two way binding flows upstream when consumed in the template'] = function testATwoWayBindingFlowsUpstreamWhenConsumedInTheTemplate() {
var _this67 = this;
var component = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
}
});
this.registerComponent('foo-bar', {
ComponentClass: FooBarComponent,
template: '{{bar}}'
});
this.render('{{localBar}} - {{foo-bar bar=localBar}}', {
localBar: 'initial value'
});
this.assertText('initial value - initial value');
this.runTask(function () {
return _this67.rerender();
});
this.assertText('initial value - initial value');
if (_features.MANDATORY_SETTER) {
expectAssertion(function () {
component.bar = 'foo-bar';
}, /You must use set\(\) to set the `bar` property \(of .+\) to `foo-bar`\./);
this.assertText('initial value - initial value');
}
this.runTask(function () {
component.set('bar', 'updated value');
});
this.assertText('updated value - updated value');
this.runTask(function () {
component.set('bar', undefined);
});
this.assertText(' - ');
this.runTask(function () {
_this67.component.set('localBar', 'initial value');
});
this.assertText('initial value - initial value');
};
_class.prototype['@test a two way binding flows upstream through a CP when consumed in the template'] = function testATwoWayBindingFlowsUpstreamThroughACPWhenConsumedInTheTemplate() {
var _this68 = this;
var component = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
bar: (0, _emberMetal.computed)({
get: function () {
return this._bar;
},
set: function (key, value) {
this._bar = value;
return this._bar;
}
})
});
this.registerComponent('foo-bar', {
ComponentClass: FooBarComponent,
template: '{{bar}}'
});
this.render('{{localBar}} - {{foo-bar bar=localBar}}', {
localBar: 'initial value'
});
this.assertText('initial value - initial value');
this.runTask(function () {
return _this68.rerender();
});
this.assertText('initial value - initial value');
this.runTask(function () {
component.set('bar', 'updated value');
});
this.assertText('updated value - updated value');
this.runTask(function () {
_this68.component.set('localBar', 'initial value');
});
this.assertText('initial value - initial value');
};
_class.prototype['@test a two way binding flows upstream through a CP without template consumption'] = function testATwoWayBindingFlowsUpstreamThroughACPWithoutTemplateConsumption() {
var _this69 = this;
var component = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
bar: (0, _emberMetal.computed)({
get: function () {
return this._bar;
},
set: function (key, value) {
this._bar = value;
return this._bar;
}
})
});
this.registerComponent('foo-bar', {
ComponentClass: FooBarComponent,
template: ''
});
this.render('{{localBar}}{{foo-bar bar=localBar}}', {
localBar: 'initial value'
});
this.assertText('initial value');
this.runTask(function () {
return _this69.rerender();
});
this.assertText('initial value');
this.runTask(function () {
component.set('bar', 'updated value');
});
this.assertText('updated value');
this.runTask(function () {
_this69.component.set('localBar', 'initial value');
});
this.assertText('initial value');
};
_class.prototype['@test services can be injected into components'] = function testServicesCanBeInjectedIntoComponents() {
var _this70 = this;
var service = void 0;
this.registerService('name', _emberRuntime.Service.extend({
init: function () {
this._super.apply(this, arguments);
service = this;
},
last: 'Jackson'
}));
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
name: _emberRuntime.inject.service()
}),
template: '{{name.last}}'
});
this.render('{{foo-bar}}');
this.assertText('Jackson');
this.runTask(function () {
return _this70.rerender();
});
this.assertText('Jackson');
this.runTask(function () {
service.set('last', 'McGuffey');
});
this.assertText('McGuffey');
this.runTask(function () {
service.set('last', 'Jackson');
});
this.assertText('Jackson');
};
_class.prototype['@test injecting an unknown service raises an exception'] = function testInjectingAnUnknownServiceRaisesAnException(assert) {
var _this71 = this;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
missingService: _emberRuntime.inject.service()
})
});
expectAssertion(function () {
_this71.render('{{foo-bar}}');
}, 'Attempting to inject an unknown injection: \'service:missingService\'');
};
_class.prototype['@test can access `actions` hash via `_actions` [DEPRECATED]'] = function testCanAccessActionsHashVia_actionsDEPRECATED() {
var _this72 = this;
var component = void 0;
function derp() {}
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
actions: {
derp: derp
}
})
});
this.render('{{foo-bar}}');
this.assert.strictEqual(component.actions.derp, derp);
expectDeprecation(function () {
_this72.assert.strictEqual(component._actions.derp, derp);
}, 'Usage of `_actions` is deprecated, use `actions` instead.');
};
_class.prototype['@test throws if `this._super` is not called from `init`'] = function testThrowsIfThis_superIsNotCalledFromInit() {
var _this73 = this;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
init: function () {}
})
});
expectAssertion(function () {
_this73.render('{{foo-bar}}');
}, /You must call `this._super\(...arguments\);` when overriding `init` on a framework object. Please update .* to call `this._super\(...arguments\);` from `init`./);
};
_class.prototype['@test should toggle visibility with isVisible'] = function testShouldToggleVisibilityWithIsVisible(assert) {
var _this74 = this;
var assertStyle = function (expected) {
var matcher = (0, _testHelpers.styles)(expected);
var actual = _this74.firstChild.getAttribute('style');
assert.pushResult({
result: matcher.match(actual),
message: matcher.message(),
actual: actual,
expected: expected
});
};
this.registerComponent('foo-bar', {
template: '<p>foo</p>'
});
this.render('{{foo-bar id="foo-bar" isVisible=visible}}', {
visible: false
});
assertStyle('display: none;');
this.assertStableRerender();
this.runTask(function () {
(0, _emberMetal.set)(_this74.context, 'visible', true);
});
assertStyle('');
this.runTask(function () {
(0, _emberMetal.set)(_this74.context, 'visible', false);
});
assertStyle('display: none;');
};
_class.prototype['@test isVisible does not overwrite component style'] = function testIsVisibleDoesNotOverwriteComponentStyle(assert) {
var _this75 = this;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
attributeBindings: ['style'],
style: (0, _helpers.htmlSafe)('color: blue;')
}),
template: '<p>foo</p>'
});
this.render('{{foo-bar id="foo-bar" isVisible=visible}}', {
visible: false
});
this.assertComponentElement(this.firstChild, {
tagName: 'div',
attrs: { id: 'foo-bar', style: (0, _testHelpers.styles)('color: blue; display: none;') }
});
this.assertStableRerender();
this.runTask(function () {
(0, _emberMetal.set)(_this75.context, 'visible', true);
});
this.assertComponentElement(this.firstChild, {
tagName: 'div',
attrs: { id: 'foo-bar', style: (0, _testHelpers.styles)('color: blue;') }
});
this.runTask(function () {
(0, _emberMetal.set)(_this75.context, 'visible', false);
});
this.assertComponentElement(this.firstChild, {
tagName: 'div',
attrs: { id: 'foo-bar', style: (0, _testHelpers.styles)('color: blue; display: none;') }
});
};
_class.prototype['@test adds isVisible binding when style binding is missing and other bindings exist'] = function testAddsIsVisibleBindingWhenStyleBindingIsMissingAndOtherBindingsExist(assert) {
var _this76 = this;
var assertStyle = function (expected) {
var matcher = (0, _testHelpers.styles)(expected);
var actual = _this76.firstChild.getAttribute('style');
assert.pushResult({
result: matcher.match(actual),
message: matcher.message(),
actual: actual,
expected: expected
});
};
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
attributeBindings: ['foo'],
foo: 'bar'
}),
template: '<p>foo</p>'
});
this.render('{{foo-bar id="foo-bar" foo=foo isVisible=visible}}', {
visible: false,
foo: 'baz'
});
assertStyle('display: none;');
this.assertStableRerender();
this.runTask(function () {
(0, _emberMetal.set)(_this76.context, 'visible', true);
});
assertStyle('');
this.runTask(function () {
(0, _emberMetal.set)(_this76.context, 'visible', false);
(0, _emberMetal.set)(_this76.context, 'foo', 'woo');
});
assertStyle('display: none;');
assert.equal(this.firstChild.getAttribute('foo'), 'woo');
};
_class.prototype['@test it can use readDOMAttr to read input value'] = function testItCanUseReadDOMAttrToReadInputValue() {
var _this77 = this;
var component = void 0;
var assertElement = function (expectedValue) {
// value is a property, not an attribute
_this77.assertHTML('<input class="ember-view" id="' + component.elementId + '">');
_this77.assert.equal(_this77.firstChild.value, expectedValue, 'value property is correct');
_this77.assert.equal((0, _emberMetal.get)(component, 'value'), expectedValue, 'component.get("value") is correct');
};
this.registerComponent('one-way-input', {
ComponentClass: _helpers.Component.extend({
tagName: 'input',
attributeBindings: ['value'],
init: function () {
this._super.apply(this, arguments);
component = this;
},
change: function () {
var value = this.readDOMAttr('value');
this.set('value', value);
}
})
});
this.render('{{one-way-input value=value}}', {
value: 'foo'
});
assertElement('foo');
this.assertStableRerender();
this.runTask(function () {
_this77.firstChild.value = 'bar';
_this77.$('input').trigger('change');
});
assertElement('bar');
this.runTask(function () {
_this77.firstChild.value = 'foo';
_this77.$('input').trigger('change');
});
assertElement('foo');
this.runTask(function () {
(0, _emberMetal.set)(component, 'value', 'bar');
});
assertElement('bar');
this.runTask(function () {
_this77.firstChild.value = 'foo';
_this77.$('input').trigger('change');
});
assertElement('foo');
};
_class.prototype['@test child triggers revalidate during parent destruction (GH#13846)'] = function testChildTriggersRevalidateDuringParentDestructionGH13846() {
this.registerComponent('x-select', {
ComponentClass: _helpers.Component.extend({
tagName: 'select',
init: function () {
this._super();
this.options = (0, _emberRuntime.A)([]);
this.value = null;
},
updateValue: function () {
var newValue = this.get('options.lastObject.value');
this.set('value', newValue);
},
registerOption: function (option) {
this.get('options').addObject(option);
},
unregisterOption: function (option) {
this.get('options').removeObject(option);
this.updateValue();
}
}),
template: '{{yield this}}'
});
this.registerComponent('x-option', {
ComponentClass: _helpers.Component.extend({
tagName: 'option',
attributeBindings: ['selected'],
didInsertElement: function () {
this._super.apply(this, arguments);
this.get('select').registerOption(this);
},
selected: (0, _emberMetal.computed)('select.value', function () {
return this.get('value') === this.get('select.value');
}),
willDestroyElement: function () {
this._super.apply(this, arguments);
this.get('select').unregisterOption(this);
}
})
});
this.render((0, _abstractTestCase.strip)(_templateObject42));
this.teardown();
this.assert.ok(true, 'no errors during teardown');
};
_class.prototype['@test setting a property in willDestroyElement does not assert (GH#14273)'] = function testSettingAPropertyInWillDestroyElementDoesNotAssertGH14273(assert) {
assert.expect(2);
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
this.showFoo = true;
},
willDestroyElement: function () {
this.set('showFoo', false);
assert.ok(true, 'willDestroyElement was fired');
this._super.apply(this, arguments);
}
}),
template: '{{#if showFoo}}things{{/if}}'
});
this.render('{{foo-bar}}');
this.assertText('things');
};
_class.prototype['@test using didInitAttrs as an event is deprecated'] = function testUsingDidInitAttrsAsAnEventIsDeprecated(assert) {
var _this78 = this;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
foo: (0, _emberMetal.on)('didInitAttrs', function () {
assert.ok(true, 'should fire `didInitAttrs` event');
})
})
});
expectDeprecation(function () {
_this78.render('{{foo-bar}}');
}, /didInitAttrs called/);
};
_class.prototype['@test did{Init,Receive}Attrs fires even if component is not rendered'] = function testDidInitReceiveAttrsFiresEvenIfComponentIsNotRendered(assert) {
var _this79 = this;
expectDeprecation(/didInitAttrs called/);
var didInitAttrsCount = 0;
var didReceiveAttrsCount = 0;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
this.didInit = true;
},
didInitAttrs: function () {
assert.ok(this.didInit, 'expected init to have run before didInitAttrs');
didInitAttrsCount++;
},
didReceiveAttrs: function () {
assert.ok(this.didInit, 'expected init to have run before didReceiveAttrs');
didReceiveAttrsCount++;
},
willRender: function () {
throw new Error('Unexpected render!');
}
})
});
assert.strictEqual(didInitAttrsCount, 0, 'precond: didInitAttrs is not fired');
assert.strictEqual(didReceiveAttrsCount, 0, 'precond: didReceiveAttrs is not fired');
this.runTask(function () {
return _this79.component = _this79.owner.lookup('component:foo-bar');
});
assert.strictEqual(didInitAttrsCount, 1, 'precond: didInitAttrs is fired');
assert.strictEqual(didReceiveAttrsCount, 1, 'precond: didReceiveAttrs is fired');
};
_class.prototype['@test did{Init,Receive}Attrs fires after .init() but before observers become active'] = function testDidInitReceiveAttrsFiresAfterInitButBeforeObserversBecomeActive(assert) {
var _this80 = this;
expectDeprecation(/didInitAttrs called/);
var fooCopyDidChangeCount = 0;
var barCopyDidChangeCount = 0;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
this.didInit = true;
},
didInitAttrs: function () {
assert.ok(this.didInit, 'expected init to have run before didInitAttrs');
this.set('fooCopy', this.attrs.foo.value + 1);
},
didReceiveAttrs: function () {
assert.ok(this.didInit, 'expected init to have run before didReceiveAttrs');
this.set('barCopy', this.attrs.bar.value + 1);
},
fooCopyDidChange: (0, _emberMetal.observer)('fooCopy', function () {
fooCopyDidChangeCount++;
}),
barCopyDidChange: (0, _emberMetal.observer)('barCopy', function () {
barCopyDidChangeCount++;
})
}),
template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}'
});
this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 });
this.assertText('1-2-3-4');
assert.strictEqual(fooCopyDidChangeCount, 0, 'expected NO observer firing for: fooCopy');
assert.strictEqual(barCopyDidChangeCount, 0, 'expected NO observer firing for: barCopy');
this.runTask(function () {
return (0, _emberMetal.set)(_this80.context, 'foo', 5);
});
this.assertText('5-2-3-4');
assert.strictEqual(fooCopyDidChangeCount, 0, 'expected observer firing for: fooCopy');
assert.strictEqual(barCopyDidChangeCount, 0, 'expected NO observer firing for: barCopy');
this.runTask(function () {
return (0, _emberMetal.set)(_this80.context, 'bar', 7);
});
this.assertText('5-2-7-8');
assert.strictEqual(fooCopyDidChangeCount, 0, 'expected observer firing for: fooCopy');
assert.strictEqual(barCopyDidChangeCount, 1, 'expected observer firing for: barCopy');
};
_class.prototype['@test overriding didReceiveAttrs does not trigger deprecation'] = function testOverridingDidReceiveAttrsDoesNotTriggerDeprecation(assert) {
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
didReceiveAttrs: function () {
assert.equal(1, this.get('foo'), 'expected attrs to have correct value');
}
}),
template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}'
});
this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 });
};
_class.prototype['@test overriding didUpdateAttrs does not trigger deprecation'] = function testOverridingDidUpdateAttrsDoesNotTriggerDeprecation(assert) {
var _this81 = this;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
didUpdateAttrs: function () {
assert.equal(5, this.get('foo'), "expected newAttrs to have new value");
}
}),
template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}'
});
this.render('{{foo-bar foo=foo bar=bar}}', { foo: 1, bar: 3 });
this.runTask(function () {
return (0, _emberMetal.set)(_this81.context, 'foo', 5);
});
};
_class.prototype['@test returning `true` from an action does not bubble if `target` is not specified (GH#14275)'] = function testReturningTrueFromAnActionDoesNotBubbleIfTargetIsNotSpecifiedGH14275(assert) {
var _this82 = this;
this.registerComponent('display-toggle', {
ComponentClass: _helpers.Component.extend({
actions: {
show: function () {
assert.ok(true, 'display-toggle show action was called');
return true;
}
}
}),
template: '<button {{action \'show\'}}>Show</button>'
});
this.render('{{display-toggle}}', {
send: function () {
assert.notOk(true, 'send should not be called when action is not "subscribed" to');
}
});
this.assertText('Show');
this.runTask(function () {
return _this82.$('button').click();
});
};
_class.prototype['@test returning `true` from an action bubbles to the `target` if specified'] = function testReturningTrueFromAnActionBubblesToTheTargetIfSpecified(assert) {
var _this83 = this;
assert.expect(4);
this.registerComponent('display-toggle', {
ComponentClass: _helpers.Component.extend({
actions: {
show: function () {
assert.ok(true, 'display-toggle show action was called');
return true;
}
}
}),
template: '<button {{action \'show\'}}>Show</button>'
});
this.render('{{display-toggle target=this}}', {
send: function (actionName) {
assert.ok(true, 'send should be called when action is "subscribed" to');
assert.equal(actionName, 'show');
}
});
this.assertText('Show');
this.runTask(function () {
return _this83.$('button').click();
});
};
_class.prototype['@test triggering an event only attempts to invoke an identically named method, if it actually is a function (GH#15228)'] = function testTriggeringAnEventOnlyAttemptsToInvokeAnIdenticallyNamedMethodIfItActuallyIsAFunctionGH15228(assert) {
assert.expect(3);
var payload = ['arbitrary', 'event', 'data'];
this.registerComponent('evented-component', {
ComponentClass: _helpers.Component.extend({
someTruthyProperty: true,
init: function () {
this._super.apply(this, arguments);
this.trigger.apply(this, ['someMethod'].concat(payload));
this.trigger.apply(this, ['someTruthyProperty'].concat(payload));
},
someMethod: function () {
for (var _len = arguments.length, data = Array(_len), _key = 0; _key < _len; _key++) {
data[_key] = arguments[_key];
}
assert.deepEqual(data, payload, 'the method `someMethod` should be called, when `someMethod` is triggered');
},
listenerForSomeMethod: (0, _emberMetal.on)('someMethod', function () {
for (var _len2 = arguments.length, data = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
data[_key2] = arguments[_key2];
}
assert.deepEqual(data, payload, 'the listener `listenerForSomeMethod` should be called, when `someMethod` is triggered');
}),
listenerForSomeTruthyProperty: (0, _emberMetal.on)('someTruthyProperty', function () {
for (var _len3 = arguments.length, data = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
data[_key3] = arguments[_key3];
}
assert.deepEqual(data, payload, 'the listener `listenerForSomeTruthyProperty` should be called, when `someTruthyProperty` is triggered');
})
})
});
this.render('{{evented-component}}');
};
_class.prototype['@test component yielding in an {{#each}} has correct block values after rerendering (GH#14284)'] = function testComponentYieldingInAnEachHasCorrectBlockValuesAfterRerenderingGH14284() {
var _this84 = this;
this.registerComponent('list-items', {
template: '{{#each items as |item|}}{{yield item}}{{/each}}'
});
this.render((0, _abstractTestCase.strip)(_templateObject43), {
editMode: false,
items: ['foo', 'bar', 'qux', 'baz']
});
this.assertText('|foo||bar||qux||baz|');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this84.context, 'editMode', true);
});
this.assertText('|foo|Remove foo|bar|Remove bar|qux|Remove qux|baz|Remove baz');
this.runTask(function () {
return (0, _emberMetal.set)(_this84.context, 'editMode', false);
});
this.assertText('|foo||bar||qux||baz|');
};
_class.prototype['@test unimplimented positionalParams do not cause an error GH#14416'] = function testUnimplimentedPositionalParamsDoNotCauseAnErrorGH14416(assert) {
this.registerComponent('foo-bar', {
template: 'hello'
});
this.render('{{foo-bar wat}}');
this.assertText('hello');
};
_class.prototype['@test using attrs for positional params'] = function testUsingAttrsForPositionalParams(assert) {
var MyComponent = _helpers.Component.extend();
this.registerComponent('foo-bar', {
ComponentClass: MyComponent.reopenClass({
positionalParams: ['myVar']
}),
template: 'MyVar1: {{attrs.myVar}} {{myVar}} MyVar2: {{myVar2}} {{attrs.myVar2}}'
});
this.render('{{foo-bar 1 myVar2=2}}');
this.assertText('MyVar1: 1 1 MyVar2: 2 2');
};
_class.prototype['@test can use `{{this}}` to emit the component\'s toString value [GH#14581]'] = function testCanUseThisToEmitTheComponentSToStringValueGH14581(assert) {
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
toString: function () {
return 'special sauce goes here!';
}
}),
template: '{{this}}'
});
this.render('{{foo-bar}}');
this.assertText('special sauce goes here!');
};
_class.prototype['@test can use `{{this` to access paths on current context [GH#14581]'] = function testCanUseThisToAccessPathsOnCurrentContextGH14581(assert) {
var instance = void 0;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
instance = this;
},
foo: {
bar: {
baz: 'huzzah!'
}
}
}),
template: '{{this.foo.bar.baz}}'
});
this.render('{{foo-bar}}');
this.assertText('huzzah!');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'foo.bar.baz', 'yippie!');
});
this.assertText('yippie!');
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'foo.bar.baz', 'huzzah!');
});
this.assertText('huzzah!');
};
_class.prototype['@test can use custom element in component layout'] = function testCanUseCustomElementInComponentLayout(assert) {
this.registerComponent('foo-bar', {
template: '<blah-zorz>Hi!</blah-zorz>'
});
this.render('{{foo-bar}}');
this.assertText('Hi!');
};
_class.prototype['@test can use nested custom element in component layout'] = function testCanUseNestedCustomElementInComponentLayout(assert) {
this.registerComponent('foo-bar', {
template: '<blah-zorz><hows-it-going>Hi!</hows-it-going></blah-zorz>'
});
this.render('{{foo-bar}}');
this.assertText('Hi!');
};
_class.prototype['@test can access properties off of rest style positionalParams array'] = function testCanAccessPropertiesOffOfRestStylePositionalParamsArray(assert) {
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'things' }),
// using `attrs` here to simulate `@things.length`
template: '{{attrs.things.length}}'
});
this.render('{{foo-bar "foo" "bar" "baz"}}');
this.assertText('3');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/curly-components-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/curly-components-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/destroy-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 destroy', 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 correctly releases the destroyed components'] = function testItCorrectlyReleasesTheDestroyedComponents(assert) {
var _this2 = this;
var FooBarComponent = _helpers.Component.extend({});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { switch: true });
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'switch', false);
});
this.assertText('');
assert.equal(this.env.destroyedComponents.length, 0, 'environment.destroyedComponents should be empty');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/destroy-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/destroy-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/dynamic-components-test', ['ember-babel', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember/features'], function (_emberBabel, _emberMetal, _helpers, _abstractTestCase, _testCase, _features) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#if cond1}}\n {{#component "foo-bar" id=1}}\n {{#if cond2}}\n {{#component "foo-bar" id=2}}{{/component}}\n {{#if cond3}}\n {{#component "foo-bar" id=3}}\n {{#if cond4}}\n {{#component "foo-bar" id=4}}\n {{#if cond5}}\n {{#component "foo-bar" id=5}}{{/component}}\n {{#component "foo-bar" id=6}}{{/component}}\n {{#component "foo-bar" id=7}}{{/component}}\n {{/if}}\n {{#component "foo-bar" id=8}}{{/component}}\n {{/component}}\n {{/if}}\n {{/component}}\n {{/if}}\n {{/if}}\n {{/component}}\n {{/if}}'], ['\n {{#if cond1}}\n {{#component "foo-bar" id=1}}\n {{#if cond2}}\n {{#component "foo-bar" id=2}}{{/component}}\n {{#if cond3}}\n {{#component "foo-bar" id=3}}\n {{#if cond4}}\n {{#component "foo-bar" id=4}}\n {{#if cond5}}\n {{#component "foo-bar" id=5}}{{/component}}\n {{#component "foo-bar" id=6}}{{/component}}\n {{#component "foo-bar" id=7}}{{/component}}\n {{/if}}\n {{#component "foo-bar" id=8}}{{/component}}\n {{/component}}\n {{/if}}\n {{/component}}\n {{/if}}\n {{/if}}\n {{/component}}\n {{/if}}']),
_templateObject2 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#each names as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each names as |name|}}\n {{name}}\n {{/each}}']),
_templateObject3 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#each n as |name|}}\n {{name}}\n {{/each}}'], ['\n {{#each n as |name|}}\n {{name}}\n {{/each}}']);
(0, _testCase.moduleFor)('Components test: dynamic components', 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 a static component name argument'] = function testItCanRenderABasicComponentWithAStaticComponentNameArgument() {
var _this2 = this;
this.registerComponent('foo-bar', { template: 'hello {{name}}' });
this.render('{{component "foo-bar" name=name}}', { name: 'Sarah' });
this.assertComponentElement(this.firstChild, { content: 'hello Sarah' });
this.runTask(function () {
return _this2.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello Sarah' });
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'name', 'Gavin');
});
this.assertComponentElement(this.firstChild, { content: 'hello Gavin' });
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'name', 'Sarah');
});
this.assertComponentElement(this.firstChild, { content: 'hello Sarah' });
};
_class.prototype['@test it can render a basic component with a dynamic component name argument'] = function testItCanRenderABasicComponentWithADynamicComponentNameArgument() {
var _this3 = this;
this.registerComponent('foo-bar', { template: 'hello {{name}} from foo-bar' });
this.registerComponent('foo-bar-baz', { template: 'hello {{name}} from foo-bar-baz' });
this.render('{{component componentName name=name}}', { componentName: 'foo-bar', name: 'Alex' });
this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' });
this.runTask(function () {
return _this3.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' });
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'name', 'Ben');
});
this.assertComponentElement(this.firstChild, { content: 'hello Ben from foo-bar' });
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'componentName', 'foo-bar-baz');
});
this.assertComponentElement(this.firstChild, { content: 'hello Ben from foo-bar-baz' });
this.runTask(function () {
(0, _emberMetal.set)(_this3.context, 'componentName', 'foo-bar');
(0, _emberMetal.set)(_this3.context, 'name', 'Alex');
});
this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' });
};
_class.prototype['@test it has an element'] = function testItHasAnElement() {
var _this4 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
instance = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{component "foo-bar"}}');
var element1 = instance.element;
this.assertComponentElement(element1, { content: 'hello' });
this.runTask(function () {
return _this4.rerender();
});
var element2 = instance.element;
this.assertComponentElement(element2, { content: 'hello' });
this.assertSameNode(element2, element1);
};
_class.prototype['@test it has a jQuery proxy to the element'] = function testItHasAJQueryProxyToTheElement(assert) {
var _this5 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
instance = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
this.render('{{component "foo-bar"}}');
var element1 = instance.$()[0];
this.assertComponentElement(element1, { content: 'hello' });
this.runTask(function () {
return _this5.rerender();
});
var element2 = instance.$()[0];
this.assertComponentElement(element2, { content: 'hello' });
this.assertSameNode(element2, element1);
};
_class.prototype['@test it scopes the jQuery proxy to the component element'] = function testItScopesTheJQueryProxyToTheComponentElement(assert) {
var _this6 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
instance = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '<span class="inner">inner</span>' });
this.render('<span class="outer">outer</span>{{component "foo-bar"}}');
var $span = instance.$('span');
assert.equal($span.length, 1);
assert.equal($span.attr('class'), 'inner');
this.runTask(function () {
return _this6.rerender();
});
$span = instance.$('span');
assert.equal($span.length, 1);
assert.equal($span.attr('class'), 'inner');
};
_class.prototype['@test it has the right parentView and childViews'] = function testItHasTheRightParentViewAndChildViews(assert) {
var _this7 = this;
var fooBarInstance = void 0,
fooBarBazInstance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
fooBarInstance = this;
}
});
var FooBarBazComponent = _helpers.Component.extend({
init: function () {
this._super();
fooBarBazInstance = this;
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'foo-bar {{foo-bar-baz}}' });
this.registerComponent('foo-bar-baz', { ComponentClass: FooBarBazComponent, template: 'foo-bar-baz' });
this.render('{{component "foo-bar"}}');
this.assertText('foo-bar foo-bar-baz');
assert.equal(fooBarInstance.parentView, this.component);
assert.equal(fooBarBazInstance.parentView, fooBarInstance);
assert.deepEqual(this.component.childViews, [fooBarInstance]);
assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]);
this.runTask(function () {
return _this7.rerender();
});
this.assertText('foo-bar foo-bar-baz');
assert.equal(fooBarInstance.parentView, this.component);
assert.equal(fooBarBazInstance.parentView, fooBarInstance);
assert.deepEqual(this.component.childViews, [fooBarInstance]);
assert.deepEqual(fooBarInstance.childViews, [fooBarBazInstance]);
};
_class.prototype['@test it can render a basic component with a block'] = function testItCanRenderABasicComponentWithABlock() {
var _this8 = this;
this.registerComponent('foo-bar', { template: '{{yield}}' });
this.render('{{#component "foo-bar"}}hello{{/component}}');
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return _this8.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
};
_class.prototype['@test it renders the layout with the component instance as the context'] = function testItRendersTheLayoutWithTheComponentInstanceAsTheContext() {
var _this9 = this;
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
instance = this;
this.set('message', 'hello');
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{message}}' });
this.render('{{component "foo-bar"}}');
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return _this9.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'message', 'goodbye');
});
this.assertComponentElement(this.firstChild, { content: 'goodbye' });
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'message', 'hello');
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
};
_class.prototype['@test it preserves the outer context when yielding'] = function testItPreservesTheOuterContextWhenYielding() {
var _this10 = this;
this.registerComponent('foo-bar', { template: '{{yield}}' });
this.render('{{#component "foo-bar"}}{{message}}{{/component}}', { message: 'hello' });
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return _this10.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'message', 'goodbye');
});
this.assertComponentElement(this.firstChild, { content: 'goodbye' });
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'message', 'hello');
});
this.assertComponentElement(this.firstChild, { content: 'hello' });
};
_class.prototype['@test the component and its child components are destroyed'] = function testTheComponentAndItsChildComponentsAreDestroyed(assert) {
var _this11 = this;
var destroyed = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 };
this.registerComponent('foo-bar', {
template: '{{id}} {{yield}}',
ComponentClass: _helpers.Component.extend({
willDestroy: function () {
this._super();
destroyed[this.get('id')]++;
}
})
});
this.render((0, _abstractTestCase.strip)(_templateObject), {
cond1: true,
cond2: true,
cond3: true,
cond4: true,
cond5: true
});
this.assertText('1 2 3 4 5 6 7 8 ');
this.runTask(function () {
return _this11.rerender();
});
assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 });
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'cond5', false);
});
this.assertText('1 2 3 4 8 ');
assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 1, 7: 1, 8: 0 });
this.runTask(function () {
(0, _emberMetal.set)(_this11.context, 'cond3', false);
(0, _emberMetal.set)(_this11.context, 'cond5', true);
(0, _emberMetal.set)(_this11.context, 'cond4', false);
});
assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 });
this.runTask(function () {
(0, _emberMetal.set)(_this11.context, 'cond2', false);
(0, _emberMetal.set)(_this11.context, 'cond1', false);
});
assert.deepEqual(destroyed, { 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 });
};
_class.prototype['@test component helper destroys underlying component when it is swapped out'] = function testComponentHelperDestroysUnderlyingComponentWhenItIsSwappedOut(assert) {
var _this12 = this;
var destroyed = { 'foo-bar': 0, 'foo-bar-baz': 0 };
var testContext = this;
this.registerComponent('foo-bar', {
template: 'hello from foo-bar',
ComponentClass: _helpers.Component.extend({
willDestroyElement: function () {
assert.equal(testContext.$('#' + this.elementId).length, 1, 'element is still attached to the document');
},
willDestroy: function () {
this._super();
destroyed['foo-bar']++;
}
})
});
this.registerComponent('foo-bar-baz', {
template: 'hello from foo-bar-baz',
ComponentClass: _helpers.Component.extend({
willDestroy: function () {
this._super();
destroyed['foo-bar-baz']++;
}
})
});
this.render('{{component componentName name=name}}', { componentName: 'foo-bar' });
assert.deepEqual(destroyed, { 'foo-bar': 0, 'foo-bar-baz': 0 });
this.runTask(function () {
return _this12.rerender();
});
assert.deepEqual(destroyed, { 'foo-bar': 0, 'foo-bar-baz': 0 });
this.runTask(function () {
return (0, _emberMetal.set)(_this12.context, 'componentName', 'foo-bar-baz');
});
assert.deepEqual(destroyed, { 'foo-bar': 1, 'foo-bar-baz': 0 });
this.runTask(function () {
return (0, _emberMetal.set)(_this12.context, 'componentName', 'foo-bar');
});
assert.deepEqual(destroyed, { 'foo-bar': 1, 'foo-bar-baz': 1 });
};
_class.prototype['@test component helper with bound properties are updating correctly in init of component'] = function testComponentHelperWithBoundPropertiesAreUpdatingCorrectlyInInitOfComponent(assert) {
var _this13 = this;
this.registerComponent('foo-bar', {
template: 'foo-bar {{location}} {{locationCopy}} {{yield}}',
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
this.set('locationCopy', this.get('location'));
}
})
});
this.registerComponent('foo-bar-baz', {
template: 'foo-bar-baz {{location}} {{locationCopy}} {{yield}}',
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
this.set('locationCopy', this.get('location'));
}
})
});
this.registerComponent('outer-component', {
template: '{{#component componentName location=location}}arepas!{{/component}}',
ComponentClass: _helpers.Component.extend({
componentName: (0, _emberMetal.computed)('location', function () {
if (this.get('location') === 'Caracas') {
return 'foo-bar';
} else {
return 'foo-bar-baz';
}
})
})
});
this.render('{{outer-component location=location}}', { location: 'Caracas' });
this.assertText('foo-bar Caracas Caracas arepas!');
this.runTask(function () {
return _this13.rerender();
});
this.assertText('foo-bar Caracas Caracas arepas!');
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'location', 'Loisaida');
});
this.assertText('foo-bar-baz Loisaida Loisaida arepas!');
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'location', 'Caracas');
});
this.assertText('foo-bar Caracas Caracas arepas!');
};
_class.prototype['@test component helper with actions'] = function testComponentHelperWithActions(assert) {
var _this15 = this;
this.registerComponent('inner-component', {
template: 'inner-component {{yield}}',
ComponentClass: _helpers.Component.extend({
classNames: 'inner-component',
didInsertElement: function () {
var _this14 = this;
// trigger action on click in absence of app's EventDispatcher
this.$().on('click', function () {
_this14.sendAction('somethingClicked');
});
},
willDestroyElement: function () {
this.$().off('click');
}
})
});
var actionTriggered = 0;
this.registerComponent('outer-component', {
template: '{{#component componentName somethingClicked="mappedAction"}}arepas!{{/component}}',
ComponentClass: _helpers.Component.extend({
classNames: 'outer-component',
componentName: 'inner-component',
actions: {
mappedAction: function () {
actionTriggered++;
}
}
})
});
this.render('{{outer-component}}');
assert.equal(actionTriggered, 0, 'action was not triggered');
this.runTask(function () {
_this15.$('.inner-component').trigger('click');
});
assert.equal(actionTriggered, 1, 'action was triggered');
};
_class.prototype['@test nested component helpers'] = function testNestedComponentHelpers(assert) {
var _this16 = this;
this.registerComponent('foo-bar', { template: 'yippie! {{attrs.location}} {{yield}}' });
this.registerComponent('baz-qux', { template: 'yummy {{attrs.location}} {{yield}}' });
this.registerComponent('corge-grault', { template: 'delicious {{attrs.location}} {{yield}}' });
this.render('{{#component componentName1 location=location}}{{#component componentName2 location=location}}arepas!{{/component}}{{/component}}', {
componentName1: 'foo-bar',
componentName2: 'baz-qux',
location: 'Caracas'
});
this.assertText('yippie! Caracas yummy Caracas arepas!');
this.runTask(function () {
return _this16.rerender();
});
this.assertText('yippie! Caracas yummy Caracas arepas!');
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'location', 'Loisaida');
});
this.assertText('yippie! Loisaida yummy Loisaida arepas!');
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'componentName1', 'corge-grault');
});
this.assertText('delicious Loisaida yummy Loisaida arepas!');
this.runTask(function () {
(0, _emberMetal.set)(_this16.context, 'componentName1', 'foo-bar');
(0, _emberMetal.set)(_this16.context, 'location', 'Caracas');
});
this.assertText('yippie! Caracas yummy Caracas arepas!');
};
_class.prototype['@test component with dynamic name argument resolving to non-existent component'] = function testComponentWithDynamicNameArgumentResolvingToNonExistentComponent(assert) {
var _this17 = this;
expectAssertion(function () {
_this17.render('{{component componentName}}', { componentName: 'does-not-exist' });
}, /Could not find component named "does-not-exist"/);
};
_class.prototype['@test component with static name argument for non-existent component'] = function testComponentWithStaticNameArgumentForNonExistentComponent(assert) {
var _this18 = this;
expectAssertion(function () {
_this18.render('{{component "does-not-exist"}}');
}, /Could not find component named "does-not-exist"/);
};
_class.prototype['@test component with dynamic component name resolving to a component, then non-existent component'] = function testComponentWithDynamicComponentNameResolvingToAComponentThenNonExistentComponent(assert) {
var _this19 = this;
this.registerComponent('foo-bar', { template: 'hello {{name}}' });
this.render('{{component componentName name=name}}', { componentName: 'foo-bar', name: 'Alex' });
this.assertText('hello Alex');
this.runTask(function () {
return _this19.rerender();
});
this.assertText('hello Alex');
this.runTask(function () {
return (0, _emberMetal.set)(_this19.context, 'componentName', undefined);
});
this.assertText('');
this.runTask(function () {
return (0, _emberMetal.set)(_this19.context, 'componentName', 'foo-bar');
});
this.assertText('hello Alex');
};
_class.prototype['@test component helper properly invalidates hash params inside an {{each}} invocation #11044'] = function testComponentHelperProperlyInvalidatesHashParamsInsideAnEachInvocation11044(assert) {
var _this20 = this;
this.registerComponent('foo-bar', {
template: '[{{internalName}} - {{name}}]',
ComponentClass: _helpers.Component.extend({
willRender: function () {
// store internally available name to ensure that the name available in `this.attrs.name`
// matches the template lookup name
(0, _emberMetal.set)(this, 'internalName', this.get('name'));
}
})
});
this.render('{{#each items as |item|}}{{component "foo-bar" name=item.name}}{{/each}}', {
items: [{ name: 'Robert' }, { name: 'Jacquie' }]
});
this.assertText('[Robert - Robert][Jacquie - Jacquie]');
this.runTask(function () {
return _this20.rerender();
});
this.assertText('[Robert - Robert][Jacquie - Jacquie]');
this.runTask(function () {
return (0, _emberMetal.set)(_this20.context, 'items', [{ name: 'Max' }, { name: 'James' }]);
});
this.assertText('[Max - Max][James - James]');
this.runTask(function () {
return (0, _emberMetal.set)(_this20.context, 'items', [{ name: 'Robert' }, { name: 'Jacquie' }]);
});
this.assertText('[Robert - Robert][Jacquie - Jacquie]');
};
_class.prototype['@test dashless components should not be found'] = function testDashlessComponentsShouldNotBeFound(assert) {
var _this21 = this;
this.registerComponent('dashless2', { template: 'Do not render me!' });
expectAssertion(function () {
_this21.render('{{component "dashless"}}');
}, /You cannot use 'dashless' as a component name. Component names must contain a hyphen./);
};
_class.prototype['@test positional parameters does not clash when rendering different components'] = function testPositionalParametersDoesNotClashWhenRenderingDifferentComponents(assert) {
var _this22 = this;
this.registerComponent('foo-bar', {
template: 'hello {{name}} ({{age}}) from foo-bar',
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name', 'age']
})
});
this.registerComponent('foo-bar-baz', {
template: 'hello {{name}} ({{age}}) from foo-bar-baz',
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['name', 'age']
})
});
this.render('{{component componentName name age}}', {
componentName: 'foo-bar',
name: 'Alex',
age: 29
});
this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' });
this.runTask(function () {
return _this22.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' });
this.runTask(function () {
return (0, _emberMetal.set)(_this22.context, 'name', 'Ben');
});
this.assertComponentElement(this.firstChild, { content: 'hello Ben (29) from foo-bar' });
this.runTask(function () {
return (0, _emberMetal.set)(_this22.context, 'age', 22);
});
this.assertComponentElement(this.firstChild, { content: 'hello Ben (22) from foo-bar' });
this.runTask(function () {
return (0, _emberMetal.set)(_this22.context, 'componentName', 'foo-bar-baz');
});
this.assertComponentElement(this.firstChild, { content: 'hello Ben (22) from foo-bar-baz' });
this.runTask(function () {
(0, _emberMetal.set)(_this22.context, 'componentName', 'foo-bar');
(0, _emberMetal.set)(_this22.context, 'name', 'Alex');
(0, _emberMetal.set)(_this22.context, 'age', 29);
});
this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' });
};
_class.prototype['@test positional parameters does not pollute the attributes when changing components'] = function testPositionalParametersDoesNotPolluteTheAttributesWhenChangingComponents(assert) {
var _this23 = this;
this.registerComponent('normal-message', {
template: 'Normal: {{something}}!',
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: ['something']
})
});
this.registerComponent('alternative-message', {
template: 'Alternative: {{something}} {{somethingElse}}!',
ComponentClass: _helpers.Component.extend({
something: 'Another'
}).reopenClass({
positionalParams: ['somethingElse']
})
});
this.render('{{component componentName message}}', { componentName: 'normal-message', message: 'Hello' });
this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' });
this.runTask(function () {
return _this23.rerender();
});
this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' });
this.runTask(function () {
return (0, _emberMetal.set)(_this23.context, 'componentName', 'alternative-message');
});
this.assertComponentElement(this.firstChild, { content: 'Alternative: Another Hello!' });
this.runTask(function () {
return (0, _emberMetal.set)(_this23.context, 'message', 'Hi');
});
this.assertComponentElement(this.firstChild, { content: 'Alternative: Another Hi!' });
this.runTask(function () {
(0, _emberMetal.set)(_this23.context, 'componentName', 'normal-message');
(0, _emberMetal.set)(_this23.context, 'message', 'Hello');
});
this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' });
};
_class.prototype['@test static arbitrary number of positional parameters'] = function testStaticArbitraryNumberOfPositionalParameters(assert) {
var _this24 = this;
this.registerComponent('sample-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'names'
}),
template: (0, _abstractTestCase.strip)(_templateObject2)
});
this.render('{{component "sample-component" "Foo" 4 "Bar" 5 "Baz" elementId="helper"}}');
this.assertText('Foo4Bar5Baz');
this.runTask(function () {
return _this24.rerender();
});
this.assertText('Foo4Bar5Baz');
};
_class.prototype['@test dynamic arbitrary number of positional parameters'] = function testDynamicArbitraryNumberOfPositionalParameters(assert) {
var _this25 = this;
this.registerComponent('sample-component', {
ComponentClass: _helpers.Component.extend().reopenClass({
positionalParams: 'n'
}),
template: (0, _abstractTestCase.strip)(_templateObject3)
});
this.render('{{component "sample-component" user1 user2}}', {
user1: 'Foo',
user2: 4
});
this.assertText('Foo4');
this.runTask(function () {
return _this25.rerender();
});
this.assertText('Foo4');
this.runTask(function () {
return _this25.context.set('user1', 'Bar');
});
this.assertText('Bar4');
this.runTask(function () {
return _this25.context.set('user2', '5');
});
this.assertText('Bar5');
this.runTask(function () {
_this25.context.set('user1', 'Foo');
_this25.context.set('user2', 4);
});
this.assertText('Foo4');
};
_class.prototype['@test component helper emits useful backtracking re-render assertion message'] = function testComponentHelperEmitsUsefulBacktrackingReRenderAssertionMessage(assert) {
var _this26 = this;
this.registerComponent('outer-component', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
this.set('person', { name: 'Alex' });
}
}),
template: 'Hi {{person.name}}! {{component "error-component" person=person}}'
});
this.registerComponent('error-component', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
this.set('person.name', { name: 'Ben' });
}
}),
template: '{{person.name}}'
});
var expectedBacktrackingMessage = /modified "person\.name" twice on \[object Object\] in a single render\. It was rendered in "component:outer-component" and modified in "component:error-component"/;
if (_features.EMBER_GLIMMER_ALLOW_BACKTRACKING_RERENDER) {
expectDeprecation(expectedBacktrackingMessage);
this.render('{{component componentName}}', { componentName: 'outer-component' });
} else {
expectAssertion(function () {
_this26.render('{{component componentName}}', { componentName: 'outer-component' });
}, expectedBacktrackingMessage);
}
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/dynamic-components-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/dynamic-components-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/fragment-components-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (_emberBabel, _testCase, _abstractTestCase, _helpers, _emberMetal) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['<div>Hey</div>bar'], ['<div>Hey</div>bar']),
_templateObject2 = (0, _emberBabel.taggedTemplateLiteralLoose)(['<!---->bar'], ['<!---->bar']),
_templateObject3 = (0, _emberBabel.taggedTemplateLiteralLoose)(['<!---->bizz'], ['<!---->bizz']);
(0, _testCase.moduleFor)('Components test: fragment components', 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.getCustomDispatcherEvents = function getCustomDispatcherEvents() {
return {
hitDem: 'folks'
};
};
_class.prototype['@test fragments do not render an outer tag'] = function testFragmentsDoNotRenderAnOuterTag() {
var instance = void 0;
var FooBarComponent = _helpers.Component.extend({
tagName: '',
init: function () {
this._super();
instance = this;
this.foo = true;
this.bar = 'bar';
}
});
var template = '{{#if foo}}<div>Hey</div>{{/if}}{{yield bar}}';
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
this.render('{{#foo-bar as |bar|}}{{bar}}{{/foo-bar}}');
this.assertHTML((0, _abstractTestCase.strip)(_templateObject));
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'foo', false);
});
this.assertHTML((0, _abstractTestCase.strip)(_templateObject2));
this.runTask(function () {
return (0, _emberMetal.set)(instance, 'bar', 'bizz');
});
this.assertHTML((0, _abstractTestCase.strip)(_templateObject3));
this.runTask(function () {
(0, _emberMetal.set)(instance, 'bar', 'bar');
(0, _emberMetal.set)(instance, 'foo', true);
});
};
_class.prototype['@test throws an error if an event function is defined in a tagless component'] = function testThrowsAnErrorIfAnEventFunctionIsDefinedInATaglessComponent() {
var _this2 = this;
var template = 'hit dem folks';
var FooBarComponent = _helpers.Component.extend({
tagName: '',
click: function () {}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
expectAssertion(function () {
_this2.render('{{#foo-bar}}{{/foo-bar}}');
}, /You can not define a function that handles DOM events in the .* tagless component since it doesn't have any DOM element./);
};
_class.prototype['@test throws an error if a custom defined event function is defined in a tagless component'] = function testThrowsAnErrorIfACustomDefinedEventFunctionIsDefinedInATaglessComponent() {
var _this3 = this;
var template = 'hit dem folks';
var FooBarComponent = _helpers.Component.extend({
tagName: '',
folks: function () {}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
expectAssertion(function () {
_this3.render('{{#foo-bar}}{{/foo-bar}}');
}, /You can not define a function that handles DOM events in the .* tagless component since it doesn't have any DOM element./);
};
_class.prototype['@test throws an error if `tagName` is an empty string and `classNameBindings` are specified'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndClassNameBindingsAreSpecified() {
var _this4 = this;
var template = 'hit dem folks';
var FooBarComponent = _helpers.Component.extend({
tagName: '',
foo: true,
classNameBindings: ['foo:is-foo:is-bar']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
expectAssertion(function () {
_this4.render('{{#foo-bar}}{{/foo-bar}}');
}, /You cannot use `classNameBindings` on a tag-less component/);
};
_class.prototype['@test throws an error if `tagName` is an empty string and `attributeBindings` are specified'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndAttributeBindingsAreSpecified() {
var _this5 = this;
var template = 'hit dem folks';
var FooBarComponent = _helpers.Component.extend({
tagName: '',
attributeBindings: ['href']
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
expectAssertion(function () {
_this5.render('{{#foo-bar}}{{/foo-bar}}');
}, /You cannot use `attributeBindings` on a tag-less component/);
};
_class.prototype['@test throws an error if `tagName` is an empty string and `elementId` is specified via JS'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndElementIdIsSpecifiedViaJS() {
var _this6 = this;
var template = 'hit dem folks';
var FooBarComponent = _helpers.Component.extend({
tagName: '',
elementId: 'turntUp'
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
expectAssertion(function () {
_this6.render('{{#foo-bar}}{{/foo-bar}}');
}, /You cannot use `elementId` on a tag-less component/);
};
_class.prototype['@test throws an error if `tagName` is an empty string and `elementId` is specified via template'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndElementIdIsSpecifiedViaTemplate() {
var _this7 = this;
var template = 'hit dem folks';
var FooBarComponent = _helpers.Component.extend({
tagName: ''
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
expectAssertion(function () {
_this7.render('{{#foo-bar elementId=\'turntUp\'}}{{/foo-bar}}');
}, /You cannot use `elementId` on a tag-less component/);
};
_class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is specified via JS'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsSpecifiedViaJS() {
var template = '{{id}}';
var FooBarComponent = _helpers.Component.extend({
tagName: '',
id: 'baz'
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
this.render('{{#foo-bar}}{{/foo-bar}}');
this.assertText('baz');
};
_class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is specified via template'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsSpecifiedViaTemplate() {
var template = '{{id}}';
var FooBarComponent = _helpers.Component.extend({
tagName: ''
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
this.render('{{#foo-bar id=\'baz\'}}{{/foo-bar}}');
this.assertText('baz');
};
_class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is bound property specified via template'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsBoundPropertySpecifiedViaTemplate() {
var _this8 = this;
var template = '{{id}}';
var FooBarComponent = _helpers.Component.extend({
tagName: ''
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
this.render('{{#foo-bar id=fooBarId}}{{/foo-bar}}', { fooBarId: 'baz' });
this.assertText('baz');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'fooBarId', 'qux');
});
this.assertText('qux');
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'fooBarId', 'baz');
});
this.assertText('baz');
};
_class.prototype['@test does not throw an error if `tagName` is an empty string and `id` is specified via template and passed to child component'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsSpecifiedViaTemplateAndPassedToChildComponent() {
var fooBarTemplate = '{{#baz-child id=id}}{{/baz-child}}';
var FooBarComponent = _helpers.Component.extend({
tagName: ''
});
var BazChildComponent = _helpers.Component.extend();
var bazChildTemplate = '{{id}}';
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: fooBarTemplate });
this.registerComponent('baz-child', { ComponentClass: BazChildComponent, template: bazChildTemplate });
this.render('{{#foo-bar id=\'baz\'}}{{/foo-bar}}');
this.assertText('baz');
};
_class.prototype['@test throws an error if when $() is accessed on component where `tagName` is an empty string'] = function testThrowsAnErrorIfWhen$IsAccessedOnComponentWhereTagNameIsAnEmptyString() {
var _this9 = this;
var template = 'hit dem folks';
var FooBarComponent = _helpers.Component.extend({
tagName: '',
init: function () {
this._super();
this.$();
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template });
expectAssertion(function () {
_this9.render('{{#foo-bar}}{{/foo-bar}}');
}, /You cannot access this.\$\(\) on a component with `tagName: \'\'` specified/);
};
_class.prototype['@test renders a contained view with omitted start tag and tagless parent view context'] = function testRendersAContainedViewWithOmittedStartTagAndTaglessParentViewContext() {
var _this10 = this;
this.registerComponent('root-component', {
ComponentClass: _helpers.Component.extend({
tagName: 'section'
}),
template: '{{frag-ment}}'
});
this.registerComponent('frag-ment', {
ComponentClass: _helpers.Component.extend({
tagName: ''
}),
template: '{{my-span}}'
});
this.registerComponent('my-span', {
ComponentClass: _helpers.Component.extend({
tagName: 'span'
}),
template: 'dab'
});
this.render('{{root-component}}');
this.assertElement(this.firstChild, { tagName: 'section' });
this.assertElement(this.firstChild.firstElementChild, { tagName: 'span' });
this.runTask(function () {
return _this10.rerender();
});
this.assertElement(this.firstChild, { tagName: 'section' });
this.assertElement(this.firstChild.firstElementChild, { tagName: 'span' });
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/fragment-components-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/fragment-components-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/instrumentation-compile-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (_emberBabel, _testCase, _helpers, _emberMetal) {
'use strict';
(0, _testCase.moduleFor)('Components compile instrumentation', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class, _RenderingTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.call(this));
_this.resetEvents();
(0, _emberMetal.instrumentationSubscribe)('render.getComponentDefinition', {
before: function (name, timestamp, payload) {
if (payload.view !== _this.component) {
_this.actual.before.push(payload);
}
},
after: function (name, timestamp, payload) {
if (payload.view !== _this.component) {
_this.actual.after.push(payload);
}
}
});
return _this;
}
_class.prototype.resetEvents = function resetEvents() {
this.expected = {
before: [],
after: []
};
this.actual = {
before: [],
after: []
};
};
_class.prototype.teardown = function teardown() {
this.assert.deepEqual(this.actual.before, [], 'No unexpected events (before)');
this.assert.deepEqual(this.actual.after, [], 'No unexpected events (after)');
_RenderingTest.prototype.teardown.call(this);
(0, _emberMetal.instrumentationReset)();
};
_class.prototype['@test it should only receive an instrumentation event for initial render'] = function testItShouldOnlyReceiveAnInstrumentationEventForInitialRender(assert) {
var _this2 = this;
var testCase = this;
var BaseClass = _helpers.Component.extend({
tagName: '',
willRender: function () {
testCase.expected.before.push(this);
testCase.expected.after.unshift(this);
}
});
this.registerComponent('x-bar', {
template: '[x-bar: {{bar}}]',
ComponentClass: BaseClass.extend()
});
this.render('[-top-level: {{foo}}] {{x-bar bar=bar}}', {
foo: 'foo', bar: 'bar'
});
this.assertText('[-top-level: foo] [x-bar: bar]');
this.assertEvents('after initial render');
this.runTask(function () {
return _this2.rerender();
});
this.assertEvents('after no-op rerender');
};
_class.prototype.assertEvents = function assertEvents(label) {
var actual = this.actual,
expected = this.expected;
this.assert.strictEqual(actual.before.length, actual.after.length, label + ': before and after callbacks should be balanced');
this._assertEvents(label + ' (before):', actual.before, expected.before);
this._assertEvents(label + ' (after):', actual.before, expected.before);
this.resetEvents();
};
_class.prototype._assertEvents = function _assertEvents(label, actual, expected) {
var _this3 = this;
this.assert.equal(actual.length, expected.length, label + ': expected ' + expected.length + ' and got ' + actual.length);
actual.forEach(function (payload, i) {
return _this3.assertPayload(payload, expected[i]);
});
};
_class.prototype.assertPayload = function assertPayload(payload, component) {
this.assert.equal(payload.object, component._debugContainerKey, 'payload.object');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/instrumentation-compile-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/instrumentation-compile-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/instrumentation-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (_emberBabel, _testCase, _helpers, _emberMetal) {
'use strict';
(0, _testCase.moduleFor)('Components instrumentation', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class, _RenderingTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.call(this));
_this.resetEvents();
(0, _emberMetal.instrumentationSubscribe)('render.component', {
before: function (name, timestamp, payload) {
if (payload.view !== _this.component) {
_this.actual.before.push(payload);
}
},
after: function (name, timestamp, payload) {
if (payload.view !== _this.component) {
_this.actual.after.push(payload);
}
}
});
return _this;
}
_class.prototype.resetEvents = function resetEvents() {
this.expected = {
before: [],
after: []
};
this.actual = {
before: [],
after: []
};
};
_class.prototype.teardown = function teardown() {
this.assert.deepEqual(this.actual.before, [], 'No unexpected events (before)');
this.assert.deepEqual(this.actual.after, [], 'No unexpected events (after)');
_RenderingTest.prototype.teardown.call(this);
(0, _emberMetal.instrumentationReset)();
};
_class.prototype['@test zomg'] = function testZomg(assert) {
assert.ok(true);
};
_class.prototype['@test it should receive an instrumentation event for both initial render and updates'] = function testItShouldReceiveAnInstrumentationEventForBothInitialRenderAndUpdates(assert) {
var _this2 = this;
var testCase = this;
var BaseClass = _helpers.Component.extend({
tagName: '',
willRender: function () {
testCase.expected.before.push(this);
testCase.expected.after.unshift(this);
}
});
this.registerComponent('x-bar', {
template: '[x-bar: {{bar}}] {{yield}}',
ComponentClass: BaseClass.extend()
});
this.registerComponent('x-baz', {
template: '[x-baz: {{baz}}]',
ComponentClass: BaseClass.extend()
});
this.registerComponent('x-bat', {
template: '[x-bat: {{bat}}]',
ComponentClass: BaseClass.extend()
});
this.render('[-top-level: {{foo}}] {{#x-bar bar=bar}}{{x-baz baz=baz}}{{/x-bar}} {{x-bat bat=bat}}', {
foo: 'foo', bar: 'bar', baz: 'baz', bat: 'bat'
});
this.assertText('[-top-level: foo] [x-bar: bar] [x-baz: baz] [x-bat: bat]');
this.assertEvents('after initial render', true);
this.runTask(function () {
return _this2.rerender();
});
this.assertEvents('after no-op rerender');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'foo', 'FOO');
});
this.assertEvents('after updating top-level');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'baz', 'BAZ');
});
this.assertEvents('after updating inner-most');
this.runTask(function () {
(0, _emberMetal.set)(_this2.context, 'bar', 'BAR');
(0, _emberMetal.set)(_this2.context, 'bat', 'BAT');
});
this.assertEvents('after updating the rest');
this.runTask(function () {
(0, _emberMetal.set)(_this2.context, 'foo', 'FOO');
(0, _emberMetal.set)(_this2.context, 'bar', 'BAR');
(0, _emberMetal.set)(_this2.context, 'baz', 'BAZ');
(0, _emberMetal.set)(_this2.context, 'bat', 'BAT');
});
this.assertEvents('after reset');
};
_class.prototype.assertEvents = function assertEvents(label) {
var initialRender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var actual = this.actual,
expected = this.expected;
this.assert.strictEqual(actual.before.length, actual.after.length, label + ': before and after callbacks should be balanced');
this._assertEvents(label + ' (before):', actual.before, expected.before, initialRender);
this._assertEvents(label + ' (after):', actual.before, expected.before, initialRender);
this.resetEvents();
};
_class.prototype._assertEvents = function _assertEvents(label, actual, expected, initialRender) {
var _this3 = this;
this.assert.equal(actual.length, expected.length, label + ': expected ' + expected.length + ' and got ' + actual.length);
actual.forEach(function (payload, i) {
return _this3.assertPayload(payload, expected[i], initialRender);
});
};
_class.prototype.assertPayload = function assertPayload(payload, component, initialRender) {
this.assert.equal(payload.object, component.toString(), 'payload.object');
this.assert.ok(payload.containerKey, 'the container key should be present');
this.assert.equal(payload.containerKey, component._debugContainerKey, 'payload.containerKey');
this.assert.equal(payload.view, component, 'payload.view');
this.assert.strictEqual(payload.initialRender, initialRender, 'payload.initialRender');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/instrumentation-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/instrumentation-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/life-cycle-test', ['ember-babel', 'ember-metal', 'ember-runtime', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/test-case', 'ember-views', 'ember-glimmer/tests/utils/test-helpers', 'ember-utils', 'internal-test-helpers'], function (_emberBabel, _emberMetal, _emberRuntime, _helpers, _abstractTestCase, _testCase, _emberViews, _testHelpers, _emberUtils, _internalTestHelpers) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <div>\n Twitter: {{', '}}|\n ', '\n </div>'], ['\n <div>\n Twitter: {{', '}}|\n ', '\n </div>']),
_templateObject2 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <div>\n Name: {{', '}}|\n ', '\n </div>'], ['\n <div>\n Name: {{', '}}|\n ', '\n </div>']),
_templateObject3 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <div>\n Website: {{', '}}\n </div>'], ['\n <div>\n Website: {{', '}}\n </div>']),
_templateObject4 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <div>\n ', '|\n ', '|\n ', '\n </div>'], ['\n <div>\n ', '|\n ', '|\n ', '\n </div>']),
_templateObject5 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <div>\n Top: ', '\n </div>'], ['\n <div>\n Top: ', '\n </div>']),
_templateObject6 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <div>\n Middle: ', '\n </div>'], ['\n <div>\n Middle: ', '\n </div>']),
_templateObject7 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <div>\n Bottom: {{', '}}\n </div>'], ['\n <div>\n Bottom: {{', '}}\n </div>']),
_templateObject8 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#nested-item}}Item: {{count}}{{/nested-item}}\n '], ['\n {{#nested-item}}Item: {{count}}{{/nested-item}}\n ']),
_templateObject9 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#nested-item}}Nothing to see here{{/nested-item}}\n '], ['\n {{#nested-item}}Nothing to see here{{/nested-item}}\n ']),
_templateObject10 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#each items as |item|}}\n ', '\n {{else}}\n ', '\n {{/each}}\n '], ['\n {{#each items as |item|}}\n ', '\n {{else}}\n ', '\n {{/each}}\n ']),
_templateObject11 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{yield}}\n <ul>\n {{#nested-component nestedId=(concat itemId \'-A\')}}A{{/nested-component}}\n {{#nested-component nestedId=(concat itemId \'-B\')}}B{{/nested-component}}\n </ul>\n '], ['\n {{yield}}\n <ul>\n {{#nested-component nestedId=(concat itemId \'-A\')}}A{{/nested-component}}\n {{#nested-component nestedId=(concat itemId \'-B\')}}B{{/nested-component}}\n </ul>\n ']),
_templateObject12 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#each items as |item|}}\n {{#parent-component itemId=item.id}}{{item.id}}{{/parent-component}}\n {{/each}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=6}}6{{/parent-component}}\n {{/if}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=7}}7{{/parent-component}}\n {{/if}}\n '], ['\n {{#each items as |item|}}\n {{#parent-component itemId=item.id}}{{item.id}}{{/parent-component}}\n {{/each}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=6}}6{{/parent-component}}\n {{/if}}\n {{#if model.shouldShow}}\n {{#parent-component itemId=7}}7{{/parent-component}}\n {{/if}}\n ']);
var LifeCycleHooksTest = function (_RenderingTest) {
(0, _emberBabel.inherits)(LifeCycleHooksTest, _RenderingTest);
function LifeCycleHooksTest() {
(0, _emberBabel.classCallCheck)(this, LifeCycleHooksTest);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.call(this));
_this.hooks = [];
_this.components = {};
_this.componentRegistry = [];
_this.teardownAssertions = [];
return _this;
}
LifeCycleHooksTest.prototype.teardown = function teardown() {
_RenderingTest.prototype.teardown.call(this);
for (var i = 0; i < this.teardownAssertions.length; i++) {
this.teardownAssertions[i]();
}
};
LifeCycleHooksTest.prototype.getBootOptions = function getBootOptions() {
return {
isInteractive: this.isInteractive
};
};
LifeCycleHooksTest.prototype.invocationFor = function invocationFor(name) {
var namedArgs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
throw new Error('Not implemented: `invocationFor`');
};
LifeCycleHooksTest.prototype.attrFor = function attrFor(name) {
throw new Error('Not implemented: `attrFor`');
};
LifeCycleHooksTest.prototype.assertRegisteredViews = function assertRegisteredViews(label) {
var viewRegistry = this.owner.lookup('-view-registry:main');
var topLevelId = (0, _emberViews.getViewId)(this.component);
var actual = Object.keys(viewRegistry).sort().filter(function (id) {
return id !== topLevelId;
});
if (this.isInteractive) {
var expected = this.componentRegistry.sort();
this.assert.deepEqual(actual, expected, 'registered views - ' + label);
} else {
this.assert.deepEqual(actual, [], 'no views should be registered for non-interactive mode');
}
};
LifeCycleHooksTest.prototype.registerComponent = function registerComponent(name, _ref) {
var _this2 = this;
var _ref$template = _ref.template,
template = _ref$template === undefined ? null : _ref$template;
var pushComponent = function (instance) {
_this2.components[name] = instance;
_this2.componentRegistry.push((0, _emberViews.getViewId)(instance));
};
var removeComponent = function (instance) {
var index = _this2.componentRegistry.indexOf(instance);
_this2.componentRegistry.splice(index, 1);
delete _this2.components[name];
};
var pushHook = function (hookName, args) {
_this2.hooks.push(hook(name, hookName, args));
};
var assertParentView = function (hookName, instance) {
_this2.assert.ok(instance.parentView, 'parentView should be present in ' + hookName);
if (hookName === 'willDestroyElement') {
_this2.assert.ok(instance.parentView.childViews.indexOf(instance) !== -1, 'view is still connected to parentView in ' + hookName);
}
};
var assertElement = function (hookName, instance) {
var inDOM = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
if (instance.tagName === '') {
return;
}
_this2.assert.ok((0, _emberViews.getViewElement)(instance), 'element should be present on ' + instance + ' during ' + hookName);
if (_this2.isInteractive) {
_this2.assert.ok(instance.element, 'this.element should be present on ' + instance + ' during ' + hookName);
_this2.assert.equal(document.body.contains(instance.element), inDOM, 'element for ' + instance + ' ' + (inDOM ? 'should' : 'should not') + ' be in the DOM during ' + hookName);
} else {
_this2.assert.throws(function () {
return instance.element;
}, /Accessing `this.element` is not allowed in non-interactive environments/);
}
};
var assertNoElement = function (hookName, instance) {
_this2.assert.strictEqual((0, _emberViews.getViewElement)(instance), null, 'element should not be present in ' + hookName);
if (_this2.isInteractive) {
_this2.assert.strictEqual(instance.element, null, 'this.element should not be present in ' + hookName);
} else {
_this2.assert.throws(function () {
return instance.element;
}, /Accessing `this.element` is not allowed in non-interactive environments/);
}
};
var assertState = function (hookName, expectedState, instance) {
_this2.assert.equal(instance._state, expectedState, 'within ' + hookName + ' the expected _state is ' + expectedState);
};
var isInteractive = this.isInteractive;
var ComponentClass = this.ComponentClass.extend({
init: function () {
var _this3 = this,
_arguments = arguments;
expectDeprecation(function () {
_this3._super.apply(_this3, _arguments);
}, /didInitAttrs called/);
this.isInitialRender = true;
this.componentName = name;
pushHook('init');
pushComponent(this);
assertParentView('init', this);
assertNoElement('init', this);
assertState('init', 'preRender', this);
this.on('init', function () {
return pushHook('on(init)');
});
_emberMetal.run.schedule('afterRender', function () {
_this3.isInitialRender = false;
});
},
didInitAttrs: function (options) {
pushHook('didInitAttrs', options);
assertParentView('didInitAttrs', this);
assertNoElement('didInitAttrs', this);
assertState('didInitAttrs', 'preRender', this);
},
didReceiveAttrs: function (options) {
pushHook('didReceiveAttrs', options);
assertParentView('didReceiveAttrs', this);
if (this.isInitialRender) {
assertNoElement('didReceiveAttrs', this);
assertState('didReceiveAttrs', 'preRender', this);
} else {
assertElement('didReceiveAttrs', this);
if (isInteractive) {
assertState('didReceiveAttrs', 'inDOM', this);
} else {
assertState('didReceiveAttrs', 'hasElement', this);
}
}
},
willInsertElement: function () {
pushHook('willInsertElement');
assertParentView('willInsertElement', this);
assertElement('willInsertElement', this, false);
assertState('willInsertElement', 'hasElement', this);
},
willRender: function () {
pushHook('willRender');
assertParentView('willRender', this);
if (this.isInitialRender) {
assertNoElement('willRender', this, false);
assertState('willRender', 'preRender', this);
} else {
assertElement('willRender', this);
assertState('willRender', 'inDOM', this);
}
},
didInsertElement: function () {
pushHook('didInsertElement');
assertParentView('didInsertElement', this);
assertElement('didInsertElement', this);
assertState('didInsertElement', 'inDOM', this);
},
didRender: function () {
pushHook('didRender');
assertParentView('didRender', this);
assertElement('didRender', this);
assertState('didRender', 'inDOM', this);
},
didUpdateAttrs: function (options) {
pushHook('didUpdateAttrs', options);
assertParentView('didUpdateAttrs', this);
if (isInteractive) {
assertState('didUpdateAttrs', 'inDOM', this);
} else {
assertState('didUpdateAttrs', 'hasElement', this);
}
},
willUpdate: function (options) {
pushHook('willUpdate', options);
assertParentView('willUpdate', this);
assertElement('willUpdate', this);
assertState('willUpdate', 'inDOM', this);
},
didUpdate: function (options) {
pushHook('didUpdate', options);
assertParentView('didUpdate', this);
assertElement('didUpdate', this);
assertState('didUpdate', 'inDOM', this);
},
willDestroyElement: function () {
pushHook('willDestroyElement');
assertParentView('willDestroyElement', this);
assertElement('willDestroyElement', this);
assertState('willDestroyElement', 'inDOM', this);
},
willClearRender: function () {
pushHook('willClearRender');
assertParentView('willClearRender', this);
assertElement('willClearRender', this);
assertState('willClearRender', 'inDOM', this);
},
didDestroyElement: function () {
pushHook('didDestroyElement');
assertNoElement('didDestroyElement', this);
assertState('didDestroyElement', 'destroying', this);
},
willDestroy: function () {
pushHook('willDestroy');
removeComponent(this);
this._super.apply(this, arguments);
}
});
_RenderingTest.prototype.registerComponent.call(this, name, { ComponentClass: ComponentClass, template: template });
};
LifeCycleHooksTest.prototype.assertHooks = function assertHooks(_ref2) {
var label = _ref2.label,
interactive = _ref2.interactive,
nonInteractive = _ref2.nonInteractive;
var rawHooks = this.isInteractive ? interactive : nonInteractive;
var hooks = rawHooks.map(function (raw) {
return hook.apply(undefined, raw);
});
this.assert.deepEqual(json(this.hooks), json(hooks), label);
this.hooks = [];
};
LifeCycleHooksTest.prototype['@test lifecycle hooks are invoked in a predictable order'] = function testLifecycleHooksAreInvokedInAPredictableOrder() {
var _this4 = this;
var _boundHelpers = this.boundHelpers,
attr = _boundHelpers.attr,
invoke = _boundHelpers.invoke;
this.registerComponent('the-top', { template: (0, _abstractTestCase.strip)(_templateObject, attr('twitter'), invoke('the-middle', { name: string('Tom Dale') }))
});
this.registerComponent('the-middle', { template: (0, _abstractTestCase.strip)(_templateObject2, attr('name'), invoke('the-bottom', { website: string('tomdale.net') }))
});
this.registerComponent('the-bottom', { template: (0, _abstractTestCase.strip)(_templateObject3, attr('website'))
});
this.render(invoke('the-top', { twitter: expr('twitter') }), { twitter: '@tomdale' });
this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net');
this.assertRegisteredViews('intial render');
var topAttrs = { twitter: '@tomdale' };
var middleAttrs = { name: 'Tom Dale' };
var bottomAttrs = { website: 'tomdale.net' };
this.assertHooks({
label: 'after initial render',
interactive: [
// Sync hooks
['the-top', 'init'], ['the-top', 'didInitAttrs'], ['the-top', 'didReceiveAttrs'], ['the-top', 'on(init)'], ['the-top', 'willRender'], ['the-top', 'willInsertElement'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs'], ['the-middle', 'didReceiveAttrs'], ['the-middle', 'on(init)'], ['the-middle', 'willRender'], ['the-middle', 'willInsertElement'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs'], ['the-bottom', 'didReceiveAttrs'], ['the-bottom', 'on(init)'], ['the-bottom', 'willRender'], ['the-bottom', 'willInsertElement'],
// Async hooks
['the-bottom', 'didInsertElement'], ['the-bottom', 'didRender'], ['the-middle', 'didInsertElement'], ['the-middle', 'didRender'], ['the-top', 'didInsertElement'], ['the-top', 'didRender']],
nonInteractive: [
// Sync hooks
['the-top', 'init'], ['the-top', 'didInitAttrs'], ['the-top', 'didReceiveAttrs'], ['the-top', 'on(init)'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs'], ['the-middle', 'didReceiveAttrs'], ['the-middle', 'on(init)'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs'], ['the-bottom', 'didReceiveAttrs'], ['the-bottom', 'on(init)']]
});
this.runTask(function () {
return _this4.components['the-bottom'].rerender();
});
this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net');
this.assertHooks({
label: 'after no-op rerender (bottom)',
interactive: [
// Sync hooks
['the-top', 'willUpdate'], ['the-top', 'willRender'], ['the-middle', 'willUpdate'], ['the-middle', 'willRender'], ['the-bottom', 'willUpdate'], ['the-bottom', 'willRender'],
// Async hooks
['the-bottom', 'didUpdate'], ['the-bottom', 'didRender'], ['the-middle', 'didUpdate'], ['the-middle', 'didRender'], ['the-top', 'didUpdate'], ['the-top', 'didRender']],
nonInteractive: []
});
this.runTask(function () {
return _this4.components['the-middle'].rerender();
});
this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net');
this.assertHooks({
label: 'after no-op rerender (middle)',
interactive: [
// Sync hooks
['the-top', 'willUpdate'], ['the-top', 'willRender'], ['the-middle', 'willUpdate'], ['the-middle', 'willRender'],
// Async hooks
['the-middle', 'didUpdate'], ['the-middle', 'didRender'], ['the-top', 'didUpdate'], ['the-top', 'didRender']],
nonInteractive: []
});
this.runTask(function () {
return _this4.components['the-top'].rerender();
});
this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net');
this.assertHooks({
label: 'after no-op rerender (top)',
interactive: [
// Sync hooks
['the-top', 'willUpdate'], ['the-top', 'willRender'],
// Async hooks
['the-top', 'didUpdate'], ['the-top', 'didRender']],
nonInteractive: []
});
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'twitter', '@horsetomdale');
});
this.assertText('Twitter: @horsetomdale|Name: Tom Dale|Website: tomdale.net');
// Because the `twitter` attr is only used by the topmost component,
// and not passed down, we do not expect to see lifecycle hooks
// called for child components. If the `didReceiveAttrs` hook used
// the new attribute to rerender itself imperatively, that would result
// in lifecycle hooks being invoked for the child.
this.assertHooks({
label: 'after update',
interactive: [
// Sync hooks
['the-top', 'didUpdateAttrs'], ['the-top', 'didReceiveAttrs'], ['the-top', 'willUpdate'], ['the-top', 'willRender'],
// Async hooks
['the-top', 'didUpdate'], ['the-top', 'didRender']],
nonInteractive: [
// Sync hooks
['the-top', 'didUpdateAttrs'], ['the-top', 'didReceiveAttrs']]
});
this.teardownAssertions.push(function () {
_this4.assertHooks({
label: 'destroy',
interactive: [['the-top', 'willDestroyElement'], ['the-top', 'willClearRender'], ['the-middle', 'willDestroyElement'], ['the-middle', 'willClearRender'], ['the-bottom', 'willDestroyElement'], ['the-bottom', 'willClearRender'], ['the-top', 'didDestroyElement'], ['the-middle', 'didDestroyElement'], ['the-bottom', 'didDestroyElement'], ['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']],
nonInteractive: [['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']]
});
_this4.assertRegisteredViews('after destroy');
});
};
LifeCycleHooksTest.prototype['@test lifecycle hooks are invoked in a correct sibling order'] = function testLifecycleHooksAreInvokedInACorrectSiblingOrder() {
var _this5 = this;
var _boundHelpers2 = this.boundHelpers,
attr = _boundHelpers2.attr,
invoke = _boundHelpers2.invoke;
this.registerComponent('the-parent', { template: (0, _abstractTestCase.strip)(_templateObject4, invoke('the-first-child', { twitter: expr(attr('twitter')) }), invoke('the-second-child', { name: expr(attr('name')) }), invoke('the-last-child', { website: expr(attr('website')) }))
});
this.registerComponent('the-first-child', { template: 'Twitter: {{' + attr('twitter') + '}}' });
this.registerComponent('the-second-child', { template: 'Name: {{' + attr('name') + '}}' });
this.registerComponent('the-last-child', { template: 'Website: {{' + attr('website') + '}}' });
this.render(invoke('the-parent', {
twitter: expr('twitter'),
name: expr('name'),
website: expr('website')
}), {
twitter: '@tomdale',
name: 'Tom Dale',
website: 'tomdale.net'
});
this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net');
this.assertRegisteredViews('intial render');
this.assertHooks({
label: 'after initial render',
interactive: [
// Sync hooks
['the-parent', 'init'], ['the-parent', 'didInitAttrs'], ['the-parent', 'didReceiveAttrs'], ['the-parent', 'on(init)'], ['the-parent', 'willRender'], ['the-parent', 'willInsertElement'], ['the-first-child', 'init'], ['the-first-child', 'didInitAttrs'], ['the-first-child', 'didReceiveAttrs'], ['the-first-child', 'on(init)'], ['the-first-child', 'willRender'], ['the-first-child', 'willInsertElement'], ['the-second-child', 'init'], ['the-second-child', 'didInitAttrs'], ['the-second-child', 'didReceiveAttrs'], ['the-second-child', 'on(init)'], ['the-second-child', 'willRender'], ['the-second-child', 'willInsertElement'], ['the-last-child', 'init'], ['the-last-child', 'didInitAttrs'], ['the-last-child', 'didReceiveAttrs'], ['the-last-child', 'on(init)'], ['the-last-child', 'willRender'], ['the-last-child', 'willInsertElement'],
// Async hooks
['the-first-child', 'didInsertElement'], ['the-first-child', 'didRender'], ['the-second-child', 'didInsertElement'], ['the-second-child', 'didRender'], ['the-last-child', 'didInsertElement'], ['the-last-child', 'didRender'], ['the-parent', 'didInsertElement'], ['the-parent', 'didRender']],
nonInteractive: [
// Sync hooks
['the-parent', 'init'], ['the-parent', 'didInitAttrs'], ['the-parent', 'didReceiveAttrs'], ['the-parent', 'on(init)'], ['the-first-child', 'init'], ['the-first-child', 'didInitAttrs'], ['the-first-child', 'didReceiveAttrs'], ['the-first-child', 'on(init)'], ['the-second-child', 'init'], ['the-second-child', 'didInitAttrs'], ['the-second-child', 'didReceiveAttrs'], ['the-second-child', 'on(init)'], ['the-last-child', 'init'], ['the-last-child', 'didInitAttrs'], ['the-last-child', 'didReceiveAttrs'], ['the-last-child', 'on(init)']]
});
this.runTask(function () {
return _this5.components['the-first-child'].rerender();
});
this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net');
this.assertHooks({
label: 'after no-op rerender (first child)',
interactive: [
// Sync hooks
['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-first-child', 'willUpdate'], ['the-first-child', 'willRender'],
// Async hooks
['the-first-child', 'didUpdate'], ['the-first-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']],
nonInteractive: []
});
this.runTask(function () {
return _this5.components['the-second-child'].rerender();
});
this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net');
this.assertHooks({
label: 'after no-op rerender (second child)',
interactive: [
// Sync hooks
['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-second-child', 'willUpdate'], ['the-second-child', 'willRender'],
// Async hooks
['the-second-child', 'didUpdate'], ['the-second-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']],
nonInteractive: []
});
this.runTask(function () {
return _this5.components['the-last-child'].rerender();
});
this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net');
this.assertHooks({
label: 'after no-op rerender (last child)',
interactive: [
// Sync hooks
['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-last-child', 'willUpdate'], ['the-last-child', 'willRender'],
// Async hooks
['the-last-child', 'didUpdate'], ['the-last-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']],
nonInteractive: []
});
this.runTask(function () {
return _this5.components['the-parent'].rerender();
});
this.assertText('Twitter: @tomdale|Name: Tom Dale|Website: tomdale.net');
this.assertHooks({
label: 'after no-op rerender (parent)',
interactive: [
// Sync hooks
['the-parent', 'willUpdate'], ['the-parent', 'willRender'],
// Async hooks
['the-parent', 'didUpdate'], ['the-parent', 'didRender']],
nonInteractive: []
});
this.runTask(function () {
return (0, _emberMetal.setProperties)(_this5.context, {
twitter: '@horsetomdale',
name: 'Horse Tom Dale',
website: 'horsetomdale.net'
});
});
this.assertText('Twitter: @horsetomdale|Name: Horse Tom Dale|Website: horsetomdale.net');
this.assertHooks({
label: 'after update',
interactive: [
// Sync hooks
['the-parent', 'didUpdateAttrs'], ['the-parent', 'didReceiveAttrs'], ['the-parent', 'willUpdate'], ['the-parent', 'willRender'], ['the-first-child', 'didUpdateAttrs'], ['the-first-child', 'didReceiveAttrs'], ['the-first-child', 'willUpdate'], ['the-first-child', 'willRender'], ['the-second-child', 'didUpdateAttrs'], ['the-second-child', 'didReceiveAttrs'], ['the-second-child', 'willUpdate'], ['the-second-child', 'willRender'], ['the-last-child', 'didUpdateAttrs'], ['the-last-child', 'didReceiveAttrs'], ['the-last-child', 'willUpdate'], ['the-last-child', 'willRender'],
// Async hooks
['the-first-child', 'didUpdate'], ['the-first-child', 'didRender'], ['the-second-child', 'didUpdate'], ['the-second-child', 'didRender'], ['the-last-child', 'didUpdate'], ['the-last-child', 'didRender'], ['the-parent', 'didUpdate'], ['the-parent', 'didRender']],
nonInteractive: [
// Sync hooks
['the-parent', 'didUpdateAttrs'], ['the-parent', 'didReceiveAttrs'], ['the-first-child', 'didUpdateAttrs'], ['the-first-child', 'didReceiveAttrs'], ['the-second-child', 'didUpdateAttrs'], ['the-second-child', 'didReceiveAttrs'], ['the-last-child', 'didUpdateAttrs'], ['the-last-child', 'didReceiveAttrs']]
});
this.teardownAssertions.push(function () {
_this5.assertHooks({
label: 'destroy',
interactive: [['the-parent', 'willDestroyElement'], ['the-parent', 'willClearRender'], ['the-first-child', 'willDestroyElement'], ['the-first-child', 'willClearRender'], ['the-second-child', 'willDestroyElement'], ['the-second-child', 'willClearRender'], ['the-last-child', 'willDestroyElement'], ['the-last-child', 'willClearRender'], ['the-parent', 'didDestroyElement'], ['the-first-child', 'didDestroyElement'], ['the-second-child', 'didDestroyElement'], ['the-last-child', 'didDestroyElement'], ['the-parent', 'willDestroy'], ['the-first-child', 'willDestroy'], ['the-second-child', 'willDestroy'], ['the-last-child', 'willDestroy']],
nonInteractive: [['the-parent', 'willDestroy'], ['the-first-child', 'willDestroy'], ['the-second-child', 'willDestroy'], ['the-last-child', 'willDestroy']]
});
_this5.assertRegisteredViews('after destroy');
});
};
LifeCycleHooksTest.prototype['@test passing values through attrs causes lifecycle hooks to fire if the attribute values have changed'] = function testPassingValuesThroughAttrsCausesLifecycleHooksToFireIfTheAttributeValuesHaveChanged() {
var _this6 = this;
var _boundHelpers3 = this.boundHelpers,
attr = _boundHelpers3.attr,
invoke = _boundHelpers3.invoke;
this.registerComponent('the-top', { template: (0, _abstractTestCase.strip)(_templateObject5, invoke('the-middle', { twitterTop: expr(attr('twitter')) }))
});
this.registerComponent('the-middle', { template: (0, _abstractTestCase.strip)(_templateObject6, invoke('the-bottom', { twitterMiddle: expr(attr('twitterTop')) }))
});
this.registerComponent('the-bottom', { template: (0, _abstractTestCase.strip)(_templateObject7, attr('twitterMiddle'))
});
this.render(invoke('the-top', { twitter: expr('twitter') }), { twitter: '@tomdale' });
this.assertText('Top: Middle: Bottom: @tomdale');
this.assertRegisteredViews('intial render');
this.assertHooks({
label: 'after initial render',
interactive: [
// Sync hooks
['the-top', 'init'], ['the-top', 'didInitAttrs'], ['the-top', 'didReceiveAttrs'], ['the-top', 'on(init)'], ['the-top', 'willRender'], ['the-top', 'willInsertElement'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs'], ['the-middle', 'didReceiveAttrs'], ['the-middle', 'on(init)'], ['the-middle', 'willRender'], ['the-middle', 'willInsertElement'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs'], ['the-bottom', 'didReceiveAttrs'], ['the-bottom', 'on(init)'], ['the-bottom', 'willRender'], ['the-bottom', 'willInsertElement'],
// Async hooks
['the-bottom', 'didInsertElement'], ['the-bottom', 'didRender'], ['the-middle', 'didInsertElement'], ['the-middle', 'didRender'], ['the-top', 'didInsertElement'], ['the-top', 'didRender']],
nonInteractive: [
// Sync hooks
['the-top', 'init'], ['the-top', 'didInitAttrs'], ['the-top', 'didReceiveAttrs'], ['the-top', 'on(init)'], ['the-middle', 'init'], ['the-middle', 'didInitAttrs'], ['the-middle', 'didReceiveAttrs'], ['the-middle', 'on(init)'], ['the-bottom', 'init'], ['the-bottom', 'didInitAttrs'], ['the-bottom', 'didReceiveAttrs'], ['the-bottom', 'on(init)']]
});
this.runTask(function () {
return (0, _emberMetal.set)(_this6.context, 'twitter', '@horsetomdale');
});
this.assertText('Top: Middle: Bottom: @horsetomdale');
// Because the `twitter` attr is used by the all of the components,
// the lifecycle hooks are invoked for all components.
this.assertHooks({
label: 'after updating (root)',
interactive: [
// Sync hooks
['the-top', 'didUpdateAttrs'], ['the-top', 'didReceiveAttrs'], ['the-top', 'willUpdate'], ['the-top', 'willRender'], ['the-middle', 'didUpdateAttrs'], ['the-middle', 'didReceiveAttrs'], ['the-middle', 'willUpdate'], ['the-middle', 'willRender'], ['the-bottom', 'didUpdateAttrs'], ['the-bottom', 'didReceiveAttrs'], ['the-bottom', 'willUpdate'], ['the-bottom', 'willRender'],
// Async hooks
['the-bottom', 'didUpdate'], ['the-bottom', 'didRender'], ['the-middle', 'didUpdate'], ['the-middle', 'didRender'], ['the-top', 'didUpdate'], ['the-top', 'didRender']],
nonInteractive: [
// Sync hooks
['the-top', 'didUpdateAttrs'], ['the-top', 'didReceiveAttrs'], ['the-middle', 'didUpdateAttrs'], ['the-middle', 'didReceiveAttrs'], ['the-bottom', 'didUpdateAttrs'], ['the-bottom', 'didReceiveAttrs']]
});
this.runTask(function () {
return _this6.rerender();
});
this.assertText('Top: Middle: Bottom: @horsetomdale');
// In this case, because the attrs are passed down, all child components are invoked.
this.assertHooks({
label: 'after no-op rernder (root)',
interactive: [],
nonInteractive: []
});
this.teardownAssertions.push(function () {
_this6.assertHooks({
label: 'destroy',
interactive: [['the-top', 'willDestroyElement'], ['the-top', 'willClearRender'], ['the-middle', 'willDestroyElement'], ['the-middle', 'willClearRender'], ['the-bottom', 'willDestroyElement'], ['the-bottom', 'willClearRender'], ['the-top', 'didDestroyElement'], ['the-middle', 'didDestroyElement'], ['the-bottom', 'didDestroyElement'], ['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']],
nonInteractive: [['the-top', 'willDestroy'], ['the-middle', 'willDestroy'], ['the-bottom', 'willDestroy']]
});
_this6.assertRegisteredViews('after destroy');
});
};
LifeCycleHooksTest.prototype['@test components rendered from `{{each}}` have correct life-cycle hooks to be called'] = function testComponentsRenderedFromEachHaveCorrectLifeCycleHooksToBeCalled() {
var _this7 = this;
var invoke = this.boundHelpers.invoke;
this.registerComponent('nested-item', { template: '{{yield}}' });
this.registerComponent('an-item', { template: (0, _abstractTestCase.strip)(_templateObject8) });
this.registerComponent('no-items', { template: (0, _abstractTestCase.strip)(_templateObject9) });
this.render((0, _abstractTestCase.strip)(_templateObject10, invoke('an-item', { count: expr('item') }), invoke('no-items')), {
items: [1, 2, 3, 4, 5]
});
this.assertText('Item: 1Item: 2Item: 3Item: 4Item: 5');
this.assertRegisteredViews('intial render');
var initialHooks = function (count) {
var ret = [['an-item', 'init'], ['an-item', 'didInitAttrs'], ['an-item', 'didReceiveAttrs'], ['an-item', 'on(init)']];
if (_this7.isInteractive) {
ret.push(['an-item', 'willRender'], ['an-item', 'willInsertElement']);
}
ret.push(['nested-item', 'init'], ['nested-item', 'didInitAttrs'], ['nested-item', 'didReceiveAttrs'], ['nested-item', 'on(init)']);
if (_this7.isInteractive) {
ret.push(['nested-item', 'willRender'], ['nested-item', 'willInsertElement']);
}
return ret;
};
var initialAfterRenderHooks = function (count) {
if (_this7.isInteractive) {
return [['nested-item', 'didInsertElement'], ['nested-item', 'didRender'], ['an-item', 'didInsertElement'], ['an-item', 'didRender']];
} else {
return [];
}
};
this.assertHooks({
label: 'after initial render',
interactive: [].concat(initialHooks(1), initialHooks(2), initialHooks(3), initialHooks(4), initialHooks(5), initialAfterRenderHooks(5), initialAfterRenderHooks(4), initialAfterRenderHooks(3), initialAfterRenderHooks(2), initialAfterRenderHooks(1)),
nonInteractive: [].concat(initialHooks(1), initialHooks(2), initialHooks(3), initialHooks(4), initialHooks(5), initialAfterRenderHooks(5), initialAfterRenderHooks(4), initialAfterRenderHooks(3), initialAfterRenderHooks(2), initialAfterRenderHooks(1))
});
// TODO: Is this correct? Should childViews be populated in non-interactive mode?
if (this.isInteractive) {
this.assert.equal(this.component.childViews.length, 5, 'childViews precond');
}
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'items', []);
});
// TODO: Is this correct? Should childViews be populated in non-interactive mode?
if (this.isInteractive) {
this.assert.equal(this.component.childViews.length, 1, 'childViews updated');
}
this.assertText('Nothing to see here');
this.assertHooks({
label: 'reset to empty array',
interactive: [['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['an-item', 'willDestroyElement'], ['an-item', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['no-items', 'init'], ['no-items', 'didInitAttrs'], ['no-items', 'didReceiveAttrs'], ['no-items', 'on(init)'], ['no-items', 'willRender'], ['no-items', 'willInsertElement'], ['nested-item', 'init'], ['nested-item', 'didInitAttrs'], ['nested-item', 'didReceiveAttrs'], ['nested-item', 'on(init)'], ['nested-item', 'willRender'], ['nested-item', 'willInsertElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['an-item', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['nested-item', 'didInsertElement'], ['nested-item', 'didRender'], ['no-items', 'didInsertElement'], ['no-items', 'didRender'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy']],
nonInteractive: [['no-items', 'init'], ['no-items', 'didInitAttrs'], ['no-items', 'didReceiveAttrs'], ['no-items', 'on(init)'], ['nested-item', 'init'], ['nested-item', 'didInitAttrs'], ['nested-item', 'didReceiveAttrs'], ['nested-item', 'on(init)'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy'], ['an-item', 'willDestroy'], ['nested-item', 'willDestroy']]
});
this.teardownAssertions.push(function () {
_this7.assertHooks({
label: 'destroy',
interactive: [['no-items', 'willDestroyElement'], ['no-items', 'willClearRender'], ['nested-item', 'willDestroyElement'], ['nested-item', 'willClearRender'], ['no-items', 'didDestroyElement'], ['nested-item', 'didDestroyElement'], ['no-items', 'willDestroy'], ['nested-item', 'willDestroy']],
nonInteractive: [['no-items', 'willDestroy'], ['nested-item', 'willDestroy']]
});
_this7.assertRegisteredViews('after destroy');
});
};
(0, _emberBabel.createClass)(LifeCycleHooksTest, [{
key: 'isInteractive',
get: function () {
return true;
}
}, {
key: 'ComponentClass',
get: function () {
throw new Error('Not implemented: `ComponentClass`');
}
}, {
key: 'boundHelpers',
get: function () {
return {
invoke: bind(this.invocationFor, this),
attr: bind(this.attrFor, this)
};
}
}]);
return LifeCycleHooksTest;
}(_testCase.RenderingTest);
var CurlyComponentsTest = function (_LifeCycleHooksTest) {
(0, _emberBabel.inherits)(CurlyComponentsTest, _LifeCycleHooksTest);
function CurlyComponentsTest() {
(0, _emberBabel.classCallCheck)(this, CurlyComponentsTest);
return (0, _emberBabel.possibleConstructorReturn)(this, _LifeCycleHooksTest.apply(this, arguments));
}
CurlyComponentsTest.prototype.invocationFor = function invocationFor(name) {
var _this9 = this;
var namedArgs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var attrs = Object.keys(namedArgs).map(function (k) {
return k + '=' + _this9.val(namedArgs[k]);
}).join(' ');
return '{{' + name + ' ' + attrs + '}}';
};
CurlyComponentsTest.prototype.attrFor = function attrFor(name) {
return '' + name;
};
CurlyComponentsTest.prototype.val = function val(value) {
if (value.isString) {
return JSON.stringify(value.value);
} else if (value.isExpr) {
return '(readonly ' + value.value + ')';
} else {
throw new Error('Unknown value: ' + value);
}
};
(0, _emberBabel.createClass)(CurlyComponentsTest, [{
key: 'ComponentClass',
get: function () {
return _helpers.Component;
}
}]);
return CurlyComponentsTest;
}(LifeCycleHooksTest);
(0, _testCase.moduleFor)('Components test: interactive lifecycle hooks (curly components)', function (_CurlyComponentsTest) {
(0, _emberBabel.inherits)(_class, _CurlyComponentsTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _CurlyComponentsTest.apply(this, arguments));
}
(0, _emberBabel.createClass)(_class, [{
key: 'isInteractive',
get: function () {
return true;
}
}]);
return _class;
}(CurlyComponentsTest));
(0, _testCase.moduleFor)('Components test: non-interactive lifecycle hooks (curly components)', function (_CurlyComponentsTest2) {
(0, _emberBabel.inherits)(_class2, _CurlyComponentsTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _CurlyComponentsTest2.apply(this, arguments));
}
(0, _emberBabel.createClass)(_class2, [{
key: 'isInteractive',
get: function () {
return false;
}
}]);
return _class2;
}(CurlyComponentsTest));
(0, _testCase.moduleFor)('Components test: interactive lifecycle hooks (tagless curly components)', function (_CurlyComponentsTest3) {
(0, _emberBabel.inherits)(_class3, _CurlyComponentsTest3);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
return (0, _emberBabel.possibleConstructorReturn)(this, _CurlyComponentsTest3.apply(this, arguments));
}
(0, _emberBabel.createClass)(_class3, [{
key: 'ComponentClass',
get: function () {
return _helpers.Component.extend({ tagName: '' });
}
}, {
key: 'isInteractive',
get: function () {
return true;
}
}]);
return _class3;
}(CurlyComponentsTest));
(0, _testCase.moduleFor)('Components test: non-interactive lifecycle hooks (tagless curly components)', function (_CurlyComponentsTest4) {
(0, _emberBabel.inherits)(_class4, _CurlyComponentsTest4);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
return (0, _emberBabel.possibleConstructorReturn)(this, _CurlyComponentsTest4.apply(this, arguments));
}
(0, _emberBabel.createClass)(_class4, [{
key: 'ComponentClass',
get: function () {
return _helpers.Component.extend({ tagName: '' });
}
}, {
key: 'isInteractive',
get: function () {
return false;
}
}]);
return _class4;
}(CurlyComponentsTest));
(0, _testCase.moduleFor)('Run loop and lifecycle hooks', function (_RenderingTest2) {
(0, _emberBabel.inherits)(_class5, _RenderingTest2);
function _class5() {
(0, _emberBabel.classCallCheck)(this, _class5);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest2.apply(this, arguments));
}
_class5.prototype['@test afterRender set'] = function testAfterRenderSet() {
var _this16 = this;
var ComponentClass = _helpers.Component.extend({
width: '5',
didInsertElement: function () {
var _this15 = this;
_emberMetal.run.schedule('afterRender', function () {
_this15.set('width', '10');
});
}
});
var template = '{{width}}';
this.registerComponent('foo-bar', { ComponentClass: ComponentClass, template: template });
this.render('{{foo-bar}}');
this.assertText('10');
this.runTask(function () {
return _this16.rerender();
});
this.assertText('10');
};
_class5.prototype['@test afterRender set on parent'] = function testAfterRenderSetOnParent() {
var _this18 = this;
var ComponentClass = _helpers.Component.extend({
didInsertElement: function () {
var _this17 = this;
_emberMetal.run.schedule('afterRender', function () {
var parent = _this17.get('parent');
parent.set('foo', 'wat');
});
}
});
var template = '{{foo}}';
this.registerComponent('foo-bar', { ComponentClass: ComponentClass, template: template });
this.render('{{foo-bar parent=this foo=foo}}');
this.assertText('wat');
this.runTask(function () {
return _this18.rerender();
});
this.assertText('wat');
};
_class5.prototype['@test `willRender` can set before render (GH#14458)'] = function testWillRenderCanSetBeforeRenderGH14458(assert) {
var ComponentClass = _helpers.Component.extend({
tagName: 'a',
customHref: 'http://google.com',
attributeBindings: ['customHref:href'],
willRender: function () {
this.set('customHref', 'http://willRender.com');
}
});
var template = 'Hello World';
this.registerComponent('foo-bar', { ComponentClass: ComponentClass, template: template });
this.render('{{foo-bar id="foo"}}');
this.assertElement(this.firstChild, {
tagName: 'a',
attrs: {
id: 'foo',
href: 'http://willRender.com',
class: (0, _testHelpers.classes)('ember-view')
}
});
};
_class5.prototype['@test that thing about destroying'] = function testThatThingAboutDestroying(assert) {
var _this19 = this;
var ParentDestroyedElements = [];
var ChildDestroyedElements = [];
var ParentComponent = _helpers.Component.extend({
willDestroyElement: function () {
ParentDestroyedElements.push({
id: this.itemId,
name: 'parent-component',
hasParent: !!this.element.parentNode,
nextSibling: !!this.element.nextSibling,
previousSibling: !!this.element.previousSibling
});
}
});
var PartentTemplate = (0, _abstractTestCase.strip)(_templateObject11);
var NestedComponent = _helpers.Component.extend({
willDestroyElement: function () {
ChildDestroyedElements.push({
id: this.nestedId,
name: 'nested-component',
hasParent: !!this.element.parentNode,
nextSibling: !!this.element.nextSibling,
previousSibling: !!this.element.previousSibling
});
}
});
var NestedTemplate = '{{yield}}';
this.registerComponent('parent-component', {
ComponentClass: ParentComponent,
template: PartentTemplate
});
this.registerComponent('nested-component', {
ComponentClass: NestedComponent,
template: NestedTemplate
});
var array = (0, _emberRuntime.A)([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]);
this.render((0, _abstractTestCase.strip)(_templateObject12), {
items: array,
model: { shouldShow: true }
});
this.assertText('1AB2AB3AB4AB5AB6AB7AB');
this.runTask(function () {
array.removeAt(2);
array.removeAt(2);
(0, _emberMetal.set)(_this19.context, 'model.shouldShow', false);
});
this.assertText('1AB2AB5AB');
assertDestroyHooks(assert, [].concat(ParentDestroyedElements), [{
id: 3,
hasParent: true,
nextSibling: true,
previousSibling: true
}, {
id: 4,
hasParent: true,
nextSibling: true,
previousSibling: true
}, {
id: 6,
hasParent: true,
nextSibling: true,
previousSibling: true
}, {
id: 7,
hasParent: true,
nextSibling: false,
previousSibling: true
}]);
assertDestroyHooks(assert, [].concat(ChildDestroyedElements), [{
id: '3-A',
hasParent: true,
nextSibling: true,
previousSibling: false
}, {
id: '3-B',
hasParent: true,
nextSibling: false,
previousSibling: true
}, {
id: '4-A',
hasParent: true,
nextSibling: true,
previousSibling: false
}, {
id: '4-B',
hasParent: true,
nextSibling: false,
previousSibling: true
}, {
id: '6-A',
hasParent: true,
nextSibling: true,
previousSibling: false
}, {
id: '6-B',
hasParent: true,
nextSibling: false,
previousSibling: true
}, {
id: '7-A',
hasParent: true,
nextSibling: true,
previousSibling: false
}, {
id: '7-B',
hasParent: true,
nextSibling: false,
previousSibling: true
}]);
};
_class5.prototype['@test lifecycle hooks have proper access to this.$()'] = function testLifecycleHooksHaveProperAccessToThis$(assert) {
assert.expect(6);
var component = void 0;
var FooBarComponent = _helpers.Component.extend({
tagName: 'div',
init: function () {
assert.notOk(this.$(), 'no access to element via this.$() on init() enter');
this._super.apply(this, arguments);
assert.notOk(this.$(), 'no access to element via this.$() after init() finished');
},
willInsertElement: function () {
component = this;
assert.ok(this.$(), 'willInsertElement has access to element via this.$()');
},
didInsertElement: function () {
assert.ok(this.$(), 'didInsertElement has access to element via this.$()');
},
willDestroyElement: function () {
assert.ok(this.$(), 'willDestroyElement has access to element via this.$()');
},
didDestroyElement: function () {
assert.notOk(this.$(), 'didDestroyElement does not have access to element via this.$()');
}
});
this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' });
var owner = this.owner;
var comp = owner.lookup('component:foo-bar');
(0, _internalTestHelpers.runAppend)(comp);
this.runTask(function () {
return (0, _emberUtils.tryInvoke)(component, 'destroy');
});
};
return _class5;
}(_testCase.RenderingTest));
function assertDestroyHooks(assert, _actual, _expected) {
_expected.forEach(function (expected, i) {
var name = expected.name;
assert.equal(expected.id, _actual[i].id, name + ' id is the same');
assert.equal(expected.hasParent, _actual[i].hasParent, name + ' has parent node');
assert.equal(expected.nextSibling, _actual[i].nextSibling, name + ' has next sibling node');
assert.equal(expected.previousSibling, _actual[i].previousSibling, name + ' has previous sibling node');
});
}
function bind(func, thisArg) {
return function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return func.apply(thisArg, args);
};
}
function string(value) {
return { isString: true, value: value };
}
function expr(value) {
return { isExpr: true, value: value };
}
function hook(name, hook) {
var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
attrs = _ref3.attrs,
oldAttrs = _ref3.oldAttrs,
newAttrs = _ref3.newAttrs;
return { name: name, hook: hook, args: { attrs: attrs, oldAttrs: oldAttrs, newAttrs: newAttrs } };
}
function json(serializable) {
return JSON.parse(JSON.stringify(serializable));
}
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/life-cycle-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/life-cycle-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/link-to-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-runtime', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-helpers'], function (_emberBabel, _testCase, _emberRuntime, _emberMetal, _helpers, _testHelpers) {
'use strict';
(0, _testCase.moduleFor)('Link-to component', function (_ApplicationTest) {
(0, _emberBabel.inherits)(_class, _ApplicationTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTest.apply(this, arguments));
}
_class.prototype.visitWithDeprecation = function visitWithDeprecation(path, deprecation) {
var _this2 = this;
var p = void 0;
expectDeprecation(function () {
p = _this2.visit(path);
}, deprecation);
return p;
};
_class.prototype['@test accessing `currentWhen` triggers a deprecation'] = function testAccessingCurrentWhenTriggersADeprecation(assert) {
var component = void 0;
this.addComponent('link-to', {
ComponentClass: _helpers.LinkComponent.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
}
})
});
this.addTemplate('application', '{{link-to \'Index\' \'index\'}}');
return this.visit('/').then(function () {
expectDeprecation(function () {
component.get('currentWhen');
}, /Usage of `currentWhen` is deprecated, use `current-when` instead/);
});
};
_class.prototype['@test should be able to be inserted in DOM when the router is not present'] = function testShouldBeAbleToBeInsertedInDOMWhenTheRouterIsNotPresent() {
var _this3 = this;
this.addTemplate('application', '{{#link-to \'index\'}}Go to Index{{/link-to}}');
return this.visit('/').then(function () {
_this3.assertText('Go to Index');
});
};
_class.prototype['@test re-renders when title changes'] = function testReRendersWhenTitleChanges() {
var _this4 = this;
var controller = void 0;
this.addTemplate('application', '{{link-to title routeName}}');
this.add('controller:application', _emberRuntime.Controller.extend({
init: function () {
this._super.apply(this, arguments);
controller = this;
},
title: 'foo',
routeName: 'index'
}));
return this.visit('/').then(function () {
_this4.assertText('foo');
_this4.runTask(function () {
return (0, _emberMetal.set)(controller, 'title', 'bar');
});
_this4.assertText('bar');
});
};
_class.prototype['@test escaped inline form (double curlies) escapes link title'] = function testEscapedInlineFormDoubleCurliesEscapesLinkTitle() {
var _this5 = this;
this.addTemplate('application', '{{link-to title \'index\'}}');
this.add('controller:application', _emberRuntime.Controller.extend({
title: '<b>blah</b>'
}));
return this.visit('/').then(function () {
_this5.assertText('<b>blah</b>');
});
};
_class.prototype['@test escaped inline form with (-html-safe) does not escape link title'] = function testEscapedInlineFormWithHtmlSafeDoesNotEscapeLinkTitle(assert) {
var _this6 = this;
this.addTemplate('application', '{{link-to (-html-safe title) \'index\'}}');
this.add('controller:application', _emberRuntime.Controller.extend({
title: '<b>blah</b>'
}));
return this.visit('/').then(function () {
_this6.assertText('blah');
assert.equal(_this6.$('b').length, 1);
});
};
_class.prototype['@test unescaped inline form (triple curlies) does not escape link title'] = function testUnescapedInlineFormTripleCurliesDoesNotEscapeLinkTitle(assert) {
var _this7 = this;
this.addTemplate('application', '{{{link-to title \'index\'}}}');
this.add('controller:application', _emberRuntime.Controller.extend({
title: '<b>blah</b>'
}));
return this.visit('/').then(function () {
_this7.assertText('blah');
assert.equal(_this7.$('b').length, 1);
});
};
_class.prototype['@test unwraps controllers'] = function testUnwrapsControllers() {
var _this8 = this;
this.router.map(function () {
this.route('profile', { path: '/profile/:id' });
});
this.addTemplate('application', '{{#link-to \'profile\' otherController}}Text{{/link-to}}');
this.add('controller:application', _emberRuntime.Controller.extend({
otherController: _emberRuntime.Controller.create({
model: 'foo'
})
}));
var deprecation = /Providing `{{link-to}}` with a param that is wrapped in a controller is deprecated./;
return this.visitWithDeprecation('/', deprecation).then(function () {
_this8.assertText('Text');
});
};
_class.prototype['@test able to safely extend the built-in component and use the normal path'] = function testAbleToSafelyExtendTheBuiltInComponentAndUseTheNormalPath() {
var _this9 = this;
this.addComponent('custom-link-to', { ComponentClass: _helpers.LinkComponent.extend() });
this.addTemplate('application', '{{#custom-link-to \'index\'}}{{title}}{{/custom-link-to}}');
this.add('controller:application', _emberRuntime.Controller.extend({
title: 'Hello'
}));
return this.visit('/').then(function () {
_this9.assertText('Hello');
});
};
_class.prototype['@test [GH#13432] able to safely extend the built-in component and invoke it inline'] = function testGH13432AbleToSafelyExtendTheBuiltInComponentAndInvokeItInline() {
var _this10 = this;
this.addComponent('custom-link-to', { ComponentClass: _helpers.LinkComponent.extend() });
this.addTemplate('application', '{{custom-link-to title \'index\'}}');
this.add('controller:application', _emberRuntime.Controller.extend({
title: 'Hello'
}));
return this.visit('/').then(function () {
_this10.assertText('Hello');
});
};
return _class;
}(_testCase.ApplicationTest));
(0, _testCase.moduleFor)('Link-to component with query-params', function (_ApplicationTest2) {
(0, _emberBabel.inherits)(_class2, _ApplicationTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
var _this11 = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTest2.apply(this, arguments));
_this11.add('controller:index', _emberRuntime.Controller.extend({
queryParams: ['foo'],
foo: '123',
bar: 'yes'
}));
return _this11;
}
_class2.prototype['@test populates href with fully supplied query param values'] = function testPopulatesHrefWithFullySuppliedQueryParamValues(assert) {
var _this12 = this;
this.addTemplate('index', '{{#link-to \'index\' (query-params foo=\'456\' bar=\'NAW\')}}Index{{/link-to}}');
return this.visit('/').then(function () {
_this12.assertComponentElement(_this12.firstChild.firstElementChild, {
tagName: 'a',
attrs: { href: '/?bar=NAW&foo=456' },
content: 'Index'
});
});
};
_class2.prototype['@test populates href with partially supplied query param values, but omits if value is default value'] = function testPopulatesHrefWithPartiallySuppliedQueryParamValuesButOmitsIfValueIsDefaultValue() {
var _this13 = this;
this.addTemplate('index', '{{#link-to \'index\' (query-params foo=\'123\')}}Index{{/link-to}}');
return this.visit('/').then(function () {
_this13.assertComponentElement(_this13.firstChild.firstElementChild, {
tagName: 'a',
attrs: { href: '/', class: (0, _testHelpers.classes)('ember-view active') },
content: 'Index'
});
});
};
return _class2;
}(_testCase.ApplicationTest));
(0, _testCase.moduleFor)('Link-to component', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class3, _RenderingTest);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.apply(this, arguments));
}
_class3.prototype['@test should be able to be inserted in DOM when the router is not present - block'] = function testShouldBeAbleToBeInsertedInDOMWhenTheRouterIsNotPresentBlock() {
this.render('{{#link-to \'index\'}}Go to Index{{/link-to}}');
this.assertText('Go to Index');
};
_class3.prototype['@test should be able to be inserted in DOM when the router is not present - inline'] = function testShouldBeAbleToBeInsertedInDOMWhenTheRouterIsNotPresentInline() {
this.render('{{link-to \'Go to Index\' \'index\'}}');
this.assertText('Go to Index');
};
return _class3;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/link-to-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/link-to-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/local-lookup-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'internal-test-helpers', 'ember-glimmer/tests/utils/helpers', 'ember/features', 'ember-glimmer'], function (_emberBabel, _testCase, _internalTestHelpers, _helpers, _features, _emberGlimmer) {
'use strict';
var LocalLookupTest = function (_RenderingTest) {
(0, _emberBabel.inherits)(LocalLookupTest, _RenderingTest);
function LocalLookupTest() {
(0, _emberBabel.classCallCheck)(this, LocalLookupTest);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.apply(this, arguments));
}
LocalLookupTest.prototype['@test it can lookup a local template'] = function testItCanLookupALocalTemplate() {
var _this2 = this;
this.registerComponent('x-outer/x-inner', { template: 'Nested template says: {{yield}}' });
this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' });
this.render('{{x-outer}}');
this.assertText('Nested template says: Hi!', 'Initial render works');
this.runTask(function () {
return _this2.rerender();
});
this.assertText('Nested template says: Hi!', 'Re-render works');
};
LocalLookupTest.prototype['@test tagless blockless component can lookup local template'] = function testTaglessBlocklessComponentCanLookupLocalTemplate() {
var _this3 = this;
this.registerComponent('x-outer/x-inner', { template: 'Nested template says: {{yield}}' });
this.registerTemplate('components/x-outer', '{{#x-inner}}Hi!{{/x-inner}}');
this.registerComponent('x-outer', {
ComponentClass: _helpers.Component.extend({ tagName: '' })
});
this.render('{{x-outer}}');
this.assertText('Nested template says: Hi!', 'Re-render works');
this.runTask(function () {
return _this3.rerender();
});
this.assertText('Nested template says: Hi!', 'Re-render works');
};
LocalLookupTest.prototype['@test it can lookup a local component template'] = function testItCanLookupALocalComponentTemplate() {
var _this4 = this;
this.registerTemplate('components/x-outer/x-inner', 'Nested template says: {{yield}}');
this.registerTemplate('components/x-outer', '{{#x-inner}}Hi!{{/x-inner}}');
this.render('{{x-outer}}');
this.assertText('Nested template says: Hi!', 'Initial render works');
this.runTask(function () {
return _this4.rerender();
});
this.assertText('Nested template says: Hi!', 'Re-render works');
};
LocalLookupTest.prototype['@test it can local lookup a dynamic component'] = function testItCanLocalLookupADynamicComponent() {
var _this5 = this;
this.registerComponent('foo-bar', { template: 'yall finished {{component child}}' });
this.registerComponent('foo-bar/biz-baz', { template: 'or yall done?' });
this.render('{{foo-bar child=child}}', { child: 'biz-baz' });
this.assertText('yall finished or yall done?');
this.runTask(function () {
return _this5.rerender();
});
this.assertText('yall finished or yall done?');
};
LocalLookupTest.prototype['@test it can local lookup a dynamic component from a dynamic component'] = function testItCanLocalLookupADynamicComponentFromADynamicComponent() {
var _this6 = this;
this.registerComponent('foo-bar', { template: 'yall finished {{component child}}' });
this.registerComponent('foo-bar/biz-baz', { template: 'or yall done?' });
this.render('{{component componentName child=child}}', { componentName: 'foo-bar', child: 'biz-baz' });
this.assertText('yall finished or yall done?');
this.runTask(function () {
return _this6.rerender();
});
this.assertText('yall finished or yall done?');
};
LocalLookupTest.prototype['@test it can local lookup a dynamic component from a passed named argument'] = function testItCanLocalLookupADynamicComponentFromAPassedNamedArgument() {
var _this7 = this;
this.registerComponent('parent-foo', { template: 'yall finished {{global-biz baz=(component \'local-bar\')}}' });
this.registerComponent('global-biz', { template: 'or {{component baz}}' });
this.registerComponent('parent-foo/local-bar', { template: 'yall done?' });
this.render('{{parent-foo}}');
this.assertText('yall finished or yall done?');
this.runTask(function () {
return _this7.rerender();
});
this.assertText('yall finished or yall done?');
};
LocalLookupTest.prototype['@test it can local lookup a re-wrapped dynamic component from a passed named argument'] = function testItCanLocalLookupAReWrappedDynamicComponentFromAPassedNamedArgument() {
var _this8 = this;
this.registerComponent('parent-foo', { template: 'yall finished {{global-x comp=(component \'local-bar\')}}' });
this.registerComponent('global-x', { template: 'or {{global-y comp=(component comp phrase=\'done\')}}' });
this.registerComponent('global-y', { template: '{{component comp}}?' });
this.registerComponent('parent-foo/local-bar', { template: 'yall {{phrase}}' });
this.render('{{parent-foo}}');
this.assertText('yall finished or yall done?');
this.runTask(function () {
return _this8.rerender();
});
this.assertText('yall finished or yall done?');
};
LocalLookupTest.prototype['@test it can nest local lookups of dynamic components from a passed named argument'] = function testItCanNestLocalLookupsOfDynamicComponentsFromAPassedNamedArgument() {
var _this9 = this;
this.registerComponent('parent-foo', { template: 'yall finished {{global-x comp=(component \'local-bar\')}}' });
this.registerComponent('global-x', { template: 'or {{global-y comp=(component comp phrase=\'done\')}}' });
this.registerComponent('global-y', { template: '{{component comp}}{{component \'local-bar\'}}' });
this.registerComponent('parent-foo/local-bar', { template: 'yall {{phrase}}' });
this.registerComponent('global-y/local-bar', { template: '?' });
this.render('{{parent-foo}}');
this.assertText('yall finished or yall done?');
this.runTask(function () {
return _this9.rerender();
});
this.assertText('yall finished or yall done?');
};
LocalLookupTest.prototype['@test it can switch from local to global lookups of dynamic components from a passed named argument'] = function testItCanSwitchFromLocalToGlobalLookupsOfDynamicComponentsFromAPassedNamedArgument() {
var _this10 = this;
this.registerComponent('parent-foo', { template: 'yall finished {{global-x comp=(component bar)}}' });
this.registerComponent('global-x', { template: 'or yall {{component comp}}' });
this.registerComponent('parent-foo/local-bar', { template: 'done?' });
this.registerComponent('global-bar', { template: 'ready?' });
this.render('{{parent-foo bar=bar}}', { bar: 'local-bar' });
this.assertText('yall finished or yall done?');
this.runTask(function () {
return _this10.context.set('bar', 'global-bar');
});
this.runTask(function () {
return _this10.rerender();
});
this.assertText('yall finished or yall ready?');
};
LocalLookupTest.prototype['@test it can lookup a local helper'] = function testItCanLookupALocalHelper() {
var _this11 = this;
this.registerHelper('x-outer/x-helper', function () {
return 'Who dis?';
});
this.registerComponent('x-outer', { template: 'Who dat? {{x-helper}}' });
this.render('{{x-outer}}');
this.assertText('Who dat? Who dis?', 'Initial render works');
this.runTask(function () {
return _this11.rerender();
});
this.assertText('Who dat? Who dis?', 'Re-render works');
};
LocalLookupTest.prototype['@test it overrides global helper lookup'] = function testItOverridesGlobalHelperLookup() {
var _this12 = this;
this.registerHelper('x-outer/x-helper', function () {
return 'Who dis?';
});
this.registerHelper('x-helper', function () {
return 'I dunno';
});
this.registerComponent('x-outer', { template: 'Who dat? {{x-helper}}' });
this.render('{{x-outer}} {{x-helper}}');
this.assertText('Who dat? Who dis? I dunno', 'Initial render works');
this.runTask(function () {
return _this12.rerender();
});
this.assertText('Who dat? Who dis? I dunno', 'Re-render works');
};
LocalLookupTest.prototype['@test lookup without match issues standard assertion (with local helper name)'] = function testLookupWithoutMatchIssuesStandardAssertionWithLocalHelperName() {
var _this13 = this;
this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' });
expectAssertion(function () {
_this13.render('{{x-outer}}');
}, /A component or helper named "x-inner" could not be found/);
};
LocalLookupTest.prototype['@test overrides global lookup'] = function testOverridesGlobalLookup() {
var _this14 = this;
this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' });
this.registerComponent('x-outer/x-inner', { template: 'Nested template says (from local): {{yield}}' });
this.registerComponent('x-inner', { template: 'Nested template says (from global): {{yield}}' });
this.render('{{#x-inner}}Hi!{{/x-inner}} {{x-outer}} {{#x-outer/x-inner}}Hi!{{/x-outer/x-inner}}');
this.assertText('Nested template says (from global): Hi! Nested template says (from local): Hi! Nested template says (from local): Hi!');
this.runTask(function () {
return _this14.rerender();
});
this.assertText('Nested template says (from global): Hi! Nested template says (from local): Hi! Nested template says (from local): Hi!');
};
return LocalLookupTest;
}(_testCase.RenderingTest);
// first run these tests with expandLocalLookup
function buildResolver() {
var resolver = {
resolve: function () {},
expandLocalLookup: function (fullName, sourceFullName) {
var _sourceFullName$split = sourceFullName.split(':'),
sourceType = _sourceFullName$split[0],
sourceName = _sourceFullName$split[1];
var _fullName$split = fullName.split(':'),
type = _fullName$split[0],
name = _fullName$split[1];
if (type !== 'template' && sourceType === 'template' && sourceName.slice(0, 11) === 'components/') {
sourceName = sourceName.slice(11);
}
if (type === 'template' && sourceType === 'template' && name.slice(0, 11) === 'components/') {
name = name.slice(11);
}
var result = type + ':' + sourceName + '/' + name;
return result;
}
};
return resolver;
}
(0, _testCase.moduleFor)('Components test: local lookup with expandLocalLookup feature', function (_LocalLookupTest) {
(0, _emberBabel.inherits)(_class, _LocalLookupTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _LocalLookupTest.apply(this, arguments));
}
_class.prototype.getResolver = function getResolver() {
return buildResolver();
};
return _class;
}(LocalLookupTest));
if (_features.EMBER_MODULE_UNIFICATION) {
var LocalLookupTestResolver = function (_ModuleBasedTestResol) {
(0, _emberBabel.inherits)(LocalLookupTestResolver, _ModuleBasedTestResol);
function LocalLookupTestResolver() {
(0, _emberBabel.classCallCheck)(this, LocalLookupTestResolver);
return (0, _emberBabel.possibleConstructorReturn)(this, _ModuleBasedTestResol.apply(this, arguments));
}
LocalLookupTestResolver.prototype.resolve = function resolve(specifier, referrer) {
var fullSpecifier = specifier;
if (referrer) {
var namespace = referrer.split('template:components/')[1];
if (specifier.indexOf('template:components/') !== -1) {
var name = specifier.split('template:components/')[1];
fullSpecifier = 'template:components/' + namespace + '/' + name;
} else if (specifier.indexOf(':') !== -1) {
var _specifier$split = specifier.split(':'),
type = _specifier$split[0],
_name = _specifier$split[1];
fullSpecifier = type + ':' + namespace + '/' + _name;
}
}
return _ModuleBasedTestResol.prototype.resolve.call(this, fullSpecifier);
};
return LocalLookupTestResolver;
}(_internalTestHelpers.ModuleBasedTestResolver);
/*
* This sub-classing changes `registerXXX` methods to use the resolver.
* Required for testing the module unification-friendly `resolve` call
* with a `referrer` argument.
*
* In theory all these tests can be ported to use the resolver instead of
* the registry.
*/
(0, _testCase.moduleFor)('Components test: local lookup with resolution referrer', function (_LocalLookupTest2) {
(0, _emberBabel.inherits)(_class2, _LocalLookupTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _LocalLookupTest2.apply(this, arguments));
}
_class2.prototype.getResolver = function getResolver() {
return new LocalLookupTestResolver();
};
_class2.prototype.registerComponent = function registerComponent(name, _ref) {
var _ref$ComponentClass = _ref.ComponentClass,
ComponentClass = _ref$ComponentClass === undefined ? null : _ref$ComponentClass,
_ref$template = _ref.template,
template = _ref$template === undefined ? null : _ref$template;
var resolver = this.resolver;
if (ComponentClass) {
resolver.add('component:' + name, ComponentClass);
}
if (typeof template === 'string') {
resolver.add('template:components/' + name, this.compile(template, {
moduleName: 'components/' + name
}));
}
};
_class2.prototype.registerTemplate = function registerTemplate(name, template) {
var resolver = this.resolver;
if (typeof template === 'string') {
resolver.add('template:' + name, this.compile(template, {
moduleName: name
}));
} else {
throw new Error('Registered template "' + name + '" must be a string');
}
};
_class2.prototype.registerHelper = function registerHelper(name, funcOrClassBody) {
var resolver = this.resolver;
var type = typeof funcOrClassBody;
if (type === 'function') {
resolver.add('helper:' + name, (0, _emberGlimmer.helper)(funcOrClassBody));
} else if (type === 'object' && type !== null) {
resolver.add('helper:' + name, _emberGlimmer.Helper.extend(funcOrClassBody));
} else {
throw new Error('Cannot register ' + funcOrClassBody + ' as a helper');
}
};
(0, _emberBabel.createClass)(_class2, [{
key: 'resolver',
get: function () {
return this.owner.__registry__.fallback.resolver;
}
}]);
return _class2;
}(LocalLookupTest));
}
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/local-lookup-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/local-lookup-test.js should pass ESLint\n\n');
});
enifed("ember-glimmer/tests/integration/components/render-to-element-test", [], function () {
"use strict";
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/render-to-element-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/render-to-element-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/target-action-test', ['ember-babel', 'ember-utils', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-runtime', 'ember-routing'], function (_emberBabel, _emberUtils, _testCase, _abstractTestCase, _emberMetal, _helpers, _emberRuntime, _emberRouting) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#component-a}}\n {{component-b bar="derp"}}\n {{/component-a}}\n '], ['\n {{#component-a}}\n {{component-b bar="derp"}}\n {{/component-a}}\n ']);
(0, _testCase.moduleFor)('Components test: sendAction', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class, _RenderingTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.call(this));
_this.actionCounts = {};
_this.sendCount = 0;
_this.actionArguments = null;
var self = _this;
_this.registerComponent('action-delegate', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super();
self.delegate = this;
this.name = 'action-delegate';
}
})
});
return _this;
}
_class.prototype.renderDelegate = function renderDelegate() {
var template = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '{{action-delegate}}';
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var root = this;
context = (0, _emberUtils.assign)(context, {
send: function (actionName) {
root.sendCount++;
root.actionCounts[actionName] = root.actionCounts[actionName] || 0;
root.actionCounts[actionName]++;
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
root.actionArguments = args;
}
});
this.render(template, context);
};
_class.prototype.assertSendCount = function assertSendCount(count) {
this.assert.equal(this.sendCount, count, 'Send was called ' + count + ' time(s)');
};
_class.prototype.assertNamedSendCount = function assertNamedSendCount(actionName, count) {
this.assert.equal(this.actionCounts[actionName], count, 'An action named \'' + actionName + '\' was sent ' + count + ' times');
};
_class.prototype.assertSentWithArgs = function assertSentWithArgs(expected) {
var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'arguments were sent with the action';
this.assert.deepEqual(this.actionArguments, expected, message);
};
_class.prototype['@test Calling sendAction on a component without an action defined does nothing'] = function testCallingSendActionOnAComponentWithoutAnActionDefinedDoesNothing() {
var _this2 = this;
this.renderDelegate();
this.runTask(function () {
return _this2.delegate.sendAction();
});
this.assertSendCount(0);
};
_class.prototype['@test Calling sendAction on a component with an action defined calls send on the controller'] = function testCallingSendActionOnAComponentWithAnActionDefinedCallsSendOnTheController() {
var _this3 = this;
this.renderDelegate();
this.runTask(function () {
(0, _emberMetal.set)(_this3.delegate, 'action', 'addItem');
_this3.delegate.sendAction();
});
this.assertSendCount(1);
this.assertNamedSendCount('addItem', 1);
};
_class.prototype['@test Calling sendAction on a component with a function calls the function'] = function testCallingSendActionOnAComponentWithAFunctionCallsTheFunction() {
var _this4 = this;
this.assert.expect(1);
this.renderDelegate();
this.runTask(function () {
(0, _emberMetal.set)(_this4.delegate, 'action', function () {
return _this4.assert.ok(true, 'function is called');
});
_this4.delegate.sendAction();
});
};
_class.prototype['@test Calling sendAction on a component with a function calls the function with arguments'] = function testCallingSendActionOnAComponentWithAFunctionCallsTheFunctionWithArguments() {
var _this5 = this;
this.assert.expect(1);
var argument = {};
this.renderDelegate();
this.runTask(function () {
(0, _emberMetal.set)(_this5.delegate, 'action', function (actualArgument) {
_this5.assert.deepEqual(argument, actualArgument, 'argument is passed');
});
_this5.delegate.sendAction('action', argument);
});
};
_class.prototype['@test Calling sendAction on a component with a reference attr calls the function with arguments'] = function testCallingSendActionOnAComponentWithAReferenceAttrCallsTheFunctionWithArguments() {
var _this6 = this;
this.renderDelegate('{{action-delegate playing=playing}}', {
playing: null
});
this.runTask(function () {
return _this6.delegate.sendAction();
});
this.assertSendCount(0);
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'playing', 'didStartPlaying');
});
this.runTask(function () {
_this6.delegate.sendAction('playing');
});
this.assertSendCount(1);
this.assertNamedSendCount('didStartPlaying', 1);
};
_class.prototype['@test Calling sendAction on a component with a {{mut}} attr calls the function with arguments'] = function testCallingSendActionOnAComponentWithAMutAttrCallsTheFunctionWithArguments() {
var _this7 = this;
this.renderDelegate('{{action-delegate playing=(mut playing)}}', {
playing: null
});
this.runTask(function () {
return _this7.delegate.sendAction('playing');
});
this.assertSendCount(0);
this.runTask(function () {
return _this7.delegate.attrs.playing.update('didStartPlaying');
});
this.runTask(function () {
return _this7.delegate.sendAction('playing');
});
this.assertSendCount(1);
this.assertNamedSendCount('didStartPlaying', 1);
};
_class.prototype['@test Calling sendAction with a named action uses the component\'s property as the action name'] = function testCallingSendActionWithANamedActionUsesTheComponentSPropertyAsTheActionName() {
var _this8 = this;
this.renderDelegate();
var component = this.delegate;
this.runTask(function () {
(0, _emberMetal.set)(_this8.delegate, 'playing', 'didStartPlaying');
component.sendAction('playing');
});
this.assertSendCount(1);
this.assertNamedSendCount('didStartPlaying', 1);
this.runTask(function () {
return component.sendAction('playing');
});
this.assertSendCount(2);
this.assertNamedSendCount('didStartPlaying', 2);
this.runTask(function () {
(0, _emberMetal.set)(component, 'action', 'didDoSomeBusiness');
component.sendAction();
});
this.assertSendCount(3);
this.assertNamedSendCount('didDoSomeBusiness', 1);
};
_class.prototype['@test Calling sendAction when the action name is not a string raises an exception'] = function testCallingSendActionWhenTheActionNameIsNotAStringRaisesAnException() {
var _this9 = this;
this.renderDelegate();
this.runTask(function () {
(0, _emberMetal.set)(_this9.delegate, 'action', {});
(0, _emberMetal.set)(_this9.delegate, 'playing', {});
});
expectAssertion(function () {
return _this9.delegate.sendAction();
});
expectAssertion(function () {
return _this9.delegate.sendAction('playing');
});
};
_class.prototype['@test Calling sendAction on a component with contexts'] = function testCallingSendActionOnAComponentWithContexts() {
var _this10 = this;
this.renderDelegate();
var testContext = { song: 'She Broke My Ember' };
var firstContext = { song: 'She Broke My Ember' };
var secondContext = { song: 'My Achey Breaky Ember' };
this.runTask(function () {
(0, _emberMetal.set)(_this10.delegate, 'playing', 'didStartPlaying');
_this10.delegate.sendAction('playing', testContext);
});
this.assertSendCount(1);
this.assertNamedSendCount('didStartPlaying', 1);
this.assertSentWithArgs([testContext], 'context was sent with the action');
this.runTask(function () {
_this10.delegate.sendAction('playing', firstContext, secondContext);
});
this.assertSendCount(2);
this.assertNamedSendCount('didStartPlaying', 2);
this.assertSentWithArgs([firstContext, secondContext], 'multiple contexts were sent to the action');
};
_class.prototype['@test calling sendAction on a component within a block sends to the outer scope GH#14216'] = function testCallingSendActionOnAComponentWithinABlockSendsToTheOuterScopeGH14216(assert) {
var testContext = this;
// overrides default action-delegate so actions can be added
this.registerComponent('action-delegate', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super();
testContext.delegate = this;
this.name = 'action-delegate';
},
actions: {
derp: function (arg1) {
assert.ok(true, 'action called on action-delgate');
assert.equal(arg1, 'something special', 'argument passed through properly');
}
}
}),
template: (0, _abstractTestCase.strip)(_templateObject)
});
this.registerComponent('component-a', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
this.name = 'component-a';
},
actions: {
derp: function () {
assert.ok(false, 'no! bad scoping!');
}
}
})
});
var innerChild = void 0;
this.registerComponent('component-b', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerChild = this;
this.name = 'component-b';
}
})
});
this.renderDelegate();
this.runTask(function () {
return innerChild.sendAction('bar', 'something special');
});
};
return _class;
}(_testCase.RenderingTest));
(0, _testCase.moduleFor)('Components test: sendAction to a controller', function (_ApplicationTest) {
(0, _emberBabel.inherits)(_class2, _ApplicationTest);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTest.apply(this, arguments));
}
_class2.prototype['@test sendAction should trigger an action on the parent component\'s controller if it exists'] = function testSendActionShouldTriggerAnActionOnTheParentComponentSControllerIfItExists(assert) {
var _this12 = this;
assert.expect(15);
var component = void 0;
this.router.map(function () {
this.route('a');
this.route('b');
this.route('c', function () {
this.route('d');
this.route('e');
});
});
this.addComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
}
}),
template: '{{val}}'
});
this.add('controller:a', _emberRuntime.Controller.extend({
send: function (actionName, actionContext) {
assert.equal(actionName, 'poke', 'send() method was invoked from a top level controller');
assert.equal(actionContext, 'top', 'action arguments were passed into the top level controller');
}
}));
this.addTemplate('a', '{{foo-bar val="a" poke="poke"}}');
this.add('route:b', _emberRouting.Route.extend({
actions: {
poke: function (actionContext) {
assert.ok(true, 'Unhandled action sent to route');
assert.equal(actionContext, 'top no controller');
}
}
}));
this.addTemplate('b', '{{foo-bar val="b" poke="poke"}}');
this.add('route:c', _emberRouting.Route.extend({
actions: {
poke: function (actionContext) {
assert.ok(true, 'Unhandled action sent to route');
assert.equal(actionContext, 'top with nested no controller');
}
}
}));
this.addTemplate('c', '{{foo-bar val="c" poke="poke"}}{{outlet}}');
this.add('route:c.d', _emberRouting.Route.extend({}));
this.add('controller:c.d', _emberRuntime.Controller.extend({
send: function (actionName, actionContext) {
assert.equal(actionName, 'poke', 'send() method was invoked from a nested controller');
assert.equal(actionContext, 'nested', 'action arguments were passed into the nested controller');
}
}));
this.addTemplate('c.d', '{{foo-bar val=".d" poke="poke"}}');
this.add('route:c.e', _emberRouting.Route.extend({
actions: {
poke: function (actionContext) {
assert.ok(true, 'Unhandled action sent to route');
assert.equal(actionContext, 'nested no controller');
}
}
}));
this.addTemplate('c.e', '{{foo-bar val=".e" poke="poke"}}');
return this.visit('/a').then(function () {
return component.sendAction('poke', 'top');
}).then(function () {
_this12.assertText('a');
return _this12.visit('/b');
}).then(function () {
return component.sendAction('poke', 'top no controller');
}).then(function () {
_this12.assertText('b');
return _this12.visit('/c');
}).then(function () {
return component.sendAction('poke', 'top with nested no controller');
}).then(function () {
_this12.assertText('c');
return _this12.visit('/c/d');
}).then(function () {
return component.sendAction('poke', 'nested');
}).then(function () {
_this12.assertText('c.d');
return _this12.visit('/c/e');
}).then(function () {
return component.sendAction('poke', 'nested no controller');
}).then(function () {
return _this12.assertText('c.e');
});
};
_class2.prototype['@test sendAction should not trigger an action in an outlet\'s controller if a parent component handles it'] = function testSendActionShouldNotTriggerAnActionInAnOutletSControllerIfAParentComponentHandlesIt(assert) {
assert.expect(1);
var component = void 0;
this.addComponent('x-parent', {
ComponentClass: _helpers.Component.extend({
actions: {
poke: function () {
assert.ok(true, 'parent component handled the aciton');
}
}
}),
template: '{{x-child poke="poke"}}'
});
this.addComponent('x-child', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
}
})
});
this.addTemplate('application', '{{x-parent}}');
this.add('controller:application', _emberRuntime.Controller.extend({
send: function (actionName) {
throw new Error('controller action should not be called');
}
}));
return this.visit('/').then(function () {
return component.sendAction('poke');
});
};
return _class2;
}(_testCase.ApplicationTest));
(0, _testCase.moduleFor)('Components test: sendAction of a closure action', function (_RenderingTest2) {
(0, _emberBabel.inherits)(_class3, _RenderingTest2);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest2.apply(this, arguments));
}
_class3.prototype['@test action should be called'] = function testActionShouldBeCalled(assert) {
assert.expect(1);
var component = void 0;
this.registerComponent('inner-component', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
}
}),
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: _helpers.Component.extend({
outerSubmit: function () {
assert.ok(true, 'outerSubmit called');
}
}),
template: '{{inner-component submitAction=(action outerSubmit)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
return component.sendAction('submitAction');
});
};
_class3.prototype['@test contexts passed to sendAction are appended to the bound arguments on a closure action'] = function testContextsPassedToSendActionAreAppendedToTheBoundArgumentsOnAClosureAction() {
var first = 'mitch';
var second = 'martin';
var third = 'matt';
var fourth = 'wacky wycats';
var innerComponent = void 0;
var actualArgs = void 0;
this.registerComponent('inner-component', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
}
}),
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: _helpers.Component.extend({
third: third,
actions: {
outerSubmit: function () {
actualArgs = [].concat(Array.prototype.slice.call(arguments));
}
}
}),
template: '{{inner-component innerSubmit=(action (action "outerSubmit" "' + first + '") "' + second + '" third)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
return innerComponent.sendAction('innerSubmit', fourth);
});
this.assert.deepEqual(actualArgs, [first, second, third, fourth], 'action has the correct args');
};
return _class3;
}(_testCase.RenderingTest));
(0, _testCase.moduleFor)('Components test: send', function (_RenderingTest3) {
(0, _emberBabel.inherits)(_class4, _RenderingTest3);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest3.apply(this, arguments));
}
_class4.prototype['@test sending to undefined actions triggers an error'] = function testSendingToUndefinedActionsTriggersAnError(assert) {
assert.expect(2);
var component = void 0;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super();
component = this;
},
actions: {
foo: function (message) {
assert.equal('bar', message);
}
}
})
});
this.render('{{foo-bar}}');
this.runTask(function () {
return component.send('foo', 'bar');
});
expectAssertion(function () {
return component.send('baz', 'bar');
}, /had no action handler for: baz/);
};
_class4.prototype['@test `send` will call send from a target if it is defined'] = function testSendWillCallSendFromATargetIfItIsDefined() {
var _this15 = this;
var component = void 0;
var target = {
send: function (message, payload) {
_this15.assert.equal('foo', message);
_this15.assert.equal('baz', payload);
}
};
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super();
component = this;
},
target: target
})
});
this.render('{{foo-bar}}');
this.runTask(function () {
return component.send('foo', 'baz');
});
};
_class4.prototype['@test a handled action can be bubbled to the target for continued processing'] = function testAHandledActionCanBeBubbledToTheTargetForContinuedProcessing() {
var _this16 = this;
this.assert.expect(2);
var component = void 0;
this.registerComponent('foo-bar', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
actions: {
poke: function () {
_this16.assert.ok(true, 'component action called');
return true;
}
},
target: _emberRuntime.Controller.extend({
actions: {
poke: function () {
_this16.assert.ok(true, 'action bubbled to controller');
}
}
}).create()
})
});
this.render('{{foo-bar poke="poke"}}');
this.runTask(function () {
return component.send('poke');
});
};
_class4.prototype['@test action can be handled by a superclass\' actions object'] = function testActionCanBeHandledByASuperclassActionsObject(assert) {
this.assert.expect(4);
var component = void 0;
var SuperComponent = _helpers.Component.extend({
actions: {
foo: function () {
assert.ok(true, 'foo');
},
bar: function (msg) {
assert.equal(msg, 'HELLO');
}
}
});
var BarViewMixin = _emberMetal.Mixin.create({
actions: {
bar: function (msg) {
assert.equal(msg, 'HELLO');
this._super(msg);
}
}
});
this.registerComponent('x-index', {
ComponentClass: SuperComponent.extend(BarViewMixin, {
init: function () {
this._super.apply(this, arguments);
component = this;
},
actions: {
baz: function () {
assert.ok(true, 'baz');
}
}
})
});
this.render('{{x-index}}');
this.runTask(function () {
component.send('foo');
component.send('bar', 'HELLO');
component.send('baz');
});
};
_class4.prototype['@test actions cannot be provided at create time'] = function testActionsCannotBeProvidedAtCreateTime(assert) {
expectAssertion(function () {
return _helpers.Component.create({
actions: {
foo: function () {
assert.ok(true, 'foo');
}
}
});
});
// but should be OK on an object that doesn't mix in Ember.ActionHandler
_emberRuntime.Object.create({
actions: ['foo']
});
};
return _class4;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/components/target-action-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/components/target-action-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/components/utils-test', ['ember-babel', 'ember-runtime', 'ember-views', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers'], function (_emberBabel, _emberRuntime, _emberViews, _testCase, _helpers) {
'use strict';
(0, _testCase.moduleFor)('View tree tests', function (_ApplicationTest) {
(0, _emberBabel.inherits)(_class, _ApplicationTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _ApplicationTest.call(this));
_this.addComponent('x-tagless', {
ComponentClass: _helpers.Component.extend({
tagName: ''
}),
template: '<div id="{{id}}">[{{id}}] {{#if isShowing}}{{yield}}{{/if}}</div>'
});
_this.addComponent('x-toggle', {
ComponentClass: _helpers.Component.extend({
isExpanded: true,
click: function () {
this.toggleProperty('isExpanded');
return false;
}
}),
template: '[{{id}}] {{#if isExpanded}}{{yield}}{{/if}}'
});
var ToggleController = _emberRuntime.Controller.extend({
isExpanded: true,
actions: {
toggle: function () {
this.toggleProperty('isExpanded');
}
}
});
_this.add('controller:application', ToggleController);
_this.addTemplate('application', '\n {{x-tagless id="root-1"}}\n\n {{#x-toggle id="root-2"}}\n {{x-toggle id="inner-1"}}\n\n {{#x-toggle id="inner-2"}}\n {{x-toggle id="inner-3"}}\n {{/x-toggle}}\n {{/x-toggle}}\n\n <button id="toggle-application" {{action "toggle"}}>Toggle</button>\n\n {{#if isExpanded}}\n {{x-toggle id="root-3"}}\n {{/if}}\n\n {{outlet}}\n ');
_this.add('controller:index', ToggleController.extend({
isExpanded: false
}));
_this.addTemplate('index', '\n {{x-tagless id="root-4"}}\n\n {{#x-toggle id="root-5" isExpanded=false}}\n {{x-toggle id="inner-4"}}\n\n {{#x-toggle id="inner-5"}}\n {{x-toggle id="inner-6"}}\n {{/x-toggle}}\n {{/x-toggle}}\n\n <button id="toggle-index" {{action "toggle"}}>Toggle</button>\n\n {{#if isExpanded}}\n {{x-toggle id="root-6"}}\n {{/if}}\n ');
_this.addTemplate('zomg', '\n {{x-tagless id="root-7"}}\n\n {{#x-toggle id="root-8"}}\n {{x-toggle id="inner-7"}}\n\n {{#x-toggle id="inner-8"}}\n {{x-toggle id="inner-9"}}\n {{/x-toggle}}\n {{/x-toggle}}\n\n {{#x-toggle id="root-9"}}\n {{outlet}}\n {{/x-toggle}}\n ');
_this.addTemplate('zomg.lol', '\n {{x-toggle id="inner-10"}}\n ');
_this.router.map(function () {
this.route('zomg', function () {
this.route('lol');
});
});
return _this;
}
_class.prototype['@test getRootViews'] = function testGetRootViews(assert) {
var _this2 = this;
return this.visit('/').then(function () {
_this2.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5']);
_this2.runTask(function () {
return (0, _emberViews.jQuery)('#toggle-application').click();
});
_this2.assertRootViews(['root-1', 'root-2', 'root-4', 'root-5']);
_this2.runTask(function () {
(0, _emberViews.jQuery)('#toggle-application').click();
(0, _emberViews.jQuery)('#toggle-index').click();
});
_this2.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5', 'root-6']);
return _this2.visit('/zomg/lol');
}).then(function () {
_this2.assertRootViews(['root-1', 'root-2', 'root-3', 'root-7', 'root-8', 'root-9']);
return _this2.visit('/');
}).then(function () {
_this2.assertRootViews(['root-1', 'root-2', 'root-3', 'root-4', 'root-5', 'root-6']);
});
};
_class.prototype.assertRootViews = function assertRootViews(ids) {
var owner = this.applicationInstance;
var actual = (0, _emberViews.getRootViews)(owner).map(function (view) {
return view.id;
}).sort();
var expected = ids.sort();
this.assert.deepEqual(actual, expected, 'root views');
};
_class.prototype['@test getChildViews'] = function testGetChildViews(assert) {
var _this3 = this;
return this.visit('/').then(function () {
_this3.assertChildViews('root-2', ['inner-1', 'inner-2']);
_this3.assertChildViews('root-5', []);
_this3.assertChildViews('inner-2', ['inner-3']);
_this3.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this3.assertChildViews('root-2', []);
_this3.runTask(function () {
return (0, _emberViews.jQuery)('#root-5').click();
});
_this3.assertChildViews('root-5', ['inner-4', 'inner-5']);
_this3.assertChildViews('inner-5', ['inner-6']);
return _this3.visit('/zomg');
}).then(function () {
_this3.assertChildViews('root-2', []);
_this3.assertChildViews('root-8', ['inner-7', 'inner-8']);
_this3.assertChildViews('inner-8', ['inner-9']);
_this3.assertChildViews('root-9', []);
_this3.runTask(function () {
return (0, _emberViews.jQuery)('#root-8').click();
});
_this3.assertChildViews('root-8', []);
return _this3.visit('/zomg/lol');
}).then(function () {
_this3.assertChildViews('root-2', []);
_this3.assertChildViews('root-8', []);
_this3.assertChildViews('root-9', ['inner-10']);
return _this3.visit('/');
}).then(function () {
_this3.assertChildViews('root-2', []);
_this3.assertChildViews('root-5', []);
_this3.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this3.runTask(function () {
return (0, _emberViews.jQuery)('#inner-2').click();
});
_this3.assertChildViews('root-2', ['inner-1', 'inner-2']);
_this3.assertChildViews('inner-2', []);
});
};
_class.prototype['@test getChildViews does not return duplicates'] = function testGetChildViewsDoesNotReturnDuplicates(assert) {
var _this4 = this;
return this.visit('/').then(function () {
_this4.assertChildViews('root-2', ['inner-1', 'inner-2']);
_this4.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this4.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this4.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this4.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this4.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this4.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this4.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this4.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this4.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this4.runTask(function () {
return (0, _emberViews.jQuery)('#root-2').click();
});
_this4.assertChildViews('root-2', ['inner-1', 'inner-2']);
});
};
_class.prototype.assertChildViews = function assertChildViews(parentId, childIds) {
var parentView = this.viewFor(parentId);
var childViews = (0, _emberViews.getChildViews)(parentView);
var actual = childViews.map(function (view) {
return view.id;
}).sort();
var expected = childIds.sort();
this.assert.deepEqual(actual, expected, 'child views for #' + parentId);
};
_class.prototype.viewFor = function viewFor(id) {
var owner = this.applicationInstance;
var registry = owner.lookup('-view-registry:main');
return registry[id];
};
return _class;
}(_testCase.ApplicationTest));
var hasGetClientRects = void 0,
hasGetBoundingClientRect = void 0;
var ClientRectListCtor = void 0,
ClientRectCtor = void 0;
(function () {
if (document.createRange) {
var range = document.createRange();
if (range.getClientRects) {
var clientRectsList = range.getClientRects();
hasGetClientRects = true;
ClientRectListCtor = clientRectsList && clientRectsList.constructor;
}
if (range.getBoundingClientRect) {
var clientRect = range.getBoundingClientRect();
hasGetBoundingClientRect = true;
ClientRectCtor = clientRect && clientRect.constructor;
}
}
})();
(0, _testCase.moduleFor)('Bounds tests', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class2, _RenderingTest);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.apply(this, arguments));
}
_class2.prototype['@test getViewBounds on a regular component'] = function testGetViewBoundsOnARegularComponent(assert) {
var component = void 0;
this.registerComponent('hi-mom', {
ComponentClass: _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
}
}),
template: '<p>Hi, mom!</p>'
});
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: '<span id="start-node">Hi,</span> <em id="before-end-node">mom</em>!'
});
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: '<p>Hi, mom!</p>'
});
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: '<p>Hi, mom!</p>'
});
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 = '<foo-bar some-attr="123">hello</foo-bar>';
this.render(template);
this.assertHTML(template);
this.assertStableRerender();
};
_class.prototype['@test custom elements can have bound attributes'] = function testCustomElementsCanHaveBoundAttributes() {
var _this2 = this;
var template = '<foo-bar some-attr="{{name}}">hello</foo-bar>';
this.render(template, { name: 'Robert' });
this.assertHTML('<foo-bar some-attr="Robert">hello</foo-bar>');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'name', 'Kris');
});
this.assertHTML('<foo-bar some-attr="Kris">hello</foo-bar>');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'name', 'Robert');
});
this.assertHTML('<foo-bar some-attr="Robert">hello</foo-bar>');
};
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('<p>hello</p>');
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 <div class="header">\n <h1>Welcome to Ember.js</h1>\n </div>\n <div class="body">\n <h2>Why you should use Ember.js?</h2>\n <ol>\n <li>It\'s great</li>\n <li>It\'s awesome</li>\n <li>It\'s Ember.js</li>\n </ol>\n </div>\n <div class="footer">\n Ember.js is free, open source and always will be.\n </div>\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('<p>{{foo.length}}</p>', { foo: undefined });
this.assertHTML('<p></p>');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'foo', 'foo');
});
this.assertHTML('<p>3</p>');
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'foo', '');
});
this.assertHTML('<p>0</p>');
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'foo', undefined);
});
this.assertHTML('<p></p>');
};
DynamicContentTest.prototype['@test resolves the array length properly'] = function testResolvesTheArrayLengthProperly() {
var _this8 = this;
this.render('<p>{{foo.length}}</p>', { foo: undefined });
this.assertHTML('<p></p>');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'foo', [1, 2, 3]);
});
this.assertHTML('<p>3</p>');
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'foo', []);
});
this.assertHTML('<p>0</p>');
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'foo', undefined);
});
this.assertHTML('<p></p>');
};
DynamicContentTest.prototype['@test it can render a capitalized path with no deprecation'] = function testItCanRenderACapitalizedPathWithNoDeprecation() {
var _this9 = this;
expectNoDeprecation();
this.renderPath('CaptializedPath', { CaptializedPath: 'no deprecation' });
this.assertContent('no deprecation');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this9.context, 'CaptializedPath', 'still no deprecation');
});
this.assertContent('still no deprecation');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this9.context, 'CaptializedPath', 'no deprecation');
});
this.assertContent('no deprecation');
this.assertInvariants();
};
DynamicContentTest.prototype['@test it can render undefined dynamic paths'] = function testItCanRenderUndefinedDynamicPaths() {
var _this10 = this;
this.renderPath('name', {});
this.assertIsEmpty();
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'name', 'foo-bar');
});
this.assertContent('foo-bar');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'name', undefined);
});
this.assertIsEmpty();
};
DynamicContentTest.prototype['@test it can render a deeply nested dynamic path'] = function testItCanRenderADeeplyNestedDynamicPath() {
var _this11 = this;
this.renderPath('a.b.c.d.e.f', {
a: { b: { c: { d: { e: { f: 'hello' } } } } }
});
this.assertContent('hello');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'a.b.c.d.e.f', 'goodbye');
});
this.assertContent('goodbye');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'a.b.c.d', { e: { f: 'aloha' } });
});
this.assertContent('aloha');
this.assertInvariants();
this.runTask(function () {
(0, _emberMetal.set)(_this11.context, 'a', { b: { c: { d: { e: { f: 'hello' } } } } });
});
this.assertContent('hello');
this.assertInvariants();
};
DynamicContentTest.prototype['@test it can render a computed property'] = function testItCanRenderAComputedProperty() {
var _this12 = this;
var Formatter = _emberRuntime.Object.extend({
formattedMessage: (0, _emberMetal.computed)('message', function () {
return this.get('message').toUpperCase();
})
});
var m = Formatter.create({ message: 'hello' });
this.renderPath('m.formattedMessage', { m: m });
this.assertContent('HELLO');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(m, 'message', 'goodbye');
});
this.assertContent('GOODBYE');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this12.context, 'm', Formatter.create({ message: 'hello' }));
});
this.assertContent('HELLO');
this.assertInvariants();
};
DynamicContentTest.prototype['@test it can render a computed property with nested dependency'] = function testItCanRenderAComputedPropertyWithNestedDependency() {
var _this13 = this;
var Formatter = _emberRuntime.Object.extend({
formattedMessage: (0, _emberMetal.computed)('messenger.message', function () {
return this.get('messenger.message').toUpperCase();
})
});
var m = Formatter.create({ messenger: { message: 'hello' } });
this.renderPath('m.formattedMessage', { m: m });
this.assertContent('HELLO');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(m, 'messenger.message', 'goodbye');
});
this.assertContent('GOODBYE');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'm', Formatter.create({ messenger: { message: 'hello' } }));
});
this.assertContent('HELLO');
this.assertInvariants();
};
DynamicContentTest.prototype['@test it can read from a proxy object'] = function testItCanReadFromAProxyObject() {
var _this14 = this;
this.renderPath('proxy.name', { proxy: _emberRuntime.ObjectProxy.create({ content: { name: 'Tom Dale' } }) });
this.assertContent('Tom Dale');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'proxy.content.name', 'Yehuda Katz');
});
this.assertContent('Yehuda Katz');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'proxy.content', { name: 'Godfrey Chan' });
});
this.assertContent('Godfrey Chan');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'proxy.name', 'Stefan Penner');
});
this.assertContent('Stefan Penner');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'proxy.content', null);
});
this.assertIsEmpty();
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'proxy', _emberRuntime.ObjectProxy.create({ content: { name: 'Tom Dale' } }));
});
this.assertContent('Tom Dale');
this.assertInvariants();
};
DynamicContentTest.prototype['@test it can read from a nested path in a proxy object'] = function testItCanReadFromANestedPathInAProxyObject() {
var _this15 = this;
this.renderPath('proxy.name.last', { proxy: _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } }) });
this.assertContent('Dale');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'proxy.content.name.last', 'Cruise');
});
this.assertContent('Cruise');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'proxy.content.name.first', 'Suri');
});
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'proxy.content.name', { first: 'Yehuda', last: 'Katz' });
});
this.assertContent('Katz');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'proxy.content', { name: { first: 'Godfrey', last: 'Chan' } });
});
this.assertContent('Chan');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'proxy.name', { first: 'Stefan', last: 'Penner' });
});
this.assertContent('Penner');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'proxy', null);
});
this.assertIsEmpty();
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'proxy', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } }));
});
this.assertContent('Dale');
this.assertInvariants();
};
DynamicContentTest.prototype['@test it can read from a path flipping between a proxy and a real object'] = function testItCanReadFromAPathFlippingBetweenAProxyAndARealObject() {
var _this16 = this;
this.renderPath('proxyOrObject.name.last', { proxyOrObject: _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } }) });
this.assertContent('Dale');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'proxyOrObject', { name: { first: 'Tom', last: 'Dale' } });
});
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'proxyOrObject.name.last', 'Cruise');
});
this.assertContent('Cruise');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'proxyOrObject.name.first', 'Suri');
});
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'proxyOrObject', { name: { first: 'Yehuda', last: 'Katz' } });
});
this.assertContent('Katz');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'proxyOrObject', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Godfrey', last: 'Chan' } } }));
});
this.assertContent('Chan');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'proxyOrObject.content.name', { first: 'Stefan', last: 'Penner' });
});
this.assertContent('Penner');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'proxyOrObject', null);
});
this.assertIsEmpty();
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'proxyOrObject', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } }));
});
this.assertContent('Dale');
this.assertInvariants();
};
DynamicContentTest.prototype['@test it can read from a path flipping between a real object and a proxy'] = function testItCanReadFromAPathFlippingBetweenARealObjectAndAProxy() {
var _this17 = this;
this.renderPath('objectOrProxy.name.last', { objectOrProxy: { name: { first: 'Tom', last: 'Dale' } } });
this.assertContent('Dale');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'objectOrProxy', _emberRuntime.ObjectProxy.create({ content: { name: { first: 'Tom', last: 'Dale' } } }));
});
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'objectOrProxy.content.name.last', 'Cruise');
});
this.assertContent('Cruise');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'objectOrProxy.content.name.first', 'Suri');
});
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'objectOrProxy.content', { name: { first: 'Yehuda', last: 'Katz' } });
});
this.assertContent('Katz');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'objectOrProxy', { name: { first: 'Godfrey', last: 'Chan' } });
});
this.assertContent('Chan');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'objectOrProxy.name', { first: 'Stefan', last: 'Penner' });
});
this.assertContent('Penner');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'objectOrProxy', null);
});
this.assertIsEmpty();
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'objectOrProxy', { name: { first: 'Tom', last: 'Dale' } });
});
this.assertContent('Dale');
this.assertInvariants();
};
DynamicContentTest.prototype['@test it can read from a null object'] = function testItCanReadFromANullObject() {
var _this18 = this;
var nullObject = Object.create(null);
nullObject['message'] = 'hello';
this.renderPath('nullObject.message', { nullObject: nullObject });
this.assertContent('hello');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(nullObject, 'message', 'goodbye');
});
this.assertContent('goodbye');
this.assertInvariants();
nullObject = Object.create(null);
nullObject['message'] = 'hello';
this.runTask(function () {
return (0, _emberMetal.set)(_this18.context, 'nullObject', nullObject);
});
this.assertContent('hello');
this.assertInvariants();
};
DynamicContentTest.prototype['@test it can render a readOnly property of a path'] = function testItCanRenderAReadOnlyPropertyOfAPath() {
var _this19 = this;
var Messenger = _emberRuntime.Object.extend({
message: _emberMetal.computed.readOnly('a.b.c')
});
var messenger = Messenger.create({
a: {
b: {
c: 'hello'
}
}
});
this.renderPath('messenger.message', { messenger: messenger });
this.assertContent('hello');
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(messenger, 'a.b.c', 'hi');
});
this.assertContent('hi');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this19.context, 'messenger.a.b', {
c: 'goodbye'
});
});
this.assertContent('goodbye');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this19.context, 'messenger', {
message: 'hello'
});
});
this.assertContent('hello');
this.assertInvariants();
};
DynamicContentTest.prototype['@test it can render a property on a function'] = function testItCanRenderAPropertyOnAFunction() {
var func = function () {};
func.aProp = 'this is a property on a function';
this.renderPath('func.aProp', { func: func });
this.assertContent('this is a property on a function');
this.assertStableRerender();
// this.runTask(() => set(func, 'aProp', 'still a property on a function'));
// this.assertContent('still a property on a function');
// this.assertInvariants();
// func = () => {};
// func.aProp = 'a prop on a new function';
// this.runTask(() => set(this.context, 'func', func));
// this.assertContent('a prop on a new function');
// this.assertInvariants();
};
return DynamicContentTest;
}(_testCase.RenderingTest);
var EMPTY = {};
var ContentTestGenerator = function () {
function ContentTestGenerator(cases) {
var tag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '@test';
(0, _emberBabel.classCallCheck)(this, ContentTestGenerator);
this.cases = cases;
this.tag = tag;
}
ContentTestGenerator.prototype.generate = function generate(_ref) {
var value = _ref[0],
expected = _ref[1],
label = _ref[2];
var tag = this.tag;
label = label || value;
if (expected === EMPTY) {
var _ref2;
return _ref2 = {}, _ref2[tag + ' rendering ' + label] = function () {
var _this20 = this;
this.renderPath('value', { value: value });
this.assertIsEmpty();
this.runTask(function () {
return (0, _emberMetal.set)(_this20.context, 'value', 'hello');
});
this.assertContent('hello');
this.runTask(function () {
return (0, _emberMetal.set)(_this20.context, 'value', value);
});
this.assertIsEmpty();
}, _ref2;
} else {
var _ref3;
return _ref3 = {}, _ref3[tag + ' rendering ' + label] = function () {
var _this21 = this;
this.renderPath('value', { value: value });
this.assertContent(expected);
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this21.context, 'value', 'hello');
});
this.assertContent('hello');
this.assertInvariants();
this.runTask(function () {
return (0, _emberMetal.set)(_this21.context, 'value', value);
});
this.assertContent(expected);
this.assertInvariants();
}, _ref3;
}
};
return ContentTestGenerator;
}();
var SharedContentTestCases = new ContentTestGenerator([['foo', 'foo'], [0, '0'], [-0, '0', '-0'], [1, '1'], [-1, '-1'], [0.0, '0', '0.0'], [0.5, '0.5'], [undefined, EMPTY], [null, EMPTY], [true, 'true'], [false, 'false'], [NaN, 'NaN'], [new Date(2000, 0, 1), String(new Date(2000, 0, 1)), 'a Date object'], [Infinity, 'Infinity'], [1 / -0, '-Infinity'], [{ foo: 'bar' }, '[object Object]', '{ foo: \'bar\' }'], [{
toString: function () {
return 'foo';
}
}, 'foo', 'an object with a custom toString function'], [{
valueOf: function () {
return 1;
}
}, '[object Object]', 'an object with a custom valueOf function'],
// Escaping tests
['<b>Max</b><b>James</b>', '<b>Max</b><b>James</b>']]);
var GlimmerContentTestCases = new ContentTestGenerator([[Object.create(null), EMPTY, 'an object with no toString']]);
if (typeof Symbol !== 'undefined') {
GlimmerContentTestCases.cases.push([Symbol('debug'), 'Symbol(debug)', 'a symbol']);
}
(0, _abstractTestCase.applyMixins)(DynamicContentTest, SharedContentTestCases, GlimmerContentTestCases);
(0, _testCase.moduleFor)('Dynamic content tests (content position)', function (_DynamicContentTest) {
(0, _emberBabel.inherits)(_class2, _DynamicContentTest);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _DynamicContentTest.apply(this, arguments));
}
_class2.prototype.renderPath = function renderPath(path) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
this.render('{{' + path + '}}', context);
};
_class2.prototype.assertContent = function assertContent(content) {
this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one text node');
this.assertTextNode(this.firstChild, content);
};
return _class2;
}(DynamicContentTest));
(0, _testCase.moduleFor)('Dynamic content tests (content concat)', function (_DynamicContentTest2) {
(0, _emberBabel.inherits)(_class3, _DynamicContentTest2);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
return (0, _emberBabel.possibleConstructorReturn)(this, _DynamicContentTest2.apply(this, arguments));
}
_class3.prototype.renderPath = function renderPath(path) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
this.render('{{concat "" ' + path + ' ""}}', context);
};
_class3.prototype.assertContent = function assertContent(content) {
this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one text node');
this.assertTextNode(this.firstChild, content);
};
return _class3;
}(DynamicContentTest));
(0, _testCase.moduleFor)('Dynamic content tests (inside an element)', function (_DynamicContentTest3) {
(0, _emberBabel.inherits)(_class4, _DynamicContentTest3);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
return (0, _emberBabel.possibleConstructorReturn)(this, _DynamicContentTest3.apply(this, arguments));
}
_class4.prototype.renderPath = function renderPath(path) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
this.render('<p>{{' + path + '}}</p>', context);
};
_class4.prototype.assertIsEmpty = function assertIsEmpty() {
this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one <p> tag');
this.assertElement(this.firstChild, { tagName: 'p' });
this.assertText('');
};
_class4.prototype.assertContent = function assertContent(content) {
this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one <p> tag');
this.assertElement(this.firstChild, { tagName: 'p' });
this.assertText(content);
};
return _class4;
}(DynamicContentTest));
(0, _testCase.moduleFor)('Dynamic content tests (attribute position)', function (_DynamicContentTest4) {
(0, _emberBabel.inherits)(_class5, _DynamicContentTest4);
function _class5() {
(0, _emberBabel.classCallCheck)(this, _class5);
return (0, _emberBabel.possibleConstructorReturn)(this, _DynamicContentTest4.apply(this, arguments));
}
_class5.prototype.renderPath = function renderPath(path) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
this.render('<div data-foo="{{' + path + '}}"></div>', context);
};
_class5.prototype.assertIsEmpty = function assertIsEmpty() {
this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one <div> tag');
this.assertElement(this.firstChild, { tagName: 'div', content: '' });
};
_class5.prototype.assertContent = function assertContent(content) {
this.assert.strictEqual(this.nodesCount, 1, 'It should render exactly one <div> tag');
this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': content }, content: '' });
};
return _class5;
}(DynamicContentTest));
var TrustedContentTest = function (_DynamicContentTest5) {
(0, _emberBabel.inherits)(TrustedContentTest, _DynamicContentTest5);
function TrustedContentTest() {
(0, _emberBabel.classCallCheck)(this, TrustedContentTest);
return (0, _emberBabel.possibleConstructorReturn)(this, _DynamicContentTest5.apply(this, arguments));
}
TrustedContentTest.prototype.assertIsEmpty = function assertIsEmpty() {
this.assert.strictEqual(this.firstChild, null);
};
TrustedContentTest.prototype.assertContent = function assertContent(content) {
this.assertHTML(content);
};
TrustedContentTest.prototype.assertStableRerender = function assertStableRerender() {
var _this27 = this;
this.takeSnapshot();
this.runTask(function () {
return _this27.rerender();
});
_DynamicContentTest5.prototype.assertInvariants.call(this);
};
TrustedContentTest.prototype.assertInvariants = function assertInvariants() {
// If it's not stable, we will wipe out all the content and replace them,
// so there are no invariants
};
return TrustedContentTest;
}(DynamicContentTest);
(0, _testCase.moduleFor)('Dynamic content tests (trusted)', function (_TrustedContentTest) {
(0, _emberBabel.inherits)(_class6, _TrustedContentTest);
function _class6() {
(0, _emberBabel.classCallCheck)(this, _class6);
return (0, _emberBabel.possibleConstructorReturn)(this, _TrustedContentTest.apply(this, arguments));
}
_class6.prototype.renderPath = function renderPath(path) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
this.render('{{{' + path + '}}}', context);
};
_class6.prototype['@test updating trusted curlies'] = function testUpdatingTrustedCurlies() {
var _this29 = this;
this.render('{{{htmlContent}}}{{{nested.htmlContent}}}', {
htmlContent: '<b>Max</b>',
nested: { htmlContent: '<b>James</b>' }
});
this.assertContent('<b>Max</b><b>James</b>');
this.runTask(function () {
return _this29.rerender();
});
this.assertStableRerender();
this.runTask(function () {
return (0, _emberMetal.set)(_this29.context, 'htmlContent', '<i>M</i><u>a</u><s>x</s>');
});
this.assertContent('<i>M</i><u>a</u><s>x</s><b>James</b>');
this.runTask(function () {
return (0, _emberMetal.set)(_this29.context, 'nested.htmlContent', 'Jammie');
});
this.assertContent('<i>M</i><u>a</u><s>x</s>Jammie');
this.runTask(function () {
(0, _emberMetal.set)(_this29.context, 'htmlContent', '<b>Max</b>');
(0, _emberMetal.set)(_this29.context, 'nested', { htmlContent: '<i>James</i>' });
});
this.assertContent('<b>Max</b><i>James</i>');
};
return _class6;
}(TrustedContentTest));
(0, _testCase.moduleFor)('Dynamic content tests (integration)', function (_RenderingTest3) {
(0, _emberBabel.inherits)(_class7, _RenderingTest3);
function _class7() {
(0, _emberBabel.classCallCheck)(this, _class7);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest3.apply(this, arguments));
}
_class7.prototype['@test it can render a dynamic template'] = function testItCanRenderADynamicTemplate() {
var _this31 = this;
var template = '\n <div class="header">\n <h1>Welcome to {{framework}}</h1>\n </div>\n <div class="body">\n <h2>Why you should use {{framework}}?</h2>\n <ol>\n <li>It\'s great</li>\n <li>It\'s awesome</li>\n <li>It\'s {{framework}}</li>\n </ol>\n </div>\n <div class="footer">\n {{framework}} is free, open source and always will be.\n </div>\n ';
var ember = '\n <div class="header">\n <h1>Welcome to Ember.js</h1>\n </div>\n <div class="body">\n <h2>Why you should use Ember.js?</h2>\n <ol>\n <li>It\'s great</li>\n <li>It\'s awesome</li>\n <li>It\'s Ember.js</li>\n </ol>\n </div>\n <div class="footer">\n Ember.js is free, open source and always will be.\n </div>\n ';
var react = '\n <div class="header">\n <h1>Welcome to React</h1>\n </div>\n <div class="body">\n <h2>Why you should use React?</h2>\n <ol>\n <li>It\'s great</li>\n <li>It\'s awesome</li>\n <li>It\'s React</li>\n </ol>\n </div>\n <div class="footer">\n React is free, open source and always will be.\n </div>\n ';
this.render(template, {
framework: 'Ember.js'
});
this.assertHTML(ember);
this.runTask(function () {
return _this31.rerender();
});
this.assertHTML(ember);
this.runTask(function () {
return (0, _emberMetal.set)(_this31.context, 'framework', 'React');
});
this.assertHTML(react);
this.runTask(function () {
return (0, _emberMetal.set)(_this31.context, 'framework', 'Ember.js');
});
this.assertHTML(ember);
};
_class7.prototype['@test it should evaluate to nothing if part of the path is `undefined`'] = function testItShouldEvaluateToNothingIfPartOfThePathIsUndefined() {
var _this32 = this;
this.render('{{foo.bar.baz.bizz}}', {
foo: {}
});
this.assertText('');
this.runTask(function () {
return _this32.rerender();
});
this.assertText('');
this.runTask(function () {
return (0, _emberMetal.set)(_this32.context, 'foo', {
bar: { baz: { bizz: 'Hey!' } }
});
});
this.assertText('Hey!');
this.runTask(function () {
return (0, _emberMetal.set)(_this32.context, 'foo', {});
});
this.assertText('');
this.runTask(function () {
return (0, _emberMetal.set)(_this32.context, 'foo', {
bar: { baz: { bizz: 'Hello!' } }
});
});
this.assertText('Hello!');
this.runTask(function () {
return (0, _emberMetal.set)(_this32.context, 'foo', {});
});
this.assertText('');
};
_class7.prototype['@test it should evaluate to nothing if part of the path is a primative'] = function testItShouldEvaluateToNothingIfPartOfThePathIsAPrimative() {
var _this33 = this;
this.render('{{foo.bar.baz.bizz}}', {
foo: { bar: true }
});
this.assertText('');
this.runTask(function () {
return _this33.rerender();
});
this.assertText('');
this.runTask(function () {
return (0, _emberMetal.set)(_this33.context, 'foo', {
bar: false
});
});
this.assertText('');
this.runTask(function () {
return (0, _emberMetal.set)(_this33.context, 'foo', {
bar: 'Haha'
});
});
this.assertText('');
this.runTask(function () {
return (0, _emberMetal.set)(_this33.context, 'foo', {
bar: null
});
});
this.assertText('');
this.runTask(function () {
return (0, _emberMetal.set)(_this33.context, 'foo', {
bar: undefined
});
});
this.assertText('');
this.runTask(function () {
return (0, _emberMetal.set)(_this33.context, 'foo', {
bar: 1
});
});
this.assertText('');
this.runTask(function () {
return (0, _emberMetal.set)(_this33.context, 'foo', {
bar: { baz: { bizz: 'Hello!' } }
});
});
this.assertText('Hello!');
this.runTask(function () {
return (0, _emberMetal.set)(_this33.context, 'foo', {
bar: true
});
});
this.assertText('');
};
_class7.prototype['@test can set dynamic href'] = function testCanSetDynamicHref() {
var _this34 = this;
this.render('<a href={{model.url}}>Example</a>', {
model: {
url: 'http://example.com'
}
});
this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://example.com' } });
this.runTask(function () {
return _this34.rerender();
});
this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://example.com' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this34.context, 'model.url', 'http://linkedin.com');
});
this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://linkedin.com' } });
this.runTask(function () {
return (0, _emberMetal.set)(_this34.context, 'model', { url: 'http://example.com' });
});
this.assertElement(this.firstChild, { tagName: 'a', content: 'Example', attrs: { 'href': 'http://example.com' } });
};
_class7.prototype['@test quoteless class attributes update correctly'] = function testQuotelessClassAttributesUpdateCorrectly() {
var _this35 = this;
this.render('<div class={{if fooBar "foo-bar"}}>hello</div>', {
fooBar: true
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo-bar') } });
this.runTask(function () {
return _this35.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo-bar') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this35.context, 'fooBar', false);
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello' });
this.runTask(function () {
return (0, _emberMetal.set)(_this35.context, 'fooBar', true);
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo-bar') } });
};
_class7.prototype['@test quoted class attributes update correctly'] = function testQuotedClassAttributesUpdateCorrectly(assert) {
var _this36 = this;
this.render('<div class="{{if fooBar "foo-bar"}}">hello</div>', {
fooBar: true
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo-bar') } });
this.runTask(function () {
return _this36.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo-bar') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this36.context, 'fooBar', false);
});
assert.equal(this.firstChild.className, '');
this.runTask(function () {
return (0, _emberMetal.set)(_this36.context, 'fooBar', true);
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo-bar') } });
};
_class7.prototype['@test unquoted class attribute can contain multiple classes'] = function testUnquotedClassAttributeCanContainMultipleClasses() {
var _this37 = this;
this.render('<div class={{model.classes}}>hello</div>', {
model: {
classes: 'foo bar baz'
}
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar baz') } });
this.runTask(function () {
return _this37.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar baz') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this37.context, 'model.classes', 'fizz bizz');
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('fizz bizz') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this37.context, 'model', { classes: 'foo bar baz' });
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar baz') } });
};
_class7.prototype['@test unquoted class attribute'] = function testUnquotedClassAttribute() {
var _this38 = this;
this.render('<div class={{model.foo}}>hello</div>', {
model: {
foo: 'foo'
}
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo') } });
this.runTask(function () {
return _this38.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this38.context, 'model.foo', 'fizz');
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('fizz') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this38.context, 'model', { foo: 'foo' });
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo') } });
};
_class7.prototype['@test quoted class attribute'] = function testQuotedClassAttribute() {
var _this39 = this;
this.render('<div class="{{model.foo}}">hello</div>', {
model: {
foo: 'foo'
}
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo') } });
this.runTask(function () {
return _this39.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this39.context, 'model.foo', 'fizz');
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('fizz') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this39.context, 'model', { foo: 'foo' });
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo') } });
};
_class7.prototype['@test quoted class attribute can contain multiple classes'] = function testQuotedClassAttributeCanContainMultipleClasses() {
var _this40 = this;
this.render('<div class="{{model.classes}}">hello</div>', {
model: {
classes: 'foo bar baz'
}
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar baz') } });
this.runTask(function () {
return _this40.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar baz') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this40.context, 'model.classes', 'fizz bizz');
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('fizz bizz') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this40.context, 'model', { classes: 'foo bar baz' });
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar baz') } });
};
_class7.prototype['@test class attribute concats bound values'] = function testClassAttributeConcatsBoundValues() {
var _this41 = this;
this.render('<div class="{{model.foo}} {{model.bar}} {{model.bizz}}">hello</div>', {
model: {
foo: 'foo',
bar: 'bar',
bizz: 'bizz'
}
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar bizz') } });
this.runTask(function () {
return _this41.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar bizz') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this41.context, 'model.foo', 'fizz');
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('fizz bar bizz') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this41.context, 'model.bar', null);
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('fizz bizz') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this41.context, 'model', {
foo: 'foo',
bar: 'bar',
bizz: 'bizz'
});
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar bizz') } });
};
_class7.prototype['@test class attribute accepts nested helpers, and updates'] = function testClassAttributeAcceptsNestedHelpersAndUpdates() {
var _this42 = this;
this.render('<div class="{{if model.hasSize model.size}} {{if model.hasShape model.shape}}">hello</div>', {
model: {
size: 'large',
hasSize: true,
hasShape: false,
shape: 'round'
}
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('large') } });
this.runTask(function () {
return _this42.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('large') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this42.context, 'model.hasShape', true);
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('large round') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this42.context, 'model.hasSize', false);
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('round') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this42.context, 'model', {
size: 'large',
hasSize: true,
hasShape: false,
shape: 'round'
});
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('large') } });
};
_class7.prototype['@test Multiple dynamic classes'] = function testMultipleDynamicClasses() {
var _this43 = this;
this.render('<div class="{{model.foo}} {{model.bar}} {{model.fizz}} {{model.baz}}">hello</div>', {
model: {
foo: 'foo',
bar: 'bar',
fizz: 'fizz',
baz: 'baz'
}
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar fizz baz') } });
this.runTask(function () {
return _this43.rerender();
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar fizz baz') } });
this.runTask(function () {
(0, _emberMetal.set)(_this43.context, 'model.foo', null);
(0, _emberMetal.set)(_this43.context, 'model.fizz', null);
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('bar baz') } });
this.runTask(function () {
(0, _emberMetal.set)(_this43.context, 'model', {
foo: 'foo',
bar: 'bar',
fizz: 'fizz',
baz: 'baz'
});
});
this.assertElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'class': (0, _testHelpers.classes)('foo bar fizz baz') } });
};
_class7.prototype['@test classes are ordered: See issue #9912'] = function testClassesAreOrderedSeeIssue9912() {
var _this44 = this;
this.render('<div class="{{model.foo}} static {{model.bar}}">hello</div>', {
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('<div style={{model.style}}></div>', {
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('<div style={{-html-safe model.style}}></div>', {
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 <div style={{userValue}}></div> generates a warning'] = function testSpecifyingDivStyleUserValueDivGeneratesAWarning(assert) {
var userValue = 'width: 42px';
this.render('<div style={{userValue}}></div>', {
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 `<div style={{{userValue}}}></div>` works properly without a warning'] = function testSpecifyingDivStyleUserValueDivWorksProperlyWithoutAWarning(assert) {
this.render('<div style={{{userValue}}}></div>', {
userValue: 'width: 42px'
});
this.assertNoWarning();
};
_class9.prototype['@test specifying `<div style={{userValue}}></div>` works properly with a SafeString'] = function testSpecifyingDivStyleUserValueDivWorksProperlyWithASafeString(assert) {
this.render('<div style={{userValue}}></div>', {
userValue: new _helpers.SafeString('width: 42px')
});
this.assertNoWarning();
};
_class9.prototype['@test null value do not generate htmlsafe warning'] = function testNullValueDoNotGenerateHtmlsafeWarning(assert) {
this.render('<div style={{userValue}}></div>', {
userValue: null
});
this.assertNoWarning();
};
_class9.prototype['@test undefined value do not generate htmlsafe warning'] = function testUndefinedValueDoNotGenerateHtmlsafeWarning(assert) {
this.render('<div style={{userValue}}></div>');
this.assertNoWarning();
};
_class9.prototype['@test no warnings are triggered when using `-html-safe`'] = function testNoWarningsAreTriggeredWhenUsingHtmlSafe(assert) {
this.render('<div style={{-html-safe userValue}}></div>', {
userValue: 'width: 42px'
});
this.assertNoWarning();
};
_class9.prototype['@test no warnings are triggered when a safe string is quoted'] = function testNoWarningsAreTriggeredWhenASafeStringIsQuoted(assert) {
this.render('<div style="{{userValue}}"></div>', {
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('<div style="{{userValue}}"></div>', {
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('<div style="color: green; {{userValue}}"></div>', {
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('<div style="color: green; width: {{userValue}}"></div>', {
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('<div style="color: green; {{userProperty}}: 42px"></div>', {
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);
};
TestComponentManager.prototype.getDestructor = function getDestructor(component) {
return component;
};
TestComponentManager.prototype.getSelf = function getSelf() {
return null;
};
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: '<input id="is-done" type="checkbox">'
});
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: '<input id="is-done" type="checkbox">'
});
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: '<input id="is-done" type="checkbox">'
});
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: '<input id="is-done" type="checkbox">'
});
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: '<input id="is-done" type="checkbox">'
});
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: '<input id="is-done" type="checkbox">'
});
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: '<p>Hello!</p>'
});
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: '<p>Hello!</p>'
});
expectDeprecation(/`eventManager` has been deprecated/);
this.render('{{x-foo}}');
};
_class2.prototype['@test a rootElement can be specified'] = function testARootElementCanBeSpecified(assert) {
this.$().append('<div id="app"></div>');
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: '<p>Hello!</p>'
});
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: '<p>hello</p>'
});
this.render('{{x-foo}}');
this.$('div').trigger('click');
assert.equal(clicked, 1, 'precond - the click handler was invoked');
var clickInstrumented = 0;
(0, _emberMetal.instrumentationSubscribe)('interaction.click', {
before: function () {
clickInstrumented++;
assert.equal(clicked, 1, 'invoked before event is handled');
},
after: function () {
clickInstrumented++;
assert.equal(clicked, 2, 'invoked after event is handled');
}
});
var keypressInstrumented = 0;
(0, _emberMetal.instrumentationSubscribe)('interaction.keypress', {
before: function () {
keypressInstrumented++;
},
after: function () {
keypressInstrumented++;
}
});
this.$('div').trigger('click');
this.$('div').trigger('change');
assert.equal(clicked, 2, 'precond - The click handler was invoked');
assert.equal(clickInstrumented, 2, 'The click was instrumented');
assert.strictEqual(keypressInstrumented, 0, 'The keypress was not instrumented');
};
return _class4;
}(_testCase.RenderingTest));
}
if (canDataTransfer) {
(0, _testCase.moduleFor)('EventDispatcher - Event Properties', function (_RenderingTest5) {
(0, _emberBabel.inherits)(_class5, _RenderingTest5);
function _class5() {
(0, _emberBabel.classCallCheck)(this, _class5);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest5.apply(this, arguments));
}
_class5.prototype['@test dataTransfer property is added to drop event'] = function testDataTransferPropertyIsAddedToDropEvent(assert) {
var receivedEvent = void 0;
this.registerComponent('x-foo', {
ComponentClass: _helpers.Component.extend({
drop: function (event) {
receivedEvent = event;
}
})
});
this.render('{{x-foo}}');
fireNativeWithDataTransfer(this.$('div')[0], 'drop', 'success');
assert.equal(receivedEvent.dataTransfer, 'success');
};
return _class5;
}(_testCase.RenderingTest));
}
});
QUnit.module('ESLint | ember-glimmer/tests/integration/event-dispatcher-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/event-dispatcher-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/helpers/-class-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/test-helpers', 'ember-metal'], function (_emberBabel, _testCase, _testHelpers, _emberMetal) {
'use strict';
(0, _testCase.moduleFor)('Helpers test: {{-class}}', 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 casts binding to dasherized class'] = function testCastsBindingToDasherizedClass() {
var _this2 = this;
this.registerComponent('foo-bar', { template: '' });
this.render('{{foo-bar class=(-class someTruth "someTruth")}}', {
someTruth: true
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('some-truth ember-view') } });
this.runTask(function () {
return _this2.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('some-truth ember-view') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'someTruth', false);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('ember-view') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'someTruth', true);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('some-truth ember-view') } });
};
_class.prototype['@tests casts leaf path of binding to dasherized class'] = function testsCastsLeafPathOfBindingToDasherizedClass() {
var _this3 = this;
this.registerComponent('foo-bar', { template: '' });
this.render('{{foo-bar class=(-class model.someTruth "someTruth")}}', {
model: {
someTruth: true
}
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('some-truth ember-view') } });
this.runTask(function () {
return _this3.rerender();
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('some-truth ember-view') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'model.someTruth', false);
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('ember-view') } });
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'model', { someTruth: true });
});
this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _testHelpers.classes)('some-truth ember-view') } });
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/-class-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/helpers/-class-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/helpers/closure-action-test', ['ember-babel', 'ember-metal', 'ember/features', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers'], function (_emberBabel, _emberMetal, _features, _testCase, _abstractTestCase, _helpers) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <div id="counter">clicked: {{clicked}}; foo: {{foo}}</div>\n\n {{click-me id="string-action" onClick=(action "on-click")}}\n {{click-me id="function-action" onClick=(action onClick)}}\n {{click-me id="mut-action" onClick=(action (mut clicked))}}\n '], ['\n <div id="counter">clicked: {{clicked}}; foo: {{foo}}</div>\n\n {{click-me id="string-action" onClick=(action "on-click")}}\n {{click-me id="function-action" onClick=(action onClick)}}\n {{click-me id="mut-action" onClick=(action (mut clicked))}}\n ']);
if (_features.EMBER_IMPROVED_INSTRUMENTATION) {
(0, _testCase.moduleFor)('Helpers test: closure {{action}} improved instrumentation', 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.subscribe = function subscribe(eventName, options) {
this.subscriber = (0, _emberMetal.instrumentationSubscribe)(eventName, options);
};
_class.prototype.teardown = function teardown() {
if (this.subscriber) {
(0, _emberMetal.instrumentationUnsubscribe)(this.subscriber);
}
_RenderingTest.prototype.teardown.call(this);
};
_class.prototype['@test interaction event subscriber should be passed parameters'] = function testInteractionEventSubscriberShouldBePassedParameters() {
var _this2 = this;
var actionParam = 'So krispy';
var beforeParameters = [];
var afterParameters = [];
var InnerComponent = _helpers.Component.extend({
actions: {
fireAction: function () {
this.attrs.submit(actionParam);
}
}
});
var OuterComponent = _helpers.Component.extend({
outerSubmit: function () {}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: '<button id="instrument-button" {{action "fireAction"}}>What it do</button>'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action outerSubmit)}}'
});
this.subscribe('interaction.ember-action', {
before: function (name, timestamp, payload) {
beforeParameters.push(payload.args);
},
after: function (name, timestamp, payload) {
afterParameters.push(payload.args);
}
});
this.render('{{outer-component}}');
this.runTask(function () {
_this2.$('#instrument-button').trigger('click');
});
this.assert.deepEqual(beforeParameters, [[], [actionParam]], 'instrumentation subscriber before function was passed closure action parameters');
this.assert.deepEqual(afterParameters, [[actionParam], []], 'instrumentation subscriber after function was passed closure action parameters');
};
_class.prototype['@test interaction event subscriber should be passed target'] = function testInteractionEventSubscriberShouldBePassedTarget() {
var _this3 = this;
var beforeParameters = [];
var afterParameters = [];
var InnerComponent = _helpers.Component.extend({
myProperty: 'inner-thing',
actions: {
fireAction: function () {
this.attrs.submit();
}
}
});
var OuterComponent = _helpers.Component.extend({
myProperty: 'outer-thing',
outerSubmit: function () {}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: '<button id="instrument-button" {{action "fireAction"}}>What it do</button>'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action outerSubmit)}}'
});
this.subscribe('interaction.ember-action', {
before: function (name, timestamp, payload) {
beforeParameters.push(payload.target.get('myProperty'));
},
after: function (name, timestamp, payload) {
afterParameters.push(payload.target.get('myProperty'));
}
});
this.render('{{outer-component}}');
this.runTask(function () {
_this3.$('#instrument-button').trigger('click');
});
this.assert.deepEqual(beforeParameters, ['inner-thing', 'outer-thing'], 'instrumentation subscriber before function was passed target');
this.assert.deepEqual(afterParameters, ['outer-thing', 'inner-thing'], 'instrumentation subscriber after function was passed target');
};
_class.prototype['@test instrumented action should return value'] = function testInstrumentedActionShouldReturnValue() {
var _this4 = this;
var returnedValue = 'Chris P is so krispy';
var actualReturnedValue = void 0;
var InnerComponent = _helpers.Component.extend({
actions: {
fireAction: function () {
actualReturnedValue = this.attrs.submit();
}
}
});
var OuterComponent = _helpers.Component.extend({
outerSubmit: function () {
return returnedValue;
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: '<button id="instrument-button" {{action "fireAction"}}>What it do</button>'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action outerSubmit)}}'
});
this.subscribe('interaction.ember-action', {
before: function (name, timestamp, payload) {},
after: function (name, timestamp, payload) {}
});
this.render('{{outer-component}}');
this.runTask(function () {
_this4.$('#instrument-button').trigger('click');
});
this.assert.equal(actualReturnedValue, returnedValue, 'action can return to caller');
};
return _class;
}(_testCase.RenderingTest));
}
(0, _testCase.moduleFor)('Helpers test: closure {{action}}', function (_RenderingTest2) {
(0, _emberBabel.inherits)(_class2, _RenderingTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest2.apply(this, arguments));
}
_class2.prototype['@test action should be called'] = function testActionShouldBeCalled() {
var outerActionCalled = false;
var component = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
fireAction: function () {
this.attrs.submit();
}
});
var OuterComponent = _helpers.Component.extend({
outerSubmit: function () {
outerActionCalled = true;
}
});
this.registerComponent('inner-component', { ComponentClass: InnerComponent, template: 'inner' });
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action outerSubmit)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
component.fireAction();
});
this.assert.ok(outerActionCalled, 'the action was called');
};
_class2.prototype['@test an error is triggered when bound action function is undefined'] = function testAnErrorIsTriggeredWhenBoundActionFunctionIsUndefined() {
var _this6 = this;
this.registerComponent('inner-component', {
template: 'inner'
});
this.registerComponent('outer-component', {
template: '{{inner-component submit=(action somethingThatIsUndefined)}}'
});
expectAssertion(function () {
_this6.render('{{outer-component}}');
}, /Action passed is null or undefined in \(action[^)]*\) from .*\./);
};
_class2.prototype['@test an error is triggered when bound action being passed in is a non-function'] = function testAnErrorIsTriggeredWhenBoundActionBeingPassedInIsANonFunction() {
var _this7 = this;
this.registerComponent('inner-component', {
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: _helpers.Component.extend({
nonFunctionThing: {}
}),
template: '{{inner-component submit=(action nonFunctionThing)}}'
});
expectAssertion(function () {
_this7.render('{{outer-component}}');
}, /An action could not be made for `.*` in .*\. Please confirm that you are using either a quoted action name \(i\.e\. `\(action '.*'\)`\) or a function available in .*\./);
};
_class2.prototype['@test [#12718] a nice error is shown when a bound action function is undefined and it is passed as attrs.foo'] = function test12718ANiceErrorIsShownWhenABoundActionFunctionIsUndefinedAndItIsPassedAsAttrsFoo() {
var _this8 = this;
this.registerComponent('inner-component', {
template: '<button id="inner-button" {{action (action attrs.external-action)}}>Click me</button>'
});
this.registerComponent('outer-component', {
template: '{{inner-component}}'
});
expectAssertion(function () {
_this8.render('{{outer-component}}');
}, /Action passed is null or undefined in \(action[^)]*\) from .*\./);
};
_class2.prototype['@test action value is returned'] = function testActionValueIsReturned() {
var expectedValue = 'terrible tom';
var returnedValue = void 0;
var innerComponent = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
returnedValue = this.attrs.submit();
}
});
var OuterComponent = _helpers.Component.extend({
outerSubmit: function () {
return expectedValue;
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action outerSubmit)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.equal(returnedValue, expectedValue, 'action can return to caller');
};
_class2.prototype['@test action should be called on the correct scope'] = function testActionShouldBeCalledOnTheCorrectScope() {
var innerComponent = void 0;
var outerComponent = void 0;
var actualComponent = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit();
}
});
var OuterComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
outerComponent = this;
},
isOuterComponent: true,
outerSubmit: function () {
actualComponent = this;
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action outerSubmit)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.equal(actualComponent, outerComponent, 'action has the correct context');
this.assert.ok(actualComponent.isOuterComponent, 'action has the correct context');
};
_class2.prototype['@test arguments to action are passed, curry'] = function testArgumentsToActionArePassedCurry() {
var first = 'mitch';
var second = 'martin';
var third = 'matt';
var fourth = 'wacky wycats';
var innerComponent = void 0;
var actualArgs = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit(fourth);
}
});
var OuterComponent = _helpers.Component.extend({
third: third,
outerSubmit: function (actualFirst, actualSecond, actualThird, actualFourth) {
actualArgs = [].concat(Array.prototype.slice.call(arguments));
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action (action outerSubmit "' + first + '") "' + second + '" third)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.deepEqual(actualArgs, [first, second, third, fourth], 'action has the correct args');
};
_class2.prototype['@test `this` can be passed as an argument'] = function testThisCanBePassedAsAnArgument() {
var value = {};
var component = void 0;
var innerComponent = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit();
}
});
var OuterComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
actions: {
outerAction: function (incomingValue) {
value = incomingValue;
}
}
});
this.registerComponent('inner-component', { ComponentClass: InnerComponent, template: 'inner' });
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action "outerAction" this)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.strictEqual(value, component, 'the component is passed at `this`');
};
_class2.prototype['@test arguments to action are bound'] = function testArgumentsToActionAreBound() {
var value = 'lazy leah';
var innerComponent = void 0;
var outerComponent = void 0;
var actualArg = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit();
}
});
var OuterComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
outerComponent = this;
},
value: '',
outerSubmit: function (incomingValue) {
actualArg = incomingValue;
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action outerSubmit value)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.strictEqual(actualArg, '', 'action has the correct first arg');
this.runTask(function () {
outerComponent.set('value', value);
});
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.strictEqual(actualArg, value, 'action has the correct first arg');
};
_class2.prototype['@test array arguments are passed correctly to action'] = function testArrayArgumentsArePassedCorrectlyToAction() {
var first = 'foo';
var second = [3, 5];
var third = [4, 9];
var actualFirst = void 0;
var actualSecond = void 0;
var actualThird = void 0;
var innerComponent = void 0;
var outerComponent = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit(second, third);
}
});
var OuterComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
outerComponent = this;
},
outerSubmit: function (incomingFirst, incomingSecond, incomingThird) {
actualFirst = incomingFirst;
actualSecond = incomingSecond;
actualThird = incomingThird;
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action outerSubmit first)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
outerComponent.set('first', first);
outerComponent.set('second', second);
});
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.equal(actualFirst, first, 'action has the correct first arg');
this.assert.equal(actualSecond, second, 'action has the correct second arg');
this.assert.equal(actualThird, third, 'action has the correct third arg');
};
_class2.prototype['@test mut values can be wrapped in actions, are settable'] = function testMutValuesCanBeWrappedInActionsAreSettable() {
var newValue = 'trollin trek';
var innerComponent = void 0;
var outerComponent = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit(newValue);
}
});
var OuterComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
outerComponent = this;
},
outerMut: 'patient peter'
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action (mut outerMut))}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.equal(outerComponent.get('outerMut'), newValue, 'mut value is set');
};
_class2.prototype['@test mut values can be wrapped in actions, are settable with a curry'] = function testMutValuesCanBeWrappedInActionsAreSettableWithACurry() {
var newValue = 'trollin trek';
var innerComponent = void 0;
var outerComponent = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit();
}
});
var OuterComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
outerComponent = this;
},
outerMut: 'patient peter'
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action (mut outerMut) \'' + newValue + '\')}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.equal(outerComponent.get('outerMut'), newValue, 'mut value is set');
};
_class2.prototype['@test action can create closures over actions'] = function testActionCanCreateClosuresOverActions() {
var first = 'raging robert';
var second = 'mild machty';
var returnValue = 'butch brian';
var actualFirst = void 0;
var actualSecond = void 0;
var actualReturnedValue = void 0;
var innerComponent = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
actualReturnedValue = this.attrs.submit(second);
}
});
var OuterComponent = _helpers.Component.extend({
actions: {
outerAction: function (incomingFirst, incomingSecond) {
actualFirst = incomingFirst;
actualSecond = incomingSecond;
return returnValue;
}
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action \'outerAction\' \'' + first + '\')}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.equal(actualReturnedValue, returnValue, 'return value is present');
this.assert.equal(actualFirst, first, 'first argument is correct');
this.assert.equal(actualSecond, second, 'second argument is correct');
};
_class2.prototype['@test provides a helpful error if an action is not present'] = function testProvidesAHelpfulErrorIfAnActionIsNotPresent() {
var _this9 = this;
var InnerComponent = _helpers.Component.extend({});
var OuterComponent = _helpers.Component.extend({
actions: {
something: function () {
// this is present to ensure `actions` hash is present
// a different error is triggered if `actions` is missing
// completely
}
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action \'doesNotExist\')}}'
});
expectAssertion(function () {
_this9.render('{{outer-component}}');
}, /An action named 'doesNotExist' was not found in /);
};
_class2.prototype['@test provides a helpful error if actions hash is not present'] = function testProvidesAHelpfulErrorIfActionsHashIsNotPresent() {
var _this10 = this;
var InnerComponent = _helpers.Component.extend({});
var OuterComponent = _helpers.Component.extend({});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action \'doesNotExist\')}}'
});
expectAssertion(function () {
_this10.render('{{outer-component}}');
}, /An action named 'doesNotExist' was not found in /);
};
_class2.prototype['@test action can create closures over actions with target'] = function testActionCanCreateClosuresOverActionsWithTarget() {
var innerComponent = void 0;
var actionCalled = false;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit();
}
});
var OuterComponent = _helpers.Component.extend({
otherComponent: (0, _emberMetal.computed)(function () {
return {
actions: {
outerAction: function () {
actionCalled = true;
}
}
};
})
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action \'outerAction\' target=otherComponent)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.ok(actionCalled, 'action called on otherComponent');
};
_class2.prototype['@test value can be used with action over actions'] = function testValueCanBeUsedWithActionOverActions() {
var newValue = 'yelping yehuda';
var innerComponent = void 0;
var actualValue = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit({
readProp: newValue
});
}
});
var OuterComponent = _helpers.Component.extend({
outerContent: {
readProp: newValue
},
actions: {
outerAction: function (incomingValue) {
actualValue = incomingValue;
}
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action \'outerAction\' value="readProp")}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.equal(actualValue, newValue, 'value is read');
};
_class2.prototype['@test action will read the value of a first property'] = function testActionWillReadTheValueOfAFirstProperty() {
var newValue = 'irate igor';
var innerComponent = void 0;
var actualValue = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit({
readProp: newValue
});
}
});
var OuterComponent = _helpers.Component.extend({
outerAction: function (incomingValue) {
actualValue = incomingValue;
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action outerAction value="readProp")}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.equal(actualValue, newValue, 'property is read');
};
_class2.prototype['@test action will read the value of a curried first argument property'] = function testActionWillReadTheValueOfACurriedFirstArgumentProperty() {
var newValue = 'kissing kris';
var innerComponent = void 0;
var actualValue = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit();
}
});
var OuterComponent = _helpers.Component.extend({
objectArgument: {
readProp: newValue
},
outerAction: function (incomingValue) {
actualValue = incomingValue;
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action outerAction objectArgument value="readProp")}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.equal(actualValue, newValue, 'property is read');
};
_class2.prototype['@test action closure does not get auto-mut wrapped'] = function testActionClosureDoesNotGetAutoMutWrapped(assert) {
var first = 'raging robert';
var second = 'mild machty';
var returnValue = 'butch brian';
var innerComponent = void 0;
var actualFirst = void 0;
var actualSecond = void 0;
var actualReturnedValue = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.get('submit')(second);
this.get('attrs-submit')(second);
var attrsSubmitReturnValue = this.attrs['attrs-submit'](second);
var submitReturnValue = this.attrs.submit(second);
assert.equal(attrsSubmitReturnValue, submitReturnValue, 'both attrs.foo and foo should behave the same');
return submitReturnValue;
}
});
var MiddleComponent = _helpers.Component.extend({});
var OuterComponent = _helpers.Component.extend({
actions: {
outerAction: function (incomingFirst, incomingSecond) {
actualFirst = incomingFirst;
actualSecond = incomingSecond;
return returnValue;
}
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('middle-component', {
ComponentClass: MiddleComponent,
template: '{{inner-component attrs-submit=attrs.submit submit=submit}}'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{middle-component submit=(action \'outerAction\' \'' + first + '\')}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
actualReturnedValue = innerComponent.fireAction();
});
this.assert.equal(actualFirst, first, 'first argument is correct');
this.assert.equal(actualSecond, second, 'second argument is correct');
this.assert.equal(actualReturnedValue, returnValue, 'return value is present');
};
_class2.prototype['@test action should be called within a run loop'] = function testActionShouldBeCalledWithinARunLoop() {
var innerComponent = void 0;
var capturedRunLoop = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
this.attrs.submit();
}
});
var OuterComponent = _helpers.Component.extend({
actions: {
submit: function () {
capturedRunLoop = _emberMetal.run.currentRunLoop;
}
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action \'submit\')}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.ok(capturedRunLoop, 'action is called within a run loop');
};
_class2.prototype['@test objects that define INVOKE can be casted to actions'] = function testObjectsThatDefineINVOKECanBeCastedToActions() {
var innerComponent = void 0;
var actionArgs = void 0;
var invokableArgs = void 0;
var InnerComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
innerComponent = this;
},
fireAction: function () {
actionArgs = this.attrs.submit(4, 5, 6);
}
});
var OuterComponent = _helpers.Component.extend({
foo: 123,
submitTask: (0, _emberMetal.computed)(function () {
var _this11 = this,
_ref;
return _ref = {}, _ref[_helpers.INVOKE] = function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
invokableArgs = args;
return _this11.foo;
}, _ref;
})
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: '{{inner-component submit=(action submitTask 1 2 3)}}'
});
this.render('{{outer-component}}');
this.runTask(function () {
innerComponent.fireAction();
});
this.assert.equal(actionArgs, 123);
this.assert.deepEqual(invokableArgs, [1, 2, 3, 4, 5, 6]);
};
_class2.prototype['@test closure action with `(mut undefinedThing)` works properly [GH#13959]'] = function testClosureActionWithMutUndefinedThingWorksProperlyGH13959() {
var _this12 = this;
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
label: undefined,
init: function () {
this._super.apply(this, arguments);
component = this;
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<button onclick={{action (mut label) "Clicked!"}}>{{if label label "Click me"}}</button>'
});
this.render('{{example-component}}');
this.assertText('Click me');
this.assertStableRerender();
this.runTask(function () {
_this12.$('button').click();
});
this.assertText('Clicked!');
this.runTask(function () {
component.set('label', 'Dun clicked');
});
this.assertText('Dun clicked');
this.runTask(function () {
_this12.$('button').click();
});
this.assertText('Clicked!');
this.runTask(function () {
component.set('label', undefined);
});
this.assertText('Click me');
};
_class2.prototype['@test closure actions does not cause component hooks to fire unnecessarily [GH#14305] [GH#14654]'] = function testClosureActionsDoesNotCauseComponentHooksToFireUnnecessarilyGH14305GH14654(assert) {
var _this14 = this;
var clicked = 0;
var didReceiveAttrsFired = 0;
var ClickMeComponent = _helpers.Component.extend({
tagName: 'button',
click: function () {
this.get('onClick').call(undefined, ++clicked);
},
didReceiveAttrs: function () {
didReceiveAttrsFired++;
}
});
this.registerComponent('click-me', {
ComponentClass: ClickMeComponent
});
var outer = void 0;
var OuterComponent = _helpers.Component.extend({
clicked: 0,
actions: {
'on-click': function () {
this.incrementProperty('clicked');
}
},
init: function () {
var _this13 = this;
this._super();
outer = this;
this.set('onClick', function () {
return _this13.incrementProperty('clicked');
});
}
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: (0, _abstractTestCase.strip)(_templateObject)
});
this.render('{{outer-component foo=foo}}', { foo: 1 });
this.assertText('clicked: 0; foo: 1');
assert.equal(didReceiveAttrsFired, 3);
this.runTask(function () {
return _this14.rerender();
});
this.assertText('clicked: 0; foo: 1');
assert.equal(didReceiveAttrsFired, 3);
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'foo', 2);
});
this.assertText('clicked: 0; foo: 2');
assert.equal(didReceiveAttrsFired, 3);
this.runTask(function () {
return _this14.$('#string-action').click();
});
this.assertText('clicked: 1; foo: 2');
assert.equal(didReceiveAttrsFired, 3);
this.runTask(function () {
return _this14.$('#function-action').click();
});
this.assertText('clicked: 2; foo: 2');
assert.equal(didReceiveAttrsFired, 3);
this.runTask(function () {
return (0, _emberMetal.set)(outer, 'onClick', function () {
outer.incrementProperty('clicked');
});
});
this.assertText('clicked: 2; foo: 2');
assert.equal(didReceiveAttrsFired, 3);
this.runTask(function () {
return _this14.$('#function-action').click();
});
this.assertText('clicked: 3; foo: 2');
assert.equal(didReceiveAttrsFired, 3);
this.runTask(function () {
return _this14.$('#mut-action').click();
});
this.assertText('clicked: 4; foo: 2');
assert.equal(didReceiveAttrsFired, 3);
};
return _class2;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/closure-action-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/helpers/closure-action-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/helpers/concat-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-metal'], function (_emberBabel, _testCase, _emberMetal) {
'use strict';
(0, _testCase.moduleFor)('Helpers test: {{concat}}', 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 concats static arguments'] = function testItConcatsStaticArguments() {
this.render('{{concat "foo" " " "bar" " " "baz"}}');
this.assertText('foo bar baz');
};
_class.prototype['@test it updates for bound arguments'] = function testItUpdatesForBoundArguments() {
var _this2 = this;
this.render('{{concat model.first model.second}}', {
model: { first: 'one', second: 'two' }
});
this.assertText('onetwo');
this.runTask(function () {
return _this2.rerender();
});
this.assertText('onetwo');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'model.first', 'three');
});
this.assertText('threetwo');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'model.second', 'four');
});
this.assertText('threefour');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'model', { first: 'one', second: 'two' });
});
this.assertText('onetwo');
};
_class.prototype['@test it can be used as a sub-expression'] = function testItCanBeUsedAsASubExpression() {
var _this3 = this;
this.render('{{concat (concat model.first model.second) (concat model.third model.fourth)}}', {
model: {
first: 'one',
second: 'two',
third: 'three',
fourth: 'four'
}
});
this.assertText('onetwothreefour');
this.runTask(function () {
return _this3.rerender();
});
this.assertText('onetwothreefour');
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'model.first', 'five');
});
this.assertText('fivetwothreefour');
this.runTask(function () {
(0, _emberMetal.set)(_this3.context, 'model.second', 'six');
(0, _emberMetal.set)(_this3.context, 'model.third', 'seven');
});
this.assertText('fivesixsevenfour');
this.runTask(function () {
(0, _emberMetal.set)(_this3.context, 'model', {
first: 'one',
second: 'two',
third: 'three',
fourth: 'four'
});
});
this.assertText('onetwothreefour');
};
_class.prototype['@test it can be used as input for other helpers'] = function testItCanBeUsedAsInputForOtherHelpers() {
var _this4 = this;
this.registerHelper('x-eq', function (_ref) {
var actual = _ref[0],
expected = _ref[1];
return actual === expected;
});
this.render('{{#if (x-eq (concat model.first model.second) "onetwo")}}Truthy!{{else}}False{{/if}}', {
model: {
first: 'one',
second: 'two'
}
});
this.assertText('Truthy!');
this.runTask(function () {
return _this4.rerender();
});
this.assertText('Truthy!');
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'model.first', 'three');
});
this.assertText('False');
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'model', { first: 'one', second: 'two' });
});
this.assertText('Truthy!');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/concat-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/helpers/concat-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/helpers/custom-helper-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'internal-test-helpers', 'ember-metal', 'ember-utils'], function (_emberBabel, _testCase, _internalTestHelpers, _emberMetal, _emberUtils) {
'use strict';
/* globals EmberDev */
var assert = QUnit.assert;
(0, _testCase.moduleFor)('Helpers test: custom helpers', 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 cannot override built-in syntax'] = function testItCannotOverrideBuiltInSyntax() {
var _this2 = this;
this.registerHelper('if', function () {
return 'Nope';
});
expectAssertion(function () {
_this2.render('{{if foo \'LOL\'}}', { foo: true });
}, /You attempted to overwrite the built-in helper \"if\" which is not allowed. Please rename the helper./);
};
_class.prototype['@test it can resolve custom simple helpers with or without dashes'] = function testItCanResolveCustomSimpleHelpersWithOrWithoutDashes() {
var _this3 = this;
this.registerHelper('hello', function () {
return 'hello';
});
this.registerHelper('hello-world', function () {
return 'hello world';
});
this.render('{{hello}} | {{hello-world}}');
this.assertText('hello | hello world');
this.runTask(function () {
return _this3.rerender();
});
this.assertText('hello | hello world');
};
_class.prototype['@test it does not resolve helpers with a `.` (period)'] = function testItDoesNotResolveHelpersWithAPeriod() {
var _this4 = this;
this.registerHelper('hello.world', function () {
return 'hello world';
});
this.render('{{hello.world}}', {
hello: {
world: ''
}
});
this.assertText('');
this.assertStableRerender();
this.assertText('');
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'hello', { world: 'hello world!' });
});
this.assertText('hello world!');
this.runTask(function () {
(0, _emberMetal.set)(_this4.context, 'hello', {
world: ''
});
});
this.assertText('');
};
_class.prototype['@test it can resolve custom class-based helpers with or without dashes'] = function testItCanResolveCustomClassBasedHelpersWithOrWithoutDashes() {
var _this5 = this;
this.registerHelper('hello', {
compute: function () {
return 'hello';
}
});
this.registerHelper('hello-world', {
compute: function () {
return 'hello world';
}
});
this.render('{{hello}} | {{hello-world}}');
this.assertText('hello | hello world');
this.runTask(function () {
return _this5.rerender();
});
this.assertText('hello | hello world');
};
_class.prototype['@test throws if `this._super` is not called from `init`'] = function testThrowsIfThis_superIsNotCalledFromInit() {
var _this6 = this;
this.registerHelper('hello-world', {
init: function () {}
});
expectAssertion(function () {
_this6.render('{{hello-world}}');
}, /You must call `this._super\(...arguments\);` when overriding `init` on a framework object. Please update .* to call `this._super\(...arguments\);` from `init`./);
};
_class.prototype['@test class-based helper can recompute a new value'] = function testClassBasedHelperCanRecomputeANewValue() {
var _this7 = this;
var destroyCount = 0;
var computeCount = 0;
var helper = void 0;
this.registerHelper('hello-world', {
init: function () {
this._super.apply(this, arguments);
helper = this;
},
compute: function () {
return ++computeCount;
},
destroy: function () {
destroyCount++;
this._super();
}
});
this.render('{{hello-world}}');
this.assertText('1');
this.runTask(function () {
return _this7.rerender();
});
this.assertText('1');
this.runTask(function () {
return helper.recompute();
});
this.assertText('2');
assert.strictEqual(destroyCount, 0, 'destroy is not called on recomputation');
};
_class.prototype['@test class-based helper with static arguments can recompute a new value'] = function testClassBasedHelperWithStaticArgumentsCanRecomputeANewValue() {
var _this8 = this;
var destroyCount = 0;
var computeCount = 0;
var helper = void 0;
this.registerHelper('hello-world', {
init: function () {
this._super.apply(this, arguments);
helper = this;
},
compute: function () {
return ++computeCount;
},
destroy: function () {
destroyCount++;
this._super();
}
});
this.render('{{hello-world "whut"}}');
this.assertText('1');
this.runTask(function () {
return _this8.rerender();
});
this.assertText('1');
this.runTask(function () {
return helper.recompute();
});
this.assertText('2');
assert.strictEqual(destroyCount, 0, 'destroy is not called on recomputation');
};
_class.prototype['@test helper params can be returned'] = function testHelperParamsCanBeReturned() {
this.registerHelper('hello-world', function (values) {
return values;
});
this.render('{{#each (hello-world model) as |item|}}({{item}}){{/each}}', {
model: ['bob']
});
this.assertText('(bob)');
};
_class.prototype['@test helper hash can be returned'] = function testHelperHashCanBeReturned() {
this.registerHelper('hello-world', function (_, hash) {
return hash.model;
});
this.render('{{get (hello-world model=model) \'name\'}}', {
model: { name: 'bob' }
});
this.assertText('bob');
};
_class.prototype['@test simple helper is called for param changes'] = function testSimpleHelperIsCalledForParamChanges() {
var _this9 = this;
var computeCount = 0;
this.registerHelper('hello-world', function (_ref) {
var value = _ref[0];
computeCount++;
return value + '-value';
});
this.render('{{hello-world model.name}}', {
model: { name: 'bob' }
});
this.assertText('bob-value');
assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time');
this.runTask(function () {
return _this9.rerender();
});
this.assertText('bob-value');
assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time');
this.runTask(function () {
return (0, _emberMetal.set)(_this9.context, 'model.name', 'sal');
});
this.assertText('sal-value');
assert.strictEqual(computeCount, 2, 'compute is called exactly 2 times');
this.runTask(function () {
return (0, _emberMetal.set)(_this9.context, 'model', { name: 'bob' });
});
this.assertText('bob-value');
assert.strictEqual(computeCount, 3, 'compute is called exactly 3 times');
};
_class.prototype['@test class-based helper compute is called for param changes'] = function testClassBasedHelperComputeIsCalledForParamChanges() {
var _this10 = this;
var createCount = 0;
var computeCount = 0;
this.registerHelper('hello-world', {
init: function () {
this._super.apply(this, arguments);
createCount++;
},
compute: function (_ref2) {
var value = _ref2[0];
computeCount++;
return value + '-value';
}
});
this.render('{{hello-world model.name}}', {
model: { name: 'bob' }
});
this.assertText('bob-value');
assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time');
this.runTask(function () {
return _this10.rerender();
});
this.assertText('bob-value');
assert.strictEqual(computeCount, 1, 'compute is called exactly 1 time');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'model.name', 'sal');
});
this.assertText('sal-value');
assert.strictEqual(computeCount, 2, 'compute is called exactly 2 times');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'model', { name: 'bob' });
});
this.assertText('bob-value');
assert.strictEqual(computeCount, 3, 'compute is called exactly 3 times');
assert.strictEqual(createCount, 1, 'helper is only created once');
};
_class.prototype['@test simple helper receives params, hash'] = function testSimpleHelperReceivesParamsHash() {
var _this11 = this;
this.registerHelper('hello-world', function (_params, _hash) {
return 'params: ' + JSON.stringify(_params) + ', hash: ' + JSON.stringify(_hash);
});
this.render('{{hello-world model.name "rich" first=model.age last="sam"}}', {
model: {
name: 'bob',
age: 42
}
});
this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}');
this.runTask(function () {
return _this11.rerender();
});
this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'model.name', 'sal');
});
this.assertText('params: ["sal","rich"], hash: {"first":42,"last":"sam"}');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'model.age', 28);
});
this.assertText('params: ["sal","rich"], hash: {"first":28,"last":"sam"}');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'model', { name: 'bob', age: 42 });
});
this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}');
};
_class.prototype['@test class-based helper receives params, hash'] = function testClassBasedHelperReceivesParamsHash() {
var _this12 = this;
this.registerHelper('hello-world', {
compute: function (_params, _hash) {
return 'params: ' + JSON.stringify(_params) + ', hash: ' + JSON.stringify(_hash);
}
});
this.render('{{hello-world model.name "rich" first=model.age last="sam"}}', {
model: {
name: 'bob',
age: 42
}
});
this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}');
this.runTask(function () {
return _this12.rerender();
});
this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}');
this.runTask(function () {
return (0, _emberMetal.set)(_this12.context, 'model.name', 'sal');
});
this.assertText('params: ["sal","rich"], hash: {"first":42,"last":"sam"}');
this.runTask(function () {
return (0, _emberMetal.set)(_this12.context, 'model.age', 28);
});
this.assertText('params: ["sal","rich"], hash: {"first":28,"last":"sam"}');
this.runTask(function () {
return (0, _emberMetal.set)(_this12.context, 'model', { name: 'bob', age: 42 });
});
this.assertText('params: ["bob","rich"], hash: {"first":42,"last":"sam"}');
};
_class.prototype['@test class-based helper usable in subexpressions'] = function testClassBasedHelperUsableInSubexpressions() {
var _this13 = this;
this.registerHelper('join-words', {
compute: function (params) {
return params.join(' ');
}
});
this.render('{{join-words "Who"\n (join-words "overcomes" "by")\n model.reason\n (join-words (join-words "hath overcome but" "half"))\n (join-words "his" (join-words "foe"))}}', { model: { reason: 'force' } });
this.assertText('Who overcomes by force hath overcome but half his foe');
this.runTask(function () {
return _this13.rerender();
});
this.assertText('Who overcomes by force hath overcome but half his foe');
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'model.reason', 'Nickleback');
});
this.assertText('Who overcomes by Nickleback hath overcome but half his foe');
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'model', { reason: 'force' });
});
this.assertText('Who overcomes by force hath overcome but half his foe');
};
_class.prototype['@test parameterless helper is usable in subexpressions'] = function testParameterlessHelperIsUsableInSubexpressions() {
var _this14 = this;
this.registerHelper('should-show', function () {
return true;
});
this.render('{{#if (should-show)}}true{{/if}}');
this.assertText('true');
this.runTask(function () {
return _this14.rerender();
});
this.assertText('true');
};
_class.prototype['@test parameterless helper is usable in attributes'] = function testParameterlessHelperIsUsableInAttributes() {
var _this15 = this;
this.registerHelper('foo-bar', function () {
return 'baz';
});
this.render('<div data-foo-bar="{{foo-bar}}"></div>');
this.assertHTML('<div data-foo-bar="baz"></div>');
this.runTask(function () {
return _this15.rerender();
});
this.assertHTML('<div data-foo-bar="baz"></div>');
};
_class.prototype['@test simple helper not usable with a block'] = function testSimpleHelperNotUsableWithABlock() {
var _this16 = this;
this.registerHelper('some-helper', function () {});
expectAssertion(function () {
_this16.render('{{#some-helper}}{{/some-helper}}');
}, /Helpers may not be used in the block form/);
};
_class.prototype['@test class-based helper not usable with a block'] = function testClassBasedHelperNotUsableWithABlock() {
var _this17 = this;
this.registerHelper('some-helper', {
compute: function () {}
});
expectAssertion(function () {
_this17.render('{{#some-helper}}{{/some-helper}}');
}, /Helpers may not be used in the block form/);
};
_class.prototype['@test simple helper not usable within element'] = function testSimpleHelperNotUsableWithinElement() {
var _this18 = this;
this.registerHelper('some-helper', function () {});
this.assert.throws(function () {
_this18.render('<div {{some-helper}}></div>');
}, /Compile Error some-helper is not a modifier: Helpers may not be used in the element form/);
};
_class.prototype['@test class-based helper not usable within element'] = function testClassBasedHelperNotUsableWithinElement() {
var _this19 = this;
this.registerHelper('some-helper', {
compute: function () {}
});
this.assert.throws(function () {
_this19.render('<div {{some-helper}}></div>');
}, /Compile Error some-helper is not a modifier: Helpers may not be used in the element form/);
};
_class.prototype['@test class-based helper is torn down'] = function testClassBasedHelperIsTornDown() {
var destroyCalled = 0;
this.registerHelper('some-helper', {
destroy: function () {
destroyCalled++;
this._super.apply(this, arguments);
},
compute: function () {
return 'must define a compute';
}
});
this.render('{{some-helper}}');
(0, _internalTestHelpers.runDestroy)(this.component);
assert.strictEqual(destroyCalled, 1, 'destroy called once');
};
_class.prototype['@test class-based helper used in subexpression can recompute'] = function testClassBasedHelperUsedInSubexpressionCanRecompute() {
var _this20 = this;
var helper = void 0;
var phrase = 'overcomes by';
this.registerHelper('dynamic-segment', {
init: function () {
this._super.apply(this, arguments);
helper = this;
},
compute: function () {
return phrase;
}
});
this.registerHelper('join-words', {
compute: function (params) {
return params.join(' ');
}
});
this.render('{{join-words "Who"\n (dynamic-segment)\n "force"\n (join-words (join-words "hath overcome but" "half"))\n (join-words "his" (join-words "foe"))}}');
this.assertText('Who overcomes by force hath overcome but half his foe');
this.runTask(function () {
return _this20.rerender();
});
this.assertText('Who overcomes by force hath overcome but half his foe');
phrase = 'believes his';
this.runTask(function () {
return helper.recompute();
});
this.assertText('Who believes his force hath overcome but half his foe');
phrase = 'overcomes by';
this.runTask(function () {
return helper.recompute();
});
this.assertText('Who overcomes by force hath overcome but half his foe');
};
_class.prototype['@test class-based helper used in subexpression can recompute component'] = function testClassBasedHelperUsedInSubexpressionCanRecomputeComponent() {
var _this21 = this;
var helper = void 0;
var phrase = 'overcomes by';
this.registerHelper('dynamic-segment', {
init: function () {
this._super.apply(this, arguments);
helper = this;
},
compute: function () {
return phrase;
}
});
this.registerHelper('join-words', {
compute: function (params) {
return params.join(' ');
}
});
this.registerComponent('some-component', {
template: '{{first}} {{second}} {{third}} {{fourth}} {{fifth}}'
});
this.render('{{some-component first="Who"\n second=(dynamic-segment)\n third="force"\n fourth=(join-words (join-words "hath overcome but" "half"))\n fifth=(join-words "his" (join-words "foe"))}}');
this.assertText('Who overcomes by force hath overcome but half his foe');
this.runTask(function () {
return _this21.rerender();
});
this.assertText('Who overcomes by force hath overcome but half his foe');
phrase = 'believes his';
this.runTask(function () {
return helper.recompute();
});
this.assertText('Who believes his force hath overcome but half his foe');
phrase = 'overcomes by';
this.runTask(function () {
return helper.recompute();
});
this.assertText('Who overcomes by force hath overcome but half his foe');
};
_class.prototype['@test class-based helper used in subexpression is destroyed'] = function testClassBasedHelperUsedInSubexpressionIsDestroyed() {
var destroyCount = 0;
this.registerHelper('dynamic-segment', {
phrase: 'overcomes by',
init: function () {
this._super.apply(this, arguments);
},
compute: function () {
return this.phrase;
},
destroy: function () {
destroyCount++;
this._super.apply(this, arguments);
}
});
this.registerHelper('join-words', {
compute: function (params) {
return params.join(' ');
}
});
this.render('{{join-words "Who"\n (dynamic-segment)\n "force"\n (join-words (join-words "hath overcome but" "half"))\n (join-words "his" (join-words "foe"))}}');
(0, _internalTestHelpers.runDestroy)(this.component);
equal(destroyCount, 1, 'destroy is called after a view is destroyed');
};
_class.prototype['@test simple helper can be invoked manually via `owner.factoryFor(...).create().compute()'] = function testSimpleHelperCanBeInvokedManuallyViaOwnerFactoryForCreateCompute(assert) {
this.registerHelper('some-helper', function () {
assert.ok(true, 'some-helper helper invoked');
return 'lolol';
});
var instance = this.owner.factoryFor('helper:some-helper').create();
assert.equal(typeof instance.compute, 'function', 'expected instance.compute to be present');
assert.equal(instance.compute(), 'lolol', 'can invoke `.compute`');
};
_class.prototype['@test class-based helper can be invoked manually via `owner.factoryFor(...).create().compute()'] = function testClassBasedHelperCanBeInvokedManuallyViaOwnerFactoryForCreateCompute() {
this.registerHelper('some-helper', {
compute: function () {
assert.ok(true, 'some-helper helper invoked');
return 'lolol';
}
});
var instance = this.owner.factoryFor('helper:some-helper').create();
assert.equal(typeof instance.compute, 'function', 'expected instance.compute to be present');
assert.equal(instance.compute(), 'lolol', 'can invoke `.compute`');
};
return _class;
}(_testCase.RenderingTest));
// these feature detects prevent errors in these tests
// on platforms (*cough* IE9 *cough*) that do not
// property support `Object.freeze`
var pushingIntoFrozenArrayThrows = function () {
var array = [];
Object.freeze(array);
try {
array.push('foo');
return false;
} catch (e) {
return true;
}
}();
var assigningExistingFrozenPropertyThrows = function () {
var obj = { foo: 'asdf' };
Object.freeze(obj);
try {
obj.foo = 'derp';
return false;
} catch (e) {
return true;
}
}();
var addingPropertyToFrozenObjectThrows = function () {
var obj = { foo: 'asdf' };
Object.freeze(obj);
try {
obj.bar = 'derp';
return false;
} catch (e) {
return true;
}
}();
if (!EmberDev.runningProdBuild && _emberUtils.HAS_NATIVE_WEAKMAP && (pushingIntoFrozenArrayThrows || assigningExistingFrozenPropertyThrows || addingPropertyToFrozenObjectThrows)) {
var HelperMutatingArgsTests = function (_RenderingTest2) {
(0, _emberBabel.inherits)(HelperMutatingArgsTests, _RenderingTest2);
function HelperMutatingArgsTests() {
(0, _emberBabel.classCallCheck)(this, HelperMutatingArgsTests);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest2.apply(this, arguments));
}
HelperMutatingArgsTests.prototype.buildCompute = function buildCompute() {
var _this23 = this;
return function (params, hash) {
if (pushingIntoFrozenArrayThrows) {
_this23.assert.throws(function () {
params.push('foo');
// cannot assert error message as it varies by platform
});
}
if (assigningExistingFrozenPropertyThrows) {
_this23.assert.throws(function () {
hash.foo = 'bar';
// cannot assert error message as it varies by platform
});
}
if (addingPropertyToFrozenObjectThrows) {
_this23.assert.throws(function () {
hash.someUnusedHashProperty = 'bar';
// cannot assert error message as it varies by platform
});
}
};
};
HelperMutatingArgsTests.prototype['@test cannot mutate params - no positional specified / named specified'] = function testCannotMutateParamsNoPositionalSpecifiedNamedSpecified() {
this.render('{{test-helper foo=bar}}', { bar: 'derp' });
};
HelperMutatingArgsTests.prototype['@test cannot mutate params - positional specified / no named specified'] = function testCannotMutateParamsPositionalSpecifiedNoNamedSpecified() {
this.render('{{test-helper bar}}', { bar: 'derp' });
};
HelperMutatingArgsTests.prototype['@test cannot mutate params - positional specified / named specified'] = function testCannotMutateParamsPositionalSpecifiedNamedSpecified() {
this.render('{{test-helper bar foo=qux}}', { bar: 'derp', qux: 'baz' });
};
HelperMutatingArgsTests.prototype['@test cannot mutate params - no positional specified / no named specified'] = function testCannotMutateParamsNoPositionalSpecifiedNoNamedSpecified() {
this.render('{{test-helper}}', { bar: 'derp', qux: 'baz' });
};
return HelperMutatingArgsTests;
}(_testCase.RenderingTest);
(0, _testCase.moduleFor)('Helpers test: mutation triggers errors - class based helper', function (_HelperMutatingArgsTe) {
(0, _emberBabel.inherits)(_class2, _HelperMutatingArgsTe);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
var _this24 = (0, _emberBabel.possibleConstructorReturn)(this, _HelperMutatingArgsTe.call(this));
var compute = _this24.buildCompute();
_this24.registerHelper('test-helper', {
compute: compute
});
return _this24;
}
return _class2;
}(HelperMutatingArgsTests));
(0, _testCase.moduleFor)('Helpers test: mutation triggers errors - simple helper', function (_HelperMutatingArgsTe2) {
(0, _emberBabel.inherits)(_class3, _HelperMutatingArgsTe2);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
var _this25 = (0, _emberBabel.possibleConstructorReturn)(this, _HelperMutatingArgsTe2.call(this));
var compute = _this25.buildCompute();
_this25.registerHelper('test-helper', compute);
return _this25;
}
return _class3;
}(HelperMutatingArgsTests));
}
});
QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/custom-helper-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/helpers/custom-helper-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/helpers/element-action-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/abstract-test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal', 'ember/features', 'ember-runtime', 'ember-views'], function (_emberBabel, _testCase, _abstractTestCase, _helpers, _emberMetal, _features, _emberRuntime, _emberViews) {
'use strict';
var _templateObject = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#inner-component}}\n <button {{action "wat"}}>Wat me!</button>\n {{/inner-component}}\n '], ['\n {{#inner-component}}\n <button {{action "wat"}}>Wat me!</button>\n {{/inner-component}}\n ']),
_templateObject2 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#target-component as |parent|}}\n {{other-component anotherTarget=parent}}\n {{/target-component}}\n '], ['\n {{#target-component as |parent|}}\n {{other-component anotherTarget=parent}}\n {{/target-component}}\n ']),
_templateObject3 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#target-component as |aTarget|}}\n <a id="edit" href="#" {{action "edit" this target=aTarget}}>click me</a>\n {{/target-component}}\n '], ['\n {{#target-component as |aTarget|}}\n <a id="edit" href="#" {{action "edit" this target=aTarget}}>click me</a>\n {{/target-component}}\n ']),
_templateObject4 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <a href="#"\n {{action "clicked" on="click"}}\n {{action "doubleClicked" on="doubleClick"}}\n >click me</a>'], ['\n <a href="#"\n {{action "clicked" on="click"}}\n {{action "doubleClicked" on="doubleClick"}}\n >click me</a>']),
_templateObject5 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n {{#middle-component}}\n {{inner-component action="hey"}}\n {{/middle-component}}\n '], ['\n {{#middle-component}}\n {{inner-component action="hey"}}\n {{/middle-component}}\n ']),
_templateObject6 = (0, _emberBabel.taggedTemplateLiteralLoose)(['\n <button>Click Me</button>\n {{yield}}\n '], ['\n <button>Click Me</button>\n {{yield}}\n ']);
function getActionAttributes(element) {
var attributes = element.attributes;
var actionAttrs = [];
for (var i = 0; i < attributes.length; i++) {
var attr = attributes.item(i);
if (attr.name.indexOf('data-ember-action-') === 0) {
actionAttrs.push(attr.name);
}
}
return actionAttrs;
}
function getActionIds(element) {
return getActionAttributes(element).map(function (attribute) {
return attribute.slice('data-ember-action-'.length);
});
}
if (_features.EMBER_IMPROVED_INSTRUMENTATION) {
(0, _testCase.moduleFor)('Helpers test: element action instrumentation', 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.teardown = function teardown() {
_RenderingTest.prototype.teardown.call(this);
(0, _emberMetal.instrumentationReset)();
};
_class.prototype['@test action should fire interaction event with proper params'] = function testActionShouldFireInteractionEventWithProperParams() {
var _this2 = this;
var subscriberCallCount = 0;
var subscriberPayload = null;
var ExampleComponent = _helpers.Component.extend({
actions: {
foo: function () {}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<button {{action "foo" "bar"}}>Click me</button>'
});
(0, _emberMetal.instrumentationSubscribe)('interaction.ember-action', {
before: function () {
subscriberCallCount++;
},
after: function (name, time, payload) {
subscriberPayload = payload;
}
});
this.render('{{example-component}}');
this.assert.equal(subscriberCallCount, 0, 'subscriber has not been called');
this.runTask(function () {
return _this2.rerender();
});
this.assert.equal(subscriberCallCount, 0, 'subscriber has not been called');
this.runTask(function () {
_this2.$('button').click();
});
this.assert.equal(subscriberCallCount, 1, 'subscriber has been called 1 time');
this.assert.equal(subscriberPayload.name, 'foo', 'subscriber called with correct name');
this.assert.equal(subscriberPayload.args[0], 'bar', 'subscriber called with correct args');
};
return _class;
}(_testCase.RenderingTest));
}
(0, _testCase.moduleFor)('Helpers test: element action', function (_RenderingTest2) {
(0, _emberBabel.inherits)(_class2, _RenderingTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest2.apply(this, arguments));
}
_class2.prototype['@test it can call an action on its enclosing component'] = function testItCanCallAnActionOnItsEnclosingComponent() {
var _this4 = this;
var fooCallCount = 0;
var ExampleComponent = _helpers.Component.extend({
actions: {
foo: function () {
fooCallCount++;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<button {{action "foo"}}>Click me</button>'
});
this.render('{{example-component}}');
this.assert.equal(fooCallCount, 0, 'foo has not been called');
this.runTask(function () {
return _this4.rerender();
});
this.assert.equal(fooCallCount, 0, 'foo has not been called');
this.runTask(function () {
_this4.$('button').click();
});
this.assert.equal(fooCallCount, 1, 'foo has been called 1 time');
this.runTask(function () {
_this4.$('button').click();
});
this.assert.equal(fooCallCount, 2, 'foo has been called 2 times');
};
_class2.prototype['@test it can call an action with parameters'] = function testItCanCallAnActionWithParameters() {
var _this5 = this;
var fooArgs = [];
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
member: 'a',
init: function () {
this._super.apply(this, arguments);
component = this;
},
actions: {
foo: function (thing) {
fooArgs.push(thing);
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<button {{action "foo" member}}>Click me</button>'
});
this.render('{{example-component}}');
this.assert.deepEqual(fooArgs, [], 'foo has not been called');
this.runTask(function () {
return _this5.rerender();
});
this.assert.deepEqual(fooArgs, [], 'foo has not been called');
this.runTask(function () {
_this5.$('button').click();
});
this.assert.deepEqual(fooArgs, ['a'], 'foo has not been called');
this.runTask(function () {
component.set('member', 'b');
});
this.runTask(function () {
_this5.$('button').click();
});
this.assert.deepEqual(fooArgs, ['a', 'b'], 'foo has been called with an updated value');
};
_class2.prototype['@test it should output a marker attribute with a guid'] = function testItShouldOutputAMarkerAttributeWithAGuid() {
this.render('<button {{action "show"}}>me the money</button>');
var button = this.$('button');
var attributes = getActionAttributes(button.get(0));
this.assert.ok(button.attr('data-ember-action').match(''), 'An empty data-ember-action attribute was added');
this.assert.ok(attributes[0].match(/data-ember-action-\d+/), 'A data-ember-action-xyz attribute with a guid was added');
};
_class2.prototype['@test it should allow alternative events to be handled'] = function testItShouldAllowAlternativeEventsToBeHandled() {
var _this6 = this;
var showCalled = false;
var ExampleComponent = _helpers.Component.extend({
actions: {
show: function () {
showCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<div id="show" {{action "show" on="mouseUp"}}></div>'
});
this.render('{{example-component}}');
this.runTask(function () {
var event = _emberViews.jQuery.Event('mouseup');
_this6.$('#show').trigger(event);
});
this.assert.ok(showCalled, 'show action was called on mouseUp');
};
_class2.prototype['@test inside a yield, the target points at the original target'] = function testInsideAYieldTheTargetPointsAtTheOriginalTarget() {
var _this7 = this;
var targetWatted = false;
var innerWatted = false;
var TargetComponent = _helpers.Component.extend({
actions: {
wat: function () {
targetWatted = true;
}
}
});
var InnerComponent = _helpers.Component.extend({
actions: {
wat: function () {
innerWatted = true;
}
}
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: '{{yield}}'
});
this.registerComponent('target-component', {
ComponentClass: TargetComponent,
template: (0, _abstractTestCase.strip)(_templateObject)
});
this.render('{{target-component}}');
this.runTask(function () {
_this7.$('button').click();
});
this.assert.ok(targetWatted, 'the correct target was watted');
this.assert.notOk(innerWatted, 'the inner target was not watted');
};
_class2.prototype['@test it should allow a target to be specified'] = function testItShouldAllowATargetToBeSpecified() {
var _this8 = this;
var targetWatted = false;
var TargetComponent = _helpers.Component.extend({
actions: {
wat: function () {
targetWatted = true;
}
}
});
var OtherComponent = _helpers.Component.extend({});
this.registerComponent('target-component', {
ComponentClass: TargetComponent,
template: '{{yield this}}'
});
this.registerComponent('other-component', {
ComponentClass: OtherComponent,
template: '<a {{action "wat" target=anotherTarget}}>Wat?</a>'
});
this.render((0, _abstractTestCase.strip)(_templateObject2));
this.runTask(function () {
_this8.$('a').click();
});
this.assert.equal(targetWatted, true, 'the specified target was watted');
};
_class2.prototype['@test it should lazily evaluate the target'] = function testItShouldLazilyEvaluateTheTarget() {
var _this9 = this;
var firstEdit = 0;
var secondEdit = 0;
var component = void 0;
var first = {
edit: function () {
firstEdit++;
}
};
var second = {
edit: function () {
secondEdit++;
}
};
var ExampleComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
theTarget: first
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a {{action "edit" target=theTarget}}>Edit</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this9.$('a').click();
});
this.assert.equal(firstEdit, 1);
this.runTask(function () {
(0, _emberMetal.set)(component, 'theTarget', second);
});
this.runTask(function () {
_this9.$('a').click();
});
this.assert.equal(firstEdit, 1);
this.assert.equal(secondEdit, 1);
};
_class2.prototype['@test it should register an event handler'] = function testItShouldRegisterAnEventHandler() {
var _this10 = this;
var editHandlerWasCalled = false;
var shortcutHandlerWasCalled = false;
var ExampleComponent = _helpers.Component.extend({
actions: {
edit: function () {
editHandlerWasCalled = true;
},
shortcut: function () {
shortcutHandlerWasCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a href="#" {{action "edit" allowedKeys="alt"}}>click me</a> <div {{action "shortcut" allowedKeys="any"}}>click me too</div>'
});
this.render('{{example-component}}');
this.runTask(function () {
var event = _emberViews.jQuery.Event('click');
event.altKey = true;
_this10.$('a[data-ember-action]').trigger(event);
});
this.assert.equal(editHandlerWasCalled, true, 'the event handler was called');
this.runTask(function () {
var event = _emberViews.jQuery.Event('click');
event.ctrlKey = true;
_this10.$('div[data-ember-action]').trigger(event);
});
this.assert.equal(shortcutHandlerWasCalled, true, 'the "any" shortcut\'s event handler was called');
};
_class2.prototype['@test it handles whitelisted bound modifier keys'] = function testItHandlesWhitelistedBoundModifierKeys() {
var _this11 = this;
var editHandlerWasCalled = false;
var shortcutHandlerWasCalled = false;
var ExampleComponent = _helpers.Component.extend({
altKey: 'alt',
anyKey: 'any',
actions: {
edit: function () {
editHandlerWasCalled = true;
},
shortcut: function () {
shortcutHandlerWasCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a href="#" {{action "edit" allowedKeys=altKey}}>click me</a> <div {{action "shortcut" allowedKeys=anyKey}}>click me too</div>'
});
this.render('{{example-component}}');
this.runTask(function () {
var event = _emberViews.jQuery.Event('click');
event.altKey = true;
_this11.$('a[data-ember-action]').trigger(event);
});
this.assert.equal(editHandlerWasCalled, true, 'the event handler was called');
this.runTask(function () {
var event = _emberViews.jQuery.Event('click');
event.ctrlKey = true;
_this11.$('div[data-ember-action]').trigger(event);
});
this.assert.equal(shortcutHandlerWasCalled, true, 'the "any" shortcut\'s event handler was called');
};
_class2.prototype['@test it handles whitelisted bound modifier keys with current value'] = function testItHandlesWhitelistedBoundModifierKeysWithCurrentValue() {
var _this12 = this;
var editHandlerWasCalled = false;
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
acceptedKeys: 'alt',
actions: {
edit: function () {
editHandlerWasCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a href="#" {{action "edit" allowedKeys=acceptedKeys}}>click me</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
var event = _emberViews.jQuery.Event('click');
event.altKey = true;
_this12.$('a[data-ember-action]').trigger(event);
});
this.assert.equal(editHandlerWasCalled, true, 'the event handler was called');
editHandlerWasCalled = false;
this.runTask(function () {
component.set('acceptedKeys', '');
});
this.runTask(function () {
var event = _emberViews.jQuery.Event('click');
_this12.$('div[data-ember-action]').trigger(event);
});
this.assert.equal(editHandlerWasCalled, false, 'the event handler was not called');
};
_class2.prototype['@test should be able to use action more than once for the same event within a view'] = function testShouldBeAbleToUseActionMoreThanOnceForTheSameEventWithinAView() {
var _this13 = this;
var editHandlerWasCalled = false;
var deleteHandlerWasCalled = false;
var originalHandlerWasCalled = false;
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
actions: {
edit: function () {
editHandlerWasCalled = true;
},
'delete': function () {
deleteHandlerWasCalled = true;
}
},
click: function () {
originalHandlerWasCalled = true;
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a id="edit" href="#" {{action "edit"}}>edit</a><a id="delete" href="#" {{action "delete"}}>delete</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this13.$('#edit').click();
});
this.assert.equal(editHandlerWasCalled, true, 'the edit action was called');
this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called');
this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called (due to bubbling)');
editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false;
this.runTask(function () {
_this13.$('#delete').click();
});
this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called');
this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called');
this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called (due to bubbling)');
editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false;
this.runTask(function () {
component.$().click();
});
this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called');
this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called');
this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called');
};
_class2.prototype['@test the event should not bubble if `bubbles=false` is passed'] = function testTheEventShouldNotBubbleIfBubblesFalseIsPassed() {
var _this14 = this;
var editHandlerWasCalled = false;
var deleteHandlerWasCalled = false;
var originalHandlerWasCalled = false;
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
actions: {
edit: function () {
editHandlerWasCalled = true;
},
'delete': function () {
deleteHandlerWasCalled = true;
}
},
click: function () {
originalHandlerWasCalled = true;
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a id="edit" href="#" {{action "edit" bubbles=false}}>edit</a><a id="delete" href="#" {{action "delete" bubbles=false}}>delete</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this14.$('#edit').click();
});
this.assert.equal(editHandlerWasCalled, true, 'the edit action was called');
this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called');
this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called');
editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false;
this.runTask(function () {
_this14.$('#delete').click();
});
this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called');
this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called');
this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called');
editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false;
this.runTask(function () {
component.$().click();
});
this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called');
this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called');
this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called');
};
_class2.prototype['@test the event should not bubble if `bubbles=false` is passed bound'] = function testTheEventShouldNotBubbleIfBubblesFalseIsPassedBound() {
var _this15 = this;
var editHandlerWasCalled = false;
var deleteHandlerWasCalled = false;
var originalHandlerWasCalled = false;
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
isFalse: false,
actions: {
edit: function () {
editHandlerWasCalled = true;
},
'delete': function () {
deleteHandlerWasCalled = true;
}
},
click: function () {
originalHandlerWasCalled = true;
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a id="edit" href="#" {{action "edit" bubbles=isFalse}}>edit</a><a id="delete" href="#" {{action "delete" bubbles=isFalse}}>delete</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this15.$('#edit').click();
});
this.assert.equal(editHandlerWasCalled, true, 'the edit action was called');
this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called');
this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called');
editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false;
this.runTask(function () {
_this15.$('#delete').click();
});
this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called');
this.assert.equal(deleteHandlerWasCalled, true, 'the delete action was called');
this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called');
editHandlerWasCalled = deleteHandlerWasCalled = originalHandlerWasCalled = false;
this.runTask(function () {
component.$().click();
});
this.assert.equal(editHandlerWasCalled, false, 'the edit action was not called');
this.assert.equal(deleteHandlerWasCalled, false, 'the delete action was not called');
this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called');
};
_class2.prototype['@test the bubbling depends on the bound parameter'] = function testTheBubblingDependsOnTheBoundParameter() {
var _this16 = this;
var editHandlerWasCalled = false;
var originalHandlerWasCalled = false;
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
shouldBubble: false,
actions: {
edit: function () {
editHandlerWasCalled = true;
}
},
click: function () {
originalHandlerWasCalled = true;
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a id="edit" href="#" {{action "edit" bubbles=shouldBubble}}>edit</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this16.$('#edit').click();
});
this.assert.equal(editHandlerWasCalled, true, 'the edit action was called');
this.assert.equal(originalHandlerWasCalled, false, 'the click handler was not called');
editHandlerWasCalled = originalHandlerWasCalled = false;
this.runTask(function () {
component.set('shouldBubble', true);
});
this.runTask(function () {
_this16.$('#edit').click();
});
this.assert.equal(editHandlerWasCalled, true, 'the edit action was called');
this.assert.equal(originalHandlerWasCalled, true, 'the click handler was called');
};
_class2.prototype['@test it should work properly in an #each block'] = function testItShouldWorkProperlyInAnEachBlock() {
var _this17 = this;
var editHandlerWasCalled = false;
var ExampleComponent = _helpers.Component.extend({
items: (0, _emberRuntime.A)([1, 2, 3, 4]),
actions: {
edit: function () {
editHandlerWasCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '{{#each items as |item|}}<a href="#" {{action "edit"}}>click me</a>{{/each}}'
});
this.render('{{example-component}}');
this.runTask(function () {
_this17.$('a').click();
});
this.assert.equal(editHandlerWasCalled, true, 'the event handler was called');
};
_class2.prototype['@test it should work properly in a {{#with foo as |bar|}} block'] = function testItShouldWorkProperlyInAWithFooAsBarBlock() {
var _this18 = this;
var editHandlerWasCalled = false;
var ExampleComponent = _helpers.Component.extend({
something: { ohai: 'there' },
actions: {
edit: function () {
editHandlerWasCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '{{#with something as |somethingElse|}}<a href="#" {{action "edit"}}>click me</a>{{/with}}'
});
this.render('{{example-component}}');
this.runTask(function () {
_this18.$('a').click();
});
this.assert.equal(editHandlerWasCalled, true, 'the event handler was called');
};
_class2.prototype['@test it should unregister event handlers when an element action is removed'] = function testItShouldUnregisterEventHandlersWhenAnElementActionIsRemoved() {
var _this19 = this;
var ExampleComponent = _helpers.Component.extend({
actions: {
edit: function () {}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '{{#if isActive}}<a href="#" {{action "edit"}}>click me</a>{{/if}}'
});
this.render('{{example-component isActive=isActive}}', { isActive: true });
equal(this.$('a[data-ember-action]').length, 1, 'The element is rendered');
var actionId = void 0;
actionId = getActionIds(this.$('a[data-ember-action]').get(0))[0];
ok(_emberViews.ActionManager.registeredActions[actionId], 'An action is registered');
this.runTask(function () {
return _this19.rerender();
});
equal(this.$('a[data-ember-action]').length, 1, 'The element is still present');
ok(_emberViews.ActionManager.registeredActions[actionId], 'The action is still registered');
this.runTask(function () {
return (0, _emberMetal.set)(_this19.context, 'isActive', false);
});
strictEqual(this.$('a[data-ember-action]').length, 0, 'The element is removed');
ok(!_emberViews.ActionManager.registeredActions[actionId], 'The action is unregistered');
this.runTask(function () {
return (0, _emberMetal.set)(_this19.context, 'isActive', true);
});
equal(this.$('a[data-ember-action]').length, 1, 'The element is rendered');
actionId = getActionIds(this.$('a[data-ember-action]').get(0))[0];
ok(_emberViews.ActionManager.registeredActions[actionId], 'A new action is registered');
};
_class2.prototype['@test it should capture events from child elements and allow them to trigger the action'] = function testItShouldCaptureEventsFromChildElementsAndAllowThemToTriggerTheAction() {
var _this20 = this;
var editHandlerWasCalled = false;
var ExampleComponent = _helpers.Component.extend({
actions: {
edit: function () {
editHandlerWasCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<div {{action "edit"}}><button>click me</button></div>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this20.$('button').click();
});
this.assert.ok(editHandlerWasCalled, 'event on a child target triggered the action of its parent');
};
_class2.prototype['@test it should allow bubbling of events from action helper to original parent event'] = function testItShouldAllowBubblingOfEventsFromActionHelperToOriginalParentEvent() {
var _this21 = this;
var editHandlerWasCalled = false;
var originalHandlerWasCalled = false;
var ExampleComponent = _helpers.Component.extend({
actions: {
edit: function () {
editHandlerWasCalled = true;
}
},
click: function () {
originalHandlerWasCalled = true;
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a href="#" {{action "edit"}}>click me</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this21.$('a').click();
});
this.assert.ok(editHandlerWasCalled && originalHandlerWasCalled, 'both event handlers were called');
};
_class2.prototype['@test it should not bubble an event from action helper to original parent event if `bubbles=false` is passed'] = function testItShouldNotBubbleAnEventFromActionHelperToOriginalParentEventIfBubblesFalseIsPassed() {
var _this22 = this;
var editHandlerWasCalled = false;
var originalHandlerWasCalled = false;
var ExampleComponent = _helpers.Component.extend({
actions: {
edit: function () {
editHandlerWasCalled = true;
}
},
click: function () {
originalHandlerWasCalled = true;
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a href="#" {{action "edit" bubbles=false}}>click me</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this22.$('a').click();
});
this.assert.ok(editHandlerWasCalled, 'the child event handler was called');
this.assert.notOk(originalHandlerWasCalled, 'the parent handler was not called');
};
_class2.prototype['@test it should allow "send" as the action name (#594)'] = function testItShouldAllowSendAsTheActionName594() {
var _this23 = this;
var sendHandlerWasCalled = false;
var ExampleComponent = _helpers.Component.extend({
actions: {
send: function () {
sendHandlerWasCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a href="#" {{action "send"}}>click me</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this23.$('a').click();
});
this.assert.ok(sendHandlerWasCalled, 'the event handler was called');
};
_class2.prototype['@test it should send the view, event, and current context to the action'] = function testItShouldSendTheViewEventAndCurrentContextToTheAction() {
var _this24 = this;
var passedTarget = void 0;
var passedContext = void 0;
var targetThis = void 0;
var TargetComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
targetThis = this;
},
actions: {
edit: function (context) {
passedTarget = this === targetThis;
passedContext = context;
}
}
});
var aContext = void 0;
var ExampleComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
aContext = this;
}
});
this.registerComponent('target-component', {
ComponentClass: TargetComponent,
template: '{{yield this}}'
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: (0, _abstractTestCase.strip)(_templateObject3)
});
this.render('{{example-component}}');
this.runTask(function () {
_this24.$('#edit').click();
});
this.assert.ok(passedTarget, 'the action is called with the target as this');
this.assert.strictEqual(passedContext, aContext, 'the parameter is passed along');
};
_class2.prototype['@test it should only trigger actions for the event they were registered on'] = function testItShouldOnlyTriggerActionsForTheEventTheyWereRegisteredOn() {
var _this25 = this;
var editHandlerWasCalled = false;
var ExampleComponent = _helpers.Component.extend({
actions: {
edit: function () {
editHandlerWasCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a href="#" {{action "edit"}}>click me</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this25.$('a').click();
});
this.assert.ok(editHandlerWasCalled, 'the event handler was called on click');
editHandlerWasCalled = false;
this.runTask(function () {
_this25.$('a').trigger('mouseover');
});
this.assert.notOk(editHandlerWasCalled, 'the event handler was not called on mouseover');
};
_class2.prototype['@test it should allow multiple contexts to be specified'] = function testItShouldAllowMultipleContextsToBeSpecified() {
var _this26 = this;
var passedContexts = void 0;
var models = [_emberRuntime.Object.create(), _emberRuntime.Object.create()];
var ExampleComponent = _helpers.Component.extend({
modelA: models[0],
modelB: models[1],
actions: {
edit: function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
passedContexts = args;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<button {{action "edit" modelA modelB}}>click me</button>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this26.$('button').click();
});
this.assert.deepEqual(passedContexts, models, 'the action was called with the passed contexts');
};
_class2.prototype['@test it should allow multiple contexts to be specified mixed with string args'] = function testItShouldAllowMultipleContextsToBeSpecifiedMixedWithStringArgs() {
var _this27 = this;
var passedContexts = void 0;
var model = _emberRuntime.Object.create();
var ExampleComponent = _helpers.Component.extend({
model: model,
actions: {
edit: function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
passedContexts = args;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<button {{action "edit" "herp" model}}>click me</button>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this27.$('button').click();
});
this.assert.deepEqual(passedContexts, ['herp', model], 'the action was called with the passed contexts');
};
_class2.prototype['@test it should not trigger action with special clicks'] = function testItShouldNotTriggerActionWithSpecialClicks() {
var showCalled = false;
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
actions: {
show: function () {
showCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<button {{action "show" href=true}}>Howdy</button>'
});
this.render('{{example-component}}');
var assert = this.assert;
function checkClick(prop, value, expected) {
var event = _emberViews.jQuery.Event('click');
event[prop] = value;
component.$('button').trigger(event);
if (expected) {
assert.ok(showCalled, 'should call action with ' + prop + ':' + value);
assert.ok(event.isDefaultPrevented(), 'should prevent default');
} else {
assert.notOk(showCalled, 'should not call action with ' + prop + ':' + value);
assert.notOk(event.isDefaultPrevented(), 'should not prevent default');
}
}
checkClick('ctrlKey', true, false);
checkClick('altKey', true, false);
checkClick('metaKey', true, false);
checkClick('shiftKey', true, false);
checkClick('which', 2, false);
checkClick('which', 1, true);
checkClick('which', undefined, true); // IE <9
};
_class2.prototype['@test it can trigger actions for keyboard events'] = function testItCanTriggerActionsForKeyboardEvents() {
var _this28 = this;
var showCalled = false;
var ExampleComponent = _helpers.Component.extend({
actions: {
show: function () {
showCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<input type="text" {{action "show" on="keyUp"}}>'
});
this.render('{{example-component}}');
this.runTask(function () {
var event = _emberViews.jQuery.Event('keyup');
event.char = 'a';
event.which = 65;
_this28.$('input').trigger(event);
});
this.assert.ok(showCalled, 'the action was called with keyup');
};
_class2.prototype['@test a quoteless parameter should allow dynamic lookup of the actionName'] = function testAQuotelessParameterShouldAllowDynamicLookupOfTheActionName() {
var lastAction = void 0;
var actionOrder = [];
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
hookMeUp: 'rock',
actions: {
rock: function () {
lastAction = 'rock';
actionOrder.push('rock');
},
paper: function () {
lastAction = 'paper';
actionOrder.push('paper');
},
scissors: function () {
lastAction = 'scissors';
actionOrder.push('scissors');
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a id="bound-param" {{action hookMeUp}}>Whistle tips go woop woooop</a>'
});
this.render('{{example-component}}');
var test = this;
function testBoundAction(propertyValue) {
test.runTask(function () {
component.set('hookMeUp', propertyValue);
});
test.runTask(function () {
component.$('#bound-param').click();
});
test.assert.ok(lastAction, propertyValue, 'lastAction set to ' + propertyValue);
}
testBoundAction('rock');
testBoundAction('paper');
testBoundAction('scissors');
this.assert.deepEqual(actionOrder, ['rock', 'paper', 'scissors'], 'action name was looked up properly');
};
_class2.prototype['@test a quoteless string parameter should resolve actionName, including path'] = function testAQuotelessStringParameterShouldResolveActionNameIncludingPath() {
var lastAction = void 0;
var actionOrder = [];
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
init: function () {
this._super.apply(this, arguments);
component = this;
},
allactions: (0, _emberRuntime.A)([{ title: 'Rock', name: 'rock' }, { title: 'Paper', name: 'paper' }, { title: 'Scissors', name: 'scissors' }]),
actions: {
rock: function () {
lastAction = 'rock';
actionOrder.push('rock');
},
paper: function () {
lastAction = 'paper';
actionOrder.push('paper');
},
scissors: function () {
lastAction = 'scissors';
actionOrder.push('scissors');
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '{{#each allactions as |allaction|}}<a id="{{allaction.name}}" {{action allaction.name}}>{{allaction.title}}</a>{{/each}}'
});
this.render('{{example-component}}');
var test = this;
function testBoundAction(propertyValue) {
test.runTask(function () {
component.$('#' + propertyValue).click();
});
test.assert.ok(lastAction, propertyValue, 'lastAction set to ' + propertyValue);
}
testBoundAction('rock');
testBoundAction('paper');
testBoundAction('scissors');
this.assert.deepEqual(actionOrder, ['rock', 'paper', 'scissors'], 'action name was looked up properly');
};
_class2.prototype['@test a quoteless function parameter should be called, including arguments'] = function testAQuotelessFunctionParameterShouldBeCalledIncludingArguments() {
var _this29 = this;
var submitCalled = false;
var incomingArg = void 0;
var arg = 'rough ray';
var ExampleComponent = _helpers.Component.extend({
submit: function (actualArg) {
incomingArg = actualArg;
submitCalled = true;
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a {{action submit \'' + arg + '\'}}>Hi</a>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this29.$('a').click();
});
this.assert.ok(submitCalled, 'submit function called');
this.assert.equal(incomingArg, arg, 'argument passed');
};
_class2.prototype['@test a quoteless parameter that does not resolve to a value asserts'] = function testAQuotelessParameterThatDoesNotResolveToAValueAsserts() {
var _this30 = this;
var ExampleComponent = _helpers.Component.extend({
actions: {
ohNoeNotValid: function () {}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a id="oops-bound-param" {{action ohNoeNotValid}}>Hi</a>'
});
expectAssertion(function () {
_this30.render('{{example-component}}');
}, 'You specified a quoteless path, `ohNoeNotValid`, to the {{action}} helper ' + 'which did not resolve to an action name (a string). ' + 'Perhaps you meant to use a quoted actionName? (e.g. {{action "ohNoeNotValid"}}).');
};
_class2.prototype['@test allows multiple actions on a single element'] = function testAllowsMultipleActionsOnASingleElement() {
var _this31 = this;
var clickActionWasCalled = false;
var doubleClickActionWasCalled = false;
var ExampleComponent = _helpers.Component.extend({
actions: {
clicked: function () {
clickActionWasCalled = true;
},
doubleClicked: function () {
doubleClickActionWasCalled = true;
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: (0, _abstractTestCase.strip)(_templateObject4)
});
this.render('{{example-component}}');
this.runTask(function () {
_this31.$('a').trigger('click');
});
this.assert.ok(clickActionWasCalled, 'the clicked action was called');
this.runTask(function () {
_this31.$('a').trigger('dblclick');
});
this.assert.ok(doubleClickActionWasCalled, 'the doubleClicked action was called');
};
_class2.prototype['@test it should respect preventDefault option if provided'] = function testItShouldRespectPreventDefaultOptionIfProvided() {
var _this32 = this;
var ExampleComponent = _helpers.Component.extend({
actions: {
show: function () {}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a {{action "show" preventDefault=false}}>Hi</a>'
});
this.render('{{example-component}}');
var event = _emberViews.jQuery.Event('click');
this.runTask(function () {
_this32.$('a').trigger(event);
});
this.assert.equal(event.isDefaultPrevented(), false, 'should not preventDefault');
};
_class2.prototype['@test it should respect preventDefault option if provided bound'] = function testItShouldRespectPreventDefaultOptionIfProvidedBound() {
var _this33 = this;
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
shouldPreventDefault: false,
init: function () {
this._super.apply(this, arguments);
component = this;
},
actions: {
show: function () {}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<a {{action "show" preventDefault=shouldPreventDefault}}>Hi</a>'
});
this.render('{{example-component}}');
var event = _emberViews.jQuery.Event('click');
this.runTask(function () {
_this33.$('a').trigger(event);
});
this.assert.equal(event.isDefaultPrevented(), false, 'should not preventDefault');
event = _emberViews.jQuery.Event('click');
this.runTask(function () {
component.set('shouldPreventDefault', true);
_this33.$('a').trigger(event);
});
this.assert.equal(event.isDefaultPrevented(), true, 'should preventDefault');
};
_class2.prototype['@test it should target the proper component when `action` is in yielded block [GH #12409]'] = function testItShouldTargetTheProperComponentWhenActionIsInYieldedBlockGH12409() {
var _this34 = this;
var outerActionCalled = false;
var innerClickCalled = false;
var OuterComponent = _helpers.Component.extend({
actions: {
hey: function () {
outerActionCalled = true;
}
}
});
var MiddleComponent = _helpers.Component.extend({});
var InnerComponent = _helpers.Component.extend({
click: function () {
innerClickCalled = true;
this.sendAction();
}
});
this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: (0, _abstractTestCase.strip)(_templateObject5)
});
this.registerComponent('middle-component', {
ComponentClass: MiddleComponent,
template: '{{yield}}'
});
this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: (0, _abstractTestCase.strip)(_templateObject6)
});
this.render('{{outer-component}}');
this.runTask(function () {
_this34.$('button').click();
});
this.assert.ok(outerActionCalled, 'the action fired on the proper target');
this.assert.ok(innerClickCalled, 'the click was triggered');
};
_class2.prototype['@test element action with (mut undefinedThing) works properly'] = function testElementActionWithMutUndefinedThingWorksProperly() {
var _this35 = this;
var component = void 0;
var ExampleComponent = _helpers.Component.extend({
label: undefined,
init: function () {
this._super.apply(this, arguments);
component = this;
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<button {{action (mut label) "Clicked!"}}>{{if label label "Click me"}}</button>'
});
this.render('{{example-component}}');
this.assertText('Click me');
this.assertStableRerender();
this.runTask(function () {
_this35.$('button').click();
});
this.assertText('Clicked!');
this.runTask(function () {
component.set('label', 'Dun clicked');
});
this.assertText('Dun clicked');
this.runTask(function () {
_this35.$('button').click();
});
this.assertText('Clicked!');
this.runTask(function () {
component.set('label', undefined);
});
this.assertText('Click me');
};
_class2.prototype['@test it supports non-registered actions [GH#14888]'] = function testItSupportsNonRegisteredActionsGH14888() {
this.render('\n {{#if show}}\n <button id=\'ddButton\' {{action (mut show) false}}>\n Show ({{show}})\n </button>\n {{/if}}\n ', { show: true });
this.assert.equal(this.$('button').text().trim(), 'Show (true)');
// We need to focus in to simulate an actual click.
this.runTask(function () {
document.getElementById('ddButton').focus();
document.getElementById('ddButton').click();
});
};
_class2.prototype['@test action handler that shifts element attributes doesn\'t trigger multiple invocations'] = function testActionHandlerThatShiftsElementAttributesDoesnTTriggerMultipleInvocations() {
var _this36 = this;
var actionCount = 0;
var ExampleComponent = _helpers.Component.extend({
selected: false,
actions: {
toggleSelected: function () {
actionCount++;
this.toggleProperty('selected');
}
}
});
this.registerComponent('example-component', {
ComponentClass: ExampleComponent,
template: '<button class="{{if selected \'selected\'}}" {{action "toggleSelected"}}>Toggle Selected</button>'
});
this.render('{{example-component}}');
this.runTask(function () {
_this36.$('button').click();
});
this.assert.equal(actionCount, 1, 'Click action only fired once.');
this.assert.ok(this.$('button').hasClass('selected'), 'Element with action handler has properly updated it\'s conditional class');
this.runTask(function () {
_this36.$('button').click();
});
this.assert.equal(actionCount, 2, 'Second click action only fired once.');
this.assert.ok(!this.$('button').hasClass('selected'), 'Element with action handler has properly updated it\'s conditional class');
};
return _class2;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/element-action-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/helpers/element-action-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/helpers/get-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (_emberBabel, _testCase, _helpers, _emberMetal) {
'use strict';
(0, _testCase.moduleFor)('Helpers test: {{get}}', 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 should be able to get an object value with a static key'] = function testShouldBeAbleToGetAnObjectValueWithAStaticKey() {
var _this2 = this;
this.render('[{{get colors \'apple\'}}] [{{if true (get colors \'apple\')}}]', {
colors: { apple: 'red' }
});
this.assertText('[red] [red]');
this.runTask(function () {
return _this2.rerender();
});
this.assertText('[red] [red]');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'colors.apple', 'green');
});
this.assertText('[green] [green]');
this.runTask(function () {
return (0, _emberMetal.set)(_this2.context, 'colors', {
apple: 'red'
});
});
this.assertText('[red] [red]');
};
_class.prototype['@test should be able to get an object value with nested static key'] = function testShouldBeAbleToGetAnObjectValueWithNestedStaticKey() {
var _this3 = this;
this.render('[{{get colors "apple.gala"}}] [{{if true (get colors "apple.gala")}}]', {
colors: {
apple: {
gala: 'red and yellow'
}
}
});
this.assertText('[red and yellow] [red and yellow]');
this.runTask(function () {
return _this3.rerender();
});
this.assertText('[red and yellow] [red and yellow]');
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'colors.apple.gala', 'yellow and red striped');
});
this.assertText('[yellow and red striped] [yellow and red striped]');
this.runTask(function () {
return (0, _emberMetal.set)(_this3.context, 'colors', { apple: { gala: 'red and yellow' } });
});
this.assertText('[red and yellow] [red and yellow]');
};
_class.prototype['@test should be able to get an object value with numeric keys'] = function testShouldBeAbleToGetAnObjectValueWithNumericKeys() {
var _this4 = this;
this.render('{{#each indexes as |index|}}[{{get items index}}]{{/each}}', {
indexes: [1, 2, 3],
items: {
1: 'First',
2: 'Second',
3: 'Third'
}
});
this.assertText('[First][Second][Third]');
this.runTask(function () {
return _this4.rerender();
});
this.assertText('[First][Second][Third]');
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'items.1', 'Qux');
});
this.assertText('[Qux][Second][Third]');
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'items', { 1: 'First', 2: 'Second', 3: 'Third' });
});
this.assertText('[First][Second][Third]');
};
_class.prototype['@test should be able to get an array value with numeric keys'] = function testShouldBeAbleToGetAnArrayValueWithNumericKeys() {
var _this5 = this;
this.render('{{#each numbers as |num index|}}[{{get numbers index}}]{{/each}}', {
numbers: [1, 2, 3]
});
this.assertText('[1][2][3]');
this.runTask(function () {
return _this5.rerender();
});
this.assertText('[1][2][3]');
this.runTask(function () {
return (0, _emberMetal.set)(_this5.context, 'numbers', [3, 2, 1]);
});
this.assertText('[3][2][1]');
};
_class.prototype['@test should be able to get an object value with a bound/dynamic key'] = function testShouldBeAbleToGetAnObjectValueWithABoundDynamicKey() {
var _this6 = this;
this.render('[{{get colors key}}] [{{if true (get colors key)}}]', {
colors: { apple: 'red', banana: 'yellow' },
key: 'apple'
});
this.assertText('[red] [red]');
this.runTask(function () {
return _this6.rerender();
});
this.assertText('[red] [red]');
this.runTask(function () {
return (0, _emberMetal.set)(_this6.context, 'key', 'banana');
});
this.assertText('[yellow] [yellow]');
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'colors.apple', 'green');
(0, _emberMetal.set)(_this6.context, 'colors.banana', 'purple');
});
this.assertText('[purple] [purple]');
this.runTask(function () {
return (0, _emberMetal.set)(_this6.context, 'key', 'apple');
});
this.assertText('[green] [green]');
this.runTask(function () {
return (0, _emberMetal.set)(_this6.context, 'colors', { apple: 'red' });
});
this.assertText('[red] [red]');
};
_class.prototype['@test should be able to get an object value with nested dynamic key'] = function testShouldBeAbleToGetAnObjectValueWithNestedDynamicKey() {
var _this7 = this;
this.render('[{{get colors key}}] [{{if true (get colors key)}}]', {
colors: {
apple: {
gala: 'red and yellow',
mcintosh: 'red'
},
banana: 'yellow'
},
key: 'apple.gala'
});
this.assertText('[red and yellow] [red and yellow]');
this.runTask(function () {
return _this7.rerender();
});
this.assertText('[red and yellow] [red and yellow]');
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'key', 'apple.mcintosh');
});
this.assertText('[red] [red]');
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'key', 'banana');
});
this.assertText('[yellow] [yellow]');
this.runTask(function () {
return (0, _emberMetal.set)(_this7.context, 'key', 'apple.gala');
});
this.assertText('[red and yellow] [red and yellow]');
};
_class.prototype['@test should be able to get an object value with subexpression returning nested key'] = function testShouldBeAbleToGetAnObjectValueWithSubexpressionReturningNestedKey() {
var _this8 = this;
this.render('[{{get colors (concat \'apple\' \'.\' \'gala\')}}] [{{if true (get colors (concat \'apple\' \'.\' \'gala\'))}}]', {
colors: {
apple: {
gala: 'red and yellow',
mcintosh: 'red'
}
},
key: 'apple.gala'
});
this.assertText('[red and yellow] [red and yellow]');
this.runTask(function () {
return _this8.rerender();
});
this.assertText('[red and yellow] [red and yellow]');
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'colors.apple.gala', 'yellow and red striped');
});
this.assertText('[yellow and red striped] [yellow and red striped]');
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'colors.apple.gala', 'yellow-redish');
});
this.assertText('[yellow-redish] [yellow-redish]');
this.runTask(function () {
return (0, _emberMetal.set)(_this8.context, 'colors', {
apple: {
gala: 'red and yellow',
mcintosh: 'red'
}
});
});
this.assertText('[red and yellow] [red and yellow]');
};
_class.prototype['@test should be able to get an object value with a get helper as the key'] = function testShouldBeAbleToGetAnObjectValueWithAGetHelperAsTheKey() {
var _this9 = this;
this.render('[{{get colors (get possibleKeys key)}}] [{{if true (get colors (get possibleKeys key))}}]', {
colors: { apple: 'red', banana: 'yellow' },
key: 'key1',
possibleKeys: { key1: 'apple', key2: 'banana' }
});
this.assertText('[red] [red]');
this.runTask(function () {
return _this9.rerender();
});
this.assertText('[red] [red]');
this.runTask(function () {
return (0, _emberMetal.set)(_this9.context, 'key', 'key2');
});
this.assertText('[yellow] [yellow]');
this.runTask(function () {
(0, _emberMetal.set)(_this9.context, 'colors.apple', 'green');
(0, _emberMetal.set)(_this9.context, 'colors.banana', 'purple');
});
this.assertText('[purple] [purple]');
this.runTask(function () {
return (0, _emberMetal.set)(_this9.context, 'key', 'key1');
});
this.assertText('[green] [green]');
this.runTask(function () {
return (0, _emberMetal.set)(_this9.context, 'colors', { apple: 'red', banana: 'yellow' });
});
this.assertText('[red] [red]');
};
_class.prototype['@test should be able to get an object value with a get helper value as a bound/dynamic key'] = function testShouldBeAbleToGetAnObjectValueWithAGetHelperValueAsABoundDynamicKey() {
var _this10 = this;
this.render('[{{get (get possibleValues objectKey) key}}] [{{if true (get (get possibleValues objectKey) key)}}]', {
possibleValues: {
colors1: { apple: 'red', banana: 'yellow' },
colors2: { apple: 'green', banana: 'purple' }
},
objectKey: 'colors1',
key: 'apple'
});
this.assertText('[red] [red]');
this.runTask(function () {
return _this10.rerender();
});
this.assertText('[red] [red]');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'objectKey', 'colors2');
});
this.assertText('[green] [green]');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'objectKey', 'colors1');
});
this.assertText('[red] [red]');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'key', 'banana');
});
this.assertText('[yellow] [yellow]');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'objectKey', 'colors2');
});
this.assertText('[purple] [purple]');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'objectKey', 'colors1');
});
this.assertText('[yellow] [yellow]');
this.runTask(function () {
return (0, _emberMetal.set)(_this10.context, 'key', 'apple');
});
};
_class.prototype['@test should be able to get an object value with a get helper as the value and a get helper as the key'] = function testShouldBeAbleToGetAnObjectValueWithAGetHelperAsTheValueAndAGetHelperAsTheKey() {
var _this11 = this;
this.render('[{{get (get possibleValues objectKey) (get possibleKeys key)}}] [{{if true (get (get possibleValues objectKey) (get possibleKeys key))}}]', {
possibleValues: {
colors1: { apple: 'red', banana: 'yellow' },
colors2: { apple: 'green', banana: 'purple' }
},
objectKey: 'colors1',
possibleKeys: {
key1: 'apple',
key2: 'banana'
},
key: 'key1'
});
this.assertText('[red] [red]');
this.runTask(function () {
return _this11.rerender();
});
this.assertText('[red] [red]');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'objectKey', 'colors2');
});
this.assertText('[green] [green]');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'objectKey', 'colors1');
});
this.assertText('[red] [red]');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'key', 'key2');
});
this.assertText('[yellow] [yellow]');
this.runTask(function () {
return (0, _emberMetal.set)(_this11.context, 'objectKey', 'colors2');
});
this.assertText('[purple] [purple]');
this.runTask(function () {
(0, _emberMetal.set)(_this11.context, 'objectKey', 'colors1');
(0, _emberMetal.set)(_this11.context, 'key', 'key1');
});
this.assertText('[red] [red]');
};
_class.prototype['@test the result of a get helper can be yielded'] = function testTheResultOfAGetHelperCanBeYielded() {
var _this12 = this;
var fooBarInstance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
fooBarInstance = this;
this.mcintosh = 'red';
}
});
this.registerComponent('foo-bar', {
ComponentClass: FooBarComponent,
template: '{{yield (get colors mcintosh)}}'
});
this.render('{{#foo-bar colors=colors as |value|}}{{value}}{{/foo-bar}}', {
colors: {
red: 'banana'
}
});
this.assertText('banana');
this.runTask(function () {
return _this12.rerender();
});
this.assertText('banana');
this.runTask(function () {
(0, _emberMetal.set)(fooBarInstance, 'mcintosh', 'yellow');
(0, _emberMetal.set)(_this12.context, 'colors', { yellow: 'bus' });
});
this.assertText('bus');
this.runTask(function () {
(0, _emberMetal.set)(fooBarInstance, 'mcintosh', 'red');
(0, _emberMetal.set)(_this12.context, 'colors', { red: 'banana' });
});
this.assertText('banana');
};
_class.prototype['@test should handle object values as nulls'] = function testShouldHandleObjectValuesAsNulls() {
var _this13 = this;
this.render('[{{get colors \'apple\'}}] [{{if true (get colors \'apple\')}}]', {
colors: null
});
this.assertText('[] []');
this.runTask(function () {
return _this13.rerender();
});
this.assertText('[] []');
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'colors', { apple: 'green', banana: 'purple' });
});
this.assertText('[green] [green]');
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'colors', null);
});
this.assertText('[] []');
};
_class.prototype['@test should handle object keys as nulls'] = function testShouldHandleObjectKeysAsNulls() {
var _this14 = this;
this.render('[{{get colors key}}] [{{if true (get colors key)}}]', {
colors: {
apple: 'red',
banana: 'yellow'
},
key: null
});
this.assertText('[] []');
this.runTask(function () {
return _this14.rerender();
});
this.assertText('[] []');
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'key', 'banana');
});
this.assertText('[yellow] [yellow]');
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'key', null);
});
this.assertText('[] []');
};
_class.prototype['@test should handle object values and keys as nulls'] = function testShouldHandleObjectValuesAndKeysAsNulls() {
this.render('[{{get colors \'apple\'}}] [{{if true (get colors key)}}]', {
colors: null,
key: null
});
this.assertText('[] []');
};
_class.prototype['@test get helper value should be updatable using {{input}} and (mut) - static key'] = function testGetHelperValueShouldBeUpdatableUsingInputAndMutStaticKey(assert) {
var _this15 = this;
this.render('{{input type=\'text\' value=(mut (get source \'banana\')) id=\'get-input\'}}', {
source: {
banana: 'banana'
}
});
assert.strictEqual(this.$('#get-input').val(), 'banana');
this.runTask(function () {
return _this15.rerender();
});
assert.strictEqual(this.$('#get-input').val(), 'banana');
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'source.banana', 'yellow');
});
assert.strictEqual(this.$('#get-input').val(), 'yellow');
this.runTask(function () {
return _this15.$('#get-input').val('some value').trigger('change');
});
assert.strictEqual(this.$('#get-input').val(), 'some value');
assert.strictEqual((0, _emberMetal.get)(this.context, 'source.banana'), 'some value');
this.runTask(function () {
return (0, _emberMetal.set)(_this15.context, 'source', { banana: 'banana' });
});
assert.strictEqual(this.$('#get-input').val(), 'banana');
};
_class.prototype['@test get helper value should be updatable using {{input}} and (mut) - dynamic key'] = function testGetHelperValueShouldBeUpdatableUsingInputAndMutDynamicKey(assert) {
var _this16 = this;
this.render('{{input type=\'text\' value=(mut (get source key)) id=\'get-input\'}}', {
source: {
apple: 'apple',
banana: 'banana'
},
key: 'banana'
});
assert.strictEqual(this.$('#get-input').val(), 'banana');
this.runTask(function () {
return _this16.rerender();
});
assert.strictEqual(this.$('#get-input').val(), 'banana');
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'source.banana', 'yellow');
});
assert.strictEqual(this.$('#get-input').val(), 'yellow');
this.runTask(function () {
return _this16.$('#get-input').val('some value').trigger('change');
});
assert.strictEqual(this.$('#get-input').val(), 'some value');
assert.strictEqual((0, _emberMetal.get)(this.context, 'source.banana'), 'some value');
this.runTask(function () {
return (0, _emberMetal.set)(_this16.context, 'key', 'apple');
});
assert.strictEqual(this.$('#get-input').val(), 'apple');
this.runTask(function () {
return _this16.$('#get-input').val('some other value').trigger('change');
});
assert.strictEqual(this.$('#get-input').val(), 'some other value');
assert.strictEqual((0, _emberMetal.get)(this.context, 'source.apple'), 'some other value');
this.runTask(function () {
(0, _emberMetal.set)(_this16.context, 'key', 'banana');
(0, _emberMetal.set)(_this16.context, 'source', { banana: 'banana' });
});
assert.strictEqual(this.$('#get-input').val(), 'banana');
};
_class.prototype['@test get helper value should be updatable using {{input}} and (mut) - dynamic nested key'] = function testGetHelperValueShouldBeUpdatableUsingInputAndMutDynamicNestedKey(assert) {
var _this17 = this;
this.render('{{input type=\'text\' value=(mut (get source key)) id=\'get-input\'}}', {
source: {
apple: {
gala: 'gala',
mcintosh: 'mcintosh'
},
banana: 'banana'
},
key: 'apple.mcintosh'
});
assert.strictEqual(this.$('#get-input').val(), 'mcintosh');
this.runTask(function () {
return _this17.rerender();
});
assert.strictEqual(this.$('#get-input').val(), 'mcintosh');
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'source.apple.mcintosh', 'red');
});
assert.strictEqual(this.$('#get-input').val(), 'red');
this.runTask(function () {
return _this17.$('#get-input').val('some value').trigger('change');
});
assert.strictEqual(this.$('#get-input').val(), 'some value');
assert.strictEqual((0, _emberMetal.get)(this.context, 'source.apple.mcintosh'), 'some value');
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'key', 'apple.gala');
});
assert.strictEqual(this.$('#get-input').val(), 'gala');
this.runTask(function () {
return _this17.$('#get-input').val('some other value').trigger('change');
});
assert.strictEqual(this.$('#get-input').val(), 'some other value');
assert.strictEqual((0, _emberMetal.get)(this.context, 'source.apple.gala'), 'some other value');
this.runTask(function () {
return (0, _emberMetal.set)(_this17.context, 'key', 'banana');
});
assert.strictEqual(this.$('#get-input').val(), 'banana');
this.runTask(function () {
return _this17.$('#get-input').val('yet another value').trigger('change');
});
assert.strictEqual(this.$('#get-input').val(), 'yet another value');
assert.strictEqual((0, _emberMetal.get)(this.context, 'source.banana'), 'yet another value');
this.runTask(function () {
(0, _emberMetal.set)(_this17.context, 'key', 'apple.mcintosh');
(0, _emberMetal.set)(_this17.context, 'source', {
apple: {
gala: 'gala',
mcintosh: 'mcintosh'
},
banana: 'banana'
});
});
assert.strictEqual(this.$('#get-input').val(), 'mcintosh');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/get-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/helpers/get-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/helpers/hash-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/helpers', 'ember-metal'], function (_emberBabel, _testCase, _helpers, _emberMetal) {
'use strict';
(0, _testCase.moduleFor)('Helpers test: {{hash}}', 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 returns a hash with the right key-value'] = function testReturnsAHashWithTheRightKeyValue() {
var _this2 = this;
this.render('{{#with (hash name="Sergio") as |person|}}{{person.name}}{{/with}}');
this.assertText('Sergio');
this.runTask(function () {
return _this2.rerender();
});
this.assertText('Sergio');
};
_class.prototype['@test can have more than one key-value'] = function testCanHaveMoreThanOneKeyValue() {
var _this3 = this;
this.render('{{#with (hash name="Sergio" lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/with}}');
this.assertText('Sergio Arbeo');
this.runTask(function () {
return _this3.rerender();
});
this.assertText('Sergio Arbeo');
};
_class.prototype['@test binds values when variables are used'] = function testBindsValuesWhenVariablesAreUsed() {
var _this4 = this;
this.render('{{#with (hash name=model.firstName lastName="Arbeo") as |person|}}{{person.name}} {{person.lastName}}{{/with}}', {
model: {
firstName: 'Marisa'
}
});
this.assertText('Marisa Arbeo');
this.runTask(function () {
return _this4.rerender();
});
this.assertText('Marisa Arbeo');
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'model.firstName', 'Sergio');
});
this.assertText('Sergio Arbeo');
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'model', { firstName: 'Marisa' });
});
this.assertText('Marisa Arbeo');
};
_class.prototype['@test binds multiple values when variables are used'] = function testBindsMultipleValuesWhenVariablesAreUsed() {
var _this5 = this;
this.render('{{#with (hash name=model.firstName lastName=model.lastName) as |person|}}{{person.name}} {{person.lastName}}{{/with}}', {
model: {
firstName: 'Marisa',
lastName: 'Arbeo'
}
});
this.assertText('Marisa Arbeo');
this.runTask(function () {
return _this5.rerender();
});
this.assertText('Marisa Arbeo');
this.runTask(function () {
return (0, _emberMetal.set)(_this5.context, 'model.firstName', 'Sergio');
});
this.assertText('Sergio Arbeo');
this.runTask(function () {
return (0, _emberMetal.set)(_this5.context, 'model.lastName', 'Smith');
});
this.assertText('Sergio Smith');
this.runTask(function () {
return (0, _emberMetal.set)(_this5.context, 'model', {
firstName: 'Marisa',
lastName: 'Arbeo'
});
});
this.assertText('Marisa Arbeo');
};
_class.prototype['@test hash helpers can be nested'] = function testHashHelpersCanBeNested() {
var _this6 = this;
this.render('{{#with (hash person=(hash name=model.firstName)) as |ctx|}}{{ctx.person.name}}{{/with}}', {
model: { firstName: 'Balint' }
});
this.assertText('Balint');
this.runTask(function () {
return _this6.rerender();
});
this.assertText('Balint');
this.runTask(function () {
return (0, _emberMetal.set)(_this6.context, 'model.firstName', 'Chad');
});
this.assertText('Chad');
this.runTask(function () {
return (0, _emberMetal.set)(_this6.context, 'model', { firstName: 'Balint' });
});
this.assertText('Balint');
};
_class.prototype['@test should yield hash of internal properties'] = function testShouldYieldHashOfInternalProperties() {
var _this7 = this;
var fooBarInstance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
fooBarInstance = this;
this.model = { firstName: 'Chad' };
}
});
this.registerComponent('foo-bar', {
ComponentClass: FooBarComponent,
template: '{{yield (hash firstName=model.firstName)}}'
});
this.render('{{#foo-bar as |values|}}{{values.firstName}}{{/foo-bar}}');
this.assertText('Chad');
this.runTask(function () {
return _this7.rerender();
});
this.assertText('Chad');
this.runTask(function () {
return (0, _emberMetal.set)(fooBarInstance, 'model.firstName', 'Godfrey');
});
this.assertText('Godfrey');
this.runTask(function () {
return (0, _emberMetal.set)(fooBarInstance, 'model', { firstName: 'Chad' });
});
this.assertText('Chad');
};
_class.prototype['@test should yield hash of internal and external properties'] = function testShouldYieldHashOfInternalAndExternalProperties() {
var _this8 = this;
var fooBarInstance = void 0;
var FooBarComponent = _helpers.Component.extend({
init: function () {
this._super();
fooBarInstance = this;
this.model = { firstName: 'Chad' };
}
});
this.registerComponent('foo-bar', {
ComponentClass: FooBarComponent,
template: '{{yield (hash firstName=model.firstName lastName=lastName)}}'
});
this.render('{{#foo-bar lastName=model.lastName as |values|}}{{values.firstName}} {{values.lastName}}{{/foo-bar}}', {
model: { lastName: 'Hietala' }
});
this.assertText('Chad Hietala');
this.runTask(function () {
return _this8.rerender();
});
this.assertText('Chad Hietala');
this.runTask(function () {
(0, _emberMetal.set)(fooBarInstance, 'model.firstName', 'Godfrey');
(0, _emberMetal.set)(_this8.context, 'model.lastName', 'Chan');
});
this.assertText('Godfrey Chan');
this.runTask(function () {
(0, _emberMetal.set)(fooBarInstance, 'model', { firstName: 'Chad' });
(0, _emberMetal.set)(_this8.context, 'model', { lastName: 'Hietala' });
});
this.assertText('Chad Hietala');
};
return _class;
}(_testCase.RenderingTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/hash-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/helpers/hash-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/helpers/if-unless-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-glimmer/tests/utils/shared-conditional-tests'], function (_emberBabel, _testCase, _sharedConditionalTests) {
'use strict';
(0, _testCase.moduleFor)('Helpers test: inline {{if}}', function (_IfUnlessHelperTest) {
(0, _emberBabel.inherits)(_class, _IfUnlessHelperTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest.apply(this, arguments));
}
_class.prototype.templateFor = function templateFor(_ref) {
var cond = _ref.cond,
truthy = _ref.truthy,
falsy = _ref.falsy;
return '{{if ' + cond + ' ' + truthy + ' ' + falsy + '}}';
};
_class.prototype['@test it raises when there are more than three arguments'] = function testItRaisesWhenThereAreMoreThanThreeArguments() {
var _this2 = this;
expectAssertion(function () {
_this2.render('{{if condition \'a\' \'b\' \'c\'}}', { condition: true });
}, /The inline form of the `if` helper expects two or three arguments/);
};
_class.prototype['@test it raises when there are less than two arguments'] = function testItRaisesWhenThereAreLessThanTwoArguments() {
var _this3 = this;
expectAssertion(function () {
_this3.render('{{if condition}}', { condition: true });
}, /The inline form of the `if` helper expects two or three arguments/);
};
return _class;
}(_sharedConditionalTests.IfUnlessHelperTest));
(0, _testCase.moduleFor)('Helpers test: nested {{if}} helpers (returning truthy values)', function (_IfUnlessHelperTest2) {
(0, _emberBabel.inherits)(_class2, _IfUnlessHelperTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest2.apply(this, arguments));
}
_class2.prototype.templateFor = function templateFor(_ref2) {
var cond = _ref2.cond,
truthy = _ref2.truthy,
falsy = _ref2.falsy;
return '{{if (if ' + cond + ' ' + cond + ' false) ' + truthy + ' ' + falsy + '}}';
};
return _class2;
}(_sharedConditionalTests.IfUnlessHelperTest));
(0, _testCase.moduleFor)('Helpers test: nested {{if}} helpers (returning falsy values)', function (_IfUnlessHelperTest3) {
(0, _emberBabel.inherits)(_class3, _IfUnlessHelperTest3);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest3.apply(this, arguments));
}
_class3.prototype.templateFor = function templateFor(_ref3) {
var cond = _ref3.cond,
truthy = _ref3.truthy,
falsy = _ref3.falsy;
return '{{if (if ' + cond + ' true ' + cond + ') ' + truthy + ' ' + falsy + '}}';
};
return _class3;
}(_sharedConditionalTests.IfUnlessHelperTest));
(0, _testCase.moduleFor)('Helpers test: {{if}} used with another helper', function (_IfUnlessHelperTest4) {
(0, _emberBabel.inherits)(_class4, _IfUnlessHelperTest4);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest4.apply(this, arguments));
}
_class4.prototype.wrapperFor = function wrapperFor(templates) {
return '{{concat ' + templates.join(' ') + '}}';
};
_class4.prototype.templateFor = function templateFor(_ref4) {
var cond = _ref4.cond,
truthy = _ref4.truthy,
falsy = _ref4.falsy;
return '(if ' + cond + ' ' + truthy + ' ' + falsy + ')';
};
return _class4;
}(_sharedConditionalTests.IfUnlessHelperTest));
(0, _testCase.moduleFor)('Helpers test: {{if}} used in attribute position', function (_IfUnlessHelperTest5) {
(0, _emberBabel.inherits)(_class5, _IfUnlessHelperTest5);
function _class5() {
(0, _emberBabel.classCallCheck)(this, _class5);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest5.apply(this, arguments));
}
_class5.prototype.wrapperFor = function wrapperFor(templates) {
return '<div data-foo="' + templates.join('') + '" />';
};
_class5.prototype.templateFor = function templateFor(_ref5) {
var cond = _ref5.cond,
truthy = _ref5.truthy,
falsy = _ref5.falsy;
return '{{if ' + cond + ' ' + truthy + ' ' + falsy + '}}';
};
_class5.prototype.textValue = function textValue() {
return this.$('div').attr('data-foo');
};
return _class5;
}(_sharedConditionalTests.IfUnlessHelperTest));
(0, _testCase.moduleFor)('Helpers test: inline {{if}} and {{unless}} without the inverse argument', function (_IfUnlessHelperTest6) {
(0, _emberBabel.inherits)(_class6, _IfUnlessHelperTest6);
function _class6() {
(0, _emberBabel.classCallCheck)(this, _class6);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest6.apply(this, arguments));
}
_class6.prototype.templateFor = function templateFor(_ref6) {
var cond = _ref6.cond,
truthy = _ref6.truthy,
falsy = _ref6.falsy;
return '{{if ' + cond + ' ' + truthy + '}}{{unless ' + cond + ' ' + falsy + '}}';
};
return _class6;
}(_sharedConditionalTests.IfUnlessHelperTest));
(0, _testCase.moduleFor)('Helpers test: inline {{unless}}', function (_IfUnlessHelperTest7) {
(0, _emberBabel.inherits)(_class7, _IfUnlessHelperTest7);
function _class7() {
(0, _emberBabel.classCallCheck)(this, _class7);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest7.apply(this, arguments));
}
_class7.prototype.templateFor = function templateFor(_ref7) {
var cond = _ref7.cond,
truthy = _ref7.truthy,
falsy = _ref7.falsy;
return '{{unless ' + cond + ' ' + falsy + ' ' + truthy + '}}';
};
_class7.prototype['@test it raises when there are more than three arguments'] = function testItRaisesWhenThereAreMoreThanThreeArguments() {
var _this10 = this;
expectAssertion(function () {
_this10.render('{{unless condition \'a\' \'b\' \'c\'}}', { condition: true });
}, /The inline form of the `unless` helper expects two or three arguments/);
};
_class7.prototype['@test it raises when there are less than two arguments'] = function testItRaisesWhenThereAreLessThanTwoArguments() {
var _this11 = this;
expectAssertion(function () {
_this11.render('{{unless condition}}', { condition: true });
}, /The inline form of the `unless` helper expects two or three arguments/);
};
return _class7;
}(_sharedConditionalTests.IfUnlessHelperTest));
(0, _testCase.moduleFor)('Helpers test: nested {{unless}} helpers (returning truthy values)', function (_IfUnlessHelperTest8) {
(0, _emberBabel.inherits)(_class8, _IfUnlessHelperTest8);
function _class8() {
(0, _emberBabel.classCallCheck)(this, _class8);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest8.apply(this, arguments));
}
_class8.prototype.templateFor = function templateFor(_ref8) {
var cond = _ref8.cond,
truthy = _ref8.truthy,
falsy = _ref8.falsy;
return '{{unless (unless ' + cond + ' false ' + cond + ') ' + falsy + ' ' + truthy + '}}';
};
return _class8;
}(_sharedConditionalTests.IfUnlessHelperTest));
(0, _testCase.moduleFor)('Helpers test: nested {{unless}} helpers (returning falsy values)', function (_IfUnlessHelperTest9) {
(0, _emberBabel.inherits)(_class9, _IfUnlessHelperTest9);
function _class9() {
(0, _emberBabel.classCallCheck)(this, _class9);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest9.apply(this, arguments));
}
_class9.prototype.templateFor = function templateFor(_ref9) {
var cond = _ref9.cond,
truthy = _ref9.truthy,
falsy = _ref9.falsy;
return '{{unless (unless ' + cond + ' ' + cond + ' true) ' + falsy + ' ' + truthy + '}}';
};
return _class9;
}(_sharedConditionalTests.IfUnlessHelperTest));
(0, _testCase.moduleFor)('Helpers test: {{unless}} used with another helper', function (_IfUnlessHelperTest10) {
(0, _emberBabel.inherits)(_class10, _IfUnlessHelperTest10);
function _class10() {
(0, _emberBabel.classCallCheck)(this, _class10);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest10.apply(this, arguments));
}
_class10.prototype.wrapperFor = function wrapperFor(templates) {
return '{{concat ' + templates.join(' ') + '}}';
};
_class10.prototype.templateFor = function templateFor(_ref10) {
var cond = _ref10.cond,
truthy = _ref10.truthy,
falsy = _ref10.falsy;
return '(unless ' + cond + ' ' + falsy + ' ' + truthy + ')';
};
return _class10;
}(_sharedConditionalTests.IfUnlessHelperTest));
(0, _testCase.moduleFor)('Helpers test: {{unless}} used in attribute position', function (_IfUnlessHelperTest11) {
(0, _emberBabel.inherits)(_class11, _IfUnlessHelperTest11);
function _class11() {
(0, _emberBabel.classCallCheck)(this, _class11);
return (0, _emberBabel.possibleConstructorReturn)(this, _IfUnlessHelperTest11.apply(this, arguments));
}
_class11.prototype.wrapperFor = function wrapperFor(templates) {
return '<div data-foo="' + templates.join('') + '" />';
};
_class11.prototype.templateFor = function templateFor(_ref11) {
var cond = _ref11.cond,
truthy = _ref11.truthy,
falsy = _ref11.falsy;
return '{{unless ' + cond + ' ' + falsy + ' ' + truthy + '}}';
};
_class11.prototype.textValue = function textValue() {
return this.$('div').attr('data-foo');
};
return _class11;
}(_sharedConditionalTests.IfUnlessHelperTest));
});
QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/if-unless-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/helpers/if-unless-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/helpers/input-test', ['ember-babel', 'ember-utils', 'ember-metal', 'ember-glimmer/tests/utils/helpers', 'ember-glimmer/tests/utils/test-case', 'internal-test-helpers'], function (_emberBabel, _emberUtils, _emberMetal, _helpers, _testCase, _internalTestHelpers) {
'use strict';
var InputRenderingTest = function (_RenderingTest) {
(0, _emberBabel.inherits)(InputRenderingTest, _RenderingTest);
function InputRenderingTest() {
(0, _emberBabel.classCallCheck)(this, InputRenderingTest);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.call(this));
_this.registerComponent('-text-field', { ComponentClass: _helpers.TextField });
_this.registerComponent('-checkbox', { ComponentClass: _helpers.Checkbox });
return _this;
}
InputRenderingTest.prototype.$input = function $input() {
return this.$('input');
};
InputRenderingTest.prototype.inputID = function inputID() {
return this.$input().prop('id');
};
InputRenderingTest.prototype.assertDisabled = function assertDisabled() {
this.assert.ok(this.$('input').prop('disabled'), 'The input is disabled');
};
InputRenderingTest.prototype.assertNotDisabled = function assertNotDisabled() {
this.assert.ok(this.$('input').is(':not(:disabled)'), 'The input is not disabled');
};
InputRenderingTest.prototype.assertInputId = function assertInputId(expectedId) {
this.assert.equal(this.inputID(), expectedId, 'the input id should be `expectedId`');
};
InputRenderingTest.prototype.assertSingleInput = function assertSingleInput() {
this.assert.equal(this.$('input').length, 1, 'A single text field was inserted');
};
InputRenderingTest.prototype.assertSingleCheckbox = function assertSingleCheckbox() {
this.assert.equal(this.$('input[type=checkbox]').length, 1, 'A single checkbox is added');
};
InputRenderingTest.prototype.assertCheckboxIsChecked = function assertCheckboxIsChecked() {
this.assert.equal(this.$input().prop('checked'), true, 'the checkbox is checked');
};
InputRenderingTest.prototype.assertCheckboxIsNotChecked = function assertCheckboxIsNotChecked() {
this.assert.equal(this.$input().prop('checked'), false, 'the checkbox is not checked');
};
InputRenderingTest.prototype.assertValue = function assertValue(expected) {
this.assert.equal(this.$input().val(), expected, 'the input value should be ' + expected);
};
InputRenderingTest.prototype.assertAttr = function assertAttr(name, expected) {
this.assert.equal(this.$input().attr(name), expected, 'the input ' + name + ' attribute has the value \'' + expected + '\'');
};
InputRenderingTest.prototype.assertAllAttrs = function assertAllAttrs(names, expected) {
var _this2 = this;
names.forEach(function (name) {
return _this2.assertAttr(name, expected);
});
};
InputRenderingTest.prototype.assertSelectionRange = function assertSelectionRange(start, end) {
var input = this.$input()[0];
this.assert.equal(input.selectionStart, start, 'the cursor start position should be ' + start);
this.assert.equal(input.selectionEnd, end, 'the cursor end position should be ' + end);
};
InputRenderingTest.prototype.triggerEvent = function triggerEvent(type, options) {
var event = document.createEvent('Events');
event.initEvent(type, true, true);
(0, _emberUtils.assign)(event, options);
var element = this.$input()[0];
this.runTask(function () {
element.dispatchEvent(event);
});
};
return InputRenderingTest;
}(_testCase.RenderingTest);
(0, _testCase.moduleFor)('Helpers test: {{input}}', function (_InputRenderingTest) {
(0, _emberBabel.inherits)(_class, _InputRenderingTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
return (0, _emberBabel.possibleConstructorReturn)(this, _InputRenderingTest.apply(this, arguments));
}
_class.prototype['@test a single text field is inserted into the DOM'] = function testASingleTextFieldIsInsertedIntoTheDOM(assert) {
var _this4 = this;
this.render('{{input type="text" value=value}}', { value: 'hello' });
var id = this.inputID();
this.assertValue('hello');
this.assertSingleInput();
this.runTask(function () {
return _this4.rerender();
});
this.assertValue('hello');
this.assertSingleInput();
this.assertInputId(id);
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'value', 'goodbye');
});
this.assertValue('goodbye');
this.assertSingleInput();
this.assertInputId(id);
this.runTask(function () {
return (0, _emberMetal.set)(_this4.context, 'value', 'hello');
});
this.assertValue('hello');
this.assertSingleInput();
this.assertInputId(id);
};
_class.prototype['@test default type'] = function testDefaultType() {
var _this5 = this;
this.render('{{input}}');
this.assertAttr('type', 'text');
this.runTask(function () {
return _this5.rerender();
});
this.assertAttr('type', 'text');
};
_class.prototype['@test dynamic attributes'] = function testDynamicAttributes() {
var _this6 = this;
this.render('\n {{input type="text"\n disabled=disabled\n value=value\n placeholder=placeholder\n name=name\n maxlength=maxlength\n minlength=minlength\n size=size\n tabindex=tabindex\n }}', {
disabled: false,
value: 'Original value',
placeholder: 'Original placeholder',
name: 'original-name',
maxlength: 10,
minlength: 5,
size: 20,
tabindex: 30
});
this.assertNotDisabled();
this.assertValue('Original value');
this.assertAttr('placeholder', 'Original placeholder');
this.assertAttr('name', 'original-name');
this.assertAttr('maxlength', '10');
this.assertAttr('minlength', '5');
// this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce)
// this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce)
this.runTask(function () {
return _this6.rerender();
});
this.assertNotDisabled();
this.assertValue('Original value');
this.assertAttr('placeholder', 'Original placeholder');
this.assertAttr('name', 'original-name');
this.assertAttr('maxlength', '10');
this.assertAttr('minlength', '5');
// this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce)
// this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce)
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'value', 'Updated value');
(0, _emberMetal.set)(_this6.context, 'disabled', true);
(0, _emberMetal.set)(_this6.context, 'placeholder', 'Updated placeholder');
(0, _emberMetal.set)(_this6.context, 'name', 'updated-name');
(0, _emberMetal.set)(_this6.context, 'maxlength', 11);
(0, _emberMetal.set)(_this6.context, 'minlength', 6);
// set(this.context, 'size', 21); //NOTE: failing in IE (TEST_SUITE=sauce)
// set(this.context, 'tabindex', 31); //NOTE: failing in IE (TEST_SUITE=sauce)
});
this.assertDisabled();
this.assertValue('Updated value');
this.assertAttr('placeholder', 'Updated placeholder');
this.assertAttr('name', 'updated-name');
this.assertAttr('maxlength', '11');
this.assertAttr('minlength', '6');
// this.assertAttr('size', '21'); //NOTE: failing in IE (TEST_SUITE=sauce)
// this.assertAttr('tabindex', '31'); //NOTE: failing in IE (TEST_SUITE=sauce)
this.runTask(function () {
(0, _emberMetal.set)(_this6.context, 'value', 'Original value');
(0, _emberMetal.set)(_this6.context, 'disabled', false);
(0, _emberMetal.set)(_this6.context, 'placeholder', 'Original placeholder');
(0, _emberMetal.set)(_this6.context, 'name', 'original-name');
(0, _emberMetal.set)(_this6.context, 'maxlength', 10);
(0, _emberMetal.set)(_this6.context, 'minlength', 5);
// set(this.context, 'size', 20); //NOTE: failing in IE (TEST_SUITE=sauce)
// set(this.context, 'tabindex', 30); //NOTE: failing in IE (TEST_SUITE=sauce)
});
this.assertNotDisabled();
this.assertValue('Original value');
this.assertAttr('placeholder', 'Original placeholder');
this.assertAttr('name', 'original-name');
this.assertAttr('maxlength', '10');
this.assertAttr('minlength', '5');
// this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce)
// this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce)
};
_class.prototype['@test static attributes'] = function testStaticAttributes() {
var _this7 = this;
this.render('\n {{input type="text"\n disabled=true\n value="Original value"\n placeholder="Original placeholder"\n name="original-name"\n maxlength=10\n minlength=5\n size=20\n tabindex=30\n }}');
this.assertDisabled();
this.assertValue('Original value');
this.assertAttr('placeholder', 'Original placeholder');
this.assertAttr('name', 'original-name');
this.assertAttr('maxlength', '10');
this.assertAttr('minlength', '5');
// this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce)
// this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce)
this.runTask(function () {
return _this7.rerender();
});
this.assertDisabled();
this.assertValue('Original value');
this.assertAttr('placeholder', 'Original placeholder');
this.assertAttr('name', 'original-name');
this.assertAttr('maxlength', '10');
this.assertAttr('minlength', '5');
// this.assertAttr('size', '20'); //NOTE: failing in IE (TEST_SUITE=sauce)
// this.assertAttr('tabindex', '30'); //NOTE: failing in IE (TEST_SUITE=sauce)
};
_class.prototype['@test cursor selection range'] = function testCursorSelectionRange(assert) {
var _this8 = this;
// Modifying input.selectionStart, which is utilized in the cursor tests,
// causes an event in Safari.
(0, _internalTestHelpers.runDestroy)(this.owner.lookup('event_dispatcher:main'));
this.render('{{input type="text" value=value}}', { value: 'original' });
var input = this.$input()[0];
// See https://ember-twiddle.com/33e506329f8176ae874422644d4cc08c?openFiles=components.input-component.js%2Ctemplates.components.input-component.hbs
// this.assertSelectionRange(8, 8); //NOTE: this is (0, 0) on Firefox (TEST_SUITE=sauce)
this.runTask(function () {
return _this8.rerender();
});
// this.assertSelectionRange(8, 8); //NOTE: this is (0, 0) on Firefox (TEST_SUITE=sauce)
this.runTask(function () {
input.selectionStart = 2;
input.selectionEnd = 4;
});
this.assertSelectionRange(2, 4);
this.runTask(function () {
return _this8.rerender();
});
this.assertSelectionRange(2, 4);
// this.runTask(() => set(this.context, 'value', 'updated'));
//
// this.assertSelectionRange(7, 7); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce)
//
// this.runTask(() => set(this.context, 'value', 'original'));
//
// this.assertSelectionRange(8, 8); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce)
};
_class.prototype['@test specifying `on="someevent" action="foo"` results in a deprecation warning'] = function testSpecifyingOnSomeeventActionFooResultsInADeprecationWarning() {
var _this9 = this;
expectDeprecation(function () {
_this9.render('{{input on="focus-in" action="doFoo" value="hello"}}');
}, 'Using \'{{input on="focus-in" action="doFoo"}}\' (\'-top-level\' @ L1:C0) is deprecated. Please use \'{{input focus-in="doFoo"}}\' instead.');
};
_class.prototype['@test sends an action with `{{input action="foo"}}` when <enter> is pressed [DEPRECATED]'] = function testSendsAnActionWithInputActionFooWhenEnterIsPressedDEPRECATED(assert) {
var _this10 = this;
assert.expect(2);
expectDeprecation(function () {
_this10.render('{{input action=\'foo\'}}', {
actions: {
foo: function () {
assert.ok(true, 'action was triggered');
}
}
});
}, /Please use '{{input enter="foo"}}' instead/);
this.triggerEvent('keyup', {
keyCode: 13
});
};
_class.prototype['@test sends an action with `{{input enter="foo"}}` when <enter> is pressed'] = function testSendsAnActionWithInputEnterFooWhenEnterIsPressed(assert) {
assert.expect(1);
this.render('{{input enter=\'foo\'}}', {
actions: {
foo: function () {
assert.ok(true, 'action was triggered');
}
}
});
this.triggerEvent('keyup', {
keyCode: 13
});
};
_class.prototype['@test sends an action with `{{input key-press="foo"}}` is pressed'] = function testSendsAnActionWithInputKeyPressFooIsPressed(assert) {
assert.expect(1);
this.render('{{input value=value key-press=\'foo\'}}', {
value: 'initial',
actions: {
foo: function () {
assert.ok(true, 'action was triggered');
}
}
});
this.triggerEvent('keypress', {
keyCode: 65
});
};
_class.prototype['@test sends an action to the parent level when `bubbles=true` is provided'] = function testSendsAnActionToTheParentLevelWhenBubblesTrueIsProvided(assert) {
assert.expect(1);
var ParentComponent = _helpers.Component.extend({
change: function () {
assert.ok(true, 'bubbled upwards');
}
});
this.registerComponent('x-parent', {
ComponentClass: ParentComponent,
template: '{{input bubbles=true}}'
});
this.render('{{x-parent}}');
this.triggerEvent('change');
};
_class.prototype['@test triggers `focus-in` when focused'] = function testTriggersFocusInWhenFocused(assert) {
var _this11 = this;
assert.expect(1);
this.render('{{input focus-in=\'foo\'}}', {
actions: {
foo: function () {
assert.ok(true, 'action was triggered');
}
}
});
this.runTask(function () {
_this11.$input().trigger('focusin');
});
};
_class.prototype['@test sends `insert-newline` when <enter> is pressed'] = function testSendsInsertNewlineWhenEnterIsPressed(assert) {
assert.expect(1);
this.render('{{input insert-newline=\'foo\'}}', {
actions: {
foo: function () {
assert.ok(true, 'action was triggered');
}
}
});
this.triggerEvent('keyup', {
keyCode: 13
});
};
_class.prototype['@test sends an action with `{{input escape-press="foo"}}` when <escape> is pressed'] = function testSendsAnActionWithInputEscapePressFooWhenEscapeIsPressed(assert) {
assert.expect(1);
this.render('{{input escape-press=\'foo\'}}', {
actions: {
foo: function () {
assert.ok(true, 'action was triggered');
}
}
});
this.triggerEvent('keyup', {
keyCode: 27
});
};
_class.prototype['@test sends an action with `{{input key-down="foo"}}` when a key is pressed'] = function testSendsAnActionWithInputKeyDownFooWhenAKeyIsPressed(assert) {
assert.expect(1);
this.render('{{input key-down=\'foo\'}}', {
actions: {
foo: function () {
assert.ok(true, 'action was triggered');
}
}
});
this.triggerEvent('keydown', {
keyCode: 65
});
};
_class.prototype['@test sends an action with `{{input key-up="foo"}}` when a key is pressed'] = function testSendsAnActionWithInputKeyUpFooWhenAKeyIsPressed(assert) {
assert.expect(1);
this.render('{{input key-up=\'foo\'}}', {
actions: {
foo: function () {
assert.ok(true, 'action was triggered');
}
}
});
this.triggerEvent('keyup', {
keyCode: 65
});
};
_class.prototype['@test GH#14727 can render a file input after having had render an input of other type'] = function testGH14727CanRenderAFileInputAfterHavingHadRenderAnInputOfOtherType() {
this.render('{{input type="text"}}{{input type="file"}}');
this.assert.equal(this.$input()[0].type, 'text');
this.assert.equal(this.$input()[1].type, 'file');
};
return _class;
}(InputRenderingTest));
(0, _testCase.moduleFor)('Helpers test: {{input}} with dynamic type', function (_InputRenderingTest2) {
(0, _emberBabel.inherits)(_class2, _InputRenderingTest2);
function _class2() {
(0, _emberBabel.classCallCheck)(this, _class2);
return (0, _emberBabel.possibleConstructorReturn)(this, _InputRenderingTest2.apply(this, arguments));
}
_class2.prototype['@test a bound property can be used to determine type'] = function testABoundPropertyCanBeUsedToDetermineType() {
var _this13 = this;
this.render('{{input type=type}}', { type: 'password' });
this.assertAttr('type', 'password');
this.runTask(function () {
return _this13.rerender();
});
this.assertAttr('type', 'password');
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'type', 'text');
});
this.assertAttr('type', 'text');
this.runTask(function () {
return (0, _emberMetal.set)(_this13.context, 'type', 'password');
});
this.assertAttr('type', 'password');
};
_class2.prototype['@test a subexpression can be used to determine type'] = function testASubexpressionCanBeUsedToDetermineType() {
var _this14 = this;
this.render('{{input type=(if isTruthy trueType falseType)}}', {
isTruthy: true,
trueType: 'text',
falseType: 'password'
});
this.assertAttr('type', 'text');
this.runTask(function () {
return _this14.rerender();
});
this.assertAttr('type', 'text');
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'isTruthy', false);
});
this.assertAttr('type', 'password');
this.runTask(function () {
return (0, _emberMetal.set)(_this14.context, 'isTruthy', true);
});
this.assertAttr('type', 'text');
};
return _class2;
}(InputRenderingTest));
(0, _testCase.moduleFor)('Helpers test: {{input type=\'checkbox\'}}', function (_InputRenderingTest3) {
(0, _emberBabel.inherits)(_class3, _InputRenderingTest3);
function _class3() {
(0, _emberBabel.classCallCheck)(this, _class3);
return (0, _emberBabel.possibleConstructorReturn)(this, _InputRenderingTest3.apply(this, arguments));
}
_class3.prototype['@test dynamic attributes'] = function testDynamicAttributes() {
var _this16 = this;
this.render('{{input\n type=\'checkbox\'\n disabled=disabled\n name=name\n checked=checked\n tabindex=tabindex\n }}', {
disabled: false,
name: 'original-name',
checked: false,
tabindex: 10
});
this.assertSingleCheckbox();
this.assertNotDisabled();
this.assertAttr('name', 'original-name');
this.assertAttr('tabindex', '10');
this.runTask(function () {
return _this16.rerender();
});
this.assertSingleCheckbox();
this.assertNotDisabled();
this.assertAttr('name', 'original-name');
this.assertAttr('tabindex', '10');
this.runTask(function () {
(0, _emberMetal.set)(_this16.context, 'disabled', true);
(0, _emberMetal.set)(_this16.context, 'name', 'updated-name');
(0, _emberMetal.set)(_this16.context, 'tabindex', 11);
});
this.assertSingleCheckbox();
this.assertDisabled();
this.assertAttr('name', 'updated-name');
this.assertAttr('tabindex', '11');
this.runTask(function () {
(0, _emberMetal.set)(_this16.context, 'disabled', false);
(0, _emberMetal.set)(_this16.context, 'name', 'original-name');
(0, _emberMetal.set)(_this16.context, 'tabindex', 10);
});
this.assertSingleCheckbox();
this.assertNotDisabled();
this.assertAttr('name', 'original-name');
this.assertAttr('tabindex', '10');
};
_class3.prototype['@test `value` property assertion'] = function testValuePropertyAssertion() {
var _this17 = this;
expectAssertion(function () {
_this17.render('{{input type="checkbox" value=value}}', { value: 'value' });
}, /you must use `checked=/);
};
_class3.prototype['@test with a bound type'] = function testWithABoundType(assert) {
var _this18 = this;
this.render('{{input type=inputType checked=isChecked}}', { inputType: 'checkbox', isChecked: true });
this.assertSingleCheckbox();
this.assertCheckboxIsChecked();
this.runTask(function () {
return _this18.rerender();
});
this.assertCheckboxIsChecked();
this.runTask(function () {
return (0, _emberMetal.set)(_this18.context, 'isChecked', false);
});
this.assertCheckboxIsNotChecked();
this.runTask(function () {
return (0, _emberMetal.set)(_this18.context, 'isChecked', true);
});
this.assertCheckboxIsChecked();
};
_class3.prototype['@test native click changes check property'] = function testNativeClickChangesCheckProperty(assert) {
this.render('{{input type="checkbox"}}');
this.assertSingleCheckbox();
this.assertCheckboxIsNotChecked();
this.$input()[0].click();
this.assertCheckboxIsChecked();
this.$input()[0].click();
this.assertCheckboxIsNotChecked();
};
_class3.prototype['@test with static values'] = function testWithStaticValues(assert) {
var _this19 = this;
this.render('{{input type="checkbox" disabled=false tabindex=10 name="original-name" checked=false}}');
this.assertSingleCheckbox();
this.assertCheckboxIsNotChecked();
this.assertNotDisabled();
this.assertAttr('tabindex', '10');
this.assertAttr('name', 'original-name');
this.runTask(function () {
return _this19.rerender();
});
this.assertSingleCheckbox();
this.assertCheckboxIsNotChecked();
this.assertNotDisabled();
this.assertAttr('tabindex', '10');
this.assertAttr('name', 'original-name');
};
return _class3;
}(InputRenderingTest));
(0, _testCase.moduleFor)('Helpers test: {{input type=\'text\'}}', function (_InputRenderingTest4) {
(0, _emberBabel.inherits)(_class4, _InputRenderingTest4);
function _class4() {
(0, _emberBabel.classCallCheck)(this, _class4);
return (0, _emberBabel.possibleConstructorReturn)(this, _InputRenderingTest4.apply(this, arguments));
}
_class4.prototype['@test null values'] = function testNullValues(assert) {
var _this21 = this;
var attributes = ['disabled', 'placeholder', 'name', 'maxlength', 'size', 'tabindex'];
this.render('\n {{input type="text"\n disabled=disabled\n value=value\n placeholder=placeholder\n name=name\n maxlength=maxlength\n size=size\n tabindex=tabindex\n }}', {
disabled: null,
value: null,
placeholder: null,
name: null,
maxlength: null,
size: null,
tabindex: null
});
this.assertValue('');
this.assertAllAttrs(attributes, undefined);
this.runTask(function () {
return _this21.rerender();
});
this.assertValue('');
this.assertAllAttrs(attributes, undefined);
this.runTask(function () {
(0, _emberMetal.set)(_this21.context, 'disabled', true);
(0, _emberMetal.set)(_this21.context, 'value', 'Updated value');
(0, _emberMetal.set)(_this21.context, 'placeholder', 'Updated placeholder');
(0, _emberMetal.set)(_this21.context, 'name', 'updated-name');
(0, _emberMetal.set)(_this21.context, 'maxlength', 11);
(0, _emberMetal.set)(_this21.context, 'size', 21);
(0, _emberMetal.set)(_this21.context, 'tabindex', 31);
});
this.assertDisabled();
this.assertValue('Updated value');
this.assertAttr('placeholder', 'Updated placeholder');
this.assertAttr('name', 'updated-name');
this.assertAttr('maxlength', '11');
this.assertAttr('size', '21');
this.assertAttr('tabindex', '31');
this.runTask(function () {
(0, _emberMetal.set)(_this21.context, 'disabled', null);
(0, _emberMetal.set)(_this21.context, 'value', null);
(0, _emberMetal.set)(_this21.context, 'placeholder', null);
(0, _emberMetal.set)(_this21.context, 'name', null);
(0, _emberMetal.set)(_this21.context, 'maxlength', null);
// set(this.context, 'size', null); //NOTE: this fails with `Error: Failed to set the 'size' property on 'HTMLInputElement': The value provided is 0, which is an invalid size.` (TEST_SUITE=sauce)
(0, _emberMetal.set)(_this21.context, 'tabindex', null);
});
this.assertAttr('disabled', undefined);
this.assertValue('');
// this.assertAttr('placeholder', undefined); //NOTE: this fails with a value of "null" (TEST_SUITE=sauce)
// this.assertAttr('name', undefined); //NOTE: this fails with a value of "null" (TEST_SUITE=sauce)
this.assertAttr('maxlength', undefined);
// this.assertAttr('size', undefined); //NOTE: re-enable once `size` bug above has been addressed
this.assertAttr('tabindex', undefined);
};
return _class4;
}(InputRenderingTest));
// These are the permutations of the set:
// ['type="range"', 'min="-5" max="50"', 'value="%x"']
['type="range" min="-5" max="50" value="%x"', 'type="range" value="%x" min="-5" max="50"', 'min="-5" max="50" type="range" value="%x"', 'min="-5" max="50" value="%x" type="range"', 'value="%x" min="-5" max="50" type="range"', 'value="%x" type="range" min="-5" max="50"'].forEach(function (attrs) {
(0, _testCase.moduleFor)('[GH#15675] Helpers test: {{input ' + attrs + '}}', function (_InputRenderingTest5) {
(0, _emberBabel.inherits)(_class5, _InputRenderingTest5);
function _class5() {
(0, _emberBabel.classCallCheck)(this, _class5);
return (0, _emberBabel.possibleConstructorReturn)(this, _InputRenderingTest5.apply(this, arguments));
}
_class5.prototype.renderInput = function renderInput() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 25;
this.render('{{input ' + attrs.replace("%x", value) + '}}');
};
_class5.prototype.assertValue = function assertValue(expected) {
var type = this.$input().attr('type');
if (type !== 'range') {
this.assert.ok(true, 'IE9 does not support range items');
return;
}
_InputRenderingTest5.prototype.assertValue.call(this, expected);
};
_class5.prototype['@test value over default max but below set max is kept'] = function testValueOverDefaultMaxButBelowSetMaxIsKept(assert) {
this.renderInput("25");
this.assertValue("25");
};
_class5.prototype['@test value below default min but above set min is kept'] = function testValueBelowDefaultMinButAboveSetMinIsKept(assert) {
this.renderInput("-2");
this.assertValue("-2");
};
_class5.prototype['@test in the valid default range is kept'] = function testInTheValidDefaultRangeIsKept(assert) {
this.renderInput("5");
this.assertValue("5");
};
_class5.prototype['@test value above max is reset to max'] = function testValueAboveMaxIsResetToMax(assert) {
this.renderInput("55");
this.assertValue("50");
};
_class5.prototype['@test value below min is reset to min'] = function testValueBelowMinIsResetToMin(assert) {
this.renderInput("-10");
this.assertValue("-5");
};
return _class5;
}(InputRenderingTest));
});
});
QUnit.module('ESLint | ember-glimmer/tests/integration/helpers/input-test.js');
QUnit.test('should pass ESLint', function(assert) {
assert.expect(1);
assert.ok(true, 'ember-glimmer/tests/integration/helpers/input-test.js should pass ESLint\n\n');
});
enifed('ember-glimmer/tests/integration/helpers/loc-test', ['ember-babel', 'ember-glimmer/tests/utils/test-case', 'ember-metal', 'ember'], function (_emberBabel, _testCase, _emberMetal, _ember) {
'use strict';
(0, _testCase.moduleFor)('Helpers test: {{loc}}', function (_RenderingTest) {
(0, _emberBabel.inherits)(_class, _RenderingTest);
function _class() {
(0, _emberBabel.classCallCheck)(this, _class);
var _this = (0, _emberBabel.possibleConstructorReturn)(this, _RenderingTest.call(this));
_this.oldString = _ember.default.STRINGS;
_ember.default.STRINGS = {
'Hello Friend': 'Hallo Freund',
'Hello': 'Hallo, %@'
};
return _this;
}
_class.prototype.teardown = function teardown() {
_RenderingTest.prototype.teardown.call(this);
_ember.default.STRINGS = this.oldString;
};
_class.prototype['@test it lets the original value through by default'] = function testItLetsTheOriginalValueThroughByDefault() {
var _this2 = this;
this.render('{{loc "Hiya buddy!"}}');
this.assertText('Hiya buddy!', 'the unlocalized string is correct');
this.runTask(function () {
return _this2.rerender();
});
this.assertText('Hiya buddy!', 'the unlocalized string is correct after rerender');
};
_class.prototype['@test it localizes a simple string'] = function testItLocalizesASimpleString() {
var _this3 = this;
this.render('{{loc "Hello Friend"}}');
this.assertText('Hallo Freund', 'the localized string is correct');
this.runTask(function () {
return _this3.rerender();
});
this.assertText('Hallo Freund', 'the localized string is correct after rerender');
};
_class.prototype['@test it takes passed formats into an account'] = function testItTakesPassedFormatsIntoAnAccount() {
var _this4 = this;
this.render('{{loc "%@, %@" "Hello" "Mr. Pitkin"}}');
this.assertText('Hello, Mr. Pitkin', 'the formatted string is correct');
this.runTask(function () {
return _this4.rerender();
});
this.assertText('Hello, Mr. Pitkin', 'the formatted string is correct after rerender');
};
_class.prototype['@test it updates when bound params change'] = function testItUpdatesWhenBoundParamsChange() {
var _this5 = this;
this.render('{{loc simple}} - {{loc personal \'Mr. Pitkin\'}}', {
simple: 'Hello Friend',
personal: 'Hello'
});
this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct');
this.runTask(function () {
return _this5.rerender();
});
this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after rerender');
this.runTask(function () {
return (0, _emberMetal.set)(_this5.context, 'simple', 'G\'day mate');
});
this.assertText('G\'day mate - Hallo, Mr. Pitkin', 'the bound value is correct after update');
this.runTask(function () {
return (0, _emberMetal.set)(_this5.context, 'simple', 'Hello Friend');
});
this.assertText('Hallo Freund - Hallo, Mr. Pitkin', 'the bound value is correct after reset');
};
_class.prototype['@test