(function() { /*! * @overview Ember - JavaScript Application Framework * @copyright Copyright 2011-2018 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 3.10.0 */ /*globals process */ var enifed, requireModule, Ember; // Used in @ember/-internals/environment/lib/global.js mainContext = this; // eslint-disable-line no-undef (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 = Object.create(null); var seen = Object.create(null); 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 Boolean(registry[moduleName]) || Boolean(registry[moduleName + '/index']); }; requireModule._eak_seen = registry; Ember.__loader = { define: enifed, require: requireModule, registry: registry, }; } else { enifed = Ember.__loader.define; requireModule = Ember.__loader.require; } })(); enifed("@ember/-internals/container/tests/container_test", ["ember-babel", "@ember/-internals/owner", "@ember/polyfills", "@ember/-internals/container", "internal-test-helpers"], function (_emberBabel, _owner, _polyfills, _container, _internalTestHelpers) { "use strict"; (0, _internalTestHelpers.moduleFor)('Container', /*#__PURE__*/ function (_AbstractTestCase) { (0, _emberBabel.inheritsLoose)(_class, _AbstractTestCase); function _class() { return _AbstractTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test A registered factory returns the same instance each time'] = function testARegisteredFactoryReturnsTheSameInstanceEachTime(assert) { 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'); assert.ok(postController instanceof PostController, 'The lookup is an instance of the factory'); assert.equal(postController, container.lookup('controller:post')); }; _proto['@test uses create time injections if factory has no extend'] = function testUsesCreateTimeInjectionsIfFactoryHasNoExtend(assert) { 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'); assert.ok(postController.apple instanceof AppleController, 'instance receives an apple of instance AppleController'); }; _proto['@test A registered factory returns a fresh instance if singleton: false is passed as an option'] = function testARegisteredFactoryReturnsAFreshInstanceIfSingletonFalseIsPassedAsAnOption(assert) { 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'); assert.equal(postController1.toString(), postController4.toString(), 'Singleton factories looked up normally return the same value'); assert.notEqual(postController1.toString(), postController2.toString(), 'Singleton factories are not equal to factories looked up with singleton: false'); assert.notEqual(postController2.toString(), postController3.toString(), 'Two factories looked up with singleton: false are not equal'); assert.notEqual(postController3.toString(), postController4.toString(), 'A singleton factory looked up after a factory called with singleton: false is not equal'); assert.ok(postController1 instanceof PostController, 'All instances are instances of the registered factory'); assert.ok(postController2 instanceof PostController, 'All instances are instances of the registered factory'); assert.ok(postController3 instanceof PostController, 'All instances are instances of the registered factory'); assert.ok(postController4 instanceof PostController, 'All instances are instances of the registered factory'); }; _proto["@test A factory type with a registered injection's instances receive that injection"] = function testAFactoryTypeWithARegisteredInjectionSInstancesReceiveThatInjection(assert) { 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'); assert.equal(postController.store, store); }; _proto['@test An individual factory with a registered injection receives the injection'] = function testAnIndividualFactoryWithARegisteredInjectionReceivesTheInjection(assert) { 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'); assert.equal(postController.store, store, 'has the correct store injected'); }; _proto['@test A factory with both type and individual injections'] = function testAFactoryWithBothTypeAndIndividualInjections(assert) { 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'); assert.equal(postController.store, store); assert.equal(postController.router, router); }; _proto['@test A non-singleton instance is never cached'] = function testANonSingletonInstanceIsNeverCached(assert) { 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'); assert.ok(postView1 !== postView2, 'Non-singletons are not cached'); }; _proto['@test A non-instantiated property is not instantiated'] = function testANonInstantiatedPropertyIsNotInstantiated(assert) { var registry = new _container.Registry(); var container = registry.container(); var template = function () {}; registry.register('template:foo', template, { instantiate: false }); assert.equal(container.lookup('template:foo'), template); }; _proto['@test A failed lookup returns undefined'] = function testAFailedLookupReturnsUndefined(assert) { var registry = new _container.Registry(); var container = registry.container(); assert.equal(container.lookup('doesnot:exist'), undefined); }; _proto['@test An invalid factory throws an error'] = function testAnInvalidFactoryThrowsAnError(assert) { var registry = new _container.Registry(); var container = registry.container(); registry.register('controller:foo', {}); assert.throws(function () { container.lookup('controller:foo'); }, /Failed to create an instance of \'controller:foo\'/); }; _proto['@test Injecting a failed lookup raises an error'] = function testInjectingAFailedLookupRaisesAnError() { var registry = new _container.Registry(); var container = registry.container(); var fooInstance = {}; var fooFactory = {}; var Foo = { create: function () { return fooInstance; }, extend: function () { return fooFactory; } }; registry.register('model:foo', Foo); registry.injection('model:foo', 'store', 'store:main'); expectAssertion(function () { container.lookup('model:foo'); }); }; _proto['@test Injecting a falsy value does not raise an error'] = function testInjectingAFalsyValueDoesNotRaiseAnError(assert) { 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'); assert.strictEqual(container.lookup('controller:application').currentUser, null); }; _proto['@test The container returns same value each time even if the value is falsy'] = function testTheContainerReturnsSameValueEachTimeEvenIfTheValueIsFalsy(assert) { var registry = new _container.Registry(); var container = registry.container(); registry.register('falsy:value', null, { instantiate: false }); assert.strictEqual(container.lookup('falsy:value'), container.lookup('falsy:value')); }; _proto['@test Destroying the container destroys any cached singletons'] = function testDestroyingTheContainerDestroysAnyCachedSingletons(assert) { 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; assert.ok(postView instanceof PostView, 'The non-singleton was injected'); container.destroy(); assert.ok(postController.isDestroyed, 'Singletons are destroyed'); assert.ok(!postView.isDestroyed, 'Non-singletons are not destroyed'); }; _proto['@test The container can use a registry hook to resolve factories lazily'] = function testTheContainerCanUseARegistryHookToResolveFactoriesLazily(assert) { 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'); assert.ok(postController instanceof PostController, 'The correct factory was provided'); }; _proto['@test The container normalizes names before resolving'] = function testTheContainerNormalizesNamesBeforeResolving(assert) { var registry = new _container.Registry(); var container = registry.container(); var PostController = (0, _internalTestHelpers.factory)(); registry.normalizeFullName = function () { return 'controller:post'; }; registry.register('controller:post', PostController); var postController = container.lookup('controller:normalized'); assert.ok(postController instanceof PostController, 'Normalizes the name before resolving'); }; _proto['@test The container normalizes names when looking factory up'] = function testTheContainerNormalizesNamesWhenLookingFactoryUp(assert) { var registry = new _container.Registry(); var container = registry.container(); var PostController = (0, _internalTestHelpers.factory)(); registry.normalizeFullName = function () { return 'controller:post'; }; registry.register('controller:post', PostController); var fact = container.factoryFor('controller:normalized'); var factInstance = fact.create(); assert.ok(factInstance instanceof PostController, 'Normalizes the name'); }; _proto['@test Options can be registered that should be applied to a given factory'] = function testOptionsCanBeRegisteredThatShouldBeAppliedToAGivenFactory(assert) { 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'); assert.ok(postView1 instanceof PostView, 'The correct factory was provided'); assert.ok(postView2 instanceof PostView, 'The correct factory was provided'); assert.ok(postView1 !== postView2, 'The two lookups are different'); }; _proto['@test Options can be registered that should be applied to all factories for a given type'] = function testOptionsCanBeRegisteredThatShouldBeAppliedToAllFactoriesForAGivenType(assert) { 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'); assert.ok(postView1 instanceof PostView, 'The correct factory was provided'); assert.ok(postView2 instanceof PostView, 'The correct factory was provided'); assert.ok(postView1 !== postView2, 'The two lookups are different'); }; _proto['@test An injected non-singleton instance is never cached'] = function testAnInjectedNonSingletonInstanceIsNeverCached(assert) { 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'); assert.ok(postView1.viewHelper !== postView2.viewHelper, 'Injected non-singletons are not cached'); }; _proto['@test Factory resolves are cached'] = function testFactoryResolvesAreCached(assert) { 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; }; assert.deepEqual(resolveWasCalled, []); container.factoryFor('controller:post'); assert.deepEqual(resolveWasCalled, ['controller:post']); container.factoryFor('controller:post'); assert.deepEqual(resolveWasCalled, ['controller:post']); }; _proto['@test factory for non extendables (MODEL) resolves are cached'] = function testFactoryForNonExtendablesMODELResolvesAreCached(assert) { 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; }; assert.deepEqual(resolveWasCalled, []); container.factoryFor('model:post'); assert.deepEqual(resolveWasCalled, ['model:post']); container.factoryFor('model:post'); assert.deepEqual(resolveWasCalled, ['model:post']); }; _proto['@test factory for non extendables resolves are cached'] = function testFactoryForNonExtendablesResolvesAreCached(assert) { var registry = new _container.Registry(); var container = registry.container(); var PostController = {}; var resolveWasCalled = []; registry.resolve = function (fullName) { resolveWasCalled.push(fullName); return PostController; }; assert.deepEqual(resolveWasCalled, []); container.factoryFor('foo:post'); assert.deepEqual(resolveWasCalled, ['foo:post']); container.factoryFor('foo:post'); assert.deepEqual(resolveWasCalled, ['foo:post']); }; _proto["@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 [{ specifier: 'orange:main' }, { specifier: 'banana:main' }]; } }); registry.register('apple:main', Apple); registry.register('orange:main', Orange); expectAssertion(function () { container.lookup('apple:main'); }, /Attempting to inject an unknown injection: 'banana:main'/); }; _proto['@test Lazy injection validations are cached'] = function testLazyInjectionValidationsAreCached(assert) { if (!false /* DEBUG */ ) { assert.expect(0); return; } assert.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 () { assert.ok(true, 'should call lazy injection method'); return [{ specifier: 'orange:main' }]; } }); registry.register('apple:main', Apple); registry.register('orange:main', Orange); container.lookup('apple:main'); container.lookup('apple:main'); }; _proto['@test An object with its owner pre-set should be returned from ownerInjection'] = function testAnObjectWithItsOwnerPreSetShouldBeReturnedFromOwnerInjection(assert) { var owner = {}; var registry = new _container.Registry(); var container = registry.container({ owner: owner }); var result = container.ownerInjection(); assert.equal(result[_owner.OWNER], owner, 'owner is properly included'); }; _proto['@test lookup passes options through to expandlocallookup'] = function testLookupPassesOptionsThroughToExpandlocallookup(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); }; _proto['@test #factoryFor class is registered class'] = function testFactoryForClassIsRegisteredClass(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'); }; _proto['@test #factoryFor must supply a fullname'] = function testFactoryForMustSupplyAFullname() { var registry = new _container.Registry(); var container = registry.container(); expectAssertion(function () { container.factoryFor('chad-bar'); }, /fullName must be a proper full name/); }; _proto['@test #factoryFor returns a factory manager'] = function testFactoryForReturnsAFactoryManager(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); }; _proto['@test #factoryFor returns a cached factory manager for the same type'] = function testFactoryForReturnsACachedFactoryManagerForTheSameType(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'); }; _proto['@test #factoryFor class returns the factory function'] = function testFactoryForClassReturnsTheFactoryFunction(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'); }; _proto['@test #factoryFor instance have a common parent'] = function testFactoryForInstanceHaveACommonParent(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); }; _proto['@test can properly reset cache'] = function testCanProperlyResetCache(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); }; _proto['@test #factoryFor created instances come with instance injections'] = function testFactoryForCreatedInstancesComeWithInstanceInjections(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); }; _proto['@test #factoryFor options passed to create clobber injections'] = function testFactoryForOptionsPassedToCreateClobberInjections(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'); }; _proto['@test #factoryFor does not add properties to the object being instantiated when _initFactory is present'] = function testFactoryForDoesNotAddPropertiesToTheObjectBeingInstantiatedWhen_initFactoryIsPresent(assert) { var registry = new _container.Registry(); var container = registry.container(); var Component = /*#__PURE__*/ function () { function Component() {} Component._initFactory = function _initFactory() {}; Component.create = function create(options) { var instance = new this(); (0, _polyfills.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), []); }; _proto["@test assert when calling lookup after destroy on a container"] = function (assert) { var registry = new _container.Registry(); var container = registry.container(); var Component = (0, _internalTestHelpers.factory)(); registry.register('component:foo-bar', Component); var instance = container.lookup('component:foo-bar'); assert.ok(instance, 'precond lookup successful'); (0, _internalTestHelpers.runTask)(function () { container.destroy(); container.finalizeDestroy(); }); expectAssertion(function () { container.lookup('component:foo-bar'); }); }; _proto["@test assert when calling factoryFor after destroy on a container"] = function (assert) { var registry = new _container.Registry(); var container = registry.container(); var Component = (0, _internalTestHelpers.factory)(); registry.register('component:foo-bar', Component); var instance = container.factoryFor('component:foo-bar'); assert.ok(instance, 'precond lookup successful'); (0, _internalTestHelpers.runTask)(function () { container.destroy(); container.finalizeDestroy(); }); expectAssertion(function () { container.factoryFor('component:foo-bar'); }); } // this is skipped until templates and the glimmer environment do not require `OWNER` to be // passed in as constructor args ; _proto['@skip #factoryFor does not add properties to the object being instantiated'] = function skipFactoryForDoesNotAddPropertiesToTheObjectBeingInstantiated(assert) { var registry = new _container.Registry(); var container = registry.container(); var Component = /*#__PURE__*/ function () { function Component() {} Component.create = function create(options) { var instance = new this(); (0, _polyfills.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), []); }; return _class; }(_internalTestHelpers.AbstractTestCase)); if (false /* EMBER_MODULE_UNIFICATION */ ) { (0, _internalTestHelpers.moduleFor)('Container module unification', /*#__PURE__*/ function (_AbstractTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _AbstractTestCase2); function _class2() { return _AbstractTestCase2.apply(this, arguments) || this; } var _proto2 = _class2.prototype; _proto2['@test The container can expand and resolve a source to factoryFor'] = function testTheContainerCanExpandAndResolveASourceToFactoryFor(assert) { var _this = this; var PrivateComponent = (0, _internalTestHelpers.factory)(); var lookup = 'component:my-input'; var expectedSource = 'template:routes/application'; var registry = new _container.Registry(); var resolveCount = 0; var expandedKey = 'boom, special expanded key'; registry.expandLocalLookup = function (specifier, options) { _this.assert.strictEqual(specifier, lookup, 'specifier is expanded'); _this.assert.strictEqual(options.source, expectedSource, 'source is expanded'); return expandedKey; }; registry.resolve = function (fullName) { resolveCount++; if (fullName === expandedKey) { 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'); }; _proto2['@test The container can expand and resolve a source to lookup'] = function testTheContainerCanExpandAndResolveASourceToLookup() { var _this2 = this; var PrivateComponent = (0, _internalTestHelpers.factory)(); var lookup = 'component:my-input'; var expectedSource = 'template:routes/application'; var registry = new _container.Registry(); var expandedKey = 'boom, special expanded key'; registry.expandLocalLookup = function (specifier, options) { _this2.assert.strictEqual(specifier, lookup, 'specifier is expanded'); _this2.assert.strictEqual(options.source, expectedSource, 'source is expanded'); return expandedKey; }; registry.resolve = function (fullName) { if (fullName === expandedKey) { return PrivateComponent; } }; var container = registry.container(); var result = container.lookup(lookup, { source: expectedSource }); this.assert.ok(result instanceof PrivateComponent, 'The correct factory was provided'); this.assert.ok(container.cache[expandedKey] instanceof PrivateComponent, 'The correct factory was stored in the cache with the correct key which includes the source.'); }; _proto2['@test The container can expand and resolve a namespace to factoryFor'] = function testTheContainerCanExpandAndResolveANamespaceToFactoryFor(assert) { var _this3 = this; var PrivateComponent = (0, _internalTestHelpers.factory)(); var lookup = 'component:my-input'; var expectedNamespace = 'my-addon'; var registry = new _container.Registry(); var resolveCount = 0; var expandedKey = 'boom, special expanded key'; registry.expandLocalLookup = function (specifier, options) { _this3.assert.strictEqual(specifier, lookup, 'specifier is expanded'); _this3.assert.strictEqual(options.namespace, expectedNamespace, 'namespace is expanded'); return expandedKey; }; registry.resolve = function (fullName) { resolveCount++; if (fullName === expandedKey) { return PrivateComponent; } }; var container = registry.container(); assert.strictEqual(container.factoryFor(lookup, { namespace: expectedNamespace }).class, PrivateComponent, 'The correct factory was provided'); assert.strictEqual(container.factoryFor(lookup, { namespace: expectedNamespace }).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'); }; _proto2['@test The container can expand and resolve a namespace to lookup'] = function testTheContainerCanExpandAndResolveANamespaceToLookup() { var _this4 = this; var PrivateComponent = (0, _internalTestHelpers.factory)(); var lookup = 'component:my-input'; var expectedNamespace = 'my-addon'; var registry = new _container.Registry(); var expandedKey = 'boom, special expanded key'; registry.expandLocalLookup = function (specifier, options) { _this4.assert.strictEqual(specifier, lookup, 'specifier is expanded'); _this4.assert.strictEqual(options.namespace, expectedNamespace, 'namespace is expanded'); return expandedKey; }; registry.resolve = function (fullName) { if (fullName === expandedKey) { return PrivateComponent; } }; var container = registry.container(); var result = container.lookup(lookup, { namespace: expectedNamespace }); this.assert.ok(result instanceof PrivateComponent, 'The correct factory was provided'); this.assert.ok(container.cache[expandedKey] instanceof PrivateComponent, 'The correct factory was stored in the cache with the correct key which includes the source.'); }; return _class2; }(_internalTestHelpers.AbstractTestCase)); } }); enifed("@ember/-internals/container/tests/owner_test", ["ember-babel", "@ember/-internals/owner", "internal-test-helpers"], function (_emberBabel, _owner, _internalTestHelpers) { "use strict"; (0, _internalTestHelpers.moduleFor)('Owner', /*#__PURE__*/ function (_AbstractTestCase) { (0, _emberBabel.inheritsLoose)(_class, _AbstractTestCase); function _class() { return _AbstractTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test An owner can be set with `setOwner` and retrieved with `getOwner`'] = function testAnOwnerCanBeSetWithSetOwnerAndRetrievedWithGetOwner(assert) { var owner = {}; var obj = {}; assert.strictEqual((0, _owner.getOwner)(obj), undefined, 'owner has not been set'); (0, _owner.setOwner)(obj, owner); assert.strictEqual((0, _owner.getOwner)(obj), owner, 'owner has been set'); assert.strictEqual(obj[_owner.OWNER], owner, 'owner has been set to the OWNER symbol'); }; return _class; }(_internalTestHelpers.AbstractTestCase)); }); enifed("@ember/-internals/container/tests/registry_test", ["ember-babel", "@ember/-internals/container", "internal-test-helpers"], function (_emberBabel, _container, _internalTestHelpers) { "use strict"; (0, _internalTestHelpers.moduleFor)('Registry', /*#__PURE__*/ function (_AbstractTestCase) { (0, _emberBabel.inheritsLoose)(_class, _AbstractTestCase); function _class() { return _AbstractTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test A registered factory is returned from resolve'] = function testARegisteredFactoryIsReturnedFromResolve(assert) { var registry = new _container.Registry(); var PostController = (0, _internalTestHelpers.factory)(); registry.register('controller:post', PostController); var PostControllerFactory = registry.resolve('controller:post'); assert.ok(PostControllerFactory, 'factory is returned'); assert.ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController'); }; _proto['@test The registered factory returned from resolve is the same factory each time'] = function testTheRegisteredFactoryReturnedFromResolveIsTheSameFactoryEachTime(assert) { var registry = new _container.Registry(); var PostController = (0, _internalTestHelpers.factory)(); registry.register('controller:post', PostController); assert.deepEqual(registry.resolve('controller:post'), registry.resolve('controller:post'), 'The return of resolve is always the same'); }; _proto['@test The registered value returned from resolve is the same value each time even if the value is falsy'] = function testTheRegisteredValueReturnedFromResolveIsTheSameValueEachTimeEvenIfTheValueIsFalsy(assert) { var registry = new _container.Registry(); registry.register('falsy:value', null, { instantiate: false }); assert.strictEqual(registry.resolve('falsy:value'), registry.resolve('falsy:value'), 'The return of resolve is always the same'); }; _proto['@test The value returned from resolver is the same value as the original value even if the value is falsy'] = function testTheValueReturnedFromResolverIsTheSameValueAsTheOriginalValueEvenIfTheValueIsFalsy(assert) { var resolver = { resolve: function (fullName) { if (fullName === 'falsy:value') { return null; } } }; var registry = new _container.Registry({ resolver: resolver }); assert.strictEqual(registry.resolve('falsy:value'), null); }; _proto['@test A registered factory returns true for `has` if an item is registered'] = function testARegisteredFactoryReturnsTrueForHasIfAnItemIsRegistered(assert) { var registry = new _container.Registry(); var PostController = (0, _internalTestHelpers.factory)(); registry.register('controller:post', PostController); assert.equal(registry.has('controller:post'), true, 'The `has` method returned true for registered factories'); assert.equal(registry.has('controller:posts'), false, 'The `has` method returned false for unregistered factories'); }; _proto['@test Throw exception when trying to inject `type:thing` on all type(s)'] = function testThrowExceptionWhenTryingToInjectTypeThingOnAllTypeS() { 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\)\./); }; _proto['@test The registry can take a hook to resolve factories lazily'] = function testTheRegistryCanTakeAHookToResolveFactoriesLazily(assert) { var PostController = (0, _internalTestHelpers.factory)(); var resolver = { resolve: function (fullName) { if (fullName === 'controller:post') { return PostController; } } }; var registry = new _container.Registry({ resolver: resolver }); assert.strictEqual(registry.resolve('controller:post'), PostController, 'The correct factory was provided'); }; _proto['@test The registry respects the resolver hook for `has`'] = function testTheRegistryRespectsTheResolverHookForHas(assert) { var PostController = (0, _internalTestHelpers.factory)(); var resolver = { resolve: function (fullName) { if (fullName === 'controller:post') { return PostController; } } }; var registry = new _container.Registry({ resolver: resolver }); assert.ok(registry.has('controller:post'), 'the `has` method uses the resolver hook'); }; _proto['@test The registry normalizes names when resolving'] = function testTheRegistryNormalizesNamesWhenResolving(assert) { var registry = new _container.Registry(); var PostController = (0, _internalTestHelpers.factory)(); registry.normalizeFullName = function () { return 'controller:post'; }; registry.register('controller:post', PostController); var type = registry.resolve('controller:normalized'); assert.strictEqual(type, PostController, 'Normalizes the name when resolving'); }; _proto['@test The registry normalizes names when checking if the factory is registered'] = function testTheRegistryNormalizesNamesWhenCheckingIfTheFactoryIsRegistered(assert) { 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'); assert.equal(isPresent, true, 'Normalizes the name when checking if the factory or instance is present'); }; _proto['@test The registry normalizes names when injecting'] = function testTheRegistryNormalizesNamesWhenInjecting(assert) { var registry = new _container.Registry(); var PostController = (0, _internalTestHelpers.factory)(); var user = { name: 'Stef' }; registry.normalize = function () { return 'controller:post'; }; registry.register('controller:post', PostController); registry.register('user:post', user, { instantiate: false }); registry.injection('controller:post', 'user', 'controller:normalized'); assert.deepEqual(registry.resolve('controller:post'), user, 'Normalizes the name when injecting'); }; _proto['@test cannot register an `undefined` factory'] = function testCannotRegisterAnUndefinedFactory() { var registry = new _container.Registry(); expectAssertion(function () { registry.register('controller:apple', undefined); }, ''); }; _proto['@test can re-register a factory'] = function testCanReRegisterAFactory(assert) { 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); assert.ok(registry.resolve('controller:apple').create() instanceof SecondApple); }; _proto['@test cannot re-register a factory if it has been resolved'] = function testCannotReRegisterAFactoryIfItHasBeenResolved(assert) { var registry = new _container.Registry(); var FirstApple = (0, _internalTestHelpers.factory)('first'); var SecondApple = (0, _internalTestHelpers.factory)('second'); registry.register('controller:apple', FirstApple); assert.strictEqual(registry.resolve('controller:apple'), FirstApple); expectAssertion(function () { registry.register('controller:apple', SecondApple); }, /Cannot re-register: 'controller:apple', as it has already been resolved\./); assert.strictEqual(registry.resolve('controller:apple'), FirstApple); }; _proto['@test registry.has should not accidentally cause injections on that factory to be run. (Mitigate merely on observing)'] = function testRegistryHasShouldNotAccidentallyCauseInjectionsOnThatFactoryToBeRunMitigateMerelyOnObserving(assert) { assert.expect(1); var registry = new _container.Registry(); var FirstApple = (0, _internalTestHelpers.factory)('first'); var SecondApple = (0, _internalTestHelpers.factory)('second'); SecondApple.extend = function () { assert.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'); assert.ok(registry.has('controller:apple')); }; _proto['@test registry.has should not error for invalid fullNames'] = function testRegistryHasShouldNotErrorForInvalidFullNames(assert) { var registry = new _container.Registry(); assert.ok(!registry.has('foo:bar:baz')); }; _proto['@test once resolved, always return the same result'] = function testOnceResolvedAlwaysReturnTheSameResult(assert) { var registry = new _container.Registry(); registry.resolver = { resolve: function () { return 'bar'; } }; var Bar = registry.resolve('models:bar'); registry.resolver = { resolve: function () { return 'not bar'; } }; assert.equal(registry.resolve('models:bar'), Bar); }; _proto['@test factory resolves are cached'] = function testFactoryResolvesAreCached(assert) { var registry = new _container.Registry(); var PostController = (0, _internalTestHelpers.factory)(); var resolveWasCalled = []; registry.resolver = { resolve: function (fullName) { resolveWasCalled.push(fullName); return PostController; } }; assert.deepEqual(resolveWasCalled, []); registry.resolve('controller:post'); assert.deepEqual(resolveWasCalled, ['controller:post']); registry.resolve('controller:post'); assert.deepEqual(resolveWasCalled, ['controller:post']); }; _proto['@test factory for non extendables (MODEL) resolves are cached'] = function testFactoryForNonExtendablesMODELResolvesAreCached(assert) { var registry = new _container.Registry(); var PostController = (0, _internalTestHelpers.factory)(); var resolveWasCalled = []; registry.resolver = { resolve: function (fullName) { resolveWasCalled.push(fullName); return PostController; } }; assert.deepEqual(resolveWasCalled, []); registry.resolve('model:post'); assert.deepEqual(resolveWasCalled, ['model:post']); registry.resolve('model:post'); assert.deepEqual(resolveWasCalled, ['model:post']); }; _proto['@test factory for non extendables resolves are cached'] = function testFactoryForNonExtendablesResolvesAreCached(assert) { var registry = new _container.Registry(); var PostController = {}; var resolveWasCalled = []; registry.resolver = { resolve: function (fullName) { resolveWasCalled.push(fullName); return PostController; } }; assert.deepEqual(resolveWasCalled, []); registry.resolve('foo:post'); assert.deepEqual(resolveWasCalled, ['foo:post']); registry.resolve('foo:post'); assert.deepEqual(resolveWasCalled, ['foo:post']); }; _proto['@test registry.container creates a container'] = function testRegistryContainerCreatesAContainer(assert) { 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'); assert.ok(postController instanceof PostController, 'The lookup is an instance of the registered factory'); }; _proto['@test `describe` will be handled by the resolver, then by the fallback registry, if available'] = function testDescribeWillBeHandledByTheResolverThenByTheFallbackRegistryIfAvailable(assert) { 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 }); assert.equal(registry.describe('controller:post'), 'controller:post-resolver', '`describe` handled by the resolver first.'); registry.resolver = null; assert.equal(registry.describe('controller:post'), 'controller:post-fallback', '`describe` handled by fallback registry next.'); registry.fallback = null; assert.equal(registry.describe('controller:post'), 'controller:post', '`describe` by default returns argument.'); }; _proto['@test `normalizeFullName` will be handled by the resolver, then by the fallback registry, if available'] = function testNormalizeFullNameWillBeHandledByTheResolverThenByTheFallbackRegistryIfAvailable(assert) { 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 }); assert.equal(registry.normalizeFullName('controller:post'), 'controller:post-resolver', '`normalizeFullName` handled by the resolver first.'); registry.resolver = null; assert.equal(registry.normalizeFullName('controller:post'), 'controller:post-fallback', '`normalizeFullName` handled by fallback registry next.'); registry.fallback = null; assert.equal(registry.normalizeFullName('controller:post'), 'controller:post', '`normalizeFullName` by default returns argument.'); }; _proto['@test `makeToString` will be handled by the resolver, then by the fallback registry, if available'] = function testMakeToStringWillBeHandledByTheResolverThenByTheFallbackRegistryIfAvailable(assert) { 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 }); assert.equal(registry.makeToString('controller:post'), 'controller:post-resolver', '`makeToString` handled by the resolver first.'); registry.resolver = null; assert.equal(registry.makeToString('controller:post'), 'controller:post-fallback', '`makeToString` handled by fallback registry next.'); registry.fallback = null; assert.equal(registry.makeToString('controller:post'), 'controller:post', '`makeToString` by default returns argument.'); }; _proto['@test `resolve` can be handled by a fallback registry'] = function testResolveCanBeHandledByAFallbackRegistry(assert) { 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'); assert.ok(PostControllerFactory, 'factory is returned'); assert.ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController'); }; _proto['@test `has` can be handled by a fallback registry'] = function testHasCanBeHandledByAFallbackRegistry(assert) { var fallback = new _container.Registry(); var registry = new _container.Registry({ fallback: fallback }); var PostController = (0, _internalTestHelpers.factory)(); fallback.register('controller:post', PostController); assert.equal(registry.has('controller:post'), true, 'Fallback registry is checked for registration'); }; _proto['@test `getInjections` includes injections from a fallback registry'] = function testGetInjectionsIncludesInjectionsFromAFallbackRegistry(assert) { var fallback = new _container.Registry(); var registry = new _container.Registry({ fallback: fallback }); assert.strictEqual(registry.getInjections('model:user'), undefined, 'No injections in the primary registry'); fallback.injection('model:user', 'post', 'model:post'); assert.equal(registry.getInjections('model:user').length, 1, 'Injections from the fallback registry are merged'); }; _proto['@test `getTypeInjections` includes type injections from a fallback registry'] = function testGetTypeInjectionsIncludesTypeInjectionsFromAFallbackRegistry(assert) { var fallback = new _container.Registry(); var registry = new _container.Registry({ fallback: fallback }); assert.strictEqual(registry.getTypeInjections('model'), undefined, 'No injections in the primary registry'); fallback.injection('model', 'source', 'source:main'); assert.equal(registry.getTypeInjections('model').length, 1, 'Injections from the fallback registry are merged'); }; _proto['@test `knownForType` contains keys for each item of a given type'] = function testKnownForTypeContainsKeysForEachItemOfAGivenType(assert) { var registry = new _container.Registry(); registry.register('foo:bar-baz', 'baz'); registry.register('foo:qux-fez', 'fez'); var found = registry.knownForType('foo'); assert.deepEqual(found, { 'foo:bar-baz': true, 'foo:qux-fez': true }); }; _proto['@test `knownForType` includes fallback registry results'] = function testKnownForTypeIncludesFallbackRegistryResults(assert) { 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'); assert.deepEqual(found, { 'foo:bar-baz': true, 'foo:qux-fez': true, 'foo:zurp-zorp': true }); }; _proto['@test `knownForType` is called on the resolver if present'] = function testKnownForTypeIsCalledOnTheResolverIfPresent(assert) { assert.expect(3); var resolver = { knownForType: function (type) { assert.ok(true, 'knownForType called on the resolver'); assert.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'); assert.deepEqual(found, { 'foo:yorp': true, 'foo:bar-baz': true }); }; _proto['@test resolver.expandLocalLookup is not required'] = function testResolverExpandLocalLookupIsNotRequired(assert) { var registry = new _container.Registry({ resolver: {} }); var result = registry.expandLocalLookup('foo:bar', { source: 'baz:qux' }); assert.equal(result, null); }; _proto['@test expandLocalLookup is called on the resolver if present'] = function testExpandLocalLookupIsCalledOnTheResolverIfPresent(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'); }; _proto['@test `expandLocalLookup` is handled by the resolver, then by the fallback registry, if available'] = function testExpandLocalLookupIsHandledByTheResolverThenByTheFallbackRegistryIfAvailable(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'); }; _proto['@test resolver.expandLocalLookup result is cached'] = function testResolverExpandLocalLookupResultIsCached(assert) { assert.expect(3); var result; var resolver = { expandLocalLookup: function () { 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'); }; _proto['@test resolver.expandLocalLookup cache is busted when any unregister is called'] = function testResolverExpandLocalLookupCacheIsBustedWhenAnyUnregisterIsCalled(assert) { assert.expect(4); var result; var resolver = { expandLocalLookup: function () { 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'); }; _proto['@test resolve calls expandLocallookup when it receives options.source'] = function testResolveCallsExpandLocallookupWhenItReceivesOptionsSource(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' }); }; _proto['@test has uses expandLocalLookup'] = function testHasUsesExpandLocalLookup(assert) { assert.expect(5); var resolvedFullNames = []; var result; var resolver = { resolve: function (name) { resolvedFullNames.push(name); return 'yippie!'; }, expandLocalLookup: function (targetFullName) { 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); }; return _class; }(_internalTestHelpers.AbstractTestCase)); (0, _internalTestHelpers.moduleFor)('Registry privatize', /*#__PURE__*/ function (_AbstractTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _AbstractTestCase2); function _class2() { return _AbstractTestCase2.apply(this, arguments) || this; } var _proto2 = _class2.prototype; _proto2['@test valid format'] = function testValidFormat(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])); }; return _class2; }(_internalTestHelpers.AbstractTestCase)); if (false /* EMBER_MODULE_UNIFICATION */ ) { (0, _internalTestHelpers.moduleFor)('Registry module unification', /*#__PURE__*/ function (_AbstractTestCase3) { (0, _emberBabel.inheritsLoose)(_class3, _AbstractTestCase3); function _class3() { return _AbstractTestCase3.apply(this, arguments) || this; } var _proto3 = _class3.prototype; _proto3['@test The registry can pass a source to the resolver'] = function testTheRegistryCanPassASourceToTheResolver(assert) { var PrivateComponent = (0, _internalTestHelpers.factory)(); var type = 'component'; var name = 'my-input'; var specifier = type + ":" + name; var source = 'template:routes/application'; var resolver = new _internalTestHelpers.ModuleBasedTestResolver(); resolver.add({ specifier: specifier, source: source }, PrivateComponent); var registry = new _container.Registry({ resolver: resolver }); assert.strictEqual(registry.resolve(specifier), undefined, 'Not returned when specifier not scoped'); assert.strictEqual(registry.resolve(specifier, { source: source }), PrivateComponent, 'The correct factory was provided'); assert.strictEqual(registry.resolve(specifier, { source: source }), PrivateComponent, 'The correct factory was provided again'); }; _proto3['@test The registry can pass a namespace to the resolver'] = function testTheRegistryCanPassANamespaceToTheResolver(assert) { var PrivateComponent = (0, _internalTestHelpers.factory)(); var type = 'component'; var name = 'my-input'; var specifier = type + ":" + name; var source = 'template:routes/application'; var namespace = 'my-addon'; var resolver = new _internalTestHelpers.ModuleBasedTestResolver(); resolver.add({ specifier: specifier, source: source, namespace: namespace }, PrivateComponent); var registry = new _container.Registry({ resolver: resolver }); assert.strictEqual(registry.resolve(specifier), undefined, 'Not returned when specifier not scoped'); assert.strictEqual(registry.resolve(specifier, { source: source }), undefined, 'Not returned when specifier is missing namespace'); assert.strictEqual(registry.resolve(specifier, { source: source, namespace: namespace }), PrivateComponent, 'The correct factory was provided'); assert.strictEqual(registry.resolve(specifier, { source: source, namespace: namespace }), PrivateComponent, 'The correct factory was provided again'); }; return _class3; }(_internalTestHelpers.AbstractTestCase)); } }); enifed("@ember/-internals/extension-support/tests/container_debug_adapter_test", ["ember-babel", "internal-test-helpers", "@ember/polyfills", "@ember/runloop", "@ember/controller", "@ember/-internals/extension-support/index", "@ember/debug"], function (_emberBabel, _internalTestHelpers, _polyfills, _runloop, _controller, _index, _debug) { "use strict"; // Must be required to export Ember.ContainerDebugAdapter. var originalDebug = (0, _debug.getDebugFunction)('debug'); (0, _internalTestHelpers.moduleFor)('Container Debug Adapter', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { var _this; (0, _debug.setDebugFunction)('debug', function () {}); _this = _ApplicationTestCase.call(this) || this; _this.adapter = _this.application.__deprecatedInstance__.lookup('container-debug-adapter:main'); return _this; } var _proto = _class.prototype; _proto.teardown = function teardown() { var _this2 = this; (0, _debug.setDebugFunction)('debug', originalDebug); (0, _runloop.run)(function () { _this2.adapter.destroy(); }); _ApplicationTestCase.prototype.teardown.call(this); }; _proto['@test default ContainerDebugAdapter cannot catalog certain entries by type'] = function testDefaultContainerDebugAdapterCannotCatalogCertainEntriesByType(assert) { assert.equal(this.adapter.canCatalogEntriesByType('model'), false, 'canCatalogEntriesByType should return false for model'); assert.equal(this.adapter.canCatalogEntriesByType('template'), false, 'canCatalogEntriesByType should return false for template'); }; _proto['@test default ContainerDebugAdapter can catalog typical entries by type'] = function testDefaultContainerDebugAdapterCanCatalogTypicalEntriesByType(assert) { assert.equal(this.adapter.canCatalogEntriesByType('controller'), true, 'canCatalogEntriesByType should return true for controller'); assert.equal(this.adapter.canCatalogEntriesByType('route'), true, 'canCatalogEntriesByType should return true for route'); assert.equal(this.adapter.canCatalogEntriesByType('view'), true, 'canCatalogEntriesByType should return true for view'); }; _proto['@test default ContainerDebugAdapter catalogs controller entries'] = function testDefaultContainerDebugAdapterCatalogsControllerEntries(assert) { this.application.PostController = _controller.default.extend(); var controllerClasses = this.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, _polyfills.assign)(_ApplicationTestCase.prototype.applicationOptions, { autoboot: true }); } }]); return _class; }(_internalTestHelpers.ApplicationTestCase)); }); enifed("@ember/-internals/extension-support/tests/data_adapter_test", ["ember-babel", "@ember/runloop", "@ember/-internals/metal", "@ember/-internals/runtime", "@ember/-internals/extension-support/lib/data_adapter", "internal-test-helpers"], function (_emberBabel, _runloop, _metal, _runtime, _data_adapter, _internalTestHelpers) { "use strict"; var adapter; var Model = _runtime.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 () { return true; }, catalogEntriesByType: function () { return (0, _runtime.A)(['post']); } }); } }); (0, _internalTestHelpers.moduleFor)('Data Adapter', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { return _ApplicationTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto.teardown = function teardown() { _ApplicationTestCase.prototype.teardown.call(this); adapter = undefined; }; _proto['@test Model types added'] = function testModelTypesAdded(assert) { var _this = this; this.add('data-adapter:main', DataAdapter.extend({ getRecords: function () { return (0, _runtime.A)([1, 2, 3]); }, columnsForType: function () { return [{ name: 'title', desc: 'Title' }]; } })); this.add('model:post', PostClass); return this.visit('/').then(function () { var adapter = _this.applicationInstance.lookup('data-adapter:main'); function modelTypesAdded(types) { assert.equal(types.length, 1); var postType = types[0]; assert.equal(postType.name, 'post', 'Correctly sets the name'); assert.equal(postType.count, 3, 'Correctly sets the record count'); assert.strictEqual(postType.object, PostClass, 'Correctly sets the object'); assert.deepEqual(postType.columns, [{ name: 'title', desc: 'Title' }], 'Correctly sets the columns'); } adapter.watchModelTypes(modelTypesAdded); }); }; _proto['@test getRecords gets a model name as second argument'] = function testGetRecordsGetsAModelNameAsSecondArgument(assert) { var _this2 = this; this.add('data-adapter:main', DataAdapter.extend({ getRecords: function (klass, name) { assert.equal(name, 'post'); return (0, _runtime.A)(); } })); this.add('model:post', PostClass); return this.visit('/').then(function () { adapter = _this2.applicationInstance.lookup('data-adapter:main'); adapter.watchModelTypes(function () {}); }); }; _proto['@test Model types added with custom container-debug-adapter'] = function testModelTypesAddedWithCustomContainerDebugAdapter(assert) { var _this3 = this; var StubContainerDebugAdapter = _runtime.Object.extend({ canCatalogEntriesByType: function () { return true; }, catalogEntriesByType: function () { return (0, _runtime.A)(['post']); } }); this.add('container-debug-adapter:main', StubContainerDebugAdapter); this.add('data-adapter:main', DataAdapter.extend({ getRecords: function () { return (0, _runtime.A)([1, 2, 3]); }, columnsForType: function () { return [{ name: 'title', desc: 'Title' }]; } })); this.add('model:post', PostClass); return this.visit('/').then(function () { var adapter = _this3.applicationInstance.lookup('data-adapter:main'); function modelTypesAdded(types) { assert.equal(types.length, 1); var postType = types[0]; assert.equal(postType.name, 'post', 'Correctly sets the name'); assert.equal(postType.count, 3, 'Correctly sets the record count'); assert.strictEqual(postType.object, PostClass, 'Correctly sets the object'); assert.deepEqual(postType.columns, [{ name: 'title', desc: 'Title' }], 'Correctly sets the columns'); } adapter.watchModelTypes(modelTypesAdded); }); }; _proto['@test Model Types Updated'] = function testModelTypesUpdated(assert) { var _this4 = this; var records = (0, _runtime.A)([1, 2, 3]); this.add('data-adapter:main', DataAdapter.extend({ getRecords: function () { return records; } })); this.add('model:post', PostClass); return this.visit('/').then(function () { adapter = _this4.applicationInstance.lookup('data-adapter:main'); function modelTypesAdded() { (0, _runloop.run)(function () { records.pushObject(4); }); } function modelTypesUpdated(types) { var postType = types[0]; assert.equal(postType.count, 4, 'Correctly updates the count'); } adapter.watchModelTypes(modelTypesAdded, modelTypesUpdated); }); }; _proto['@test Model Types Updated but Unchanged Do not Trigger Callbacks'] = function testModelTypesUpdatedButUnchangedDoNotTriggerCallbacks(assert) { var _this5 = this; assert.expect(0); var records = (0, _runtime.A)([1, 2, 3]); this.add('data-adapter:main', DataAdapter.extend({ getRecords: function () { return records; } })); this.add('model:post', PostClass); return this.visit('/').then(function () { adapter = _this5.applicationInstance.lookup('data-adapter:main'); function modelTypesAdded() { (0, _runloop.run)(function () { records.arrayContentDidChange(0, 0, 0); }); } function modelTypesUpdated() { assert.ok(false, "modelTypesUpdated should not be triggered if the array didn't change"); } adapter.watchModelTypes(modelTypesAdded, modelTypesUpdated); }); }; _proto['@test Records Added'] = function testRecordsAdded(assert) { var _this6 = this; var countAdded = 1; var post = PostClass.create(); var recordList = (0, _runtime.A)([post]); this.add('data-adapter:main', DataAdapter.extend({ getRecords: function () { 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 = _this6.applicationInstance.lookup('data-adapter:main'); function recordsAdded(records) { var record = records[0]; assert.equal(record.color, 'blue', 'Sets the color correctly'); assert.deepEqual(record.columnValues, { title: 'Post ' + countAdded }, 'Sets the column values correctly'); assert.deepEqual(record.searchKeywords, ['Post ' + countAdded], 'Sets search keywords correctly'); assert.strictEqual(record.object, post, 'Sets the object to the record instance'); } adapter.watchRecords('post', recordsAdded); countAdded++; post = PostClass.create(); recordList.pushObject(post); }); }; _proto['@test Observes and releases a record correctly'] = function testObservesAndReleasesARecordCorrectly(assert) { var _this7 = this; var updatesCalled = 0; var post = PostClass.create({ title: 'Post' }); var recordList = (0, _runtime.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, _metal.addObserver)(record, 'title', callback); return function () { (0, _metal.removeObserver)(record, 'title', callback); }; }, getRecordColumnValues: function (record) { return { title: (0, _metal.get)(record, 'title') }; } })); this.add('model:post', PostClass); return this.visit('/').then(function () { adapter = _this7.applicationInstance.lookup('data-adapter:main'); function recordsAdded() { (0, _metal.set)(post, 'title', 'Post Modified'); } function recordsUpdated(records) { updatesCalled++; assert.equal(records[0].columnValues.title, 'Post Modified'); } var release = adapter.watchRecords('post', recordsAdded, recordsUpdated); release(); (0, _metal.set)(post, 'title', 'New Title'); assert.equal(updatesCalled, 1, 'Release function removes observers'); }); }; _proto['@test _nameToClass does not error when not found'] = function test_nameToClassDoesNotErrorWhenNotFound(assert) { var _this8 = this; this.add('data-adapter:main', DataAdapter); return this.visit('/').then(function () { adapter = _this8.applicationInstance.lookup('data-adapter:main'); var klass = adapter._nameToClass('foo'); assert.equal(klass, undefined, 'returns undefined'); }); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/application/actions-test", ["ember-babel", "internal-test-helpers", "@ember/controller", "@ember/debug", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _controller, _debug, _helpers) { "use strict"; var originalDebug = (0, _debug.getDebugFunction)('debug'); var noop = function () {}; (0, _internalTestHelpers.moduleFor)('Application test: actions', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { (0, _debug.setDebugFunction)('debug', noop); return _ApplicationTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto.teardown = function teardown() { (0, _debug.setDebugFunction)('debug', originalDebug); }; _proto['@test actions in top level template application template target application controller'] = function testActionsInTopLevelTemplateApplicationTemplateTargetApplicationController(assert) { var _this = this; assert.expect(1); this.add('controller:application', _controller.default.extend({ actions: { handleIt: function () { assert.ok(true, 'controller received action properly'); } } })); this.addTemplate('application', ''); return this.visit('/').then(function () { (0, _internalTestHelpers.runTask)(function () { return _this.$('#handle-it').click(); }); }); }; _proto['@test actions in nested outlet template target their controller'] = function testActionsInNestedOutletTemplateTargetTheirController(assert) { var _this2 = this; assert.expect(1); this.add('controller:application', _controller.default.extend({ actions: { handleIt: function () { assert.ok(false, 'application controller should not have received action!'); } } })); this.add('controller:index', _controller.default.extend({ actions: { handleIt: function () { assert.ok(true, 'controller received action properly'); } } })); this.addTemplate('index', ''); return this.visit('/').then(function () { (0, _internalTestHelpers.runTask)(function () { return _this2.$('#handle-it').click(); }); }); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)('Rendering test: non-interactive actions', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class2, _RenderingTestCase); function _class2() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto2 = _class2.prototype; _proto2.getBootOptions = function getBootOptions() { return { isInteractive: false }; }; _proto2["@test doesn't attatch actions"] = function (assert) { this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ actions: { fire: function () { assert.ok(false); } } }), template: "" }); this.render('{{foo-bar tagName=""}}'); this.assertHTML(''); this.$('button').click(); }; return _class2; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/application/engine-test", ["ember-babel", "internal-test-helpers", "@ember/controller", "@ember/-internals/runtime", "@ember/-internals/glimmer", "@ember/engine", "@ember/-internals/routing", "@ember/runloop", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _controller, _runtime, _glimmer, _engine, _routing, _runloop, _helpers) { "use strict"; function _templateObject6() { const data = _taggedTemplateLiteralLoose(["\n

Component!

\n "]); _templateObject6 = function () { return data; }; return data; } function _templateObject5() { const data = _taggedTemplateLiteralLoose(["\n

Engine

\n {{my-component}}\n {{outlet}}\n "]); _templateObject5 = function () { return data; }; return data; } function _templateObject4() { const data = _taggedTemplateLiteralLoose(["\n

Application

\n {{my-component ambiguous-curlies=\"Local Data!\"}}\n {{outlet}}\n "]); _templateObject4 = function () { return data; }; return data; } function _templateObject3() { const data = _taggedTemplateLiteralLoose(["\n {{ambiguous-curlies}}\n "]); _templateObject3 = function () { return data; }; return data; } function _templateObject2() { const data = _taggedTemplateLiteralLoose(["\n

Component!

\n "]); _templateObject2 = function () { return data; }; return data; } function _templateObject() { const data = _taggedTemplateLiteralLoose(["\n

{{contextType}}

\n {{ambiguous-curlies}}\n\n {{outlet}}\n "]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } (0, _internalTestHelpers.moduleFor)('Application test: engine rendering', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { return _ApplicationTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto.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', _routing.Route.extend({ model: function () { hooks.push('application - application'); } })); this.add('engine:blog', _engine.default.extend({ init: function () { this._super.apply(this, arguments); this.register('controller:application', _controller.default.extend({ queryParams: ['lang'], lang: '' })); this.register('controller:category', _controller.default.extend({ queryParams: ['type'] })); this.register('controller:authorKtrl', _controller.default.extend({ queryParams: ['official'] })); this.register('template:application', (0, _helpers.compile)('Engine{{lang}}{{outlet}}')); this.register('route:application', _routing.Route.extend({ model: function () { hooks.push('engine - application'); } })); this.register('route:author', _routing.Route.extend({ controllerName: 'authorKtrl' })); if (self._additionalEngineRegistrations) { self._additionalEngineRegistrations.call(this); } } })); }; _proto.setupAppAndRoutelessEngine = function setupAppAndRoutelessEngine(hooks) { this.setupRoutelessEngine(hooks); this.add('engine:chat-engine', _engine.default.extend({ init: function () { this._super.apply(this, arguments); this.register('template:application', (0, _helpers.compile)('Engine')); this.register('controller:application', _controller.default.extend({ init: function () { this._super.apply(this, arguments); hooks.push('engine - application'); } })); } })); }; _proto.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', _routing.Route.extend({ model: function () { hooks.push('application - application'); } })); this.add('engine:blog', _engine.default.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', _routing.Route.extend({ model: function () { hooks.push('engine - application'); } })); } })); }; _proto.setupRoutelessEngine = function setupRoutelessEngine(hooks) { this.addTemplate('application', 'Application{{mount "chat-engine"}}'); this.add('route:application', _routing.Route.extend({ model: function () { hooks.push('application - application'); } })); }; _proto.setupAppAndRoutlessEngineWithPartial = function setupAppAndRoutlessEngineWithPartial(hooks) { this.setupRoutelessEngine(hooks); this.add('engine:chat-engine', _engine.default.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', _controller.default.extend({ init: function () { this._super.apply(this, arguments); hooks.push('engine - application'); } })); } })); }; _proto.additionalEngineRegistrations = function additionalEngineRegistrations(callback) { this._additionalEngineRegistrations = callback; }; _proto.setupEngineWithAttrs = function setupEngineWithAttrs() { this.addTemplate('application', 'Application{{mount "chat-engine"}}'); this.add('engine:chat-engine', _engine.default.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', _controller.default.extend({ contextType: 'Engine' })); this.register('template:application', (0, _helpers.compile)('Engine {{foo-bar wat=contextType}}')); } })); }; _proto.stringsEndWith = function stringsEndWith(str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; }; _proto['@test attrs in an engine'] = function testAttrsInAnEngine() { var _this = this; this.setupEngineWithAttrs([]); return this.visit('/').then(function () { _this.assertText('ApplicationEngine Engine'); }); }; _proto['@test sharing a template between engine and application has separate refinements'] = function testSharingATemplateBetweenEngineAndApplicationHasSeparateRefinements() { var _this2 = this; this.assert.expect(1); var sharedTemplate = (0, _helpers.compile)((0, _internalTestHelpers.strip)(_templateObject())); this.add('template:application', sharedTemplate); this.add('controller:application', _controller.default.extend({ contextType: 'Application', 'ambiguous-curlies': 'Controller Data!' })); this.router.map(function () { this.mount('blog'); }); this.add('route-map:blog', function () {}); this.add('engine:blog', _engine.default.extend({ init: function () { this._super.apply(this, arguments); this.register('controller:application', _controller.default.extend({ contextType: 'Engine' })); this.register('template:application', sharedTemplate); this.register('template:components/ambiguous-curlies', (0, _helpers.compile)((0, _internalTestHelpers.strip)(_templateObject2()))); } })); return this.visit('/blog').then(function () { _this2.assertText('ApplicationController Data!EngineComponent!'); }); }; _proto['@test sharing a layout between engine and application has separate refinements'] = function testSharingALayoutBetweenEngineAndApplicationHasSeparateRefinements() { var _this3 = this; this.assert.expect(1); var sharedLayout = (0, _helpers.compile)((0, _internalTestHelpers.strip)(_templateObject3())); var sharedComponent = _glimmer.Component.extend({ layout: sharedLayout }); this.addTemplate('application', (0, _internalTestHelpers.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', _engine.default.extend({ init: function () { this._super.apply(this, arguments); this.register('template:application', (0, _helpers.compile)((0, _internalTestHelpers.strip)(_templateObject5()))); this.register('component:my-component', sharedComponent); this.register('template:components/ambiguous-curlies', (0, _helpers.compile)((0, _internalTestHelpers.strip)(_templateObject6()))); } })); return this.visit('/blog').then(function () { _this3.assertText('ApplicationLocal Data!EngineComponent!'); }); }; _proto['@test visit() with `shouldRender: true` returns a promise that resolves when application and engine templates have rendered'] = function testVisitWithShouldRenderTrueReturnsAPromiseThatResolvesWhenApplicationAndEngineTemplatesHaveRendered(assert) { var _this4 = this; assert.expect(2); var hooks = []; this.setupAppAndRoutableEngine(hooks); return this.visit('/blog', { shouldRender: true }).then(function () { _this4.assertText('ApplicationEngine'); _this4.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected model hooks were fired'); }); }; _proto['@test visit() with `shouldRender: false` returns a promise that resolves without rendering'] = function testVisitWithShouldRenderFalseReturnsAPromiseThatResolvesWithoutRendering(assert) { var _this5 = this; assert.expect(2); var hooks = []; this.setupAppAndRoutableEngine(hooks); return this.visit('/blog', { shouldRender: false }).then(function () { assert.strictEqual(document.getElementById('qunit-fixture').children.length, 0, "there are no elements in the qunit-fixture element"); _this5.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected model hooks were fired'); }); }; _proto['@test visit() with `shouldRender: true` returns a promise that resolves when application and routeless engine templates have rendered'] = function testVisitWithShouldRenderTrueReturnsAPromiseThatResolvesWhenApplicationAndRoutelessEngineTemplatesHaveRendered(assert) { var _this6 = this; assert.expect(2); var hooks = []; this.setupAppAndRoutelessEngine(hooks); return this.visit('/', { shouldRender: true }).then(function () { _this6.assertText('ApplicationEngine'); _this6.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired'); }); }; _proto['@test visit() with partials in routable engine'] = function testVisitWithPartialsInRoutableEngine(assert) { var _this7 = this; assert.expect(2); var hooks = []; this.setupAppAndRoutableEngineWithPartial(hooks); return this.visit('/blog', { shouldRender: true }).then(function () { _this7.assertText('ApplicationEngine foo partial'); _this7.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired'); }); }; _proto['@test visit() with partials in non-routable engine'] = function testVisitWithPartialsInNonRoutableEngine(assert) { var _this8 = this; assert.expect(2); var hooks = []; this.setupAppAndRoutlessEngineWithPartial(hooks); return this.visit('/', { shouldRender: true }).then(function () { _this8.assertText('ApplicationEngine foo partial'); _this8.assert.deepEqual(hooks, ['application - application', 'engine - application'], 'the expected hooks were fired'); }); }; _proto['@test deactivate should be called on Engine Routes before destruction'] = function testDeactivateShouldBeCalledOnEngineRoutesBeforeDestruction(assert) { var _this9 = this; assert.expect(3); this.setupAppAndRoutableEngine(); this.add('engine:blog', _engine.default.extend({ init: function () { this._super.apply(this, arguments); this.register('template:application', (0, _helpers.compile)('Engine{{outlet}}')); this.register('route:application', _routing.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 () { _this9.assertText('ApplicationEngine'); }); }; _proto['@test engine should lookup and use correct controller'] = function testEngineShouldLookupAndUseCorrectController() { var _this10 = this; this.setupAppAndRoutableEngine(); return this.visit('/blog?lang=English').then(function () { _this10.assertText('ApplicationEngineEnglish'); }); }; _proto['@test error substate route works for the application route of an Engine'] = function testErrorSubstateRouteWorksForTheApplicationRouteOfAnEngine(assert) { var _this11 = this; assert.expect(2); var errorEntered = _runtime.RSVP.defer(); this.setupAppAndRoutableEngine(); this.additionalEngineRegistrations(function () { this.register('route:application_error', _routing.Route.extend({ activate: function () { (0, _runloop.next)(errorEntered.resolve); } })); this.register('template:application_error', (0, _helpers.compile)('Error! {{model.message}}')); this.register('route:post', _routing.Route.extend({ model: function () { return _runtime.RSVP.reject(new Error('Oh, noes!')); } })); }); return this.visit('/').then(function () { _this11.assertText('Application'); return _this11.transitionTo('blog.post'); }).then(function () { return errorEntered.promise; }).then(function () { _this11.assertText('ApplicationError! Oh, noes!'); }); }; _proto['@test error route works for the application route of an Engine'] = function testErrorRouteWorksForTheApplicationRouteOfAnEngine(assert) { var _this12 = this; assert.expect(2); var errorEntered = _runtime.RSVP.defer(); this.setupAppAndRoutableEngine(); this.additionalEngineRegistrations(function () { this.register('route:error', _routing.Route.extend({ activate: function () { (0, _runloop.next)(errorEntered.resolve); } })); this.register('template:error', (0, _helpers.compile)('Error! {{model.message}}')); this.register('route:post', _routing.Route.extend({ model: function () { return _runtime.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('ApplicationEngineError! Oh, noes!'); }); }; _proto['@test error substate route works for a child route of an Engine'] = function testErrorSubstateRouteWorksForAChildRouteOfAnEngine(assert) { var _this13 = this; assert.expect(2); var errorEntered = _runtime.RSVP.defer(); this.setupAppAndRoutableEngine(); this.additionalEngineRegistrations(function () { this.register('route:post_error', _routing.Route.extend({ activate: function () { (0, _runloop.next)(errorEntered.resolve); } })); this.register('template:post_error', (0, _helpers.compile)('Error! {{model.message}}')); this.register('route:post', _routing.Route.extend({ model: function () { return _runtime.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!'); }); }; _proto['@test error route works for a child route of an Engine'] = function testErrorRouteWorksForAChildRouteOfAnEngine(assert) { var _this14 = this; assert.expect(2); var errorEntered = _runtime.RSVP.defer(); this.setupAppAndRoutableEngine(); this.additionalEngineRegistrations(function () { this.register('route:post.error', _routing.Route.extend({ activate: function () { (0, _runloop.next)(errorEntered.resolve); } })); this.register('template:post.error', (0, _helpers.compile)('Error! {{model.message}}')); this.register('route:post.comments', _routing.Route.extend({ model: function () { return _runtime.RSVP.reject(new Error('Oh, noes!')); } })); }); return this.visit('/').then(function () { _this14.assertText('Application'); return _this14.transitionTo('blog.post.comments'); }).then(function () { return errorEntered.promise; }).then(function () { _this14.assertText('ApplicationEngineError! Oh, noes!'); }); }; _proto['@test loading substate route works for the application route of an Engine'] = function testLoadingSubstateRouteWorksForTheApplicationRouteOfAnEngine(assert) { var _this15 = this; assert.expect(3); var done = assert.async(); var loadingEntered = _runtime.RSVP.defer(); var resolveLoading = _runtime.RSVP.defer(); this.setupAppAndRoutableEngine(); this.additionalEngineRegistrations(function () { this.register('route:application_loading', _routing.Route.extend({ activate: function () { (0, _runloop.next)(loadingEntered.resolve); } })); this.register('template:application_loading', (0, _helpers.compile)('Loading')); this.register('template:post', (0, _helpers.compile)('Post')); this.register('route:post', _routing.Route.extend({ model: function () { return resolveLoading.promise; } })); }); return this.visit('/').then(function () { _this15.assertText('Application'); var transition = _this15.transitionTo('blog.post'); loadingEntered.promise.then(function () { _this15.assertText('ApplicationLoading'); resolveLoading.resolve(); return (0, _internalTestHelpers.runTaskNext)().then(function () { _this15.assertText('ApplicationEnginePost'); done(); }); }); return transition; }); }; _proto['@test loading route works for the application route of an Engine'] = function testLoadingRouteWorksForTheApplicationRouteOfAnEngine(assert) { var _this16 = this; assert.expect(3); var done = assert.async(); var loadingEntered = _runtime.RSVP.defer(); var resolveLoading = _runtime.RSVP.defer(); this.setupAppAndRoutableEngine(); this.additionalEngineRegistrations(function () { this.register('route:loading', _routing.Route.extend({ activate: function () { (0, _runloop.next)(loadingEntered.resolve); } })); this.register('template:loading', (0, _helpers.compile)('Loading')); this.register('template:post', (0, _helpers.compile)('Post')); this.register('route:post', _routing.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('ApplicationEngineLoading'); resolveLoading.resolve(); return (0, _internalTestHelpers.runTaskNext)().then(function () { _this16.assertText('ApplicationEnginePost'); done(); }); }); return transition; }); }; _proto['@test loading substate route works for a child route of an Engine'] = function testLoadingSubstateRouteWorksForAChildRouteOfAnEngine(assert) { var _this17 = this; assert.expect(3); var resolveLoading; 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', _routing.Route.extend({ model: function () { return new _runtime.RSVP.Promise(function (resolve) { resolveLoading = resolve; }); } })); }); return this.visit('/blog/post/comments').then(function () { _this17.assertText('ApplicationEngineComments'); var transition = _this17.transitionTo('blog.post.likes'); (0, _internalTestHelpers.runTaskNext)().then(function () { _this17.assertText('ApplicationEngineLoading'); resolveLoading(); }); return transition.then(function () { return (0, _internalTestHelpers.runTaskNext)(); }).then(function () { return _this17.assertText('ApplicationEngineLikes'); }); }); }; _proto['@test loading route works for a child route of an Engine'] = function testLoadingRouteWorksForAChildRouteOfAnEngine(assert) { var _this18 = this; assert.expect(3); var done = assert.async(); var loadingEntered = _runtime.RSVP.defer(); var resolveLoading = _runtime.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', _routing.Route.extend({ activate: function () { (0, _runloop.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', _routing.Route.extend({ model: function () { return resolveLoading.promise; } })); }); return this.visit('/blog/post/comments').then(function () { _this18.assertText('ApplicationEngineComments'); var transition = _this18.transitionTo('blog.post.likes'); loadingEntered.promise.then(function () { _this18.assertText('ApplicationEngineLoading'); resolveLoading.resolve(); return (0, _internalTestHelpers.runTaskNext)().then(function () { _this18.assertText('ApplicationEngineLikes'); done(); }); }); return transition; }); }; _proto["@test query params don't have stickiness by default between model"] = function testQueryParamsDonTHaveStickinessByDefaultBetweenModel(assert) { var _this19 = 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 = _this19.element.querySelector('a').href; // check if link ends with the suffix assert.ok(_this19.stringsEndWith(href, suffix)); }); }; _proto['@test query params in customized controllerName have stickiness by default between model'] = function testQueryParamsInCustomizedControllerNameHaveStickinessByDefaultBetweenModel(assert) { var _this20 = 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 = _this20.element.querySelector('.author-1').href; var suffix1337 = '/blog/author/1337'; var href1337 = _this20.element.querySelector('.author-1337').href; // check if link ends with the suffix assert.ok(_this20.stringsEndWith(href1, suffix1), href1 + " ends with " + suffix1); assert.ok(_this20.stringsEndWith(href1337, suffix1337), href1337 + " ends with " + suffix1337); }); }; _proto['@test visit() routable engine which errors on init'] = function testVisitRoutableEngineWhichErrorsOnInit(assert) { var _this21 = this; assert.expect(1); var hooks = []; this.additionalEngineRegistrations(function () { this.register('route:application', _routing.Route.extend({ init: function () { throw new Error('Whoops! Something went wrong...'); } })); }); this.setupAppAndRoutableEngine(hooks); return this.visit('/', { shouldRender: true }).then(function () { return _this21.visit('/blog'); }).catch(function (error) { assert.equal(error.message, 'Whoops! Something went wrong...'); }); }; (0, _emberBabel.createClass)(_class, [{ key: "routerOptions", get: function () { return { location: 'none', setupRouter: function () { var _this22 = this; this._super.apply(this, arguments); var getRoute = this._routerMicrolib.getRoute; this._enginePromises = Object.create(null); this._resolvedEngines = Object.create(null); this._routerMicrolib.getRoute = function (name) { var engineInfo = _this22._engineInfoByRoute[name]; if (!engineInfo) { return getRoute(name); } var engineName = engineInfo.name; if (_this22._resolvedEngines[engineName]) { return getRoute(name); } var enginePromise = _this22._enginePromises[engineName]; if (!enginePromise) { enginePromise = new _runtime.RSVP.Promise(function (resolve) { setTimeout(function () { _this22._resolvedEngines[engineName] = true; resolve(); }, 1); }); _this22._enginePromises[engineName] = enginePromise; } return enginePromise.then(function () { return getRoute(name); }); }; } }; } }]); return _class; }(_internalTestHelpers.ApplicationTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/application/helper-registration-test", ["ember-babel", "internal-test-helpers", "@ember/controller", "@ember/service", "@ember/-internals/glimmer"], function (_emberBabel, _internalTestHelpers, _controller, _service, _glimmer) { "use strict"; (0, _internalTestHelpers.moduleFor)('Application Lifecycle - Helper Registration', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { return _ApplicationTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test Unbound dashed helpers registered on the container can be late-invoked'] = function testUnboundDashedHelpersRegisteredOnTheContainerCanBeLateInvoked(assert) { var _this = this; this.addTemplate('application', "
{{x-borf}} {{x-borf 'YES'}}
"); var myHelper = (0, _glimmer.helper)(function (params) { return params[0] || 'BORF'; }); this.application.register('helper:x-borf', myHelper); return this.visit('/').then(function () { assert.equal(_this.$('#wrapper').text(), 'BORF YES', 'The helper was invoked from the container'); }); }; _proto['@test Bound helpers registered on the container can be late-invoked'] = function testBoundHelpersRegisteredOnTheContainerCanBeLateInvoked(assert) { var _this2 = this; this.addTemplate('application', "
{{x-reverse}} {{x-reverse foo}}
"); this.add('controller:application', _controller.default.extend({ foo: 'alex' })); this.application.register('helper:x-reverse', (0, _glimmer.helper)(function (_ref) { var value = _ref[0]; return value ? value.split('').reverse().join('') : '--'; })); return this.visit('/').then(function () { assert.equal(_this2.$('#wrapper').text(), '-- xela', 'The bound helper was invoked from the container'); }); }; _proto['@test Undashed helpers registered on the container can be invoked'] = function testUndashedHelpersRegisteredOnTheContainerCanBeInvoked(assert) { var _this3 = this; this.addTemplate('application', "
{{omg}}|{{yorp 'boo'}}|{{yorp 'ya'}}
"); this.application.register('helper:omg', (0, _glimmer.helper)(function () { return 'OMG'; })); this.application.register('helper:yorp', (0, _glimmer.helper)(function (_ref2) { var value = _ref2[0]; return value; })); return this.visit('/').then(function () { assert.equal(_this3.$('#wrapper').text(), 'OMG|boo|ya', 'The helper was invoked from the container'); }); }; _proto['@test Helpers can receive injections'] = function testHelpersCanReceiveInjections(assert) { this.addTemplate('application', "
{{full-name}}
"); var serviceCalled = false; this.add('service:name-builder', _service.default.extend({ build: function () { serviceCalled = true; } })); this.add('helper:full-name', _glimmer.Helper.extend({ nameBuilder: (0, _service.inject)('name-builder'), compute: function () { this.get('nameBuilder').build(); } })); return this.visit('/').then(function () { assert.ok(serviceCalled, 'service was injected, method called'); }); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/application/hot-reload-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/environment", "@ember/service", "@ember/-internals/glimmer", "@glimmer/util"], function (_emberBabel, _internalTestHelpers, _environment, _service, _glimmer, _util) { "use strict"; function _templateObject12() { const data = _taggedTemplateLiteralLoose(["\n [x-foo: first (8)]\n [x-foo: second (9)]\n [x-bar (10)]\n "]); _templateObject12 = function () { return data; }; return data; } function _templateObject11() { const data = _taggedTemplateLiteralLoose(["\n [x-foo first (6)]\n [x-foo second (7)]\n [

wow (5)

]\n "]); _templateObject11 = function () { return data; }; return data; } function _templateObject10() { const data = _taggedTemplateLiteralLoose(["\n [

first (3)

]\n [

second (4)

]\n [

wow (5)

]\n "]); _templateObject10 = function () { return data; }; return data; } function _templateObject9() { const data = _taggedTemplateLiteralLoose(["\n [

first (3)

]\n [

second (4)

]\n [x-bar (2)]\n "]); _templateObject9 = function () { return data; }; return data; } function _templateObject8() { const data = _taggedTemplateLiteralLoose(["\n [x-foo: first (0)]\n [x-foo: second (1)]\n [x-bar (2)]\n "]); _templateObject8 = function () { return data; }; return data; } function _templateObject7() { const data = _taggedTemplateLiteralLoose(["\n [{{component (hot-reload \"x-foo\") name=\"first\"}}]\n [{{component (hot-reload \"x-foo\") name=\"second\"}}]\n [{{component (hot-reload \"x-bar\")}}]\n "]); _templateObject7 = function () { return data; }; return data; } function _templateObject6() { const data = _taggedTemplateLiteralLoose(["\n [x-foo: first]\n [x-foo: second]\n [x-bar]\n "]); _templateObject6 = function () { return data; }; return data; } function _templateObject5() { const data = _taggedTemplateLiteralLoose(["\n [x-foo first]\n [x-foo second]\n [

wow

]\n "]); _templateObject5 = function () { return data; }; return data; } function _templateObject4() { const data = _taggedTemplateLiteralLoose(["\n [

first

]\n [

second

]\n [

wow

]\n "]); _templateObject4 = function () { return data; }; return data; } function _templateObject3() { const data = _taggedTemplateLiteralLoose(["\n [

first

]\n [

second

]\n [x-bar]\n "]); _templateObject3 = function () { return data; }; return data; } function _templateObject2() { const data = _taggedTemplateLiteralLoose(["\n [x-foo: first]\n [x-foo: second]\n [x-bar]\n "]); _templateObject2 = function () { return data; }; return data; } function _templateObject() { const data = _taggedTemplateLiteralLoose(["\n [{{component (hot-reload \"x-foo\") name=\"first\"}}]\n [{{component (hot-reload \"x-foo\") name=\"second\"}}]\n [{{component (hot-reload \"x-bar\")}}]\n "]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } // This simuates what the template hot-reloading would do in development mode // to avoid regressions (0, _internalTestHelpers.moduleFor)('Appliation test: template hot reloading', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { var _this; _this = _ApplicationTestCase.apply(this, arguments) || this; _this._APPLICATION_TEMPLATE_WRAPPER = _environment.ENV._APPLICATION_TEMPLATE_WRAPPER; _this._TEMPLATE_ONLY_GLIMMER_COMPONENTS = _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS; _environment.ENV._APPLICATION_TEMPLATE_WRAPPER = false; _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = true; var didCreateReloader = function (reloader) { _this.reloader = reloader; }; _this.add('service:reloader', _service.default.extend({ init: function () { this._super.apply(this, arguments); this.revisions = {}; this.callbacks = []; didCreateReloader(this); }, onReload: function (callback) { this.callbacks.push(callback); }, revisionFor: function (name) { return this.revisions[name]; }, invalidate: function (name) { var revision = this.revisions[name]; if (revision === undefined) { revision = 0; } this.revisions[name] = ++revision; this.callbacks.forEach(function (callback) { return callback(); }); } })); _this.add('helper:hot-reload', _glimmer.Helper.extend({ reloader: (0, _service.inject)(), init: function () { var _this2 = this; this._super.apply(this, arguments); this.reloader.onReload(function () { return _this2.recompute(); }); }, compute: function (_ref) { var name = _ref[0]; var revision = this.reloader.revisionFor(name); if (revision === undefined) { return name; } else { return name + "--hot-reload-" + revision; } } })); return _this; } var _proto = _class.prototype; _proto.teardown = function teardown() { _ApplicationTestCase.prototype.teardown.call(this); _environment.ENV._APPLICATION_TEMPLATE_WRAPPER = this._APPLICATION_TEMPLATE_WRAPPER; _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = this._TEMPLATE_ONLY_GLIMMER_COMPONENTS; }; _proto.hotReload = function hotReload(name, template) { var reloader = (0, _util.expect)(this.reloader); var revision = (reloader.revisionFor(name) || 0) + 1; var ComponentClass = this.applicationInstance.resolveRegistration("component:" + name) || null; this.addComponent(name + "--hot-reload-" + revision, { ComponentClass: ComponentClass, template: template }); reloader.invalidate(name); }; _proto['@test hot reloading template-only components'] = function testHotReloadingTemplateOnlyComponents() { var _this3 = this; this.addTemplate('application', (0, _internalTestHelpers.strip)(_templateObject())); this.addComponent('x-foo', { ComponentClass: null, template: 'x-foo: {{@name}}' }); this.addComponent('x-bar', { ComponentClass: null, template: 'x-bar' }); return this.visit('/').then(function () { _this3.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject2())); (0, _internalTestHelpers.runTask)(function () { _this3.hotReload('x-foo', '

{{@name}}

'); }); _this3.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject3())); (0, _internalTestHelpers.runTask)(function () { _this3.hotReload('x-bar', '

wow

'); }); _this3.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject4())); (0, _internalTestHelpers.runTask)(function () { _this3.hotReload('x-foo', 'x-foo {{@name}}'); }); _this3.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject5())); (0, _internalTestHelpers.runTask)(function () { _this3.hotReload('x-foo', 'x-foo: {{@name}}'); _this3.hotReload('x-bar', 'x-bar'); }); _this3.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject6())); }); }; _proto['@test hot reloading class-based components'] = function testHotReloadingClassBasedComponents() { var _this4 = this; this.addTemplate('application', (0, _internalTestHelpers.strip)(_templateObject7())); var id = 0; this.addComponent('x-foo', { ComponentClass: _glimmer.Component.extend({ tagName: '', init: function () { this._super.apply(this, arguments); this.set('id', id++); } }), template: 'x-foo: {{@name}} ({{this.id}})' }); this.addComponent('x-bar', { ComponentClass: _glimmer.Component.extend({ tagName: '', init: function () { this._super.apply(this, arguments); this.set('id', id++); } }), template: 'x-bar ({{this.id}})' }); return this.visit('/').then(function () { _this4.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject8())); (0, _internalTestHelpers.runTask)(function () { _this4.hotReload('x-foo', '

{{@name}} ({{this.id}})

'); }); _this4.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject9())); (0, _internalTestHelpers.runTask)(function () { _this4.hotReload('x-bar', '

wow ({{this.id}})

'); }); _this4.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject10())); (0, _internalTestHelpers.runTask)(function () { _this4.hotReload('x-foo', 'x-foo {{@name}} ({{this.id}})'); }); _this4.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject11())); (0, _internalTestHelpers.runTask)(function () { _this4.hotReload('x-foo', 'x-foo: {{@name}} ({{this.id}})'); _this4.hotReload('x-bar', 'x-bar ({{this.id}})'); }); _this4.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject12())); }); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/application/rendering-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/environment", "@ember/controller", "@ember/-internals/routing", "@ember/-internals/glimmer"], function (_emberBabel, _internalTestHelpers, _environment, _controller, _routing, _glimmer) { "use strict"; function _templateObject12() { const data = _taggedTemplateLiteralLoose(["\n \n
\n \n
\n "]); _templateObject12 = function () { return data; }; return data; } function _templateObject11() { const data = _taggedTemplateLiteralLoose(["\n \n "]); _templateObject11 = function () { return data; }; return data; } function _templateObject10() { const data = _taggedTemplateLiteralLoose(["\n Ember\n "]); _templateObject10 = function () { return data; }; return data; } function _templateObject9() { const data = _taggedTemplateLiteralLoose(["\n \n
{{outlet}}
\n "]); _templateObject9 = function () { return data; }; return data; } function _templateObject8() { const data = _taggedTemplateLiteralLoose(["\n \n
\n \n
\n "]); _templateObject8 = function () { return data; }; return data; } function _templateObject7() { const data = _taggedTemplateLiteralLoose(["\n \n "]); _templateObject7 = function () { return data; }; return data; } function _templateObject6() { const data = _taggedTemplateLiteralLoose(["\n Ember\n "]); _templateObject6 = function () { return data; }; return data; } function _templateObject5() { const data = _taggedTemplateLiteralLoose(["\n \n
{{outlet}}
\n "]); _templateObject5 = function () { return data; }; return data; } function _templateObject4() { const data = _taggedTemplateLiteralLoose(["\n \n "]); _templateObject4 = function () { return data; }; return data; } function _templateObject3() { const data = _taggedTemplateLiteralLoose(["\n \n "]); _templateObject3 = function () { return data; }; return data; } function _templateObject2() { const data = _taggedTemplateLiteralLoose(["\n \n "]); _templateObject2 = function () { return data; }; return data; } function _templateObject() { const data = _taggedTemplateLiteralLoose(["\n \n "]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } (0, _internalTestHelpers.moduleFor)('Application test: rendering', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { var _this; _this = _ApplicationTestCase.apply(this, arguments) || this; _this._APPLICATION_TEMPLATE_WRAPPER = _environment.ENV._APPLICATION_TEMPLATE_WRAPPER; return _this; } var _proto = _class.prototype; _proto.teardown = function teardown() { _ApplicationTestCase.prototype.teardown.call(this); _environment.ENV._APPLICATION_TEMPLATE_WRAPPER = this._APPLICATION_TEMPLATE_WRAPPER; }; _proto['@test it can render the application template with a wrapper'] = function testItCanRenderTheApplicationTemplateWithAWrapper() { var _this2 = this; _environment.ENV._APPLICATION_TEMPLATE_WRAPPER = true; this.addTemplate('application', 'Hello world!'); return this.visit('/').then(function () { _this2.assertComponentElement(_this2.element, { content: 'Hello world!' }); }); }; _proto['@test it can render the application template without a wrapper'] = function testItCanRenderTheApplicationTemplateWithoutAWrapper() { var _this3 = this; _environment.ENV._APPLICATION_TEMPLATE_WRAPPER = false; this.addTemplate('application', 'Hello world!'); return this.visit('/').then(function () { _this3.assertInnerHTML('Hello world!'); }); }; _proto['@test it can access the model provided by the route'] = function testItCanAccessTheModelProvidedByTheRoute() { var _this4 = this; this.add('route:application', _routing.Route.extend({ model: function () { return ['red', 'yellow', 'blue']; } })); this.addTemplate('application', (0, _internalTestHelpers.strip)(_templateObject())); return this.visit('/').then(function () { _this4.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject2())); }); }; _proto['@test it can render a nested route'] = function testItCanRenderANestedRoute() { var _this5 = 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', _routing.Route.extend({ model: function () { return ['red', 'yellow', 'blue']; } })); this.addTemplate('lists.colors.favorite', (0, _internalTestHelpers.strip)(_templateObject3())); return this.visit('/lists/colors/favorite').then(function () { _this5.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject4())); }); }; _proto['@test it can render into named outlets'] = function testItCanRenderIntoNamedOutlets() { var _this6 = this; this.router.map(function () { this.route('colors'); }); this.addTemplate('application', (0, _internalTestHelpers.strip)(_templateObject5())); this.addTemplate('nav', (0, _internalTestHelpers.strip)(_templateObject6())); this.add('route:application', _routing.Route.extend({ renderTemplate: function () { this.render(); this.render('nav', { into: 'application', outlet: 'nav' }); } })); this.add('route:colors', _routing.Route.extend({ model: function () { return ['red', 'yellow', 'blue']; } })); this.addTemplate('colors', (0, _internalTestHelpers.strip)(_templateObject7())); return this.visit('/colors').then(function () { _this6.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject8())); }); }; _proto['@test it can render into named outlets'] = function testItCanRenderIntoNamedOutlets() { var _this7 = this; this.router.map(function () { this.route('colors'); }); this.addTemplate('application', (0, _internalTestHelpers.strip)(_templateObject9())); this.addTemplate('nav', (0, _internalTestHelpers.strip)(_templateObject10())); this.add('route:application', _routing.Route.extend({ renderTemplate: function () { this.render(); this.render('nav', { into: 'application', outlet: 'nav' }); } })); this.add('route:colors', _routing.Route.extend({ model: function () { return ['red', 'yellow', 'blue']; } })); this.addTemplate('colors', (0, _internalTestHelpers.strip)(_templateObject11())); return this.visit('/colors').then(function () { _this7.assertInnerHTML((0, _internalTestHelpers.strip)(_templateObject12())); }); }; _proto['@test it should update the outlets when switching between routes'] = function testItShouldUpdateTheOutletsWhenSwitchingBetweenRoutes() { var _this8 = 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' }); _this8.assertText('BC'); return _this8.visit('/a'); }).then(function () { // this.assertComponentElement(this.firstChild, { content: 'A' }); _this8.assertText('A'); return _this8.visit('/b/d'); }).then(function () { _this8.assertText('BD'); // this.assertComponentElement(this.firstChild, { content: 'BD' }); }); }; _proto['@test it should produce a stable DOM when the model changes'] = function testItShouldProduceAStableDOMWhenTheModelChanges() { var _this9 = this; this.router.map(function () { this.route('color', { path: '/colors/:color' }); }); this.add('route:color', _routing.Route.extend({ model: function (params) { return params.color; } })); this.addTemplate('color', 'color: {{model}}'); return this.visit('/colors/red').then(function () { _this9.assertInnerHTML('color: red'); _this9.takeSnapshot(); return _this9.visit('/colors/green'); }).then(function () { _this9.assertInnerHTML('color: green'); _this9.assertInvariants(); }); }; _proto['@test it should have the right controller in scope for the route template'] = function testItShouldHaveTheRightControllerInScopeForTheRouteTemplate() { var _this10 = this; this.router.map(function () { this.route('a'); this.route('b'); }); this.add('controller:a', _controller.default.extend({ value: 'a' })); this.add('controller:b', _controller.default.extend({ value: 'b' })); this.addTemplate('a', '{{value}}'); this.addTemplate('b', '{{value}}'); return this.visit('/a').then(function () { _this10.assertText('a'); return _this10.visit('/b'); }).then(function () { return _this10.assertText('b'); }); }; _proto['@test it should update correctly when the controller changes'] = function testItShouldUpdateCorrectlyWhenTheControllerChanges() { var _this11 = this; this.router.map(function () { this.route('color', { path: '/colors/:color' }); }); this.add('route:color', _routing.Route.extend({ model: function (params) { return { color: params.color }; }, renderTemplate: function (controller, model) { this.render({ controller: model.color, model: model }); } })); this.add('controller:red', _controller.default.extend({ color: 'red' })); this.add('controller:green', _controller.default.extend({ color: 'green' })); this.addTemplate('color', 'model color: {{model.color}}, controller color: {{color}}'); return this.visit('/colors/red').then(function () { _this11.assertInnerHTML('model color: red, controller color: red'); return _this11.visit('/colors/green'); }).then(function () { _this11.assertInnerHTML('model color: green, controller color: green'); }); }; _proto['@test it should produce a stable DOM when two routes render the same template'] = function testItShouldProduceAStableDOMWhenTwoRoutesRenderTheSameTemplate() { var _this12 = this; this.router.map(function () { this.route('a'); this.route('b'); }); this.add('route:a', _routing.Route.extend({ model: function () { return 'A'; }, renderTemplate: function (controller, model) { this.render('common', { controller: 'common', model: model }); } })); this.add('route:b', _routing.Route.extend({ model: function () { return 'B'; }, renderTemplate: function (controller, model) { this.render('common', { controller: 'common', model: model }); } })); this.add('controller:common', _controller.default.extend({ prefix: 'common' })); this.addTemplate('common', '{{prefix}} {{model}}'); return this.visit('/a').then(function () { _this12.assertInnerHTML('common A'); _this12.takeSnapshot(); return _this12.visit('/b'); }).then(function () { _this12.assertInnerHTML('common B'); _this12.assertInvariants(); }); } // Regression test, glimmer child outlets tried to assume the first element. // but the if put-args clobbered the args used by did-create-element. // I wish there was a way to assert that the OutletComponentManager did not // receive a didCreateElement. ; _proto['@test a child outlet is always a fragment'] = function testAChildOutletIsAlwaysAFragment() { var _this13 = this; this.addTemplate('application', '{{outlet}}'); this.addTemplate('index', '{{#if true}}1{{/if}}
2
'); return this.visit('/').then(function () { _this13.assertInnerHTML('1
2
'); }); }; _proto['@test it allows a transition during route activate'] = function testItAllowsATransitionDuringRouteActivate() { var _this14 = this; this.router.map(function () { this.route('a'); }); this.add('route:index', _routing.Route.extend({ activate: function () { this.transitionTo('a'); } })); this.addTemplate('a', 'Hello from A!'); return this.visit('/').then(function () { _this14.assertInnerHTML('Hello from A!'); }); }; _proto['@test it emits a useful backtracking re-render assertion message'] = function testItEmitsAUsefulBacktrackingReRenderAssertionMessage() { var _this15 = this; this.router.map(function () { this.route('routeWithError'); }); this.add('route:routeWithError', _routing.Route.extend({ model: function () { return { name: 'Alex' }; } })); this.addTemplate('routeWithError', 'Hi {{model.name}} {{x-foo person=model}}'); this.addComponent('x-foo', { ComponentClass: _glimmer.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:my-app\/templates\/routeWithError.hbs" and modified in "component:x-foo"/; return this.visit('/').then(function () { expectAssertion(function () { _this15.visit('/routeWithError'); }, expectedBacktrackingMessage); }); }; _proto['@test route templates with {{{undefined}}} [GH#14924] [GH#16172]'] = function testRouteTemplatesWithUndefinedGH14924GH16172() { var _this16 = this; this.router.map(function () { this.route('first'); this.route('second'); }); this.addTemplate('first', 'first'); this.addTemplate('second', '{{{undefined}}}second'); return this.visit('/first').then(function () { _this16.assertText('first'); return _this16.visit('/second'); }).then(function () { _this16.assertText('second'); return _this16.visit('/first'); }).then(function () { _this16.assertText('first'); }); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/angle-bracket-invocation-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/environment", "@ember/-internals/metal", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _environment, _metal, _helpers) { "use strict"; function _templateObject9() { const data = _taggedTemplateLiteralLoose(["\n {{#let (component \"foo-bar/inner\") as |Inner|}}\n {{yield}}\n

Inside the let

\n {{/let}}\n

Outside the let

\n "]); _templateObject9 = function () { return data; }; return data; } function _templateObject8() { const data = _taggedTemplateLiteralLoose(["\n {{#let (component 'x-outer') as |Thing|}}\n Hello!\n {{/let}}\n "]); _templateObject8 = function () { return data; }; return data; } function _templateObject7() { const data = _taggedTemplateLiteralLoose(["\n \n "]); _templateObject7 = function () { return data; }; return data; } function _templateObject6() { const data = _taggedTemplateLiteralLoose(["\n {{#if (has-block)}}\n Yes\n {{else}}\n No\n {{/if}}"]); _templateObject6 = function () { return data; }; return data; } function _templateObject5() { const data = _taggedTemplateLiteralLoose(["{{test-harness foo=(hash bar=(component 'foo-bar'))}}"]); _templateObject5 = function () { return data; }; return data; } function _templateObject4() { const data = _taggedTemplateLiteralLoose(["{{test-harness foo=(component 'foo-bar')}}"]); _templateObject4 = function () { return data; }; return data; } function _templateObject3() { const data = _taggedTemplateLiteralLoose(["{{test-harness foo=(component 'foo-bar')}}"]); _templateObject3 = function () { return data; }; return data; } function _templateObject2() { const data = _taggedTemplateLiteralLoose(["\n {{#with (component 'foo-bar') as |Other|}}\n \n {{/with}}\n "]); _templateObject2 = function () { return data; }; return data; } function _templateObject() { const data = _taggedTemplateLiteralLoose(["\n \n \n \n "]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } (0, _internalTestHelpers.moduleFor)('AngleBracket Invocation', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test it can resolve to x-blah'] = function testItCanResolveXBlahToXBlah() { var _this = this; this.registerComponent('x-blah', { template: 'hello' }); this.render(''); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; _proto['@test it can resolve to x-blah'] = function testItCanResolveXBlahToXBlah() { var _this2 = this; this.registerComponent('x-blah', { template: 'hello' }); this.render(''); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; _proto['@test it can render a basic template only component'] = function testItCanRenderABasicTemplateOnlyComponent() { var _this3 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.render(''); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; _proto['@test it can render a basic component with template and javascript'] = function testItCanRenderABasicComponentWithTemplateAndJavascript() { this.registerComponent('foo-bar', { template: 'FIZZ BAR {{local}}', ComponentClass: _helpers.Component.extend({ local: 'hey' }) }); this.render(''); this.assertComponentElement(this.firstChild, { content: 'FIZZ BAR hey' }); }; _proto['@test it can render a single word component name'] = function testItCanRenderASingleWordComponentName() { var _this4 = this; this.registerComponent('foo', { template: 'hello' }); this.render(''); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this4.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; _proto['@test it can not render a component name without initial capital letter'] = function testItCanNotRenderAComponentNameWithoutInitialCapitalLetter(assert) { this.registerComponent('div', { ComponentClass: _helpers.Component.extend({ init: function () { assert.ok(false, 'should not have created component'); } }) }); this.render('
'); this.assertElement(this.firstChild, { tagName: 'div', content: '' }); }; _proto['@test it can have a custom id and it is not bound'] = function testItCanHaveACustomIdAndItIsNotBound() { var _this5 = this; this.registerComponent('foo-bar', { template: '{{id}} {{elementId}}' }); this.render('', { customId: 'bizz' }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' }); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this5.context, 'customId', 'bar'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bar bizz' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this5.context, 'customId', 'bizz'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' }); }; _proto['@test it can have a custom id attribute and it is bound'] = function testItCanHaveACustomIdAttributeAndItIsBound() { var _this6 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.render('', { customId: 'bizz' }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'hello' }); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this6.context, 'customId', 'bar'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bar' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this6.context, 'customId', 'bizz'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'hello' }); }; _proto['@test it can have a custom tagName'] = function testItCanHaveACustomTagName() { var _this7 = this; var FooBarComponent = _helpers.Component.extend({ tagName: 'foo-bar' }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); this.render(''); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this7.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); }; _proto['@test it can have a custom tagName from the invocation'] = function testItCanHaveACustomTagNameFromTheInvocation() { var _this8 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.render(''); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this8.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); }; _proto['@test it can have custom classNames'] = function testItCanHaveCustomClassNames() { var _this9 = this; var FooBarComponent = _helpers.Component.extend({ classNames: ['foo', 'bar'] }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); this.render(''); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this9.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar') }, content: 'hello' }); }; _proto['@test class property on components can be dynamic'] = function testClassPropertyOnComponentsCanBeDynamic() { var _this10 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.render('', { fooBar: true }); this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo-bar') } }); (0, _internalTestHelpers.runTask)(function () { return _this10.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo-bar') } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this10.context, 'fooBar', false); }); this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('ember-view') } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this10.context, 'fooBar', true); }); this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo-bar') } }); }; _proto['@test it can set custom classNames from the invocation'] = function testItCanSetCustomClassNamesFromTheInvocation() { var _this11 = this; var FooBarComponent = _helpers.Component.extend({ classNames: ['foo'] }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); this.render((0, _internalTestHelpers.strip)(_templateObject())); this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar baz') }, content: 'hello' }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar baz') }, content: 'hello' }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this11.rerender(); }); this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar baz') }, content: 'hello' }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar baz') }, content: 'hello' }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo') }, content: 'hello' }); }; _proto['@test it has an element'] = function testItHasAnElement() { var _this12 = this; var instance; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super(); instance = this; } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); this.render(''); var element1 = instance.element; this.assertComponentElement(element1, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this12.rerender(); }); var element2 = instance.element; this.assertComponentElement(element2, { content: 'hello' }); this.assertSameNode(element2, element1); }; _proto['@test it has the right parentView and childViews'] = function testItHasTheRightParentViewAndChildViews(assert) { var _this13 = this; var fooBarInstance, fooBarBazInstance; 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(''); 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]); (0, _internalTestHelpers.runTask)(function () { return _this13.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]); }; _proto['@test it renders passed named arguments'] = function testItRendersPassedNamedArguments() { var _this14 = this; this.registerComponent('foo-bar', { template: '{{@foo}}' }); this.render('', { model: { bar: 'Hola' } }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this14.rerender(); }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this14.context.set('model.bar', 'Hello'); }); this.assertText('Hello'); (0, _internalTestHelpers.runTask)(function () { return _this14.context.set('model', { bar: 'Hola' }); }); this.assertText('Hola'); }; _proto['@test it reflects named arguments as properties'] = function testItReflectsNamedArgumentsAsProperties() { var _this15 = this; this.registerComponent('foo-bar', { template: '{{foo}}' }); this.render('', { model: { bar: 'Hola' } }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this15.rerender(); }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this15.context.set('model.bar', 'Hello'); }); this.assertText('Hello'); (0, _internalTestHelpers.runTask)(function () { return _this15.context.set('model', { bar: 'Hola' }); }); this.assertText('Hola'); }; _proto['@test it can render a basic component with a block'] = function testItCanRenderABasicComponentWithABlock() { var _this16 = this; this.registerComponent('foo-bar', { template: '{{yield}} - In component' }); this.render('hello'); this.assertComponentElement(this.firstChild, { content: 'hello - In component' }); (0, _internalTestHelpers.runTask)(function () { return _this16.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello - In component' }); }; _proto['@test it can yield internal and external properties positionally'] = function testItCanYieldInternalAndExternalPropertiesPositionally() { var _this17 = this; var instance; 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('{{name}} {{person.lastName}}, {{greeting}}', { person: { firstName: 'Joel', lastName: 'Kang' } }); this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); (0, _internalTestHelpers.runTask)(function () { return _this17.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this17.context, 'person', { firstName: 'Dora', lastName: 'the Explorer' }); }); this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'greeting', 'hola'); }); this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hola' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(instance, 'greeting', 'hello'); (0, _metal.set)(_this17.context, 'person', { firstName: 'Joel', lastName: 'Kang' }); }); this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); }; _proto['@test positional parameters are not allowed'] = function testPositionalParametersAreNotAllowed() { this.registerComponent('sample-component', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: ['first', 'second'] }), template: '{{first}}{{second}}' }); // this is somewhat silly as the browser "corrects" for these as // attribute names, but regardless the thing we care about here is that // they are **not** used as positional params this.render(''); this.assertText(''); }; _proto['@test can invoke curried components with capitalized block param names'] = function testCanInvokeCurriedComponentsWithCapitalizedBlockParamNames() { var _this18 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.render((0, _internalTestHelpers.strip)(_templateObject2())); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this18.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); this.assertStableRerender(); }; _proto['@test can invoke curried components with named args'] = function testCanInvokeCurriedComponentsWithNamedArgs() { var _this19 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.registerComponent('test-harness', { template: '<@foo />' }); this.render((0, _internalTestHelpers.strip)(_templateObject3())); this.assertComponentElement(this.firstChild.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this19.rerender(); }); this.assertComponentElement(this.firstChild.firstChild, { content: 'hello' }); this.assertStableRerender(); }; _proto['@test can invoke curried components with a path'] = function testCanInvokeCurriedComponentsWithAPath() { var _this20 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.registerComponent('test-harness', { template: '' }); this.render((0, _internalTestHelpers.strip)(_templateObject4())); this.assertComponentElement(this.firstChild.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this20.rerender(); }); this.assertComponentElement(this.firstChild.firstChild, { content: 'hello' }); this.assertStableRerender(); }; _proto['@test can not invoke curried components with an implicit `this` path'] = function testCanNotInvokeCurriedComponentsWithAnImplicitThisPath(assert) { assert.expect(0); this.registerComponent('foo-bar', { template: 'hello', ComponentClass: _helpers.Component.extend({ init: function () { this._super.apply(this, arguments); assert.ok(false, 'should not have instantiated'); } }) }); this.registerComponent('test-harness', { template: '' }); this.render((0, _internalTestHelpers.strip)(_templateObject5())); }; _proto['@test has-block'] = function testHasBlock() { this.registerComponent('check-block', { template: (0, _internalTestHelpers.strip)(_templateObject6()) }); this.render((0, _internalTestHelpers.strip)(_templateObject7())); this.assertComponentElement(this.firstChild, { content: 'No' }); this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); this.assertStableRerender(); }; _proto['@test includes invocation specified attributes in root element ("splattributes")'] = function testIncludesInvocationSpecifiedAttributesInRootElementSplattributes() { var _this21 = this; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend(), template: 'hello' }); this.render('', { foo: 'foo', bar: 'bar' }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this21.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this21.context, 'foo', 'FOO'); (0, _metal.set)(_this21.context, 'bar', undefined); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this21.context, 'foo', 'foo'); (0, _metal.set)(_this21.context, 'bar', 'bar'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); }; _proto['@test attributes without values passed at invocation are included in `...attributes` ("splattributes")'] = function testAttributesWithoutValuesPassedAtInvocationAreIncludedInAttributesSplattributes() { this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '
hello
' }); this.render(''); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-bar': '' }, content: 'hello' }); this.assertStableRerender(); }; _proto['@test attributes without values at definition are included in `...attributes` ("splattributes")'] = function testAttributesWithoutValuesAtDefinitionAreIncludedInAttributesSplattributes() { this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '
hello
' }); this.render(''); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-bar': '' }, content: 'hello' }); this.assertStableRerender(); }; _proto['@test includes invocation specified attributes in `...attributes` slot in tagless component ("splattributes")'] = function testIncludesInvocationSpecifiedAttributesInAttributesSlotInTaglessComponentSplattributes() { var _this22 = this; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '
hello
' }); this.render('', { foo: 'foo', bar: 'bar' }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this22.rerender(); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this22.context, 'foo', 'FOO'); (0, _metal.set)(_this22.context, 'bar', undefined); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this22.context, 'foo', 'foo'); (0, _metal.set)(_this22.context, 'bar', 'bar'); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); }; _proto['@test merges attributes with `...attributes` in tagless component ("splattributes")'] = function testMergesAttributesWithAttributesInTaglessComponentSplattributes() { var _this23 = this; var instance; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '', init: function () { instance = this; this._super.apply(this, arguments); this.localProp = 'qux'; } }), template: '
hello
' }); this.render('', { foo: 'foo', bar: 'bar' }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-derp': 'qux', 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this23.rerender(); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-derp': 'qux', 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this23.context, 'foo', 'FOO'); (0, _metal.set)(_this23.context, 'bar', undefined); (0, _metal.set)(instance, 'localProp', 'QUZ'); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-derp': 'QUZ', 'data-foo': 'FOO' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this23.context, 'foo', 'foo'); (0, _metal.set)(_this23.context, 'bar', 'bar'); (0, _metal.set)(instance, 'localProp', 'qux'); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-derp': 'qux', 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); }; _proto['@test merges class attribute with `...attributes` in tagless component ("splattributes")'] = function testMergesClassAttributeWithAttributesInTaglessComponentSplattributes() { var _this24 = this; var instance; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '', init: function () { instance = this; this._super.apply(this, arguments); this.localProp = 'qux'; } }), template: '
hello
' }); this.render('', { bar: 'bar' }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('qux bar') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this24.rerender(); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('qux bar') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this24.context, 'bar', undefined); (0, _metal.set)(instance, 'localProp', 'QUZ'); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('QUZ') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this24.context, 'bar', 'bar'); (0, _metal.set)(instance, 'localProp', 'qux'); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('qux bar') }, content: 'hello' }); }; _proto['@test merges trailing class attribute with `...attributes` in tagless component ("splattributes")'] = function testMergesTrailingClassAttributeWithAttributesInTaglessComponentSplattributes() { var _this25 = this; var instance; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '', init: function () { instance = this; this._super.apply(this, arguments); this.localProp = 'qux'; } }), template: '
hello
' }); this.render('', { bar: 'bar' }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('bar qux') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this25.rerender(); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('bar qux') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this25.context, 'bar', undefined); (0, _metal.set)(instance, 'localProp', 'QUZ'); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('QUZ') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this25.context, 'bar', 'bar'); (0, _metal.set)(instance, 'localProp', 'qux'); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('bar qux') }, content: 'hello' }); }; _proto['@test merges class attribute with `...attributes` in yielded contextual component ("splattributes")'] = function testMergesClassAttributeWithAttributesInYieldedContextualComponentSplattributes() { this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '{{yield (hash baz=(component "foo-bar/baz"))}}' }); this.registerComponent('foo-bar/baz', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '
hello
' }); this.render(''); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('default-class custom-class'), title: 'foo' }, content: 'hello' }); }; _proto['@test merges trailing class attribute with `...attributes` in yielded contextual component ("splattributes")'] = function testMergesTrailingClassAttributeWithAttributesInYieldedContextualComponentSplattributes() { this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '{{yield (hash baz=(component "foo-bar/baz"))}}' }); this.registerComponent('foo-bar/baz', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '
hello
' }); this.render(''); this.assertElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('custom-class default-class'), title: 'foo' }, content: 'hello' }); }; _proto['@test the attributes passed on invocation trump over the default ones on elements with `...attributes` in yielded contextual component ("splattributes")'] = function testTheAttributesPassedOnInvocationTrumpOverTheDefaultOnesOnElementsWithAttributesInYieldedContextualComponentSplattributes() { this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '{{yield (hash baz=(component "foo-bar/baz"))}}' }); this.registerComponent('foo-bar/baz', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '
hello
' }); this.render(''); this.assertElement(this.firstChild, { tagName: 'div', attrs: { title: 'foo' }, content: 'hello' }); }; _proto['@test can forward ...attributes to dynamic component invocation ("splattributes")'] = function testCanForwardAttributesToDynamicComponentInvocationSplattributes() { this.registerComponent('x-outer', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '{{yield}}' }); this.registerComponent('x-inner', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '
{{yield}}
' }); this.render((0, _internalTestHelpers.strip)(_templateObject8())); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': '' }, content: 'Hello!' }); }; _proto['@test an inner angle invocation can forward ...attributes through dynamic component invocation ("splattributes")'] = function testAnInnerAngleInvocationCanForwardAttributesThroughDynamicComponentInvocationSplattributes() { this.registerComponent('x-outer', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: "{{#let (component 'x-inner') as |Thing|}}{{yield}}{{/let}}" }); this.registerComponent('x-inner', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '
{{yield}}
' }); this.render('Hello!'); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': '' }, content: 'Hello!' }); }; _proto['@test an inner angle invocation can forward ...attributes through static component invocation ("splattributes")'] = function testAnInnerAngleInvocationCanForwardAttributesThroughStaticComponentInvocationSplattributes() { this.registerComponent('x-outer', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: "{{yield}}" }); this.registerComponent('x-inner', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '
{{yield}}
' }); this.render('Hello!'); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': '' }, content: 'Hello!' }); }; _proto['@test can include `...attributes` in multiple elements in tagless component ("splattributes")'] = function testCanIncludeAttributesInMultipleElementsInTaglessComponentSplattributes() { var _this26 = this; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '
hello

world

' }); this.render('', { foo: 'foo', bar: 'bar' }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); this.assertElement(this.nthChild(1), { tagName: 'p', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'world' }); (0, _internalTestHelpers.runTask)(function () { return _this26.rerender(); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); this.assertElement(this.nthChild(1), { tagName: 'p', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'world' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this26.context, 'foo', 'FOO'); (0, _metal.set)(_this26.context, 'bar', undefined); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); this.assertElement(this.nthChild(1), { tagName: 'p', attrs: { 'data-foo': 'FOO' }, content: 'world' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this26.context, 'foo', 'foo'); (0, _metal.set)(_this26.context, 'bar', 'bar'); }); this.assertElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); this.assertElement(this.nthChild(1), { tagName: 'p', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'world' }); }; _proto['@test can yield content to contextual components invoked with angle-bracket components that receives splattributes'] = function testCanYieldContentToContextualComponentsInvokedWithAngleBracketComponentsThatReceivesSplattributes() { this.registerComponent('foo-bar/inner', { ComponentClass: _helpers.Component.extend({ tagName: '' }), template: '

{{yield}}

' }); this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ tagName: '' }), // If doesn't receive splattributes this test passes template: (0, _internalTestHelpers.strip)(_templateObject9()) }); this.render('Yielded content'); this.assertElement(this.firstChild, { tagName: 'h1', attrs: {}, content: 'Yielded content' }); this.assertElement(this.nthChild(1), { tagName: 'h2', attrs: {}, content: 'Inside the let' }); this.assertElement(this.nthChild(2), { tagName: 'h3', attrs: {}, content: 'Outside the let' }); }; return _class; }(_internalTestHelpers.RenderingTestCase)); (0, _internalTestHelpers.moduleFor)('AngleBracket Invocation (splattributes)', /*#__PURE__*/ function (_RenderingTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _RenderingTestCase2); function _class2() { var _this27; _this27 = _RenderingTestCase2.apply(this, arguments) || this; _this27._TEMPLATE_ONLY_GLIMMER_COMPONENTS = _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS; _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = true; return _this27; } var _proto2 = _class2.prototype; _proto2.teardown = function teardown() { _RenderingTestCase2.prototype.teardown.call(this); _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = this._TEMPLATE_ONLY_GLIMMER_COMPONENTS; }; _proto2.registerComponent = function registerComponent(name, template) { _RenderingTestCase2.prototype.registerComponent.call(this, name, { template: template, ComponentClass: null }); }; _proto2['@test angle bracket invocation can pass merge ...attributes'] = function testAngleBracketInvocationCanPassMergeAttributes() { this.registerComponent('qux', '
'); this.registerComponent('bar', ''); this.registerComponent('foo', ''); this.render(''); this.assertHTML(""); }; _proto2['@test angle bracket invocation can allow invocation side to override attributes with ...attributes'] = function testAngleBracketInvocationCanAllowInvocationSideToOverrideAttributesWithAttributes() { this.registerComponent('qux', '
'); this.registerComponent('bar', ''); this.registerComponent('foo', ''); this.render(''); this.assertHTML('
'); }; _proto2['@test angle bracket invocation can override invocation side attributes with ...attributes'] = function testAngleBracketInvocationCanOverrideInvocationSideAttributesWithAttributes() { this.registerComponent('qux', '
'); this.registerComponent('bar', ''); this.registerComponent('foo', ''); this.render(''); this.assertHTML('
'); }; _proto2['@test angle bracket invocation can forward classes before ...attributes to a nested component'] = function testAngleBracketInvocationCanForwardClassesBeforeAttributesToANestedComponent() { this.registerComponent('qux', '
'); this.registerComponent('bar', ''); this.registerComponent('foo', ''); this.render(''); this.assertHTML('
'); }; _proto2['@test angle bracket invocation can forward classes after ...attributes to a nested component'] = function testAngleBracketInvocationCanForwardClassesAfterAttributesToANestedComponent() { this.registerComponent('qux', '
'); this.registerComponent('bar', ''); this.registerComponent('foo', ''); this.render(''); this.assertHTML('
'); }; return _class2; }(_internalTestHelpers.RenderingTestCase)); if (true /* EMBER_GLIMMER_ANGLE_BRACKET_NESTED_LOOKUP */ ) { (0, _internalTestHelpers.moduleFor)('AngleBracket Invocation Nested Lookup', /*#__PURE__*/ function (_RenderingTestCase3) { (0, _emberBabel.inheritsLoose)(_class3, _RenderingTestCase3); function _class3() { return _RenderingTestCase3.apply(this, arguments) || this; } var _proto3 = _class3.prototype; _proto3['@test it can resolve to foo/bar/baz-bing'] = function testItCanResolveFooBarBazBingToFooBarBazBing() { var _this28 = this; this.registerComponent('foo/bar/baz-bing', { template: 'hello' }); this.render(''); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this28.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; return _class3; }(_internalTestHelpers.RenderingTestCase)); } }); enifed("@ember/-internals/glimmer/tests/integration/components/append-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/metal", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _metal, _helpers) { "use strict"; function _templateObject() { const data = _taggedTemplateLiteralLoose(["\n {{#if showFooBar}}\n {{foo-bar}}\n {{else}}\n {{baz-qux}}\n {{/if}}\n "]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } var AbstractAppendTest = /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(AbstractAppendTest, _RenderingTestCase); function AbstractAppendTest() { var _this; _this = _RenderingTestCase.apply(this, arguments) || this; _this.components = []; _this.ids = []; return _this; } var _proto = AbstractAppendTest.prototype; _proto.teardown = function teardown() { this.component = null; this.components.forEach(function (component) { (0, _internalTestHelpers.runTask)(function () { return component.destroy(); }); }); this.ids.forEach(function (id) { var $element = document.getElementById(id); if ($element) { $element.parentNode.removeChild($element); } // this.assert.strictEqual($element.length, 0, `Should not leak element: #${id}`); }); _RenderingTestCase.prototype.teardown.call(this); } /* abstract append(component): Element; */ ; _proto.didAppend = function didAppend(component) { this.components.push(component); this.ids.push(component.elementId); }; _proto['@test lifecycle hooks during component append'] = function testLifecycleHooksDuringComponentAppend(assert) { var _this2 = 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 () { this._super.apply(this, arguments); 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)'); }); }, 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; XParent = this.owner.factoryFor('component:x-parent'); this.component = XParent.create({ foo: 'zomg' }); assert.deepEqual(hooks, [['x-parent', 'init'], ['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', 'on(init)'], ['x-child', 'didReceiveAttrs'], ['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; (0, _internalTestHelpers.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; (0, _internalTestHelpers.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; (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.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; (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.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; (0, _internalTestHelpers.runTask)(function () { return _this2.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'); }; _proto['@test appending, updating and destroying a single component'] = function testAppendingUpdatingAndDestroyingASingleComponent(assert) { var _this3 = 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; 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'); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); this.assertComponentElement(componentElement, { content: '[parent: zomg][child: zomg][yielded: zomg]' }); assert.equal(componentElement.parentElement, this.element, 'It should be attached to the target'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.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'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.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'); (0, _internalTestHelpers.runTask)(function () { return _this3.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); }; _proto['@test releasing a root component after it has been destroy'] = function testReleasingARootComponentAfterItHasBeenDestroy(assert) { var _this4 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this4.component.destroy(); }); assert.equal(renderer._roots.length, 0, 'released the root component'); }; _proto['@test appending, updating and destroying multiple components'] = function testAppendingUpdatingAndDestroyingMultipleComponents(assert) { var _this5 = 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, Second; 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, wrapper2; (0, _internalTestHelpers.runTask)(function () { return wrapper1 = _this5.append(first); }); (0, _internalTestHelpers.runTask)(function () { return wrapper2 = _this5.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'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.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'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.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'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(first, 'foo', 'foo'); (0, _metal.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'); (0, _internalTestHelpers.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); }; _proto['@test can appendTo while rendering'] = function testCanAppendToWhileRendering() { var _this6 = this; var owner = this.owner; var append = function (component) { return _this6.append(component); }; var element1, element2; 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'); (0, _internalTestHelpers.runTask)(function () { return append(FirstComponent.create()); }); this.assertComponentElement(element1, { content: 'component-one' }); this.assertComponentElement(element2, { content: 'component-two' }); }; _proto['@test can appendTo and remove while rendering'] = function testCanAppendToAndRemoveWhileRendering(assert) { var _this7 = this; var owner = this.owner; var append = function (component) { return _this7.append(component); }; var element1, element2, element3, element4, component1, component2; 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, _internalTestHelpers.strip)(_templateObject()), { showFooBar: true }); this.assertComponentElement(element1, {}); this.assertComponentElement(element2, { content: 'fake-thing: 0' }); assert.equal(instantiatedRoots, 1); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this7.context, 'showFooBar', false); }); assert.equal(instantiatedRoots, 2); assert.equal(destroyedRoots, 1); this.assertComponentElement(element3, {}); this.assertComponentElement(element4, { content: 'fake-thing: 1' }); (0, _internalTestHelpers.runTask)(function () { component1.destroy(); component2.destroy(); }); assert.equal(instantiatedRoots, 2); assert.equal(destroyedRoots, 2); }; return AbstractAppendTest; }(_internalTestHelpers.RenderingTestCase); (0, _internalTestHelpers.moduleFor)('append: no arguments (attaching to document.body)', /*#__PURE__*/ function (_AbstractAppendTest) { (0, _emberBabel.inheritsLoose)(_class, _AbstractAppendTest); function _class() { return _AbstractAppendTest.apply(this, arguments) || this; } var _proto2 = _class.prototype; _proto2.append = function append(component) { (0, _internalTestHelpers.runTask)(function () { return component.append(); }); this.didAppend(component); return document.body; }; return _class; }(AbstractAppendTest)); (0, _internalTestHelpers.moduleFor)('appendTo: a selector', /*#__PURE__*/ function (_AbstractAppendTest2) { (0, _emberBabel.inheritsLoose)(_class2, _AbstractAppendTest2); function _class2() { return _AbstractAppendTest2.apply(this, arguments) || this; } var _proto3 = _class2.prototype; _proto3.append = function append(component) { (0, _internalTestHelpers.runTask)(function () { return component.appendTo('#qunit-fixture'); }); this.didAppend(component); return document.getElementById('qunit-fixture'); }; _proto3['@test raises an assertion when the target does not exist in the DOM'] = function testRaisesAnAssertionWhenTheTargetDoesNotExistInTheDOM(assert) { var _this8 = 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'); (0, _internalTestHelpers.runTask)(function () { expectAssertion(function () { _this8.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, _internalTestHelpers.moduleFor)('appendTo: an element', /*#__PURE__*/ function (_AbstractAppendTest3) { (0, _emberBabel.inheritsLoose)(_class3, _AbstractAppendTest3); function _class3() { return _AbstractAppendTest3.apply(this, arguments) || this; } var _proto4 = _class3.prototype; _proto4.append = function append(component) { var element = document.getElementById('qunit-fixture'); (0, _internalTestHelpers.runTask)(function () { return component.appendTo(element); }); this.didAppend(component); return element; }; return _class3; }(AbstractAppendTest)); (0, _internalTestHelpers.moduleFor)('appendTo: with multiple components', /*#__PURE__*/ function (_AbstractAppendTest4) { (0, _emberBabel.inheritsLoose)(_class4, _AbstractAppendTest4); function _class4() { return _AbstractAppendTest4.apply(this, arguments) || this; } var _proto5 = _class4.prototype; _proto5.append = function append(component) { (0, _internalTestHelpers.runTask)(function () { return component.appendTo('#qunit-fixture'); }); this.didAppend(component); return document.getElementById('qunit-fixture'); }; return _class4; }(AbstractAppendTest)); }); enifed("@ember/-internals/glimmer/tests/integration/components/attribute-bindings-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/metal", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _metal, _helpers) { "use strict"; function _templateObject() { const data = _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 "]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } (0, _internalTestHelpers.moduleFor)('Attribute bindings integration', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test it can have attribute bindings'] = function testItCanHaveAttributeBindings() { var _this = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this.context, 'foo', 'FOO'); (0, _metal.set)(_this.context, 'bar', undefined); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'FOO' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this.context, 'foo', 'foo'); (0, _metal.set)(_this.context, 'bar', 'bar'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo', 'data-bar': 'bar' }, content: 'hello' }); }; _proto['@test it can have attribute bindings with attrs'] = function testItCanHaveAttributeBindingsWithAttrs() { var _this2 = 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' } }); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this2.context, 'model.foo', 'foo'); (0, _metal.set)(_this2.context, 'model.baz.bar', undefined); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'foo' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'model', { foo: undefined, baz: { bar: 'bar' } }); }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { 'data-bar': 'bar' } }); }; _proto['@test it can have attribute bindings with a nested path'] = function testItCanHaveAttributeBindingsWithANestedPath() { var _this3 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.context, 'foo.bar', 'FOO-BAR'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'FOO-BAR' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.context, 'foo.bar', undefined); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.context, 'foo', undefined); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.context, 'foo', { bar: 'foo-bar' }); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo-bar': 'foo-bar' }, content: 'hello' }); }; _proto['@test handles non-microsyntax attributeBindings'] = function testHandlesNonMicrosyntaxAttributeBindings() { var _this4 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this4.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this4.context, 'submit', 'password'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this4.context, 'submit', null); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this4.context, 'submit', 'submit'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'submit' }, content: 'hello' }); }; _proto['@test non-microsyntax attributeBindings cannot contain nested paths'] = function testNonMicrosyntaxAttributeBindingsCannotContainNestedPaths() { var _this5 = this; var FooBarComponent = _helpers.Component.extend({ attributeBindings: ['foo.bar'] }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); expectAssertion(function () { _this5.render('{{foo-bar foo=foo}}', { foo: { bar: 'foo-bar' } }); }, /Illegal attributeBinding: 'foo.bar' is not a valid attribute name./); }; _proto['@test normalizes attributeBindings for property names'] = function testNormalizesAttributeBindingsForPropertyNames() { var _this6 = 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(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this6.context, 'name', null); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this6.context, 'name', 'qux'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { title: 'qux' }, content: 'hello' }); }; _proto['@test normalizes attributeBindings for attribute names'] = function testNormalizesAttributeBindingsForAttributeNames() { var _this7 = 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(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this7.context, 'foo', null); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this7.context, 'foo', 'qux'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'data-foo': 'qux' }, content: 'hello' }); }; _proto['@test attributeBindings preserves case for mixed-case attributes'] = function testAttributeBindingsPreservesCaseForMixedCaseAttributes() { var _this8 = this; var FooBarComponent = _helpers.Component.extend({ tagName: 'svg', attributeBindings: ['viewBox'] }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '' }); this.render('{{foo-bar viewBox=foo}}', { foo: '0 0 100 100' }); this.assert.equal(this.firstChild.getAttribute('viewBox'), '0 0 100 100', 'viewBox attribute'); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this8.context, 'foo', null); }); this.assert.ok(!this.firstChild.hasAttribute('viewBox'), 'viewBox attribute removed'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this8.context, 'foo', '0 0 100 200'); }); this.assert.equal(this.firstChild.getAttribute('viewBox'), '0 0 100 200', 'viewBox attribute'); }; _proto['@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' }); (0, _internalTestHelpers.runTask)(function () { return _this9.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this9.context, 'fizz', 'fizz'); (0, _metal.set)(_this9.context, 'bar', 'bar'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { fizz: 'fizz', bar: 'bar' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this9.context, 'fizz', null); (0, _metal.set)(_this9.context, 'bar', undefined); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: {}, content: 'hello' }); }; _proto['@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' }); (0, _internalTestHelpers.runTask)(function () { return _this10.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this10.context, 'size', 0); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '0' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this10.context, 'size', 21); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { size: '21' }, content: 'hello' }); }; _proto['@test handles internal and external changes'] = function testHandlesInternalAndExternalChanges() { var _this11 = this; var component; 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' }); (0, _internalTestHelpers.runTask)(function () { return _this11.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(component, 'type', 'checkbox'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'checkbox' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(component, 'type', 'password'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { type: 'password' }, content: 'hello' }); }; _proto['@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' } }); (0, _internalTestHelpers.runTask)(function () { return _this12.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this12.context, 'type', 'checkbox'); (0, _metal.set)(_this12.context, 'disabled', true); }); this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'checkbox', disabled: '' } }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this12.context, 'type', 'password'); (0, _metal.set)(_this12.context, 'disabled', false); }); this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { type: 'password' } }); }; _proto['@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' } }); (0, _internalTestHelpers.runTask)(function () { return _this13.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this13.context, 'xlinkHref', '/lol.png'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/lol.png' } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this13.context, 'xlinkHref', '/foo.png'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { 'xlink:href': '/foo.png' } }); } // This comes into play when using the {{#each}} helper. If the // passed array item is a String, it will be converted into a // String object instead of a normal string. ; _proto['@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' } }); (0, _internalTestHelpers.runTask)(function () { return _this14.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { foo: 'bar' } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this14.context, 'foo', function () { return this; }.call('baz')); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { foo: 'baz' } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this14.context, 'foo', function () { return this; }.call('bar')); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { foo: 'bar' } }); }; _proto['@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' } }); (0, _internalTestHelpers.runTask)(function () { return _this15.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'special-sauce' } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this15.context, 'sauce', 'foo'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'special-sauce' } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this15.context, 'sauce', 'special-sauce'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'special-sauce' } }); }; _proto['@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' } }); (0, _internalTestHelpers.runTask)(function () { return _this16.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'dog.html' } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this16.context, 'href', 'cat.html'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { href: 'cat.html' } }); }; _proto['@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, _internalTestHelpers.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' }); (0, _internalTestHelpers.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' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this17.context, 'foo', 'FOO'); (0, _metal.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' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.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' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this17.context, 'foo', 'foo'); (0, _metal.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' }); }; _proto['@test asserts if an attributeBinding is setup on class'] = function testAssertsIfAnAttributeBindingIsSetupOnClass() { var _this18 = this; var FooBarComponent = _helpers.Component.extend({ attributeBindings: ['class'] }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); expectAssertion(function () { _this18.render('{{foo-bar}}'); }, /You cannot use class as an attributeBinding, use classNameBindings instead./i); }; _proto['@test blacklists href bindings based on protocol'] = function testBlacklistsHrefBindingsBasedOnProtocol() { 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')" } }); }; _proto['@test it can bind the role attribute (issue #14007)'] = function testItCanBindTheRoleAttributeIssue14007() { var _this19 = 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' } }); (0, _internalTestHelpers.runTask)(function () { return _this19.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'button' } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this19.context, 'role', 'combobox'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { role: 'combobox' } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this19.context, 'role', null); }); this.assertComponentElement(this.firstChild, { tagName: 'div' }); }; _proto['@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'); }; _proto['@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; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/attrs-lookup-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/metal", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _metal, _helpers) { "use strict"; (0, _internalTestHelpers.moduleFor)('Components test: attrs lookup', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test it should be able to lookup attrs without `attrs.` - template access'] = function testItShouldBeAbleToLookupAttrsWithoutAttrsTemplateAccess() { var _this = this; this.registerComponent('foo-bar', { template: '{{first}}' }); this.render("{{foo-bar first=firstAttr}}", { firstAttr: 'first attr' }); this.assertText('first attr'); (0, _internalTestHelpers.runTask)(function () { return _this.rerender(); }); this.assertText('first attr'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this.context, 'firstAttr', 'second attr'); }); this.assertText('second attr'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this.context, 'firstAttr', 'first attr'); }); this.assertText('first attr'); }; _proto['@test it should be able to lookup attrs without `attrs.` - component access'] = function testItShouldBeAbleToLookupAttrsWithoutAttrsComponentAccess(assert) { var _this2 = this; var instance; 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'); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); assert.equal(instance.get('first'), 'first attr'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'firstAttr', 'second attr'); }); assert.equal(instance.get('first'), 'second attr'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'firstAttr', 'first attr'); }); this.assertText('first attr'); }; _proto['@test should be able to modify a provided attr into local state #11571 / #11559'] = function testShouldBeAbleToModifyAProvidedAttrIntoLocalState1157111559(assert) { var _this3 = this; var instance; 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'); (0, _internalTestHelpers.runTask)(function () { return _this3.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 }; _proto['@test should be able to access unspecified attr #12035'] = function testShouldBeAbleToAccessUnspecifiedAttr12035(assert) { var _this4 = this; var instance; 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'); (0, _internalTestHelpers.runTask)(function () { return _this4.rerender(); }); assert.equal(instance.get('woot'), 'yes', 'component found attr after rerender'); (0, _internalTestHelpers.runTask)(function () { wootVal = 'nope'; (0, _metal.set)(_this4.context, 'woot', wootVal); }); assert.equal(instance.get('woot'), 'nope', 'component found attr after attr change'); (0, _internalTestHelpers.runTask)(function () { wootVal = 'yes'; (0, _metal.set)(_this4.context, 'woot', wootVal); }); assert.equal(instance.get('woot'), 'yes', 'component found attr after reset'); }; _proto['@test getAttr() should return the same value as get()'] = function testGetAttrShouldReturnTheSameValueAsGet(assert) { var _this5 = this; assert.expect(33); var instance; 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'); assert.equal(rootFirstPositional, attrFirstPositional, 'root property matches attrs value'); assert.equal(rootFirst, attrFirst, 'root property matches attrs value'); assert.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'); (0, _internalTestHelpers.runTask)(function () { return _this5.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'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.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'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.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'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.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'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.context, 'firstPositional', 'firstPositional'); (0, _metal.set)(_this5.context, 'first', 'first'); (0, _metal.set)(_this5.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'); }; _proto['@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, _metal.computed)('height', 'color', function () { var height = this.get('height'); var color = this.get('color'); return (0, _helpers.htmlSafe)("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, _internalTestHelpers.styles)('height: 20px; background-color: red;') } }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { style: (0, _internalTestHelpers.styles)('height: 150px; background-color: yellow;') } }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { style: (0, _internalTestHelpers.styles)('height: 150px; background-color: green;') } }); this.assertStableRerender(); // No U-R }; return _class; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/class-bindings-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/metal", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _metal, _helpers) { "use strict"; function _templateObject() { const data = _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 "]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } (0, _internalTestHelpers.moduleFor)('ClassNameBindings integration', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test it can have class name bindings on the class definition'] = function testItCanHaveClassNameBindingsOnTheClassDefinition() { var _this = 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, _internalTestHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this.context, 'foo', 'FOO'); (0, _metal.set)(_this.context, 'isEnabled', false); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view FOO sad') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this.context, 'foo', undefined); (0, _metal.set)(_this.context, 'isHappy', true); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view happy') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this.context, 'foo', 'foo'); (0, _metal.set)(_this.context, 'isEnabled', true); (0, _metal.set)(_this.context, 'isHappy', false); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' }); }; _proto['@test attrs in classNameBindings'] = function testAttrsInClassNameBindings() { var _this2 = 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, _internalTestHelpers.classes)('ember-view green black') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view green black') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this2.context, 'model.wat', true); (0, _metal.set)(_this2.context, 'model.super.robin', false); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view purple red') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'model', { wat: false, super: { robin: true } }); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view green black') }, content: 'hello' }); }; _proto['@test it can have class name bindings in the template'] = function testItCanHaveClassNameBindingsInTheTemplate() { var _this3 = 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, _internalTestHelpers.classes)('ember-view some-initially-true-property static big closed isTruthy') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); this.assertComponentElement(this.firstChild, { attrs: { class: (0, _internalTestHelpers.classes)('ember-view some-initially-true-property static big closed isTruthy') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this3.context, 'model.someInitiallyTrueProperty', false); (0, _metal.set)(_this3.context, 'model.someInitiallyFalseProperty', true); (0, _metal.set)(_this3.context, 'model.someInitiallyUndefinedProperty', true); (0, _metal.set)(_this3.context, 'model.isBig', false); (0, _metal.set)(_this3.context, 'model.isOpen', true); (0, _metal.set)(_this3.context, 'model.isUp', false); (0, _metal.set)(_this3.context, 'model.bar', false); }); this.assertComponentElement(this.firstChild, { attrs: { class: (0, _internalTestHelpers.classes)('ember-view some-initially-false-property some-initially-undefined-property static open down isFalsy') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this3.context, 'model', { someInitiallyTrueProperty: true, someInitiallyFalseProperty: false, someInitiallyUndefinedProperty: undefined, isBig: true, isOpen: false, isUp: true, bar: true }); }); this.assertComponentElement(this.firstChild, { attrs: { class: (0, _internalTestHelpers.classes)('ember-view some-initially-true-property static big closed isTruthy') }, content: 'hello' }); }; _proto['@test it can have class name bindings with nested paths'] = function testItCanHaveClassNameBindingsWithNestedPaths() { var _this4 = 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, _internalTestHelpers.classes)('ember-view foo-bar enabled sad') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this4.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo-bar enabled sad') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this4.context, 'foo.bar', 'FOO-BAR'); (0, _metal.set)(_this4.context, 'is.enabled', false); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view FOO-BAR sad') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this4.context, 'foo.bar', null); (0, _metal.set)(_this4.context, 'is.happy', true); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view happy') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this4.context, 'foo', null); (0, _metal.set)(_this4.context, 'is', null); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view sad') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this4.context, 'foo', { bar: 'foo-bar' }); (0, _metal.set)(_this4.context, 'is', { enabled: true, happy: false }); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo-bar enabled sad') }, content: 'hello' }); }; _proto['@test it should dasherize the path when the it resolves to true'] = function testItShouldDasherizeThePathWhenTheItResolvesToTrue() { var _this5 = 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, _internalTestHelpers.classes)('ember-view foo-bar') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this5.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo-bar') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.context, 'fooBar', false); (0, _metal.set)(_this5.context, 'nested.fooBarBaz', true); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo-bar-baz') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.context, 'fooBar', 'FOO-BAR'); (0, _metal.set)(_this5.context, 'nested.fooBarBaz', null); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view FOO-BAR') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this5.context, 'nested', null); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view FOO-BAR') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.context, 'fooBar', true); (0, _metal.set)(_this5.context, 'nested', { fooBarBaz: false }); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo-bar') }, content: 'hello' }); }; _proto['@test const bindings can be set as attrs'] = function testConstBindingsCanBeSetAsAttrs() { var _this6 = 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, _internalTestHelpers.classes)('ember-view enabled') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this6.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view enabled') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this6.context, 'foo', false); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view disabled') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this6.context, 'foo', true); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view enabled') }, content: 'hello' }); }; _proto['@test :: class name syntax works with an empty true class'] = function testClassNameSyntaxWorksWithAnEmptyTrueClass() { var _this7 = 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, _internalTestHelpers.classes)('ember-view not-enabled') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this7.context, 'enabled', true); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this7.context, 'enabled', false); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view not-enabled') }, content: 'hello' }); }; _proto['@test uses all provided static class names (issue #11193)'] = function testUsesAllProvidedStaticClassNamesIssue11193() { var _this8 = 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, _internalTestHelpers.classes)('ember-view class-one class-two') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this8.context, 'enabled', true); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view class-one class-two') }, content: 'hello' }); }; _proto['@test Providing a binding with a space in it asserts'] = function testProvidingABindingWithASpaceInItAsserts() { var _this9 = this; var FooBarComponent = _helpers.Component.extend({ classNameBindings: 'i:think:i am:so:clever' }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); expectAssertion(function () { _this9.render('{{foo-bar}}'); }, /classNameBindings must not have spaces in them/i); }; _proto['@test it asserts that items must be strings'] = function testItAssertsThatItemsMustBeStrings() { var _this10 = 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 () { _this10.render('{{foo-bar}}'); }, /classNameBindings must be non-empty strings/); }; _proto['@test it asserts that items must be non-empty strings'] = function testItAssertsThatItemsMustBeNonEmptyStrings() { var _this11 = this; var FooBarComponent = _helpers.Component.extend({ foo: 'foo', bar: 'bar', classNameBindings: ['foo', '', 'bar'] }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); expectAssertion(function () { _this11.render('{{foo-bar}}'); }, /classNameBindings must be non-empty strings/); }; _proto['@test it can set class name bindings in the constructor'] = function testItCanSetClassNameBindingsInTheConstructor() { var _this12 = 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, _internalTestHelpers.strip)(_templateObject()), { foo: 'foo', isEnabled: true, isHappy: false }); this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo enabled') }, content: 'hello' }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo sad') }, content: 'hello' }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this12.rerender(); }); this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo enabled') }, content: 'hello' }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo sad') }, content: 'hello' }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this12.context, 'foo', 'FOO'); (0, _metal.set)(_this12.context, 'isEnabled', false); }); this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view FOO') }, content: 'hello' }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view FOO sad') }, content: 'hello' }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view FOO sad') }, content: 'hello' }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view FOO') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this12.context, 'foo', undefined); (0, _metal.set)(_this12.context, 'isHappy', true); }); this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view') }, content: 'hello' }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view happy') }, content: 'hello' }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view happy') }, content: 'hello' }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this12.context, 'foo', 'foo'); (0, _metal.set)(_this12.context, 'isEnabled', true); (0, _metal.set)(_this12.context, 'isHappy', false); }); this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo enabled') }, content: 'hello' }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo sad') }, content: 'hello' }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo enabled sad') }, content: 'hello' }); this.assertComponentElement(this.nthChild(3), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo') }, content: 'hello' }); }; _proto['@test using a computed property for classNameBindings triggers an assertion'] = function testUsingAComputedPropertyForClassNameBindingsTriggersAnAssertion() { var _this13 = this; var FooBarComponent = _helpers.Component.extend({ classNameBindings: (0, _metal.computed)(function () { return ['isHappy:happy:sad']; }) }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); expectAssertion(function () { _this13.render('{{foo-bar}}'); }, /Only arrays are allowed/); }; return _class; }(_internalTestHelpers.RenderingTestCase)); (0, _internalTestHelpers.moduleFor)('ClassBinding integration', /*#__PURE__*/ function (_RenderingTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _RenderingTestCase2); function _class2() { return _RenderingTestCase2.apply(this, arguments) || this; } var _proto2 = _class2.prototype; _proto2['@test it should apply classBinding without condition always'] = function testItShouldApplyClassBindingWithoutConditionAlways() { var _this14 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar classBinding=":foo"}}'); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('foo ember-view') } }); (0, _internalTestHelpers.runTask)(function () { return _this14.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('foo ember-view') } }); }; _proto2['@test it should merge classBinding with class'] = function testItShouldMergeClassBindingWithClass() { var _this15 = 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, _internalTestHelpers.classes)('respeck myName ember-view') } }); (0, _internalTestHelpers.runTask)(function () { return _this15.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('respeck myName ember-view') } }); }; _proto2['@test it should apply classBinding with only truthy condition'] = function testItShouldApplyClassBindingWithOnlyTruthyCondition() { var _this16 = 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, _internalTestHelpers.classes)('respeck ember-view') } }); (0, _internalTestHelpers.runTask)(function () { return _this16.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('respeck ember-view') } }); }; _proto2['@test it should apply classBinding with only falsy condition'] = function testItShouldApplyClassBindingWithOnlyFalsyCondition() { var _this17 = 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, _internalTestHelpers.classes)('shade ember-view') } }); (0, _internalTestHelpers.runTask)(function () { return _this17.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('shade ember-view') } }); }; _proto2['@test it should apply nothing when classBinding is falsy but only supplies truthy class'] = function testItShouldApplyNothingWhenClassBindingIsFalsyButOnlySuppliesTruthyClass() { var _this18 = 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, _internalTestHelpers.classes)('ember-view') } }); (0, _internalTestHelpers.runTask)(function () { return _this18.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('ember-view') } }); }; _proto2['@test it should apply nothing when classBinding is truthy but only supplies falsy class'] = function testItShouldApplyNothingWhenClassBindingIsTruthyButOnlySuppliesFalsyClass() { var _this19 = 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, _internalTestHelpers.classes)('ember-view') } }); (0, _internalTestHelpers.runTask)(function () { return _this19.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('ember-view') } }); }; _proto2['@test it should apply classBinding with falsy condition'] = function testItShouldApplyClassBindingWithFalsyCondition() { var _this20 = 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, _internalTestHelpers.classes)('scrub ember-view') } }); (0, _internalTestHelpers.runTask)(function () { return _this20.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('scrub ember-view') } }); }; _proto2['@test it should apply classBinding with truthy condition'] = function testItShouldApplyClassBindingWithTruthyCondition() { var _this21 = 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, _internalTestHelpers.classes)('fresh ember-view') } }); (0, _internalTestHelpers.runTask)(function () { return _this21.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('fresh ember-view') } }); }; return _class2; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/contextual-components-test", ["ember-babel", "internal-test-helpers", "@ember/polyfills", "@ember/-internals/metal", "@ember/-internals/runtime", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _polyfills, _metal, _runtime, _helpers) { "use strict"; function _templateObject21() { const data = _taggedTemplateLiteralLoose(["\n "]); _templateObject21 = function () { return data; }; return data; } function _templateObject20() { const data = _taggedTemplateLiteralLoose(["\n {{#let 'foo-bar' as |foo|}}\n {{foo 1 2 3}}\n {{/let}}\n "]); _templateObject20 = function () { return data; }; return data; } function _templateObject19() { const data = _taggedTemplateLiteralLoose(["\n {{#let (component 'foo-bar') as |foo|}}\n {{foo 1 2 3}}\n {{/let}}\n "]); _templateObject19 = function () { return data; }; return data; } function _templateObject18() { const data = _taggedTemplateLiteralLoose(["\n {{#let (component 'foo-bar') as |foo|}}\n {{foo}}\n {{/let}}\n "]); _templateObject18 = function () { return data; }; return data; } function _templateObject17() { const data = _taggedTemplateLiteralLoose(["\n {{#with (hash ctxCmp=(component compName isOpen=isOpen)) as |thing|}}\n {{#thing.ctxCmp}}This is a contextual component{{/thing.ctxCmp}}\n {{/with}}\n "]); _templateObject17 = function () { return data; }; return data; } function _templateObject16() { const data = _taggedTemplateLiteralLoose(["\n {{#with (hash ctxCmp=(component compName isOpen=isOpen)) as |thing|}}\n {{#thing.ctxCmp}}This is a contextual component{{/thing.ctxCmp}}\n {{/with}}\n "]); _templateObject16 = function () { return data; }; return data; } function _templateObject15() { const data = _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 "]); _templateObject15 = function () { return data; }; return data; } function _templateObject14() { const data = _taggedTemplateLiteralLoose(["\n message: {{message}}{{inner-component message=message}}\n "]); _templateObject12 = function () { return data; }; return data; } function _templateObject11() { const data = _taggedTemplateLiteralLoose(["\n {{#select-box as |sb|}}\n {{sb.option label=\"Foo\"}}\n {{sb.option}}\n {{/select-box}}"]); _templateObject11 = function () { return data; }; return data; } function _templateObject10() { const data = _taggedTemplateLiteralLoose(["\n {{#my-component my-attr=myProp as |api|}}\n {{api.my-nested-component}}\n {{/my-component}}\n
\n "]); _templateObject10 = function () { return data; }; return data; } function _templateObject9() { const data = _taggedTemplateLiteralLoose(["\n {{#with (hash my-component=(component 'my-component' first)) as |c|}}\n {{c.my-component}}\n {{/with}}"]); _templateObject9 = function () { return data; }; return data; } function _templateObject8() { const data = _taggedTemplateLiteralLoose(["\n {{#with (hash lookedup=(component \"-looked-up\")) as |object|}}\n {{object.lookedup model.expectedText \"Hola\"}}\n {{/with}}"]); _templateObject8 = function () { return data; }; return data; } function _templateObject7() { const data = _taggedTemplateLiteralLoose(["\n {{#with (hash lookedup=(component \"-looked-up\" expectedText=model.expectedText)) as |object|}}\n {{object.lookedup}}\n {{/with}}"]); _templateObject7 = function () { return data; }; return data; } function _templateObject6() { const data = _taggedTemplateLiteralLoose(["\n {{#with (hash lookedup=(component \"-looked-up\")) as |object|}}\n {{object.lookedup expectedText=model.expectedText}}\n {{/with}}"]); _templateObject6 = function () { return data; }; return data; } function _templateObject5() { const data = _taggedTemplateLiteralLoose(["\n {{#with (hash lookedup=(component \"-looked-up\")) as |object|}}\n {{object.lookedup}}\n {{/with}}"]); _templateObject5 = function () { return data; }; return data; } function _templateObject4() { const data = _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}}"]); _templateObject4 = function () { return data; }; return data; } function _templateObject3() { const data = _taggedTemplateLiteralLoose(["\n {{#with (hash comp=(component \"-looked-up\" greeting=model.greeting)) as |my|}}\n {{#my.comp}}{{/my.comp}}\n {{/with}}"]); _templateObject3 = function () { return data; }; return data; } function _templateObject2() { const data = _taggedTemplateLiteralLoose(["\n {{component (component \"-looked-up\" \"Hodari\" greeting=\"Hodi\")\n greeting=\"Hola\"}}"]); _templateObject2 = function () { return data; }; return data; } function _templateObject() { const data = _taggedTemplateLiteralLoose(["\n {{component (component \"-looked-up\") \"Hodari\" greeting=\"Hodi\"}}"]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } (0, _internalTestHelpers.moduleFor)('Components test: contextual components', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test renders with component helper'] = function testRendersWithComponentHelper() { var _this = this; var expectedText = 'Hodi'; this.registerComponent('-looked-up', { template: expectedText }); this.render('{{component (component "-looked-up")}}'); this.assertText(expectedText); (0, _internalTestHelpers.runTask)(function () { return _this.rerender(); }); this.assertText(expectedText); }; _proto['@test renders with component helper with invocation params, hash'] = function testRendersWithComponentHelperWithInvocationParamsHash() { var _this2 = this; this.registerComponent('-looked-up', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: ['name'] }), template: '{{greeting}} {{name}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject())); this.assertText('Hodi Hodari'); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); this.assertText('Hodi Hodari'); }; _proto['@test GH#13742 keeps nested rest positional parameters if rendered with no positional parameters'] = function testGH13742KeepsNestedRestPositionalParametersIfRenderedWithNoPositionalParameters() { var _this3 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); this.assertText('Gabon Zack'); (0, _internalTestHelpers.runTask)(function () { return _this3.context.set('model.greeting', 'Good morning '); }); this.assertText('Good morning Zack'); (0, _internalTestHelpers.runTask)(function () { return _this3.context.set('model.name', 'Matthew'); }); this.assertText('Good morning Matthew'); (0, _internalTestHelpers.runTask)(function () { return _this3.context.set('model', { greeting: 'Gabon ', name: 'Zack' }); }); this.assertText('Gabon Zack'); } // Take a look at this one. Seems to pass even when currying isn't implemented. ; _proto['@test overwrites nested rest positional parameters if rendered with positional parameters'] = function testOverwritesNestedRestPositionalParametersIfRenderedWithPositionalParameters() { 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.name model.greeting}}', { model: { greeting: 'Gabon ', name: 'Zack ' } }); this.assertText('Gabon Zack Zack Gabon '); (0, _internalTestHelpers.runTask)(function () { return _this4.rerender(); }); this.assertText('Gabon Zack Zack Gabon '); (0, _internalTestHelpers.runTask)(function () { return _this4.context.set('model.greeting', 'Good morning '); }); this.assertText('Good morning Zack Zack Good morning '); (0, _internalTestHelpers.runTask)(function () { return _this4.context.set('model.name', 'Matthew '); }); this.assertText('Good morning Matthew Matthew Good morning '); (0, _internalTestHelpers.runTask)(function () { return _this4.context.set('model', { greeting: 'Gabon ', name: 'Zack ' }); }); this.assertText('Gabon Zack Zack Gabon '); }; _proto['@test GH#13742 keeps nested rest positional parameters if nested and rendered with no positional parameters'] = function testGH13742KeepsNestedRestPositionalParametersIfNestedAndRenderedWithNoPositionalParameters() { 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 (component "-looked-up" model.greeting model.name))}}', { model: { greeting: 'Gabon ', name: 'Zack' } }); this.assertText('Gabon Zack'); (0, _internalTestHelpers.runTask)(function () { return _this5.rerender(); }); this.assertText('Gabon Zack'); (0, _internalTestHelpers.runTask)(function () { return _this5.context.set('model.greeting', 'Good morning '); }); this.assertText('Good morning Zack'); (0, _internalTestHelpers.runTask)(function () { return _this5.context.set('model.name', 'Matthew'); }); this.assertText('Good morning Matthew'); (0, _internalTestHelpers.runTask)(function () { return _this5.context.set('model', { greeting: 'Gabon ', name: 'Zack' }); }); this.assertText('Gabon Zack'); }; _proto['@test overwrites nested rest positional parameters if nested with new pos params and rendered with no positional parameters'] = function testOverwritesNestedRestPositionalParametersIfNestedWithNewPosParamsAndRenderedWithNoPositionalParameters() { 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.name model.greeting)}}', { model: { greeting: 'Gabon ', name: 'Zack ' } }); this.assertText('Gabon Zack Zack Gabon '); (0, _internalTestHelpers.runTask)(function () { return _this6.rerender(); }); this.assertText('Gabon Zack Zack Gabon '); (0, _internalTestHelpers.runTask)(function () { return _this6.context.set('model.greeting', 'Good morning '); }); this.assertText('Good morning Zack Zack Good morning '); (0, _internalTestHelpers.runTask)(function () { return _this6.context.set('model.name', 'Matthew '); }); this.assertText('Good morning Matthew Matthew Good morning '); (0, _internalTestHelpers.runTask)(function () { return _this6.context.set('model', { greeting: 'Gabon ', name: 'Zack ' }); }); this.assertText('Gabon Zack Zack Gabon '); }; _proto['@test renders with component helper with curried params, hash'] = function testRendersWithComponentHelperWithCurriedParamsHash() { var _this7 = this; this.registerComponent('-looked-up', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: ['name'] }), template: '{{greeting}} {{name}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject2())); this.assertText('Hola Hodari'); (0, _internalTestHelpers.runTask)(function () { return _this7.rerender(); }); this.assertText('Hola Hodari'); }; _proto['@test updates when component path is bound'] = function testUpdatesWhenComponentPathIsBound() { var _this8 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this8.rerender(); }); this.assertText('ni hao'); (0, _internalTestHelpers.runTask)(function () { return _this8.context.set('model.lookupComponent', '-hindi'); }); this.assertText('Namaste'); (0, _internalTestHelpers.runTask)(function () { return _this8.context.set('model', { lookupComponent: '-mandarin' }); }); this.assertText('ni hao'); }; _proto['@test updates when curried hash argument is bound'] = function testUpdatesWhenCurriedHashArgumentIsBound() { var _this9 = this; this.registerComponent('-looked-up', { template: '{{greeting}}' }); this.render("{{component (component \"-looked-up\" greeting=model.greeting)}}", { model: { greeting: 'Hodi' } }); this.assertText('Hodi'); (0, _internalTestHelpers.runTask)(function () { return _this9.rerender(); }); this.assertText('Hodi'); (0, _internalTestHelpers.runTask)(function () { return _this9.context.set('model.greeting', 'Hola'); }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this9.context.set('model', { greeting: 'Hodi' }); }); this.assertText('Hodi'); }; _proto['@test updates when curried hash arguments is bound in block form'] = function testUpdatesWhenCurriedHashArgumentsIsBoundInBlockForm() { var _this10 = this; this.registerComponent('-looked-up', { template: '{{greeting}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject3()), { model: { greeting: 'Hodi' } }); this.assertText('Hodi'); (0, _internalTestHelpers.runTask)(function () { return _this10.rerender(); }); this.assertText('Hodi'); (0, _internalTestHelpers.runTask)(function () { return _this10.context.set('model.greeting', 'Hola'); }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this10.context.set('model', { greeting: 'Hodi' }); }); this.assertText('Hodi'); }; _proto['@test nested components do not overwrite positional parameters'] = function testNestedComponentsDoNotOverwritePositionalParameters() { var _this11 = 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('Sergio 29'); (0, _internalTestHelpers.runTask)(function () { return _this11.rerender(); }); this.assertText('Sergio 29'); }; _proto['@test positional parameters are combined not clobbered'] = function testPositionalParametersAreCombinedNotClobbered() { var _this12 = this; this.registerComponent('-looked-up', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: ['greeting', 'name', 'age'] }), template: '{{greeting}} {{name}} {{age}}' }); this.render('{{component (component (component "-looked-up" "Hi") "Max") 9}}'); this.assertText('Hi Max 9'); (0, _internalTestHelpers.runTask)(function () { return _this12.rerender(); }); this.assertText('Hi Max 9'); }; _proto['@test nested components overwrite hash parameters'] = function testNestedComponentsOverwriteHashParameters() { var _this13 = this; this.registerComponent('-looked-up', { template: '{{greeting}} {{name}} {{age}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject4()), { model: { greeting: 'Hodi' } }); this.assertText('Hodi Sigmundur 33'); (0, _internalTestHelpers.runTask)(function () { return _this13.rerender(); }); this.assertText('Hodi Sigmundur 33'); (0, _internalTestHelpers.runTask)(function () { return _this13.context.set('model.greeting', 'Kaixo'); }); this.assertText('Kaixo Sigmundur 33'); (0, _internalTestHelpers.runTask)(function () { return _this13.context.set('model', { greeting: 'Hodi' }); }); this.assertText('Hodi Sigmundur 33'); }; _proto['@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('Outer 28'); (0, _internalTestHelpers.runTask)(function () { return _this14.rerender(); }); this.assertText('Outer 28'); (0, _internalTestHelpers.runTask)(function () { return _this14.context.set('model.outerAge', 29); }); this.assertText('Outer 29'); (0, _internalTestHelpers.runTask)(function () { return _this14.context.set('model.outerName', 'Not outer'); }); this.assertText('Not outer 29'); (0, _internalTestHelpers.runTask)(function () { _this14.context.set('model', { outerName: 'Outer', outerAge: 28 }); }); this.assertText('Outer 28'); }; _proto['@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'); (0, _internalTestHelpers.runTask)(function () { return _this15.rerender(); }); this.assertText('Inner 28'); (0, _internalTestHelpers.runTask)(function () { return _this15.context.set('model.outerAge', 29); }); this.assertText('Inner 29'); (0, _internalTestHelpers.runTask)(function () { return _this15.context.set('model.outerName', 'Not outer'); }); this.assertText('Inner 29'); (0, _internalTestHelpers.runTask)(function () { _this15.context.set('model', { outerName: 'Outer', outerAge: 28 }); }); this.assertText('Inner 28'); }; _proto['@test conflicting positional and hash parameters does not raise an assertion if rerendered'] = function testConflictingPositionalAndHashParametersDoesNotRaiseAnAssertionIfRerendered() { var _this16 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this16.rerender(); }); this.assertText('Hodi Hodari'); (0, _internalTestHelpers.runTask)(function () { return _this16.context.set('model.name', 'Sergio'); }); this.assertText('Hodi Sergio'); (0, _internalTestHelpers.runTask)(function () { return _this16.context.set('model', { name: 'Hodari' }); }); this.assertText('Hodi Hodari'); }; _proto['@test component with dynamic component name resolving to undefined, then an existing component'] = function testComponentWithDynamicComponentNameResolvingToUndefinedThenAnExistingComponent() { var _this17 = this; this.registerComponent('foo-bar', { template: 'hello {{name}}' }); this.render('{{component (component componentName name=name)}}', { componentName: undefined, name: 'Alex' }); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return _this17.rerender(); }); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return _this17.context.set('componentName', 'foo-bar'); }); this.assertText('hello Alex'); (0, _internalTestHelpers.runTask)(function () { return _this17.context.set('componentName', undefined); }); this.assertText(''); }; _proto['@test component with dynamic component name resolving to a component, then undefined'] = function testComponentWithDynamicComponentNameResolvingToAComponentThenUndefined() { var _this18 = this; this.registerComponent('foo-bar', { template: 'hello {{name}}' }); this.render('{{component (component componentName name=name)}}', { componentName: 'foo-bar', name: 'Alex' }); this.assertText('hello Alex'); (0, _internalTestHelpers.runTask)(function () { return _this18.rerender(); }); this.assertText('hello Alex'); (0, _internalTestHelpers.runTask)(function () { return _this18.context.set('componentName', undefined); }); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return _this18.context.set('componentName', 'foo-bar'); }); this.assertText('hello Alex'); }; _proto['@test component with dynamic component name resolving to null, then an existing component'] = function testComponentWithDynamicComponentNameResolvingToNullThenAnExistingComponent() { var _this19 = this; this.registerComponent('foo-bar', { template: 'hello {{name}}' }); this.render('{{component (component componentName name=name)}}', { componentName: null, name: 'Alex' }); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return _this19.rerender(); }); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return _this19.context.set('componentName', 'foo-bar'); }); this.assertText('hello Alex'); (0, _internalTestHelpers.runTask)(function () { return _this19.context.set('componentName', null); }); this.assertText(''); }; _proto['@test component with dynamic component name resolving to a component, then null'] = function testComponentWithDynamicComponentNameResolvingToAComponentThenNull() { var _this20 = this; this.registerComponent('foo-bar', { template: 'hello {{name}}' }); this.render('{{component (component componentName name=name)}}', { componentName: 'foo-bar', name: 'Alex' }); this.assertText('hello Alex'); (0, _internalTestHelpers.runTask)(function () { return _this20.rerender(); }); this.assertText('hello Alex'); (0, _internalTestHelpers.runTask)(function () { return _this20.context.set('componentName', null); }); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return _this20.context.set('componentName', 'foo-bar'); }); this.assertText('hello Alex'); }; _proto['@test raises an assertion when component path is not a component name (static)'] = function testRaisesAnAssertionWhenComponentPathIsNotAComponentNameStatic() { var _this21 = this; expectAssertion(function () { _this21.render('{{component (component "not-a-component")}}'); }, 'Could not find component named "not-a-component" (no component or template with that name was found)'); }; _proto['@test raises an assertion when component path is not a component name (dynamic)'] = function testRaisesAnAssertionWhenComponentPathIsNotAComponentNameDynamic() { var _this22 = this; expectAssertion(function () { _this22.render('{{component (component compName)}}', { compName: 'not-a-component' }); }, 'Could not find component named "not-a-component" (no component or template with that name was found)'); }; _proto['@test renders with dot path'] = function testRendersWithDotPath() { var _this23 = this; var expectedText = 'Hodi'; this.registerComponent('-looked-up', { template: expectedText }); this.render((0, _internalTestHelpers.strip)(_templateObject5())); this.assertText(expectedText); (0, _internalTestHelpers.runTask)(function () { return _this23.rerender(); }); this.assertText(expectedText); }; _proto['@test renders with dot path and attr'] = function testRendersWithDotPathAndAttr() { var _this24 = this; var expectedText = 'Hodi'; this.registerComponent('-looked-up', { template: '{{expectedText}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject6()), { model: { expectedText: expectedText } }); this.assertText(expectedText); (0, _internalTestHelpers.runTask)(function () { return _this24.rerender(); }); this.assertText(expectedText); (0, _internalTestHelpers.runTask)(function () { return _this24.context.set('model.expectedText', 'Hola'); }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this24.context.set('model', { expectedText: expectedText }); }); this.assertText(expectedText); }; _proto['@test renders with dot path and curried over attr'] = function testRendersWithDotPathAndCurriedOverAttr() { var _this25 = this; var expectedText = 'Hodi'; this.registerComponent('-looked-up', { template: '{{expectedText}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject7()), { model: { expectedText: expectedText } }); this.assertText(expectedText); (0, _internalTestHelpers.runTask)(function () { return _this25.rerender(); }); this.assertText(expectedText); (0, _internalTestHelpers.runTask)(function () { return _this25.context.set('model.expectedText', 'Hola'); }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this25.context.set('model', { expectedText: expectedText }); }); this.assertText(expectedText); }; _proto['@test renders with dot path and with rest positional parameters'] = function testRendersWithDotPathAndWithRestPositionalParameters() { var _this26 = this; this.registerComponent('-looked-up', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'params' }), template: '{{params}}' }); var expectedText = 'Hodi'; this.render((0, _internalTestHelpers.strip)(_templateObject8()), { model: { expectedText: expectedText } }); this.assertText(expectedText + ",Hola"); (0, _internalTestHelpers.runTask)(function () { return _this26.rerender(); }); this.assertText(expectedText + ",Hola"); (0, _internalTestHelpers.runTask)(function () { return _this26.context.set('model.expectedText', 'Kaixo'); }); this.assertText('Kaixo,Hola'); (0, _internalTestHelpers.runTask)(function () { return _this26.context.set('model', { expectedText: expectedText }); }); this.assertText(expectedText + ",Hola"); }; _proto['@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, _internalTestHelpers.strip)(_templateObject9()), { first: 'first' }); assert.equal(value, 'first', 'value is the expected parameter'); }; _proto['@test renders with dot path and updates attributes'] = function testRendersWithDotPathAndUpdatesAttributes(assert) { var _this27 = this; this.registerComponent('my-nested-component', { ComponentClass: _helpers.Component.extend({ didReceiveAttrs: function () { this.set('myProp', this.getAttr('my-parent-attr')); } }), template: '{{myProp}}' }); 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, _internalTestHelpers.strip)(_templateObject10()) }); this.render('{{my-action-component myProp=model.myProp}}', { model: { myProp: 1 } }); assert.equal(this.$('#nested-prop').text(), '1'); (0, _internalTestHelpers.runTask)(function () { return _this27.rerender(); }); assert.equal(this.$('#nested-prop').text(), '1'); (0, _internalTestHelpers.runTask)(function () { return _this27.$('button').click(); }); assert.equal(this.$('#nested-prop').text(), '2'); (0, _internalTestHelpers.runTask)(function () { return _this27.$('button').click(); }); assert.equal(this.$('#nested-prop').text(), '3'); (0, _internalTestHelpers.runTask)(function () { return _this27.context.set('model', { myProp: 1 }); }); assert.equal(this.$('#nested-prop').text(), '1'); }; _proto["@test adding parameters to a contextual component's instance does not add it to other instances"] = function testAddingParametersToAContextualComponentSInstanceDoesNotAddItToOtherInstances() { var _this28 = 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, _internalTestHelpers.strip)(_templateObject11())); this.assertText('Foo'); (0, _internalTestHelpers.runTask)(function () { return _this28.rerender(); }); this.assertText('Foo'); }; _proto['@test parameters in a contextual component are mutable when value is a param'] = function testParametersInAContextualComponentAreMutableWhenValueIsAParam(assert) { var _this29 = 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, _internalTestHelpers.strip)(_templateObject12()) }); this.render((0, _internalTestHelpers.strip)(_templateObject13()), { model: { val2: 8 } }); assert.equal(this.$('.value').text(), '8'); (0, _internalTestHelpers.runTask)(function () { return _this29.rerender(); }); assert.equal(this.$('.value').text(), '8'); (0, _internalTestHelpers.runTask)(function () { return _this29.$('.my-button').click(); }); assert.equal(this.$('.value').text(), '10'); (0, _internalTestHelpers.runTask)(function () { return _this29.context.set('model', { val2: 8 }); }); assert.equal(this.$('.value').text(), '8'); }; _proto['@test tagless blockless components render'] = function testTaglessBlocklessComponentsRender(assert) { var _this30 = this; this.registerComponent('my-comp', { ComponentClass: _helpers.Component.extend({ tagName: '' }) }); this.render("{{my-comp}}"); (0, _internalTestHelpers.runTask)(function () { return _this30.rerender(); }); assert.equal(this.$().text(), ''); }; _proto['@test GH#13494 tagless blockless component with property binding'] = function testGH13494TaglessBlocklessComponentWithPropertyBinding(assert) { var _this31 = this; this.registerComponent('outer-component', { ComponentClass: _helpers.Component.extend({ message: 'hello', actions: { change: function () { this.set('message', 'goodbye'); } } }), template: (0, _internalTestHelpers.strip)(_templateObject14()) }); this.registerComponent('inner-component', { ComponentClass: _helpers.Component.extend({ tagName: '' }) }); this.render("{{outer-component}}"); assert.equal(this.$().text(), 'message: hello'); (0, _internalTestHelpers.runTask)(function () { return _this31.rerender(); }); assert.equal(this.$().text(), 'message: hello'); (0, _internalTestHelpers.runTask)(function () { return _this31.$('button').click(); }); assert.equal(this.$().text(), 'message: goodbye'); (0, _internalTestHelpers.runTask)(function () { return _this31.rerender(); }); assert.equal(this.$().text(), 'message: goodbye'); }; _proto['@test GH#13982 contextual component ref is stable even when bound params change'] = function testGH13982ContextualComponentRefIsStableEvenWhenBoundParamsChange(assert) { var _this32 = this; var instance, previousInstance; 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, _internalTestHelpers.strip)(_templateObject15()), { isOpen: true }); assert.ok(!(0, _metal.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"'); (0, _internalTestHelpers.runTask)(function () { return _this32.rerender(); }); assert.ok(!(0, _metal.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"'); (0, _internalTestHelpers.runTask)(function () { return _this32.context.set('isOpen', false); }); assert.ok(!(0, _metal.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"'); (0, _internalTestHelpers.runTask)(function () { return _this32.rerender(); }); assert.ok(!(0, _metal.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"'); (0, _internalTestHelpers.runTask)(function () { return _this32.context.set('isOpen', true); }); assert.ok(!(0, _metal.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"'); }; _proto['@test GH#13982 contextual component ref is stable even when bound params change (bound name param)'] = function testGH13982ContextualComponentRefIsStableEvenWhenBoundParamsChangeBoundNameParam(assert) { var _this33 = this; var instance, previousInstance; 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, _internalTestHelpers.strip)(_templateObject16()), { compName: 'my-comp', isOpen: true }); assert.ok(!(0, _metal.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"'); (0, _internalTestHelpers.runTask)(function () { return _this33.rerender(); }); assert.ok(!(0, _metal.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"'); (0, _internalTestHelpers.runTask)(function () { return _this33.context.set('isOpen', false); }); assert.ok(!(0, _metal.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"'); (0, _internalTestHelpers.runTask)(function () { return _this33.rerender(); }); assert.ok(!(0, _metal.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"'); (0, _internalTestHelpers.runTask)(function () { return _this33.context.set('isOpen', true); }); assert.ok(!(0, _metal.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"'); }; _proto['@test GH#13982 contextual component ref is recomputed when component name param changes'] = function testGH13982ContextualComponentRefIsRecomputedWhenComponentNameParamChanges(assert) { var _this34 = this; var instance, previousInstance; 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, _internalTestHelpers.strip)(_templateObject17()), { compName: 'my-comp', isOpen: true }); assert.ok(!(0, _metal.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'); (0, _internalTestHelpers.runTask)(function () { return _this34.rerender(); }); assert.ok(!(0, _metal.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'); (0, _internalTestHelpers.runTask)(function () { return _this34.context.set('compName', 'your-comp'); }); assert.ok(!(0, _metal.isEmpty)(instance), 'an instance was created after component name changed'); assert.ok(!(0, _metal.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'); (0, _internalTestHelpers.runTask)(function () { return _this34.rerender(); }); assert.ok(!(0, _metal.isEmpty)(instance), 'an instance was created after component name changed (rerender)'); assert.ok(!(0, _metal.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'); (0, _internalTestHelpers.runTask)(function () { return _this34.context.set('compName', 'my-comp'); }); assert.ok(!(0, _metal.isEmpty)(instance), 'an instance was created after component name changed'); assert.ok(!(0, _metal.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'); }; _proto['@test GH#14508 rest positional params are received when passed as named parameter'] = function testGH14508RestPositionalParamsAreReceivedWhenPassedAsNamedParameter() { var _this35 = 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, _runtime.A)(['a', 'b']) }); this.assertText('ab'); (0, _internalTestHelpers.runTask)(function () { return _this35.rerender(); }); this.assertText('ab'); (0, _internalTestHelpers.runTask)(function () { return _this35.context.get('allParams').pushObject('c'); }); this.assertText('abc'); (0, _internalTestHelpers.runTask)(function () { return _this35.context.get('allParams').popObject(); }); this.assertText('ab'); (0, _internalTestHelpers.runTask)(function () { return _this35.context.get('allParams').clear(); }); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return _this35.context.set('allParams', (0, _runtime.A)(['1', '2'])); }); this.assertText('12'); (0, _internalTestHelpers.runTask)(function () { return _this35.context.set('allParams', (0, _runtime.A)(['a', 'b'])); }); this.assertText('ab'); }; _proto['@test GH#14508 rest positional params are received when passed as named parameter with dot notation'] = function testGH14508RestPositionalParamsAreReceivedWhenPassedAsNamedParameterWithDotNotation() { var _this36 = 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, _runtime.A)(['a', 'b']) }); this.assertText('ab'); (0, _internalTestHelpers.runTask)(function () { return _this36.rerender(); }); this.assertText('ab'); (0, _internalTestHelpers.runTask)(function () { return _this36.context.get('allParams').pushObject('c'); }); this.assertText('abc'); (0, _internalTestHelpers.runTask)(function () { return _this36.context.get('allParams').popObject(); }); this.assertText('ab'); (0, _internalTestHelpers.runTask)(function () { return _this36.context.get('allParams').clear(); }); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return _this36.context.set('allParams', (0, _runtime.A)(['1', '2'])); }); this.assertText('12'); (0, _internalTestHelpers.runTask)(function () { return _this36.context.set('allParams', (0, _runtime.A)(['a', 'b'])); }); this.assertText('ab'); }; _proto['@feature(!ember-glimmer-angle-bracket-built-ins) GH#14632 give useful warning when calling contextual components with input as a name'] = function featureEmberGlimmerAngleBracketBuiltInsGH14632GiveUsefulWarningWhenCallingContextualComponentsWithInputAsAName() { var _this37 = this; expectAssertion(function () { _this37.render('{{component (component "input" type="text")}}'); }, 'Invoking `{{input}}` using angle bracket syntax or `component` helper is not yet supported.'); }; _proto['@feature(ember-glimmer-angle-bracket-built-ins) it can invoke input component'] = function featureEmberGlimmerAngleBracketBuiltInsItCanInvokeInputComponent() { var _this38 = this; this.render('{{component (component "input" type="text" value=value)}}', { value: 'foo' }); this.assertComponentElement(this.firstChild, { tagName: 'input', attrs: { class: 'ember-text-field ember-view', type: 'text' } }); this.assert.strictEqual('foo', this.firstChild.value); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return _this38.context.set('value', 'bar'); }); this.assert.strictEqual('bar', this.firstChild.value); (0, _internalTestHelpers.runTask)(function () { return _this38.context.set('value', 'foo'); }); this.assert.strictEqual('foo', this.firstChild.value); }; _proto['@feature(!ember-glimmer-angle-bracket-built-ins) GH#14632 give useful warning when calling contextual components with textarea as a name'] = function featureEmberGlimmerAngleBracketBuiltInsGH14632GiveUsefulWarningWhenCallingContextualComponentsWithTextareaAsAName() { var _this39 = this; expectAssertion(function () { _this39.render('{{component (component "textarea")}}'); }, 'Invoking `{{textarea}}` using angle bracket syntax or `component` helper is not yet supported.'); }; _proto['@feature(ember-glimmer-angle-bracket-built-ins) it can invoke textarea component'] = function featureEmberGlimmerAngleBracketBuiltInsItCanInvokeTextareaComponent() { var _this40 = this; this.render('{{component (component "textarea" value=value)}}', { value: 'foo' }); this.assertComponentElement(this.firstChild, { tagName: 'textarea', attrs: { class: 'ember-text-area ember-view' } }); this.assert.strictEqual('foo', this.firstChild.value); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return _this40.context.set('value', 'bar'); }); this.assert.strictEqual('bar', this.firstChild.value); (0, _internalTestHelpers.runTask)(function () { return _this40.context.set('value', 'foo'); }); this.assert.strictEqual('foo', this.firstChild.value); }; _proto['@test GH#17121 local variable should win over helper (without arguments)'] = function testGH17121LocalVariableShouldWinOverHelperWithoutArguments() { this.registerHelper('foo', function () { return 'foo helper'; }); this.registerComponent('foo-bar', { template: 'foo-bar component' }); this.render((0, _internalTestHelpers.strip)(_templateObject18())); this.assertText('foo-bar component'); this.assertStableRerender(); }; _proto['@test GH#17121 local variable should win over helper (with arguments)'] = function testGH17121LocalVariableShouldWinOverHelperWithArguments() { this.registerHelper('foo', function (params) { return "foo helper: " + params.join(' '); }); this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'params' }), template: 'foo-bar component:{{#each params as |param|}} {{param}}{{/each}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject19())); this.assertText('foo-bar component: 1 2 3'); this.assertStableRerender(); }; _proto['@test GH#17121 implicit component invocations should not perform string lookup'] = function testGH17121ImplicitComponentInvocationsShouldNotPerformStringLookup() { var _this41 = this; this.registerComponent('foo-bar', { template: 'foo-bar component' }); expectAssertion(function () { return _this41.render((0, _internalTestHelpers.strip)(_templateObject20())); }, "expected `foo` to be a contextual component but found a string. Did you mean `(component foo)`? ('-top-level' @ L1:C29) "); }; _proto['@test RFC#311 invoking named args (without arguments)'] = function testRFC311InvokingNamedArgsWithoutArguments() { this.registerComponent('x-outer', { template: '{{@inner}}' }); this.registerComponent('x-inner', { template: 'inner' }); this.render('{{x-outer inner=(component "x-inner")}}'); this.assertText('inner'); this.assertStableRerender(); }; _proto['@test RFC#311 invoking named args (with arguments)'] = function testRFC311InvokingNamedArgsWithArguments() { this.registerComponent('x-outer', { template: '{{@inner 1 2 3}}' }); this.registerComponent('x-inner', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'params' }), template: 'inner:{{#each params as |param|}} {{param}}{{/each}}' }); this.render('{{x-outer inner=(component "x-inner")}}'); this.assertText('inner: 1 2 3'); this.assertStableRerender(); }; _proto['@test RFC#311 invoking named args (with a block)'] = function testRFC311InvokingNamedArgsWithABlock() { this.registerComponent('x-outer', { template: '{{#@inner}}outer{{/@inner}}' }); this.registerComponent('x-inner', { template: 'inner {{yield}}' }); this.render('{{x-outer inner=(component "x-inner")}}'); this.assertText('inner outer'); this.assertStableRerender(); }; return _class; }(_internalTestHelpers.RenderingTestCase)); var ContextualComponentMutableParamsTest = /*#__PURE__*/ function (_RenderingTestCase2) { (0, _emberBabel.inheritsLoose)(ContextualComponentMutableParamsTest, _RenderingTestCase2); function ContextualComponentMutableParamsTest() { return _RenderingTestCase2.apply(this, arguments) || this; } var _proto2 = ContextualComponentMutableParamsTest.prototype; _proto2.render = function render(templateStr) { var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _RenderingTestCase2.prototype.render.call(this, templateStr + "{{model.val2}}", (0, _polyfills.assign)(context, { model: { val2: 8 } })); }; return ContextualComponentMutableParamsTest; }(_internalTestHelpers.RenderingTestCase); var MutableParamTestGenerator = /*#__PURE__*/ function () { function MutableParamTestGenerator(cases) { this.cases = cases; } var _proto3 = MutableParamTestGenerator.prototype; _proto3.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 _this42 = this; this.registerComponent('change-button', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: ['val'] }), template: (0, _internalTestHelpers.strip)(_templateObject21()) }); setup.call(this, assert); assert.equal(this.$('.value').text(), '8'); (0, _internalTestHelpers.runTask)(function () { return _this42.rerender(); }); assert.equal(this.$('.value').text(), '8'); (0, _internalTestHelpers.runTask)(function () { return _this42.$('.my-button').click(); }); assert.equal(this.$('.value').text(), '10'); (0, _internalTestHelpers.runTask)(function () { return _this42.context.set('model', { val2: 8 }); }); assert.equal(this.$('.value').text(), '8'); }, _ref2; }; return MutableParamTestGenerator; }(); (0, _internalTestHelpers.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, _internalTestHelpers.moduleFor)('Components test: contextual components -- mutable params', ContextualComponentMutableParamsTest); }); enifed("@ember/-internals/glimmer/tests/integration/components/curly-components-test", ["ember-babel", "internal-test-helpers", "@ember/runloop", "@ember/-internals/metal", "@ember/service", "@ember/-internals/runtime", "@ember/-internals/views", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _runloop, _metal, _service, _runtime, _views, _helpers) { "use strict"; function _templateObject55() { const data = _taggedTemplateLiteralLoose(["\n {{#list-items items=items as |thing|}}\n |{{thing}}|\n\n {{#if editMode}}\n Remove {{thing}}\n {{/if}}\n {{/list-items}}\n "]); _templateObject55 = function () { return data; }; return data; } function _templateObject54() { const data = _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 "]); _templateObject54 = function () { return data; }; return data; } function _templateObject53() { const data = _taggedTemplateLiteralLoose(["\n {{#some-clicky-thing blahzz=\"baz\"}}\n Click Me\n {{/some-clicky-thing}}"]); _templateObject53 = function () { return data; }; return data; } function _templateObject52() { const data = _taggedTemplateLiteralLoose(["\n {{#each blahzz as |p|}}\n {{p}}\n {{/each}}\n - {{yield}}"]); _templateObject52 = function () { return data; }; return data; } function _templateObject51() { const data = _taggedTemplateLiteralLoose(["\n {{#some-clicky-thing classNames=\"baz\"}}\n Click Me\n {{/some-clicky-thing}}"]); _templateObject51 = function () { return data; }; return data; } function _templateObject50() { const data = _taggedTemplateLiteralLoose(["\n In layout. {{#each items as |item|}}\n [{{child-non-block item=item}}]\n {{/each}}"]); _templateObject50 = function () { return data; }; return data; } function _templateObject49() { const data = _taggedTemplateLiteralLoose(["\n {{#x-outer}}\n {{#if showInner}}\n {{x-inner}}\n {{/if}}\n {{/x-outer}}"]); _templateObject49 = function () { return data; }; return data; } function _templateObject48() { const data = _taggedTemplateLiteralLoose(["\n {{#check-helper}}{{/check-helper}}\n {{#check-helper as |something|}}{{/check-helper}}"]); _templateObject48 = function () { return data; }; return data; } function _templateObject47() { const data = _taggedTemplateLiteralLoose(["\n {{#check-helper}}{{/check-helper}}\n {{#check-helper as |something|}}{{/check-helper}}"]); _templateObject47 = function () { return data; }; return data; } function _templateObject46() { const data = _taggedTemplateLiteralLoose(["\n {{#check-helper}}{{/check-helper}}\n {{#check-helper as |something|}}{{/check-helper}}"]); _templateObject46 = function () { return data; }; return data; } function _templateObject45() { const data = _taggedTemplateLiteralLoose(["\n {{#check-helper}}{{/check-helper}}\n {{#check-helper}}{{else}}{{/check-helper}}"]); _templateObject45 = function () { return data; }; return data; } function _templateObject44() { const data = _taggedTemplateLiteralLoose(["\n {{check-helper}}\n {{#check-helper}}{{/check-helper}}"]); _templateObject44 = function () { return data; }; return data; } function _templateObject43() { const data = _taggedTemplateLiteralLoose(["\n {{check-helper}}\n {{#check-helper}}{{/check-helper}}"]); _templateObject43 = function () { return data; }; return data; } function _templateObject42() { const data = _taggedTemplateLiteralLoose(["\n {{#check-attr}}{{/check-attr}}\n {{#check-attr as |something|}}{{/check-attr}}"]); _templateObject42 = function () { return data; }; return data; } function _templateObject41() { const data = _taggedTemplateLiteralLoose(["\n {{#check-attr}}{{/check-attr}}\n {{#check-attr as |something|}}{{/check-attr}}"]); _templateObject41 = function () { return data; }; return data; } function _templateObject40() { const data = _taggedTemplateLiteralLoose(["\n {{#check-attr}}{{/check-attr}}\n {{#check-attr}}{{else}}{{/check-attr}}"]); _templateObject40 = function () { return data; }; return data; } function _templateObject39() { const data = _taggedTemplateLiteralLoose(["\n {{check-attr}}\n {{#check-attr}}{{/check-attr}}"]); _templateObject39 = function () { return data; }; return data; } function _templateObject38() { const data = _taggedTemplateLiteralLoose(["\n {{#check-params}}{{/check-params}}\n {{#check-params as |foo|}}{{/check-params}}"]); _templateObject38 = function () { return data; }; return data; } function _templateObject37() { const data = _taggedTemplateLiteralLoose(["\n {{#if hasBlockParams}}\n Yes\n {{else}}\n No\n {{/if}}"]); _templateObject37 = function () { return data; }; return data; } function _templateObject36() { const data = _taggedTemplateLiteralLoose(["\n {{#check-params}}{{/check-params}}\n {{#check-params as |foo|}}{{/check-params}}"]); _templateObject36 = function () { return data; }; return data; } function _templateObject35() { const data = _taggedTemplateLiteralLoose(["\n {{#if (hasBlockParams)}}\n Yes\n {{else}}\n No\n {{/if}}"]); _templateObject35 = function () { return data; }; return data; } function _templateObject34() { const data = _taggedTemplateLiteralLoose(["\n {{check-block}}\n {{#check-block}}{{/check-block}}"]); _templateObject34 = function () { return data; }; return data; } function _templateObject33() { const data = _taggedTemplateLiteralLoose(["\n {{#if hasBlock}}\n Yes\n {{else}}\n No\n {{/if}}"]); _templateObject33 = function () { return data; }; return data; } function _templateObject32() { const data = _taggedTemplateLiteralLoose(["\n {{#check-block}}{{/check-block}}\n {{#check-block as |something|}}{{/check-block}}"]); _templateObject32 = function () { return data; }; return data; } function _templateObject31() { const data = _taggedTemplateLiteralLoose(["\n {{#if (hasBlockParams)}}\n Yes\n {{else}}\n No\n {{/if}}"]); _templateObject31 = function () { return data; }; return data; } function _templateObject30() { const data = _taggedTemplateLiteralLoose(["\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse as |something|}}{{/check-inverse}}"]); _templateObject30 = function () { return data; }; return data; } function _templateObject29() { const data = _taggedTemplateLiteralLoose(["\n {{#if (hasBlockParams \"inverse\")}}\n Yes\n {{else}}\n No\n {{/if}}"]); _templateObject29 = function () { return data; }; return data; } function _templateObject28() { const data = _taggedTemplateLiteralLoose(["\n {{check-block}}\n {{#check-block}}{{/check-block}}"]); _templateObject28 = function () { return data; }; return data; } function _templateObject27() { const data = _taggedTemplateLiteralLoose(["\n {{#if (hasBlock)}}\n Yes\n {{else}}\n No\n {{/if}}"]); _templateObject27 = function () { return data; }; return data; } function _templateObject26() { const data = _taggedTemplateLiteralLoose(["\n {{#check-inverse}}{{/check-inverse}}\n {{#check-inverse}}{{else}}{{/check-inverse}}"]); _templateObject26 = function () { return data; }; return data; } function _templateObject25() { const data = _taggedTemplateLiteralLoose(["\n {{#if (hasBlock \"inverse\")}}\n Yes\n {{else}}\n No\n {{/if}}"]); _templateObject25 = function () { return data; }; return data; } function _templateObject24() { const data = _taggedTemplateLiteralLoose(["\n {{#my-if predicate=activated someValue=42 as |result|}}\n Hello{{result}}\n {{else}}\n Goodbye\n {{/my-if}}"]); _templateObject24 = function () { return data; }; return data; } function _templateObject23() { const data = _taggedTemplateLiteralLoose(["\n {{#if predicate}}\n Yes:{{yield someValue}}\n {{else}}\n No:{{yield to=\"inverse\"}}\n {{/if}}"]); _templateObject23 = function () { return data; }; return data; } function _templateObject22() { const data = _taggedTemplateLiteralLoose(["\n {{#with-block}}\n In block\n {{/with-block}}"]); _templateObject22 = function () { return data; }; return data; } function _templateObject21() { const data = _taggedTemplateLiteralLoose(["\n {{#if hasBlockParams}}\n {{yield this}}\n {{else}}\n {{yield}} No Block Param!\n {{/if}}"]); _templateObject21 = function () { return data; }; return data; } function _templateObject20() { const data = _taggedTemplateLiteralLoose(["\n {{#with-block as |something|}}\n In template\n {{/with-block}}"]); _templateObject20 = function () { return data; }; return data; } function _templateObject19() { const data = _taggedTemplateLiteralLoose(["\n {{#if hasBlockParams}}\n {{yield this}} - In Component\n {{else}}\n {{yield}} No Block!\n {{/if}}"]); _templateObject19 = function () { return data; }; return data; } function _templateObject18() { const data = _taggedTemplateLiteralLoose(["\n {{#if hasBlock}}\n {{yield}}\n {{else}}\n No Block!\n {{/if}}"]); _templateObject18 = function () { return data; }; return data; } function _templateObject17() { const data = _taggedTemplateLiteralLoose(["\n {{#with-block}}\n In template\n {{/with-block}}"]); _templateObject17 = function () { return data; }; return data; } function _templateObject16() { const data = _taggedTemplateLiteralLoose(["\n {{#if hasBlock}}\n {{yield}}\n {{else}}\n No Block!\n {{/if}}"]); _templateObject16 = function () { return data; }; return data; } function _templateObject15() { const data = _taggedTemplateLiteralLoose(["\n {{#with-template name=\"with-block\"}}\n [In block - {{name}}]\n {{/with-template}}\n {{with-template name=\"without-block\"}}"]); _templateObject15 = function () { return data; }; return data; } function _templateObject14() { const data = _taggedTemplateLiteralLoose(["\n {{#each n as |name|}}\n {{name}}\n {{/each}}"]); _templateObject14 = function () { return data; }; return data; } function _templateObject13() { const data = _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\"}}"]); _templateObject13 = function () { return data; }; return data; } function _templateObject12() { const data = _taggedTemplateLiteralLoose(["\n {{#each names as |name|}}\n {{name}}\n {{/each}}"]); _templateObject12 = function () { return data; }; return data; } function _templateObject11() { const data = _taggedTemplateLiteralLoose(["\n {{#each names as |name|}}\n {{name}}\n {{/each}}"]); _templateObject11 = function () { return data; }; return data; } function _templateObject10() { const data = _taggedTemplateLiteralLoose(["\n {{sample-component \"Foo\" 4 \"Bar\" elementId=\"args-3\"}}\n {{sample-component \"Foo\" 4 \"Bar\" 5 \"Baz\" elementId=\"args-5\"}}"]); _templateObject10 = function () { return data; }; return data; } function _templateObject9() { const data = _taggedTemplateLiteralLoose(["\n {{#each names as |name|}}\n {{name}}\n {{/each}}"]); _templateObject9 = function () { return data; }; return data; } function _templateObject8() { const data = _taggedTemplateLiteralLoose(["\n {{#with-block someProp=prop}}\n In template\n {{/with-block}}"]); _templateObject8 = function () { return data; }; return data; } function _templateObject7() { const data = _taggedTemplateLiteralLoose(["\n {{#with-block someProp=prop}}\n In template\n {{/with-block}}"]); _templateObject7 = function () { return data; }; return data; } function _templateObject6() { const data = _taggedTemplateLiteralLoose(["\n {{#with-block someProp=prop}}\n In template\n {{/with-block}}"]); _templateObject6 = function () { return data; }; return data; } function _templateObject5() { const data = _taggedTemplateLiteralLoose(["Args: lul | lul | lul | lul1111"]); _templateObject5 = function () { return data; }; return data; } function _templateObject4() { const data = _taggedTemplateLiteralLoose(["\n Args: {{this.attrs.value}} | {{attrs.value}} | {{@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 {{#each items as |item|}}\n {{item}}\n {{/each}}\n "]); _templateObject4 = function () { return data; }; return data; } function _templateObject3() { const data = _taggedTemplateLiteralLoose(["\n {{#if isStream}}\n true\n {{else}}\n false\n {{/if}}\n "]); _templateObject3 = function () { return data; }; return data; } function _templateObject2() { const data = _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}}"]); _templateObject2 = function () { return data; }; return data; } function _templateObject() { const data = _taggedTemplateLiteralLoose(["\n {{foo-bar class=\"bar baz\"}}\n {{foo-bar classNames=\"bar baz\"}}\n {{foo-bar}}\n "]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } (0, _internalTestHelpers.moduleFor)('Components test: curly components', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test it can render a basic component'] = function testItCanRenderABasicComponent() { var _this = this; this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar}}'); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; _proto['@test it can have a custom id and it is not bound'] = function testItCanHaveACustomIdAndItIsNotBound() { var _this2 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'customId', 'bar'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bar bizz' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'customId', 'bizz'); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'bizz' }, content: 'bizz bizz' }); }; _proto['@test elementId cannot change'] = function testElementIdCannotChange(assert) { var component; 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, _runloop.run)(null, _metal.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' }); } }; _proto['@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'); }; _proto['@test layout supports computed property'] = function testLayoutSupportsComputedProperty() { var FooBarComponent = _helpers.Component.extend({ elementId: 'blahzorz', layout: (0, _metal.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'); }; _proto['@test passing undefined elementId results in a default elementId'] = function testPassingUndefinedElementIdResultsInADefaultElementId(assert) { var _this3 = 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 + ').'); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); var newFoundId = this.$('h1').attr('id'); assert.ok(/^ember/.test(newFoundId), 'Has a reasonable id attribute (found id=' + newFoundId + ').'); assert.equal(foundId, newFoundId); }; _proto['@test id is an alias for elementId'] = function testIdIsAnAliasForElementId(assert) { var _this4 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this4.rerender(); }); var newFoundId = this.$('h1').attr('id'); assert.equal(newFoundId, 'custom-id'); assert.equal(foundId, newFoundId); }; _proto['@test cannot pass both id and elementId at the same time'] = function testCannotPassBothIdAndElementIdAtTheSameTime() { var _this5 = this; this.registerComponent('foo-bar', { template: '' }); expectAssertion(function () { _this5.render('{{foo-bar id="zomg" elementId="lol"}}'); }, /You cannot invoke a component with both 'id' and 'elementId' at the same time./); }; _proto['@test it can have a custom tagName'] = function testItCanHaveACustomTagName() { var _this6 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this6.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); }; _proto['@test it can have a custom tagName set in the constructor'] = function testItCanHaveACustomTagNameSetInTheConstructor() { var _this7 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this7.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); }; _proto['@test it can have a custom tagName from the invocation'] = function testItCanHaveACustomTagNameFromTheInvocation() { var _this8 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar tagName="foo-bar"}}'); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this8.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'foo-bar', content: 'hello' }); }; _proto['@test tagName can not be a computed property'] = function testTagNameCanNotBeAComputedProperty() { var _this9 = this; var FooBarComponent = _helpers.Component.extend({ tagName: (0, _metal.computed)(function () { return 'foo-bar'; }) }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); expectAssertion(function () { _this9.render('{{foo-bar}}'); }, /You cannot use a computed property for the component's `tagName` \(<.+?>\)\./); }; _proto['@test class is applied before didInsertElement'] = function testClassIsAppliedBeforeDidInsertElement(assert) { var componentClass; 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'); }; _proto['@test it can have custom classNames'] = function testItCanHaveCustomClassNames() { var _this10 = 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, _internalTestHelpers.classes)('ember-view foo bar') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this10.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar') }, content: 'hello' }); }; _proto['@test should not apply falsy class name'] = function testShouldNotApplyFalsyClassName() { var _this11 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this11.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, content: 'hello' }); }; _proto['@test should update class using inline if, initially false, no alternate'] = function testShouldUpdateClassUsingInlineIfInitiallyFalseNoAlternate() { var _this12 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar class=(if predicate "thing") }}', { predicate: false }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this12.context, 'predicate', true); }); (0, _internalTestHelpers.runTask)(function () { return _this12.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view thing') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this12.context, 'predicate', false); }); (0, _internalTestHelpers.runTask)(function () { return _this12.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, content: 'hello' }); }; _proto['@test should update class using inline if, initially true, no alternate'] = function testShouldUpdateClassUsingInlineIfInitiallyTrueNoAlternate() { var _this13 = this; this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar class=(if predicate "thing") }}', { predicate: true }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view thing') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this13.context, 'predicate', false); }); (0, _internalTestHelpers.runTask)(function () { return _this13.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: 'ember-view' }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this13.context, 'predicate', true); }); (0, _internalTestHelpers.runTask)(function () { return _this13.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view thing') }, content: 'hello' }); }; _proto['@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, _internalTestHelpers.classes)('ember-view some-truth') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this14.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view some-truth') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this14.context, 'model.someTruth', false); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this14.context, 'model', { someTruth: true }); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view some-truth') }, content: 'hello' }); }; _proto['@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, _internalTestHelpers.classes)('ember-view foo-bar') } }); (0, _internalTestHelpers.runTask)(function () { return _this15.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo-bar') } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this15.context, 'fooBar', false); }); this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('ember-view') } }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this15.context, 'fooBar', true); }); this.assertComponentElement(this.firstChild, { content: 'hello', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo-bar') } }); }; _proto['@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, _internalTestHelpers.classes)('ember-view foo bar outside-baz') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this16.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar outside-baz') }, content: 'hello' }); }; _proto['@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, _internalTestHelpers.strip)(_templateObject())); this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar baz') }, content: 'hello' }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar baz') }, content: 'hello' }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this17.rerender(); }); this.assertComponentElement(this.nthChild(0), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar baz') }, content: 'hello' }); this.assertComponentElement(this.nthChild(1), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo bar baz') }, content: 'hello' }); this.assertComponentElement(this.nthChild(2), { tagName: 'div', attrs: { class: (0, _internalTestHelpers.classes)('ember-view foo') }, content: 'hello' }); }; _proto['@test it has an element'] = function testItHasAnElement() { var _this18 = this; var instance; 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' }); (0, _internalTestHelpers.runTask)(function () { return _this18.rerender(); }); var element2 = instance.element; this.assertComponentElement(element2, { content: 'hello' }); this.assertSameNode(element2, element1); }; _proto['@test an empty component does not have childNodes'] = function testAnEmptyComponentDoesNotHaveChildNodes(assert) { var _this19 = this; var fooBarInstance; 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); (0, _internalTestHelpers.runTask)(function () { return _this19.rerender(); }); this.assertComponentElement(this.firstChild, { tagName: 'input' }); assert.strictEqual(fooBarInstance.element.childNodes.length, 0); }; _proto['@test it has the right parentView and childViews'] = function testItHasTheRightParentViewAndChildViews(assert) { var _this20 = this; var fooBarInstance, fooBarBazInstance; 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]); (0, _internalTestHelpers.runTask)(function () { return _this20.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]); }; _proto['@test it renders passed named arguments'] = function testItRendersPassedNamedArguments() { var _this21 = this; this.registerComponent('foo-bar', { template: '{{@foo}}' }); this.render('{{foo-bar foo=model.bar}}', { model: { bar: 'Hola' } }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this21.rerender(); }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this21.context.set('model.bar', 'Hello'); }); this.assertText('Hello'); (0, _internalTestHelpers.runTask)(function () { return _this21.context.set('model', { bar: 'Hola' }); }); this.assertText('Hola'); }; _proto['@test it reflects named arguments as properties'] = function testItReflectsNamedArgumentsAsProperties() { var _this22 = this; this.registerComponent('foo-bar', { template: '{{foo}}' }); this.render('{{foo-bar foo=model.bar}}', { model: { bar: 'Hola' } }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this22.rerender(); }); this.assertText('Hola'); (0, _internalTestHelpers.runTask)(function () { return _this22.context.set('model.bar', 'Hello'); }); this.assertText('Hello'); (0, _internalTestHelpers.runTask)(function () { return _this22.context.set('model', { bar: 'Hola' }); }); this.assertText('Hola'); }; _proto['@test it can render a basic component with a block'] = function testItCanRenderABasicComponentWithABlock() { var _this23 = this; this.registerComponent('foo-bar', { template: '{{yield}} - In component' }); this.render('{{#foo-bar}}hello{{/foo-bar}}'); this.assertComponentElement(this.firstChild, { content: 'hello - In component' }); (0, _internalTestHelpers.runTask)(function () { return _this23.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello - In component' }); }; _proto['@test it can render a basic component with a block when the yield is in a partial'] = function testItCanRenderABasicComponentWithABlockWhenTheYieldIsInAPartial() { var _this24 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this24.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' }); }; _proto['@test it can render a basic component with a block param when the yield is in a partial'] = function testItCanRenderABasicComponentWithABlockParamWhenTheYieldIsInAPartial() { var _this25 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this25.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'yielded: [hello] - In component' }); }; _proto['@test it renders the layout with the component instance as the context'] = function testItRendersTheLayoutWithTheComponentInstanceAsTheContext() { var _this26 = this; var instance; 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' }); (0, _internalTestHelpers.runTask)(function () { return _this26.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'message', 'goodbye'); }); this.assertComponentElement(this.firstChild, { content: 'goodbye' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'message', 'hello'); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; _proto['@test it preserves the outer context when yielding'] = function testItPreservesTheOuterContextWhenYielding() { var _this27 = this; this.registerComponent('foo-bar', { template: '{{yield}}' }); this.render('{{#foo-bar}}{{message}}{{/foo-bar}}', { message: 'hello' }); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this27.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this27.context, 'message', 'goodbye'); }); this.assertComponentElement(this.firstChild, { content: 'goodbye' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this27.context, 'message', 'hello'); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; _proto['@test it can yield a block param named for reserved words [GH#14096]'] = function testItCanYieldABlockParamNamedForReservedWordsGH14096() { var instance; 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(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'name', 'derp-qux'); }); this.assertComponentElement(this.firstChild, { content: 'derp-qux' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'name', 'foo-bar'); }); this.assertComponentElement(this.firstChild, { content: 'foo-bar' }); }; _proto['@test it can yield internal and external properties positionally'] = function testItCanYieldInternalAndExternalPropertiesPositionally() { var _this28 = this; var instance; 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' }); (0, _internalTestHelpers.runTask)(function () { return _this28.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this28.context, 'person', { firstName: 'Dora', lastName: 'the Explorer' }); }); this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'greeting', 'hola'); }); this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hola' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(instance, 'greeting', 'hello'); (0, _metal.set)(_this28.context, 'person', { firstName: 'Joel', lastName: 'Kang' }); }); this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' }); }; _proto['@test #11519 - block param infinite loop'] = function test11519BlockParamInfiniteLoop() { var _this29 = this; var instance; 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. (0, _internalTestHelpers.runTask)(function () { return _this29.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. (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'danger', 1); }); this.assertText('1'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'danger', 0); }); this.assertText('0'); }; _proto['@test the component and its child components are destroyed'] = function testTheComponentAndItsChildComponentsAreDestroyed(assert) { var _this30 = 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, _internalTestHelpers.strip)(_templateObject2()), { cond1: true, cond2: true, cond3: true, cond4: true, cond5: true }); this.assertText('1 2 3 4 5 6 7 8 '); (0, _internalTestHelpers.runTask)(function () { return _this30.rerender(); }); assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this30.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 }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this30.context, 'cond3', false); (0, _metal.set)(_this30.context, 'cond5', true); (0, _metal.set)(_this30.context, 'cond4', false); }); assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this30.context, 'cond2', false); (0, _metal.set)(_this30.context, 'cond1', false); }); assert.deepEqual(destroyed, { 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); }; _proto['@test should escape HTML in normal mustaches'] = function testShouldEscapeHTMLInNormalMustaches() { var _this31 = this; var component; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super.apply(this, arguments); component = this; }, output: 'you need to be more bold' }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{output}}' }); this.render('{{foo-bar}}'); this.assertText('you need to be more bold'); (0, _internalTestHelpers.runTask)(function () { return _this31.rerender(); }); this.assertText('you need to be more bold'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(component, 'output', 'you are so super'); }); this.assertText('you are so super'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(component, 'output', 'you need to be more bold'); }); }; _proto['@test should not escape HTML in triple mustaches'] = function testShouldNotEscapeHTMLInTripleMustaches() { var _this32 = this; var expectedHtmlBold = 'you need to be more bold'; var expectedHtmlItalic = 'you are so super'; var component; 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, _internalTestHelpers.equalTokens)(this.firstChild, expectedHtmlBold); (0, _internalTestHelpers.runTask)(function () { return _this32.rerender(); }); (0, _internalTestHelpers.equalTokens)(this.firstChild, expectedHtmlBold); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(component, 'output', expectedHtmlItalic); }); (0, _internalTestHelpers.equalTokens)(this.firstChild, expectedHtmlItalic); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(component, 'output', expectedHtmlBold); }); (0, _internalTestHelpers.equalTokens)(this.firstChild, expectedHtmlBold); }; _proto['@test should not escape HTML if string is a htmlSafe'] = function testShouldNotEscapeHTMLIfStringIsAHtmlSafe() { var _this33 = this; var expectedHtmlBold = 'you need to be more bold'; var expectedHtmlItalic = 'you are so super'; var component; 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, _internalTestHelpers.equalTokens)(this.firstChild, expectedHtmlBold); (0, _internalTestHelpers.runTask)(function () { return _this33.rerender(); }); (0, _internalTestHelpers.equalTokens)(this.firstChild, expectedHtmlBold); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(component, 'output', (0, _helpers.htmlSafe)(expectedHtmlItalic)); }); (0, _internalTestHelpers.equalTokens)(this.firstChild, expectedHtmlItalic); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(component, 'output', (0, _helpers.htmlSafe)(expectedHtmlBold)); }); (0, _internalTestHelpers.equalTokens)(this.firstChild, expectedHtmlBold); }; _proto['@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 Component from '@ember/component'; // import layout from './template'; // // export default 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); }; _proto['@test can use isStream property without conflict (#13271)'] = function testCanUseIsStreamPropertyWithoutConflict13271() { var _this34 = this; var component; var FooBarComponent = _helpers.Component.extend({ isStream: true, init: function () { this._super.apply(this, arguments); component = this; } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: (0, _internalTestHelpers.strip)(_templateObject3()) }); this.render('{{foo-bar}}'); this.assertComponentElement(this.firstChild, { content: 'true' }); (0, _internalTestHelpers.runTask)(function () { return _this34.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'true' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(component, 'isStream', false); }); this.assertComponentElement(this.firstChild, { content: 'false' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(component, 'isStream', true); }); this.assertComponentElement(this.firstChild, { content: 'true' }); }; _proto['@test lookup of component takes priority over property'] = function testLookupOfComponentTakesPriorityOverProperty() { var _this35 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this35.rerender(); }); this.assertText('some-prop some-component'); }; _proto['@feature(ember-glimmer-angle-bracket-built-ins) component without dash is looked up'] = function featureEmberGlimmerAngleBracketBuiltInsComponentWithoutDashIsLookedUp() { var _this36 = this; this.registerComponent('somecomponent', { template: 'somecomponent' }); this.render('{{somecomponent}}', { somecomponent: 'notsomecomponent' }); this.assertText('somecomponent'); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return _this36.context.set('somecomponent', 'not not notsomecomponent'); }); this.assertText('somecomponent'); (0, _internalTestHelpers.runTask)(function () { return _this36.context.set('somecomponent', 'notsomecomponent'); }); this.assertText('somecomponent'); }; _proto['@feature(!ember-glimmer-angle-bracket-built-ins) component without dash is not looked up'] = function featureEmberGlimmerAngleBracketBuiltInsComponentWithoutDashIsNotLookedUp() { var _this37 = this; this.registerComponent('somecomponent', { template: 'somecomponent' }); this.render('{{somecomponent}}', { somecomponent: 'notsomecomponent' }); this.assertText('notsomecomponent'); (0, _internalTestHelpers.runTask)(function () { return _this37.rerender(); }); this.assertText('notsomecomponent'); (0, _internalTestHelpers.runTask)(function () { return _this37.context.set('somecomponent', 'not not notsomecomponent'); }); this.assertText('not not notsomecomponent'); (0, _internalTestHelpers.runTask)(function () { return _this37.context.set('somecomponent', 'notsomecomponent'); }); this.assertText('notsomecomponent'); }; _proto['@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'); (0, _internalTestHelpers.runTask)(function () { return _this38.rerender(); }); this.assertText('In layout - someProp: something here'); (0, _internalTestHelpers.runTask)(function () { return _this38.context.set('prop', 'other thing there'); }); this.assertText('In layout - someProp: other thing there'); (0, _internalTestHelpers.runTask)(function () { return _this38.context.set('prop', 'something here'); }); this.assertText('In layout - someProp: something here'); }; _proto['@test non-block with named argument'] = function testNonBlockWithNamedArgument() { var _this39 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this39.rerender(); }); this.assertText('In layout - someProp: something here'); (0, _internalTestHelpers.runTask)(function () { return _this39.context.set('prop', 'other thing there'); }); this.assertText('In layout - someProp: other thing there'); (0, _internalTestHelpers.runTask)(function () { return _this39.context.set('prop', 'something here'); }); this.assertText('In layout - someProp: something here'); }; _proto['@test non-block with properties overridden in init'] = function testNonBlockWithPropertiesOverriddenInInit() { var _this40 = this; var instance; 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'); (0, _internalTestHelpers.runTask)(function () { return _this40.rerender(); }); this.assertText('In layout - someProp: value set in instance'); (0, _internalTestHelpers.runTask)(function () { return _this40.context.set('prop', 'updated something passed when invoked'); }); this.assertText('In layout - someProp: updated something passed when invoked'); (0, _internalTestHelpers.runTask)(function () { return instance.set('someProp', 'update value set in instance'); }); this.assertText('In layout - someProp: update value set in instance'); (0, _internalTestHelpers.runTask)(function () { return _this40.context.set('prop', 'something passed when invoked'); }); (0, _internalTestHelpers.runTask)(function () { return instance.set('someProp', 'value set in instance'); }); this.assertText('In layout - someProp: value set in instance'); }; _proto['@test rerendering component with attrs from parent'] = function testRerenderingComponentWithAttrsFromParent(assert) { var _this41 = 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 () { _this41.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 () { (0, _internalTestHelpers.runTask)(function () { return _this41.rerender(); }); }); this.assertText('In layout - someProp: wycats'); expectHooks({ willUpdate: true, didReceiveAttrs: true }, function () { (0, _internalTestHelpers.runTask)(function () { return _this41.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 () { (0, _internalTestHelpers.runTask)(function () { return _this41.rerender(); }); }); this.assertText('In layout - someProp: tomdale'); expectHooks({ willUpdate: true, didReceiveAttrs: true }, function () { (0, _internalTestHelpers.runTask)(function () { return _this41.context.set('someProp', 'wycats'); }); }); this.assertText('In layout - someProp: wycats'); }; _proto['@test this.attrs.foo === attrs.foo === @foo === foo'] = function testThisAttrsFooAttrsFooFooFoo() { var _this42 = this; this.registerComponent('foo-bar', { template: (0, _internalTestHelpers.strip)(_templateObject4()) }); this.render('{{foo-bar value=model.value items=model.items}}', { model: { value: 'wat', items: [1, 2, 3] } }); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { _this42.context.set('model.value', 'lul'); _this42.context.set('model.items', [1]); }); this.assertText((0, _internalTestHelpers.strip)(_templateObject5())); (0, _internalTestHelpers.runTask)(function () { return _this42.context.set('model', { value: 'wat', items: [1, 2, 3] }); }); this.assertText('Args: wat | wat | wat | wat123123123123'); }; _proto['@test non-block with properties on self'] = function testNonBlockWithPropertiesOnSelf() { var _this43 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this43.rerender(); }); this.assertText('In layout - someProp: something here'); (0, _internalTestHelpers.runTask)(function () { return _this43.context.set('prop', 'something else'); }); this.assertText('In layout - someProp: something else'); (0, _internalTestHelpers.runTask)(function () { return _this43.context.set('prop', 'something here'); }); this.assertText('In layout - someProp: something here'); }; _proto['@test block with properties on self'] = function testBlockWithPropertiesOnSelf() { var _this44 = this; this.registerComponent('with-block', { template: 'In layout - someProp: {{someProp}} - {{yield}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject6()), { prop: 'something here' }); this.assertText('In layout - someProp: something here - In template'); (0, _internalTestHelpers.runTask)(function () { return _this44.rerender(); }); this.assertText('In layout - someProp: something here - In template'); (0, _internalTestHelpers.runTask)(function () { return _this44.context.set('prop', 'something else'); }); this.assertText('In layout - someProp: something else - In template'); (0, _internalTestHelpers.runTask)(function () { return _this44.context.set('prop', 'something here'); }); this.assertText('In layout - someProp: something here - In template'); }; _proto['@test block with properties on attrs'] = function testBlockWithPropertiesOnAttrs() { var _this45 = this; this.registerComponent('with-block', { template: 'In layout - someProp: {{attrs.someProp}} - {{yield}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject7()), { prop: 'something here' }); this.assertText('In layout - someProp: something here - In template'); (0, _internalTestHelpers.runTask)(function () { return _this45.rerender(); }); this.assertText('In layout - someProp: something here - In template'); (0, _internalTestHelpers.runTask)(function () { return _this45.context.set('prop', 'something else'); }); this.assertText('In layout - someProp: something else - In template'); (0, _internalTestHelpers.runTask)(function () { return _this45.context.set('prop', 'something here'); }); this.assertText('In layout - someProp: something here - In template'); }; _proto['@test block with named argument'] = function testBlockWithNamedArgument() { var _this46 = this; this.registerComponent('with-block', { template: 'In layout - someProp: {{@someProp}} - {{yield}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject8()), { prop: 'something here' }); this.assertText('In layout - someProp: something here - In template'); (0, _internalTestHelpers.runTask)(function () { return _this46.rerender(); }); this.assertText('In layout - someProp: something here - In template'); (0, _internalTestHelpers.runTask)(function () { return _this46.context.set('prop', 'something else'); }); this.assertText('In layout - someProp: something else - In template'); (0, _internalTestHelpers.runTask)(function () { return _this46.context.set('prop', 'something here'); }); this.assertText('In layout - someProp: something here - In template'); }; _proto['@test static arbitrary number of positional parameters'] = function testStaticArbitraryNumberOfPositionalParameters(assert) { var _this47 = this; this.registerComponent('sample-component', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'names' }), template: (0, _internalTestHelpers.strip)(_templateObject9()) }); this.render((0, _internalTestHelpers.strip)(_templateObject10())); assert.equal(this.$('#args-3').text(), 'Foo4Bar'); assert.equal(this.$('#args-5').text(), 'Foo4Bar5Baz'); (0, _internalTestHelpers.runTask)(function () { return _this47.rerender(); }); assert.equal(this.$('#args-3').text(), 'Foo4Bar'); assert.equal(this.$('#args-5').text(), 'Foo4Bar5Baz'); }; _proto['@test arbitrary positional parameter conflict with hash parameter is reported'] = function testArbitraryPositionalParameterConflictWithHashParameterIsReported() { var _this48 = this; this.registerComponent('sample-component', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'names' }), template: (0, _internalTestHelpers.strip)(_templateObject11()) }); expectAssertion(function () { _this48.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`.'); }; _proto['@test can use hash parameter instead of arbitrary positional param [GH #12444]'] = function testCanUseHashParameterInsteadOfArbitraryPositionalParamGH12444() { var _this49 = this; this.registerComponent('sample-component', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'names' }), template: (0, _internalTestHelpers.strip)(_templateObject12()) }); this.render('{{sample-component names=things}}', { things: (0, _runtime.A)(['Foo', 4, 'Bar']) }); this.assertText('Foo4Bar'); (0, _internalTestHelpers.runTask)(function () { return _this49.rerender(); }); this.assertText('Foo4Bar'); (0, _internalTestHelpers.runTask)(function () { return _this49.context.get('things').pushObject(5); }); this.assertText('Foo4Bar5'); (0, _internalTestHelpers.runTask)(function () { return _this49.context.get('things').shiftObject(); }); this.assertText('4Bar5'); (0, _internalTestHelpers.runTask)(function () { return _this49.context.get('things').clear(); }); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return _this49.context.set('things', (0, _runtime.A)(['Foo', 4, 'Bar'])); }); this.assertText('Foo4Bar'); }; _proto['@test can use hash parameter instead of positional param'] = function testCanUseHashParameterInsteadOfPositionalParam(assert) { var _this50 = 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, _internalTestHelpers.strip)(_templateObject13())); assert.equal(this.$('#two-positional').text(), 'one - two'); assert.equal(this.$('#one-positional').text(), 'one - two'); assert.equal(this.$('#no-positional').text(), 'one - two'); (0, _internalTestHelpers.runTask)(function () { return _this50.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'); }; _proto['@test dynamic arbitrary number of positional parameters'] = function testDynamicArbitraryNumberOfPositionalParameters() { var _this51 = this; this.registerComponent('sample-component', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'n' }), template: (0, _internalTestHelpers.strip)(_templateObject14()) }); this.render("{{sample-component user1 user2}}", { user1: 'Foo', user2: 4 }); this.assertText('Foo4'); (0, _internalTestHelpers.runTask)(function () { return _this51.rerender(); }); this.assertText('Foo4'); (0, _internalTestHelpers.runTask)(function () { return _this51.context.set('user1', 'Bar'); }); this.assertText('Bar4'); (0, _internalTestHelpers.runTask)(function () { return _this51.context.set('user2', '5'); }); this.assertText('Bar5'); (0, _internalTestHelpers.runTask)(function () { _this51.context.set('user1', 'Foo'); _this51.context.set('user2', 4); }); this.assertText('Foo4'); }; _proto['@test with ariaRole specified'] = function testWithAriaRoleSpecified() { var _this52 = this; this.registerComponent('aria-test', { template: 'Here!' }); this.render('{{aria-test ariaRole=role}}', { role: 'main' }); this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } }); (0, _internalTestHelpers.runTask)(function () { return _this52.rerender(); }); this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } }); (0, _internalTestHelpers.runTask)(function () { return _this52.context.set('role', 'input'); }); this.assertComponentElement(this.firstChild, { attrs: { role: 'input' } }); (0, _internalTestHelpers.runTask)(function () { return _this52.context.set('role', 'main'); }); this.assertComponentElement(this.firstChild, { attrs: { role: 'main' } }); }; _proto['@test with ariaRole defined but initially falsey GH#16379'] = function testWithAriaRoleDefinedButInitiallyFalseyGH16379() { var _this53 = this; this.registerComponent('aria-test', { template: 'Here!' }); this.render('{{aria-test ariaRole=role}}', { role: undefined }); this.assertComponentElement(this.firstChild, { attrs: {} }); (0, _internalTestHelpers.runTask)(function () { return _this53.rerender(); }); this.assertComponentElement(this.firstChild, { attrs: {} }); (0, _internalTestHelpers.runTask)(function () { return _this53.context.set('role', 'input'); }); this.assertComponentElement(this.firstChild, { attrs: { role: 'input' } }); (0, _internalTestHelpers.runTask)(function () { return _this53.context.set('role', undefined); }); this.assertComponentElement(this.firstChild, { attrs: {} }); }; _proto['@test without ariaRole defined initially'] = function testWithoutAriaRoleDefinedInitially() { var _this54 = this; // we are using the ability to lazily add a role as a sign that we are // doing extra work var instance; this.registerComponent('aria-test', { ComponentClass: _helpers.Component.extend({ init: function () { this._super.apply(this, arguments); instance = this; } }), template: 'Here!' }); this.render('{{aria-test}}'); this.assertComponentElement(this.firstChild, { attrs: {} }); (0, _internalTestHelpers.runTask)(function () { return _this54.rerender(); }); this.assertComponentElement(this.firstChild, { attrs: {} }); (0, _internalTestHelpers.runTask)(function () { return instance.set('ariaRole', 'input'); }); this.assertComponentElement(this.firstChild, { attrs: {} }); }; _proto['@test `template` specified in component is overridden by block'] = function testTemplateSpecifiedInComponentIsOverriddenByBlock() { var _this55 = 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, _internalTestHelpers.strip)(_templateObject15()), { name: 'Whoop, whoop!' }); this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] '); (0, _internalTestHelpers.runTask)(function () { return _this55.rerender(); }); this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] '); (0, _internalTestHelpers.runTask)(function () { return _this55.context.set('name', 'Ole, ole'); }); this.assertText('[In layout - with-block] [In block - Ole, ole][In layout - without-block] '); (0, _internalTestHelpers.runTask)(function () { return _this55.context.set('name', 'Whoop, whoop!'); }); this.assertText('[In layout - with-block] [In block - Whoop, whoop!][In layout - without-block] '); }; _proto['@test hasBlock is true when block supplied'] = function testHasBlockIsTrueWhenBlockSupplied() { var _this56 = this; this.registerComponent('with-block', { template: (0, _internalTestHelpers.strip)(_templateObject16()) }); this.render((0, _internalTestHelpers.strip)(_templateObject17())); this.assertText('In template'); (0, _internalTestHelpers.runTask)(function () { return _this56.rerender(); }); this.assertText('In template'); }; _proto['@test hasBlock is false when no block supplied'] = function testHasBlockIsFalseWhenNoBlockSupplied() { var _this57 = this; this.registerComponent('with-block', { template: (0, _internalTestHelpers.strip)(_templateObject18()) }); this.render('{{with-block}}'); this.assertText('No Block!'); (0, _internalTestHelpers.runTask)(function () { return _this57.rerender(); }); this.assertText('No Block!'); }; _proto['@test hasBlockParams is true when block param supplied'] = function testHasBlockParamsIsTrueWhenBlockParamSupplied() { var _this58 = this; this.registerComponent('with-block', { template: (0, _internalTestHelpers.strip)(_templateObject19()) }); this.render((0, _internalTestHelpers.strip)(_templateObject20())); this.assertText('In template - In Component'); (0, _internalTestHelpers.runTask)(function () { return _this58.rerender(); }); this.assertText('In template - In Component'); }; _proto['@test hasBlockParams is false when no block param supplied'] = function testHasBlockParamsIsFalseWhenNoBlockParamSupplied() { var _this59 = this; this.registerComponent('with-block', { template: (0, _internalTestHelpers.strip)(_templateObject21()) }); this.render((0, _internalTestHelpers.strip)(_templateObject22())); this.assertText('In block No Block Param!'); (0, _internalTestHelpers.runTask)(function () { return _this59.rerender(); }); this.assertText('In block No Block Param!'); }; _proto['@test static named positional parameters'] = function testStaticNamedPositionalParameters() { var _this60 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this60.rerender(); }); this.assertText('Quint4'); }; _proto['@test dynamic named positional parameters'] = function testDynamicNamedPositionalParameters() { var _this61 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this61.rerender(); }); this.assertText('Quint4'); (0, _internalTestHelpers.runTask)(function () { return _this61.context.set('myName', 'Sergio'); }); this.assertText('Sergio4'); (0, _internalTestHelpers.runTask)(function () { return _this61.context.set('myAge', 2); }); this.assertText('Sergio2'); (0, _internalTestHelpers.runTask)(function () { _this61.context.set('myName', 'Quint'); _this61.context.set('myAge', 4); }); this.assertText('Quint4'); }; _proto['@test if a value is passed as a non-positional parameter, it raises an assertion'] = function testIfAValueIsPassedAsANonPositionalParameterItRaisesAnAssertion() { var _this62 = this; this.registerComponent('sample-component', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: ['name'] }), template: '{{name}}' }); expectAssertion(function () { _this62.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`.'); }; _proto['@test yield to inverse'] = function testYieldToInverse() { var _this63 = this; this.registerComponent('my-if', { template: (0, _internalTestHelpers.strip)(_templateObject23()) }); this.render((0, _internalTestHelpers.strip)(_templateObject24()), { activated: true }); this.assertText('Yes:Hello42'); (0, _internalTestHelpers.runTask)(function () { return _this63.rerender(); }); this.assertText('Yes:Hello42'); (0, _internalTestHelpers.runTask)(function () { return _this63.context.set('activated', false); }); this.assertText('No:Goodbye'); (0, _internalTestHelpers.runTask)(function () { return _this63.context.set('activated', true); }); this.assertText('Yes:Hello42'); }; _proto['@test expression hasBlock inverse'] = function testExpressionHasBlockInverse() { this.registerComponent('check-inverse', { template: (0, _internalTestHelpers.strip)(_templateObject25()) }); this.render((0, _internalTestHelpers.strip)(_templateObject26())); this.assertComponentElement(this.firstChild, { content: 'No' }); this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); this.assertStableRerender(); }; _proto['@test expression hasBlock default'] = function testExpressionHasBlockDefault() { this.registerComponent('check-block', { template: (0, _internalTestHelpers.strip)(_templateObject27()) }); this.render((0, _internalTestHelpers.strip)(_templateObject28())); this.assertComponentElement(this.firstChild, { content: 'No' }); this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); this.assertStableRerender(); }; _proto['@test expression hasBlockParams inverse'] = function testExpressionHasBlockParamsInverse() { this.registerComponent('check-inverse', { template: (0, _internalTestHelpers.strip)(_templateObject29()) }); this.render((0, _internalTestHelpers.strip)(_templateObject30())); this.assertComponentElement(this.firstChild, { content: 'No' }); this.assertComponentElement(this.nthChild(1), { content: 'No' }); this.assertStableRerender(); }; _proto['@test expression hasBlockParams default'] = function testExpressionHasBlockParamsDefault() { this.registerComponent('check-block', { template: (0, _internalTestHelpers.strip)(_templateObject31()) }); this.render((0, _internalTestHelpers.strip)(_templateObject32())); this.assertComponentElement(this.firstChild, { content: 'No' }); this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); this.assertStableRerender(); }; _proto['@test non-expression hasBlock'] = function testNonExpressionHasBlock() { this.registerComponent('check-block', { template: (0, _internalTestHelpers.strip)(_templateObject33()) }); this.render((0, _internalTestHelpers.strip)(_templateObject34())); this.assertComponentElement(this.firstChild, { content: 'No' }); this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); this.assertStableRerender(); }; _proto['@test expression hasBlockParams'] = function testExpressionHasBlockParams() { this.registerComponent('check-params', { template: (0, _internalTestHelpers.strip)(_templateObject35()) }); this.render((0, _internalTestHelpers.strip)(_templateObject36())); this.assertComponentElement(this.firstChild, { content: 'No' }); this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); this.assertStableRerender(); }; _proto['@test non-expression hasBlockParams'] = function testNonExpressionHasBlockParams() { this.registerComponent('check-params', { template: (0, _internalTestHelpers.strip)(_templateObject37()) }); this.render((0, _internalTestHelpers.strip)(_templateObject38())); this.assertComponentElement(this.firstChild, { content: 'No' }); this.assertComponentElement(this.nthChild(1), { content: 'Yes' }); this.assertStableRerender(); }; _proto['@test hasBlock expression in an attribute'] = function testHasBlockExpressionInAnAttribute(assert) { this.registerComponent('check-attr', { template: '' }); this.render((0, _internalTestHelpers.strip)(_templateObject39())); (0, _internalTestHelpers.equalsElement)(assert, this.$('button')[0], 'button', { name: 'false' }, ''); (0, _internalTestHelpers.equalsElement)(assert, this.$('button')[1], 'button', { name: 'true' }, ''); this.assertStableRerender(); }; _proto['@test hasBlock inverse expression in an attribute'] = function testHasBlockInverseExpressionInAnAttribute(assert) { this.registerComponent('check-attr', { template: '' }, ''); this.render((0, _internalTestHelpers.strip)(_templateObject40())); (0, _internalTestHelpers.equalsElement)(assert, this.$('button')[0], 'button', { name: 'false' }, ''); (0, _internalTestHelpers.equalsElement)(assert, this.$('button')[1], 'button', { name: 'true' }, ''); this.assertStableRerender(); }; _proto['@test hasBlockParams expression in an attribute'] = function testHasBlockParamsExpressionInAnAttribute(assert) { this.registerComponent('check-attr', { template: '' }); this.render((0, _internalTestHelpers.strip)(_templateObject41())); (0, _internalTestHelpers.equalsElement)(assert, this.$('button')[0], 'button', { name: 'false' }, ''); (0, _internalTestHelpers.equalsElement)(assert, this.$('button')[1], 'button', { name: 'true' }, ''); this.assertStableRerender(); }; _proto['@test hasBlockParams inverse expression in an attribute'] = function testHasBlockParamsInverseExpressionInAnAttribute(assert) { this.registerComponent('check-attr', { template: '' }, ''); this.render((0, _internalTestHelpers.strip)(_templateObject42())); (0, _internalTestHelpers.equalsElement)(assert, this.$('button')[0], 'button', { name: 'false' }, ''); (0, _internalTestHelpers.equalsElement)(assert, this.$('button')[1], 'button', { name: 'false' }, ''); this.assertStableRerender(); }; _proto['@test hasBlock as a param to a helper'] = function testHasBlockAsAParamToAHelper() { this.registerComponent('check-helper', { template: '{{if hasBlock "true" "false"}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject43())); this.assertComponentElement(this.firstChild, { content: 'false' }); this.assertComponentElement(this.nthChild(1), { content: 'true' }); this.assertStableRerender(); }; _proto['@test hasBlock as an expression param to a helper'] = function testHasBlockAsAnExpressionParamToAHelper() { this.registerComponent('check-helper', { template: '{{if (hasBlock) "true" "false"}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject44())); this.assertComponentElement(this.firstChild, { content: 'false' }); this.assertComponentElement(this.nthChild(1), { content: 'true' }); this.assertStableRerender(); }; _proto['@test hasBlock inverse as a param to a helper'] = function testHasBlockInverseAsAParamToAHelper() { this.registerComponent('check-helper', { template: '{{if (hasBlock "inverse") "true" "false"}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject45())); this.assertComponentElement(this.firstChild, { content: 'false' }); this.assertComponentElement(this.nthChild(1), { content: 'true' }); this.assertStableRerender(); }; _proto['@test hasBlockParams as a param to a helper'] = function testHasBlockParamsAsAParamToAHelper() { this.registerComponent('check-helper', { template: '{{if hasBlockParams "true" "false"}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject46())); this.assertComponentElement(this.firstChild, { content: 'false' }); this.assertComponentElement(this.nthChild(1), { content: 'true' }); this.assertStableRerender(); }; _proto['@test hasBlockParams as an expression param to a helper'] = function testHasBlockParamsAsAnExpressionParamToAHelper() { this.registerComponent('check-helper', { template: '{{if (hasBlockParams) "true" "false"}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject47())); this.assertComponentElement(this.firstChild, { content: 'false' }); this.assertComponentElement(this.nthChild(1), { content: 'true' }); this.assertStableRerender(); }; _proto['@test hasBlockParams inverse as a param to a helper'] = function testHasBlockParamsInverseAsAParamToAHelper() { this.registerComponent('check-helper', { template: '{{if (hasBlockParams "inverse") "true" "false"}}' }); this.render((0, _internalTestHelpers.strip)(_templateObject48())); this.assertComponentElement(this.firstChild, { content: 'false' }); this.assertComponentElement(this.nthChild(1), { content: 'false' }); this.assertStableRerender(); }; _proto['@test component in template of a yielding component should have the proper parentView'] = function testComponentInTemplateOfAYieldingComponentShouldHaveTheProperParentView(assert) { var _this64 = this; var outer, innerTemplate, innerLayout; 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'); (0, _internalTestHelpers.runTask)(function () { return _this64.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'); }; _proto['@test newly-added sub-components get correct parentView'] = function testNewlyAddedSubComponentsGetCorrectParentView(assert) { var _this65 = this; var outer, inner; 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, _internalTestHelpers.strip)(_templateObject49()), { showInner: false }); assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); (0, _internalTestHelpers.runTask)(function () { return _this65.rerender(); }); assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView (after rerender)'); (0, _internalTestHelpers.runTask)(function () { return _this65.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'); (0, _internalTestHelpers.runTask)(function () { return _this65.context.set('showInner', false); }); assert.equal(outer.parentView, this.context, 'x-outer receives the ambient scope as its parentView'); }; _proto["@test when a property is changed during children's rendering"] = function testWhenAPropertyIsChangedDuringChildrenSRendering(assert) { var _this66 = this; var outer, middle; 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: '
{{value}}
{{yield}}' }); this.registerComponent('x-inner', { ComponentClass: _helpers.Component.extend({ value: null, pushDataUp: (0, _metal.observer)('value', function () { middle.set('value', this.get('value')); }) }), template: '
{{value}}
' }); 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)'); (0, _internalTestHelpers.runTask)(function () { return _this66.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"/; expectAssertion(function () { (0, _internalTestHelpers.runTask)(function () { return outer.set('value', 2); }); }, expectedBacktrackingMessage); }; _proto["@test when a shared dependency is changed during children's rendering"] = function testWhenASharedDependencyIsChangedDuringChildrenSRendering() { var _this67 = this; this.registerComponent('x-outer', { ComponentClass: _helpers.Component.extend({ value: 1, wrapper: _runtime.Object.create({ content: null }) }), template: '
{{wrapper.content}}
{{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: '
{{wrapper.content}}
' }); var expectedBacktrackingMessage = /modified "wrapper\.content" twice on <.+?> in a single render\. It was rendered in "component:x-outer" and modified in "component:x-inner"/; expectAssertion(function () { _this67.render('{{x-outer}}'); }, expectedBacktrackingMessage); }; _proto['@test non-block with each rendering child components'] = function testNonBlockWithEachRenderingChildComponents() { var _this68 = this; this.registerComponent('non-block', { template: (0, _internalTestHelpers.strip)(_templateObject50()) }); this.registerComponent('child-non-block', { template: 'Child: {{item}}.' }); var items = (0, _runtime.A)(['Tom', 'Dick', 'Harry']); this.render('{{non-block items=items}}', { items: items }); this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); (0, _internalTestHelpers.runTask)(function () { return _this68.rerender(); }); this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); (0, _internalTestHelpers.runTask)(function () { return _this68.context.get('items').pushObject('Sergio'); }); this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.][Child: Sergio.]'); (0, _internalTestHelpers.runTask)(function () { return _this68.context.get('items').shiftObject(); }); this.assertText('In layout. [Child: Dick.][Child: Harry.][Child: Sergio.]'); (0, _internalTestHelpers.runTask)(function () { return _this68.context.set('items', (0, _runtime.A)(['Tom', 'Dick', 'Harry'])); }); this.assertText('In layout. [Child: Tom.][Child: Dick.][Child: Harry.]'); }; _proto['@test specifying classNames results in correct class'] = function testSpecifyingClassNamesResultsInCorrectClass(assert) { var _this69 = this; this.registerComponent('some-clicky-thing', { ComponentClass: _helpers.Component.extend({ tagName: 'button', classNames: ['foo', 'bar'] }) }); this.render((0, _internalTestHelpers.strip)(_templateObject51())); // 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, _internalTestHelpers.classes)(expectedClassNames.join(' ')) } }); (0, _internalTestHelpers.runTask)(function () { return _this69.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, _internalTestHelpers.classes)(expectedClassNames.join(' ')) } }); }; _proto['@test specifying custom concatenatedProperties avoids clobbering'] = function testSpecifyingCustomConcatenatedPropertiesAvoidsClobbering() { var _this70 = this; this.registerComponent('some-clicky-thing', { ComponentClass: _helpers.Component.extend({ concatenatedProperties: ['blahzz'], blahzz: ['blark', 'pory'] }), template: (0, _internalTestHelpers.strip)(_templateObject52()) }); this.render((0, _internalTestHelpers.strip)(_templateObject53())); this.assertText('blarkporybaz- Click Me'); (0, _internalTestHelpers.runTask)(function () { return _this70.rerender(); }); this.assertText('blarkporybaz- Click Me'); }; _proto['@test a two way binding flows upstream when consumed in the template'] = function testATwoWayBindingFlowsUpstreamWhenConsumedInTheTemplate() { var _this71 = this; var component; 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'); (0, _internalTestHelpers.runTask)(function () { return _this71.rerender(); }); this.assertText('initial value - initial value'); if (false /* DEBUG */ ) { 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'); } (0, _internalTestHelpers.runTask)(function () { component.set('bar', 'updated value'); }); this.assertText('updated value - updated value'); (0, _internalTestHelpers.runTask)(function () { component.set('bar', undefined); }); this.assertText(' - '); (0, _internalTestHelpers.runTask)(function () { _this71.component.set('localBar', 'initial value'); }); this.assertText('initial value - initial value'); }; _proto['@test a two way binding flows upstream through a CP when consumed in the template'] = function testATwoWayBindingFlowsUpstreamThroughACPWhenConsumedInTheTemplate() { var _this72 = this; var component; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super.apply(this, arguments); component = this; }, bar: (0, _metal.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'); (0, _internalTestHelpers.runTask)(function () { return _this72.rerender(); }); this.assertText('initial value - initial value'); (0, _internalTestHelpers.runTask)(function () { component.set('bar', 'updated value'); }); this.assertText('updated value - updated value'); (0, _internalTestHelpers.runTask)(function () { _this72.component.set('localBar', 'initial value'); }); this.assertText('initial value - initial value'); }; _proto['@test a two way binding flows upstream through a CP without template consumption'] = function testATwoWayBindingFlowsUpstreamThroughACPWithoutTemplateConsumption() { var _this73 = this; var component; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super.apply(this, arguments); component = this; }, bar: (0, _metal.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'); (0, _internalTestHelpers.runTask)(function () { return _this73.rerender(); }); this.assertText('initial value'); (0, _internalTestHelpers.runTask)(function () { component.set('bar', 'updated value'); }); this.assertText('updated value'); (0, _internalTestHelpers.runTask)(function () { _this73.component.set('localBar', 'initial value'); }); this.assertText('initial value'); }; _proto['@test services can be injected into components'] = function testServicesCanBeInjectedIntoComponents() { var _this74 = this; var service; this.registerService('name', _service.default.extend({ init: function () { this._super.apply(this, arguments); service = this; }, last: 'Jackson' })); this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ name: (0, _service.inject)() }), template: '{{name.last}}' }); this.render('{{foo-bar}}'); this.assertText('Jackson'); (0, _internalTestHelpers.runTask)(function () { return _this74.rerender(); }); this.assertText('Jackson'); (0, _internalTestHelpers.runTask)(function () { service.set('last', 'McGuffey'); }); this.assertText('McGuffey'); (0, _internalTestHelpers.runTask)(function () { service.set('last', 'Jackson'); }); this.assertText('Jackson'); }; _proto['@test injecting an unknown service raises an exception'] = function testInjectingAnUnknownServiceRaisesAnException() { var _this75 = this; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ missingService: (0, _service.inject)() }) }); expectAssertion(function () { _this75.render('{{foo-bar}}'); }, "Attempting to inject an unknown injection: 'service:missingService'"); }; _proto['@test throws if `this._super` is not called from `init`'] = function testThrowsIfThis_superIsNotCalledFromInit() { var _this76 = this; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ init: function () {} }) }); expectAssertion(function () { _this76.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`./); }; _proto['@test should toggle visibility with isVisible'] = function testShouldToggleVisibilityWithIsVisible(assert) { var _this77 = this; var assertStyle = function (expected) { var matcher = (0, _internalTestHelpers.styles)(expected); var actual = _this77.firstChild.getAttribute('style'); assert.pushResult({ result: matcher.match(actual), message: matcher.message(), actual: actual, expected: expected }); }; this.registerComponent('foo-bar', { template: "

foo

" }); this.render("{{foo-bar id=\"foo-bar\" isVisible=visible}}", { visible: false }); assertStyle('display: none;'); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this77.context, 'visible', true); }); assertStyle(''); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this77.context, 'visible', false); }); assertStyle('display: none;'); }; _proto['@test isVisible does not overwrite component style'] = function testIsVisibleDoesNotOverwriteComponentStyle() { var _this78 = this; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ attributeBindings: ['style'], style: (0, _helpers.htmlSafe)('color: blue;') }), template: "

foo

" }); this.render("{{foo-bar id=\"foo-bar\" isVisible=visible}}", { visible: false }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'foo-bar', style: (0, _internalTestHelpers.styles)('color: blue; display: none;') } }); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this78.context, 'visible', true); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'foo-bar', style: (0, _internalTestHelpers.styles)('color: blue;') } }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this78.context, 'visible', false); }); this.assertComponentElement(this.firstChild, { tagName: 'div', attrs: { id: 'foo-bar', style: (0, _internalTestHelpers.styles)('color: blue; display: none;') } }); }; _proto['@test adds isVisible binding when style binding is missing and other bindings exist'] = function testAddsIsVisibleBindingWhenStyleBindingIsMissingAndOtherBindingsExist(assert) { var _this79 = this; var assertStyle = function (expected) { var matcher = (0, _internalTestHelpers.styles)(expected); var actual = _this79.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: "

foo

" }); this.render("{{foo-bar id=\"foo-bar\" foo=foo isVisible=visible}}", { visible: false, foo: 'baz' }); assertStyle('display: none;'); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this79.context, 'visible', true); }); assertStyle(''); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this79.context, 'visible', false); (0, _metal.set)(_this79.context, 'foo', 'woo'); }); assertStyle('display: none;'); assert.equal(this.firstChild.getAttribute('foo'), 'woo'); }; _proto['@test it can use readDOMAttr to read input value'] = function testItCanUseReadDOMAttrToReadInputValue() { var _this80 = this; var component; var assertElement = function (expectedValue) { // value is a property, not an attribute _this80.assertHTML(""); _this80.assert.equal(_this80.firstChild.value, expectedValue, 'value property is correct'); _this80.assert.equal((0, _metal.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(); (0, _internalTestHelpers.runTask)(function () { _this80.firstChild.value = 'bar'; _this80.$('input').trigger('change'); }); assertElement('bar'); (0, _internalTestHelpers.runTask)(function () { _this80.firstChild.value = 'foo'; _this80.$('input').trigger('change'); }); assertElement('foo'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(component, 'value', 'bar'); }); assertElement('bar'); (0, _internalTestHelpers.runTask)(function () { _this80.firstChild.value = 'foo'; _this80.$('input').trigger('change'); }); assertElement('foo'); }; _proto['@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, _runtime.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, _metal.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, _internalTestHelpers.strip)(_templateObject54())); this.teardown(); this.assert.ok(true, 'no errors during teardown'); }; _proto['@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'); }; _proto['@test didReceiveAttrs fires after .init() but before observers become active'] = function testDidReceiveAttrsFiresAfterInitButBeforeObserversBecomeActive(assert) { var _this81 = this; var barCopyDidChangeCount = 0; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ init: function () { this._super.apply(this, arguments); this.didInit = true; }, didReceiveAttrs: function () { assert.ok(this.didInit, 'expected init to have run before didReceiveAttrs'); this.set('barCopy', this.attrs.bar.value + 1); }, barCopyDidChange: (0, _metal.observer)('barCopy', function () { barCopyDidChangeCount++; }) }), template: '{{bar}}-{{barCopy}}' }); this.render("{{foo-bar bar=bar}}", { bar: 3 }); this.assertText('3-4'); assert.strictEqual(barCopyDidChangeCount, 1, 'expected observer firing for: barCopy'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this81.context, 'bar', 7); }); this.assertText('7-8'); assert.strictEqual(barCopyDidChangeCount, 2, 'expected observer firing for: barCopy'); }; _proto['@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 }); }; _proto['@test overriding didUpdateAttrs does not trigger deprecation'] = function testOverridingDidUpdateAttrsDoesNotTriggerDeprecation(assert) { var _this82 = 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 }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this82.context, 'foo', 5); }); }; _proto['@test returning `true` from an action does not bubble if `target` is not specified (GH#14275)'] = function testReturningTrueFromAnActionDoesNotBubbleIfTargetIsNotSpecifiedGH14275(assert) { var _this83 = this; this.registerComponent('display-toggle', { ComponentClass: _helpers.Component.extend({ actions: { show: function () { assert.ok(true, 'display-toggle show action was called'); return true; } } }), template: "" }); this.render("{{display-toggle}}", { send: function () { assert.notOk(true, 'send should not be called when action is not "subscribed" to'); } }); this.assertText('Show'); (0, _internalTestHelpers.runTask)(function () { return _this83.$('button').click(); }); }; _proto['@test returning `true` from an action bubbles to the `target` if specified'] = function testReturningTrueFromAnActionBubblesToTheTargetIfSpecified(assert) { var _this84 = 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: "" }); 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'); (0, _internalTestHelpers.runTask)(function () { return _this84.$('button').click(); }); }; _proto['@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 = new 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, _metal.on)('someMethod', function () { for (var _len2 = arguments.length, data = new 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, _metal.on)('someTruthyProperty', function () { for (var _len3 = arguments.length, data = new 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}}"); }; _proto['@test component yielding in an {{#each}} has correct block values after rerendering (GH#14284)'] = function testComponentYieldingInAnEachHasCorrectBlockValuesAfterRerenderingGH14284() { var _this85 = this; this.registerComponent('list-items', { template: "{{#each items as |item|}}{{yield item}}{{/each}}" }); this.render((0, _internalTestHelpers.strip)(_templateObject55()), { editMode: false, items: ['foo', 'bar', 'qux', 'baz'] }); this.assertText('|foo||bar||qux||baz|'); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this85.context, 'editMode', true); }); this.assertText('|foo|Remove foo|bar|Remove bar|qux|Remove qux|baz|Remove baz'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this85.context, 'editMode', false); }); this.assertText('|foo||bar||qux||baz|'); }; _proto['@test unimplimented positionalParams do not cause an error GH#14416'] = function testUnimplimentedPositionalParamsDoNotCauseAnErrorGH14416() { this.registerComponent('foo-bar', { template: 'hello' }); this.render('{{foo-bar wat}}'); this.assertText('hello'); }; _proto['@test using attrs for positional params'] = function testUsingAttrsForPositionalParams() { 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'); }; _proto['@test using named arguments for positional params'] = function testUsingNamedArgumentsForPositionalParams() { var MyComponent = _helpers.Component.extend(); this.registerComponent('foo-bar', { ComponentClass: MyComponent.reopenClass({ positionalParams: ['myVar'] }), template: 'MyVar1: {{@myVar}} {{myVar}} MyVar2: {{myVar2}} {{@myVar2}}' }); this.render('{{foo-bar 1 myVar2=2}}'); this.assertText('MyVar1: 1 1 MyVar2: 2 2'); }; _proto["@test can use `{{this}}` to emit the component's toString value [GH#14581]"] = function testCanUseThisToEmitTheComponentSToStringValueGH14581() { 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!'); }; _proto['@test can use `{{this` to access paths on current context [GH#14581]'] = function testCanUseThisToAccessPathsOnCurrentContextGH14581() { var instance; 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(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'foo.bar.baz', 'yippie!'); }); this.assertText('yippie!'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'foo.bar.baz', 'huzzah!'); }); this.assertText('huzzah!'); }; _proto['@test can use custom element in component layout'] = function testCanUseCustomElementInComponentLayout() { this.registerComponent('foo-bar', { template: 'Hi!' }); this.render('{{foo-bar}}'); this.assertText('Hi!'); }; _proto['@test can use nested custom element in component layout'] = function testCanUseNestedCustomElementInComponentLayout() { this.registerComponent('foo-bar', { template: 'Hi!' }); this.render('{{foo-bar}}'); this.assertText('Hi!'); }; _proto['@test can access properties off of rest style positionalParams array'] = function testCanAccessPropertiesOffOfRestStylePositionalParamsArray() { this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'things' }), template: "{{@things.length}}" }); this.render('{{foo-bar "foo" "bar" "baz"}}'); this.assertText('3'); }; _proto['@test has attrs by didReceiveAttrs with native classes'] = function testHasAttrsByDidReceiveAttrsWithNativeClasses(assert) { var FooBarComponent = /*#__PURE__*/ function (_Component) { (0, _emberBabel.inheritsLoose)(FooBarComponent, _Component); function FooBarComponent(injections) { var _this86; _this86 = _Component.call(this, injections) || this; // analagous to class field defaults _this86.foo = 'bar'; return _this86; } var _proto2 = FooBarComponent.prototype; _proto2.didReceiveAttrs = function didReceiveAttrs() { assert.equal(this.foo, 'bar', 'received default attrs correctly'); }; return FooBarComponent; }(_helpers.Component); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); this.render('{{foo-bar}}'); }; _proto['@test ensure aliases are watched properly [GH#17243]'] = function testEnsureAliasesAreWatchedProperlyGH17243() { var fooInstance, barInstance; var FooComponent = _helpers.Component.extend({ source: 'first', foo: (0, _metal.alias)('source'), init: function () { this._super.apply(this, arguments); fooInstance = this; } }); this.registerComponent('foo', { ComponentClass: FooComponent, template: '{{this.foo}}' }); var BarComponent = _helpers.Component.extend({ target: null, init: function () { this._super.apply(this, arguments); barInstance = this; }, bar: (0, _metal.computed)('target.foo', function () { if (this.target) { return this.target.foo.toUpperCase(); } }) }); this.registerComponent('bar', { ComponentClass: BarComponent, template: '{{this.bar}}' }); this.render('[][]'); this.assertText('[first][]'); // addObserver (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(barInstance, 'target', fooInstance); }); this.assertText('[first][FIRST]'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(fooInstance, 'source', 'second'); }); this.assertText('[second][SECOND]'); // removeObserver (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(barInstance, 'target', null); }); this.assertText('[second][]'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(fooInstance, 'source', 'third'); }); this.assertText('[third][]'); }; return _class; }(_internalTestHelpers.RenderingTestCase)); if (_views.jQueryDisabled) { (0, _internalTestHelpers.moduleFor)('Components test: curly components: jQuery disabled', /*#__PURE__*/ function (_RenderingTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _RenderingTestCase2); function _class2() { return _RenderingTestCase2.apply(this, arguments) || this; } var _proto3 = _class2.prototype; _proto3['@test jQuery proxy is not available without jQuery'] = function testJQueryProxyIsNotAvailableWithoutJQuery() { var instance; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super(); instance = this; } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); this.render('{{foo-bar}}'); expectAssertion(function () { instance.$()[0]; }, 'You cannot access this.$() with `jQuery` disabled.'); }; return _class2; }(_internalTestHelpers.RenderingTestCase)); } else { (0, _internalTestHelpers.moduleFor)('Components test: curly components: jQuery enabled', /*#__PURE__*/ function (_RenderingTestCase3) { (0, _emberBabel.inheritsLoose)(_class3, _RenderingTestCase3); function _class3() { return _RenderingTestCase3.apply(this, arguments) || this; } var _proto4 = _class3.prototype; _proto4['@test it has a jQuery proxy to the element'] = function testItHasAJQueryProxyToTheElement() { var _this87 = this; var instance; var element1; var element2; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super(); instance = this; } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); this.render('{{foo-bar}}'); expectDeprecation(function () { element1 = instance.$()[0]; }, 'Using this.$() in a component has been deprecated, consider using this.element'); this.assertComponentElement(element1, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this87.rerender(); }); expectDeprecation(function () { element2 = instance.$()[0]; }, 'Using this.$() in a component has been deprecated, consider using this.element'); this.assertComponentElement(element2, { content: 'hello' }); this.assertSameNode(element2, element1); }; _proto4['@test it scopes the jQuery proxy to the component element'] = function testItScopesTheJQueryProxyToTheComponentElement(assert) { var _this88 = this; var instance; var $span; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super(); instance = this; } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'inner' }); this.render('outer{{foo-bar}}'); expectDeprecation(function () { $span = instance.$('span'); }, 'Using this.$() in a component has been deprecated, consider using this.element'); assert.equal($span.length, 1); assert.equal($span.attr('class'), 'inner'); (0, _internalTestHelpers.runTask)(function () { return _this88.rerender(); }); expectDeprecation(function () { $span = instance.$('span'); }, 'Using this.$() in a component has been deprecated, consider using this.element'); assert.equal($span.length, 1); assert.equal($span.attr('class'), 'inner'); }; return _class3; }(_internalTestHelpers.RenderingTestCase)); } }); enifed("@ember/-internals/glimmer/tests/integration/components/destroy-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/metal", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _metal, _helpers) { "use strict"; (0, _internalTestHelpers.moduleFor)('Component destroy', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test it correctly releases the destroyed components'] = function testItCorrectlyReleasesTheDestroyedComponents(assert) { var _this = 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' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this.context, 'switch', false); }); this.assertText(''); assert.equal(this.env.destroyedComponents.length, 0, 'environment.destroyedComponents should be empty'); }; return _class; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/dynamic-components-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/metal", "@ember/-internals/views", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _metal, _views, _helpers) { "use strict"; function _templateObject3() { const data = _taggedTemplateLiteralLoose(["\n {{#each n as |name|}}\n {{name}}\n {{/each}}"]); _templateObject3 = function () { return data; }; return data; } function _templateObject2() { const data = _taggedTemplateLiteralLoose(["\n {{#each names as |name|}}\n {{name}}\n {{/each}}"]); _templateObject2 = function () { return data; }; return data; } function _templateObject() { const data = _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}}"]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } (0, _internalTestHelpers.moduleFor)('Components test: dynamic components', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test it can render a basic component with a static component name argument'] = function testItCanRenderABasicComponentWithAStaticComponentNameArgument() { var _this = this; this.registerComponent('foo-bar', { template: 'hello {{name}}' }); this.render('{{component "foo-bar" name=name}}', { name: 'Sarah' }); this.assertComponentElement(this.firstChild, { content: 'hello Sarah' }); (0, _internalTestHelpers.runTask)(function () { return _this.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello Sarah' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this.context, 'name', 'Gavin'); }); this.assertComponentElement(this.firstChild, { content: 'hello Gavin' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this.context, 'name', 'Sarah'); }); this.assertComponentElement(this.firstChild, { content: 'hello Sarah' }); }; _proto['@test it can render a basic component with a dynamic component name argument'] = function testItCanRenderABasicComponentWithADynamicComponentNameArgument() { var _this2 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'name', 'Ben'); }); this.assertComponentElement(this.firstChild, { content: 'hello Ben from foo-bar' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'componentName', 'foo-bar-baz'); }); this.assertComponentElement(this.firstChild, { content: 'hello Ben from foo-bar-baz' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this2.context, 'componentName', 'foo-bar'); (0, _metal.set)(_this2.context, 'name', 'Alex'); }); this.assertComponentElement(this.firstChild, { content: 'hello Alex from foo-bar' }); }; _proto['@test it has an element'] = function testItHasAnElement() { var _this3 = this; var instance; 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' }); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); var element2 = instance.element; this.assertComponentElement(element2, { content: 'hello' }); this.assertSameNode(element2, element1); }; _proto['@test it has the right parentView and childViews'] = function testItHasTheRightParentViewAndChildViews(assert) { var _this4 = this; var fooBarInstance, fooBarBazInstance; 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]); (0, _internalTestHelpers.runTask)(function () { return _this4.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]); }; _proto['@test it can render a basic component with a block'] = function testItCanRenderABasicComponentWithABlock() { var _this5 = this; this.registerComponent('foo-bar', { template: '{{yield}}' }); this.render('{{#component "foo-bar"}}hello{{/component}}'); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this5.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; _proto['@test it renders the layout with the component instance as the context'] = function testItRendersTheLayoutWithTheComponentInstanceAsTheContext() { var _this6 = this; var instance; 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' }); (0, _internalTestHelpers.runTask)(function () { return _this6.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'message', 'goodbye'); }); this.assertComponentElement(this.firstChild, { content: 'goodbye' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'message', 'hello'); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; _proto['@test it preserves the outer context when yielding'] = function testItPreservesTheOuterContextWhenYielding() { var _this7 = this; this.registerComponent('foo-bar', { template: '{{yield}}' }); this.render('{{#component "foo-bar"}}{{message}}{{/component}}', { message: 'hello' }); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this7.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this7.context, 'message', 'goodbye'); }); this.assertComponentElement(this.firstChild, { content: 'goodbye' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this7.context, 'message', 'hello'); }); this.assertComponentElement(this.firstChild, { content: 'hello' }); }; _proto['@test the component and its child components are destroyed'] = function testTheComponentAndItsChildComponentsAreDestroyed(assert) { var _this8 = 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, _internalTestHelpers.strip)(_templateObject()), { cond1: true, cond2: true, cond3: true, cond4: true, cond5: true }); this.assertText('1 2 3 4 5 6 7 8 '); (0, _internalTestHelpers.runTask)(function () { return _this8.rerender(); }); assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this8.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 }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this8.context, 'cond3', false); (0, _metal.set)(_this8.context, 'cond5', true); (0, _metal.set)(_this8.context, 'cond4', false); }); assert.deepEqual(destroyed, { 1: 0, 2: 0, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this8.context, 'cond2', false); (0, _metal.set)(_this8.context, 'cond1', false); }); assert.deepEqual(destroyed, { 1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1 }); }; _proto['@test component helper destroys underlying component when it is swapped out'] = function testComponentHelperDestroysUnderlyingComponentWhenItIsSwappedOut(assert) { var _this9 = 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 }); (0, _internalTestHelpers.runTask)(function () { return _this9.rerender(); }); assert.deepEqual(destroyed, { 'foo-bar': 0, 'foo-bar-baz': 0 }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this9.context, 'componentName', 'foo-bar-baz'); }); assert.deepEqual(destroyed, { 'foo-bar': 1, 'foo-bar-baz': 0 }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this9.context, 'componentName', 'foo-bar'); }); assert.deepEqual(destroyed, { 'foo-bar': 1, 'foo-bar-baz': 1 }); }; _proto['@test component helper with bound properties are updating correctly in init of component'] = function testComponentHelperWithBoundPropertiesAreUpdatingCorrectlyInInitOfComponent() { var _this10 = 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, _metal.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!'); (0, _internalTestHelpers.runTask)(function () { return _this10.rerender(); }); this.assertText('foo-bar Caracas Caracas arepas!'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this10.context, 'location', 'Loisaida'); }); this.assertText('foo-bar-baz Loisaida Loisaida arepas!'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this10.context, 'location', 'Caracas'); }); this.assertText('foo-bar Caracas Caracas arepas!'); }; _proto['@test component helper with actions'] = function testComponentHelperWithActions(assert) { var _this12 = this; this.registerComponent('inner-component', { template: 'inner-component {{yield}}', ComponentClass: _helpers.Component.extend({ classNames: 'inner-component', didInsertElement: function () { var _this11 = this; // trigger action on click in absence of app's EventDispatcher var sendAction = this.eventHandler = function () { if (_this11.somethingClicked) { _this11.somethingClicked(); } }; this.element.addEventListener('click', sendAction); }, willDestroyElement: function () { this.element.removeEventListener('click', this.eventHandler); } }) }); var actionTriggered = 0; this.registerComponent('outer-component', { template: '{{#component componentName somethingClicked=(action "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'); (0, _internalTestHelpers.runTask)(function () { _this12.$('.inner-component').click(); }); assert.equal(actionTriggered, 1, 'action was triggered'); }; _proto['@test nested component helpers'] = function testNestedComponentHelpers() { var _this13 = 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!'); (0, _internalTestHelpers.runTask)(function () { return _this13.rerender(); }); this.assertText('yippie! Caracas yummy Caracas arepas!'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this13.context, 'location', 'Loisaida'); }); this.assertText('yippie! Loisaida yummy Loisaida arepas!'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this13.context, 'componentName1', 'corge-grault'); }); this.assertText('delicious Loisaida yummy Loisaida arepas!'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this13.context, 'componentName1', 'foo-bar'); (0, _metal.set)(_this13.context, 'location', 'Caracas'); }); this.assertText('yippie! Caracas yummy Caracas arepas!'); }; _proto['@test component with dynamic name argument resolving to non-existent component'] = function testComponentWithDynamicNameArgumentResolvingToNonExistentComponent() { var _this14 = this; expectAssertion(function () { _this14.render('{{component componentName}}', { componentName: 'does-not-exist' }); }, /Could not find component named "does-not-exist"/); }; _proto['@test component with static name argument for non-existent component'] = function testComponentWithStaticNameArgumentForNonExistentComponent() { var _this15 = this; expectAssertion(function () { _this15.render('{{component "does-not-exist"}}'); }, /Could not find component named "does-not-exist"/); }; _proto['@test component with dynamic component name resolving to a component, then non-existent component'] = function testComponentWithDynamicComponentNameResolvingToAComponentThenNonExistentComponent() { var _this16 = this; this.registerComponent('foo-bar', { template: 'hello {{name}}' }); this.render('{{component componentName name=name}}', { componentName: 'foo-bar', name: 'Alex' }); this.assertText('hello Alex'); (0, _internalTestHelpers.runTask)(function () { return _this16.rerender(); }); this.assertText('hello Alex'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this16.context, 'componentName', undefined); }); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this16.context, 'componentName', 'foo-bar'); }); this.assertText('hello Alex'); }; _proto['@test component helper properly invalidates hash params inside an {{each}} invocation #11044'] = function testComponentHelperProperlyInvalidatesHashParamsInsideAnEachInvocation11044() { var _this17 = 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, _metal.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]'); (0, _internalTestHelpers.runTask)(function () { return _this17.rerender(); }); this.assertText('[Robert - Robert][Jacquie - Jacquie]'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this17.context, 'items', [{ name: 'Max' }, { name: 'James' }]); }); this.assertText('[Max - Max][James - James]'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this17.context, 'items', [{ name: 'Robert' }, { name: 'Jacquie' }]); }); this.assertText('[Robert - Robert][Jacquie - Jacquie]'); }; _proto['@test positional parameters does not clash when rendering different components'] = function testPositionalParametersDoesNotClashWhenRenderingDifferentComponents() { var _this18 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this18.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this18.context, 'name', 'Ben'); }); this.assertComponentElement(this.firstChild, { content: 'hello Ben (29) from foo-bar' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this18.context, 'age', 22); }); this.assertComponentElement(this.firstChild, { content: 'hello Ben (22) from foo-bar' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this18.context, 'componentName', 'foo-bar-baz'); }); this.assertComponentElement(this.firstChild, { content: 'hello Ben (22) from foo-bar-baz' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this18.context, 'componentName', 'foo-bar'); (0, _metal.set)(_this18.context, 'name', 'Alex'); (0, _metal.set)(_this18.context, 'age', 29); }); this.assertComponentElement(this.firstChild, { content: 'hello Alex (29) from foo-bar' }); }; _proto['@test positional parameters does not pollute the attributes when changing components'] = function testPositionalParametersDoesNotPolluteTheAttributesWhenChangingComponents() { var _this19 = 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!' }); (0, _internalTestHelpers.runTask)(function () { return _this19.rerender(); }); this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this19.context, 'componentName', 'alternative-message'); }); this.assertComponentElement(this.firstChild, { content: 'Alternative: Another Hello!' }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this19.context, 'message', 'Hi'); }); this.assertComponentElement(this.firstChild, { content: 'Alternative: Another Hi!' }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this19.context, 'componentName', 'normal-message'); (0, _metal.set)(_this19.context, 'message', 'Hello'); }); this.assertComponentElement(this.firstChild, { content: 'Normal: Hello!' }); }; _proto['@test static arbitrary number of positional parameters'] = function testStaticArbitraryNumberOfPositionalParameters() { var _this20 = this; this.registerComponent('sample-component', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'names' }), template: (0, _internalTestHelpers.strip)(_templateObject2()) }); this.render("{{component \"sample-component\" \"Foo\" 4 \"Bar\" 5 \"Baz\" elementId=\"helper\"}}"); this.assertText('Foo4Bar5Baz'); (0, _internalTestHelpers.runTask)(function () { return _this20.rerender(); }); this.assertText('Foo4Bar5Baz'); }; _proto['@test dynamic arbitrary number of positional parameters'] = function testDynamicArbitraryNumberOfPositionalParameters() { var _this21 = this; this.registerComponent('sample-component', { ComponentClass: _helpers.Component.extend().reopenClass({ positionalParams: 'n' }), template: (0, _internalTestHelpers.strip)(_templateObject3()) }); this.render("{{component \"sample-component\" user1 user2}}", { user1: 'Foo', user2: 4 }); this.assertText('Foo4'); (0, _internalTestHelpers.runTask)(function () { return _this21.rerender(); }); this.assertText('Foo4'); (0, _internalTestHelpers.runTask)(function () { return _this21.context.set('user1', 'Bar'); }); this.assertText('Bar4'); (0, _internalTestHelpers.runTask)(function () { return _this21.context.set('user2', '5'); }); this.assertText('Bar5'); (0, _internalTestHelpers.runTask)(function () { _this21.context.set('user1', 'Foo'); _this21.context.set('user2', 4); }); this.assertText('Foo4'); }; _proto['@test component helper emits useful backtracking re-render assertion message'] = function testComponentHelperEmitsUsefulBacktrackingReRenderAssertionMessage() { var _this22 = 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"/; expectAssertion(function () { _this22.render('{{component componentName}}', { componentName: 'outer-component' }); }, expectedBacktrackingMessage); }; return _class; }(_internalTestHelpers.RenderingTestCase)); if (_views.jQueryDisabled) { (0, _internalTestHelpers.moduleFor)('Components test: dynamic components: jQuery disabled', /*#__PURE__*/ function (_RenderingTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _RenderingTestCase2); function _class2() { return _RenderingTestCase2.apply(this, arguments) || this; } var _proto2 = _class2.prototype; _proto2['@test jQuery proxy is not available without jQuery'] = function testJQueryProxyIsNotAvailableWithoutJQuery() { var instance; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super(); instance = this; } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); this.render('{{component "foo-bar"}}'); expectAssertion(function () { instance.$()[0]; }, 'You cannot access this.$() with `jQuery` disabled.'); }; return _class2; }(_internalTestHelpers.RenderingTestCase)); } else { (0, _internalTestHelpers.moduleFor)('Components test: dynamic components : jQuery enabled', /*#__PURE__*/ function (_RenderingTestCase3) { (0, _emberBabel.inheritsLoose)(_class3, _RenderingTestCase3); function _class3() { return _RenderingTestCase3.apply(this, arguments) || this; } var _proto3 = _class3.prototype; _proto3['@test it has a jQuery proxy to the element'] = function testItHasAJQueryProxyToTheElement() { var _this23 = this; var instance; var element1; var element2; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super(); instance = this; } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); this.render('{{component "foo-bar"}}'); expectDeprecation(function () { element1 = instance.$()[0]; }, 'Using this.$() in a component has been deprecated, consider using this.element'); this.assertComponentElement(element1, { content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this23.rerender(); }); expectDeprecation(function () { element2 = instance.$()[0]; }, 'Using this.$() in a component has been deprecated, consider using this.element'); this.assertComponentElement(element2, { content: 'hello' }); this.assertSameNode(element2, element1); }; _proto3['@test it scopes the jQuery proxy to the component element'] = function testItScopesTheJQueryProxyToTheComponentElement(assert) { var _this24 = this; var instance; var $span; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super(); instance = this; } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'inner' }); this.render('outer{{component "foo-bar"}}'); expectDeprecation(function () { $span = instance.$('span'); }, 'Using this.$() in a component has been deprecated, consider using this.element'); assert.equal($span.length, 1); assert.equal($span.attr('class'), 'inner'); (0, _internalTestHelpers.runTask)(function () { return _this24.rerender(); }); expectDeprecation(function () { $span = instance.$('span'); }, 'Using this.$() in a component has been deprecated, consider using this.element'); assert.equal($span.length, 1); assert.equal($span.attr('class'), 'inner'); }; return _class3; }(_internalTestHelpers.RenderingTestCase)); } }); enifed("@ember/-internals/glimmer/tests/integration/components/error-handling-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/metal", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _metal, _helpers) { "use strict"; (0, _internalTestHelpers.moduleFor)('Errors thrown during render', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test it can recover resets the transaction when an error is thrown during initial render'] = function testItCanRecoverResetsTheTransactionWhenAnErrorIsThrownDuringInitialRender(assert) { var _this = this; var shouldThrow = true; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super.apply(this, arguments); if (shouldThrow) { throw new Error('silly mistake in init!'); } } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); assert.throws(function () { _this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { switch: true }); }, /silly mistake in init/); assert.equal(this.env.inTransaction, false, 'should not be in a transaction even though an error was thrown'); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this.context, 'switch', false); }); shouldThrow = false; (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this.context, 'switch', true); }); this.assertText('hello'); }; _proto['@skip it can recover resets the transaction when an error is thrown during rerender'] = function skipItCanRecoverResetsTheTransactionWhenAnErrorIsThrownDuringRerender(assert) { var _this2 = this; var shouldThrow = false; var FooBarComponent = _helpers.Component.extend({ init: function () { this._super.apply(this, arguments); if (shouldThrow) { throw new Error('silly mistake in init!'); } } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { switch: true }); this.assertText('hello'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'switch', false); }); shouldThrow = true; assert.throws(function () { (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'switch', true); }); }, /silly mistake in init/); assert.equal(this.env.inTransaction, false, 'should not be in a transaction even though an error was thrown'); this.assertText(''); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'switch', false); }); shouldThrow = false; (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'switch', true); }); this.assertText('hello'); }; _proto['@test it can recover resets the transaction when an error is thrown during didInsertElement'] = function testItCanRecoverResetsTheTransactionWhenAnErrorIsThrownDuringDidInsertElement(assert) { var _this3 = this; var shouldThrow = true; var FooBarComponent = _helpers.Component.extend({ didInsertElement: function () { this._super.apply(this, arguments); if (shouldThrow) { throw new Error('silly mistake!'); } } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); assert.throws(function () { _this3.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { switch: true }); }, /silly mistake/); assert.equal(this.env.inTransaction, false, 'should not be in a transaction even though an error was thrown'); this.assertText('hello'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.context, 'switch', false); }); this.assertText(''); }; _proto['@test it can recover resets the transaction when an error is thrown during destroy'] = function testItCanRecoverResetsTheTransactionWhenAnErrorIsThrownDuringDestroy(assert) { var _this4 = this; var shouldThrow = true; var FooBarComponent = _helpers.Component.extend({ destroy: function () { this._super.apply(this, arguments); if (shouldThrow) { throw new Error('silly mistake!'); } } }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: 'hello' }); this.render('{{#if switch}}{{#foo-bar}}{{foo-bar}}{{/foo-bar}}{{/if}}', { switch: true }); this.assertText('hello'); assert.throws(function () { (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this4.context, 'switch', false); }); }, /silly mistake/); this.assertText(''); shouldThrow = false; (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this4.context, 'switch', true); }); this.assertText('hello'); }; return _class; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/fragment-components-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/metal", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _metal, _helpers) { "use strict"; function _templateObject3() { const data = _taggedTemplateLiteralLoose(["bizz"]); _templateObject3 = function () { return data; }; return data; } function _templateObject2() { const data = _taggedTemplateLiteralLoose(["bar"]); _templateObject2 = function () { return data; }; return data; } function _templateObject() { const data = _taggedTemplateLiteralLoose(["
Hey
bar"]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } (0, _internalTestHelpers.moduleFor)('Components test: fragment components', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto.getCustomDispatcherEvents = function getCustomDispatcherEvents() { return { hitDem: 'folks' }; }; _proto['@test fragments do not render an outer tag'] = function testFragmentsDoNotRenderAnOuterTag() { var instance; var FooBarComponent = _helpers.Component.extend({ tagName: '', init: function () { this._super(); instance = this; this.foo = true; this.bar = 'bar'; } }); var template = "{{#if foo}}
Hey
{{/if}}{{yield bar}}"; this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); this.render("{{#foo-bar as |bar|}}{{bar}}{{/foo-bar}}"); this.assertHTML((0, _internalTestHelpers.strip)(_templateObject())); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'foo', false); }); this.assertHTML((0, _internalTestHelpers.strip)(_templateObject2())); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(instance, 'bar', 'bizz'); }); this.assertHTML((0, _internalTestHelpers.strip)(_templateObject3())); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(instance, 'bar', 'bar'); (0, _metal.set)(instance, 'foo', true); }); }; _proto['@test throws an error if an event function is defined in a tagless component'] = function testThrowsAnErrorIfAnEventFunctionIsDefinedInATaglessComponent() { var _this = this; var template = "hit dem folks"; var FooBarComponent = _helpers.Component.extend({ tagName: '', click: function () {}, mouseEnter: function () {} }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); expectAssertion(function () { _this.render("{{#foo-bar}}{{/foo-bar}}"); }, /You can not define `click,mouseEnter` function\(s\) to handle DOM event in the .* tagless component since it doesn't have any DOM element./); }; _proto['@test throws an error if a custom defined event function is defined in a tagless component'] = function testThrowsAnErrorIfACustomDefinedEventFunctionIsDefinedInATaglessComponent() { var _this2 = this; var template = "hit dem folks"; var FooBarComponent = _helpers.Component.extend({ tagName: '', folks: function () {} }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); expectAssertion(function () { _this2.render("{{#foo-bar}}{{/foo-bar}}"); }, /You can not define `folks` function\(s\) to handle DOM event in the .* tagless component since it doesn't have any DOM element./); }; _proto['@test throws an error if `tagName` is an empty string and `classNameBindings` are specified'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndClassNameBindingsAreSpecified() { var _this3 = 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 () { _this3.render("{{#foo-bar}}{{/foo-bar}}"); }, /You cannot use `classNameBindings` on a tag-less component/); }; _proto['@test throws an error if `tagName` is an empty string and `attributeBindings` are specified'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndAttributeBindingsAreSpecified() { var _this4 = this; var template = "hit dem folks"; var FooBarComponent = _helpers.Component.extend({ tagName: '', attributeBindings: ['href'] }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); expectAssertion(function () { _this4.render("{{#foo-bar}}{{/foo-bar}}"); }, /You cannot use `attributeBindings` on a tag-less component/); }; _proto['@test throws an error if `tagName` is an empty string and `elementId` is specified via JS'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndElementIdIsSpecifiedViaJS() { var _this5 = this; var template = "hit dem folks"; var FooBarComponent = _helpers.Component.extend({ tagName: '', elementId: 'turntUp' }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); expectAssertion(function () { _this5.render("{{#foo-bar}}{{/foo-bar}}"); }, /You cannot use `elementId` on a tag-less component/); }; _proto['@test throws an error if `tagName` is an empty string and `elementId` is specified via template'] = function testThrowsAnErrorIfTagNameIsAnEmptyStringAndElementIdIsSpecifiedViaTemplate() { var _this6 = this; var template = "hit dem folks"; var FooBarComponent = _helpers.Component.extend({ tagName: '' }); this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: template }); expectAssertion(function () { _this6.render("{{#foo-bar elementId='turntUp'}}{{/foo-bar}}"); }, /You cannot use `elementId` on a tag-less component/); }; _proto['@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'); }; _proto['@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'); }; _proto['@test does not throw an error if `tagName` is an empty string and `id` is bound property specified via template'] = function testDoesNotThrowAnErrorIfTagNameIsAnEmptyStringAndIdIsBoundPropertySpecifiedViaTemplate() { var _this7 = 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(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this7.context, 'fooBarId', 'qux'); }); this.assertText('qux'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this7.context, 'fooBarId', 'baz'); }); this.assertText('baz'); }; _proto['@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'); }; _proto['@test throws an error if when $() is accessed on component where `tagName` is an empty string'] = function testThrowsAnErrorIfWhen$IsAccessedOnComponentWhereTagNameIsAnEmptyString() { var _this8 = 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 () { _this8.render("{{#foo-bar}}{{/foo-bar}}"); }, /You cannot access this.\$\(\) on a component with `tagName: \'\'` specified/); }; _proto['@test renders a contained view with omitted start tag and tagless parent view context'] = function testRendersAContainedViewWithOmittedStartTagAndTaglessParentViewContext() { var _this9 = 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' }); (0, _internalTestHelpers.runTask)(function () { return _this9.rerender(); }); this.assertElement(this.firstChild, { tagName: 'section' }); this.assertElement(this.firstChild.firstElementChild, { tagName: 'span' }); }; return _class; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/input-angle-test", ["ember-babel", "internal-test-helpers", "@ember/polyfills", "@ember/-internals/metal", "@ember/-internals/views", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _polyfills, _metal, _views, _helpers) { "use strict"; if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { var InputRenderingTest = /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(InputRenderingTest, _RenderingTestCase); function InputRenderingTest() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = InputRenderingTest.prototype; _proto.$input = function $input() { return this.$('input'); }; _proto.inputID = function inputID() { return this.$input().prop('id'); }; _proto.assertDisabled = function assertDisabled() { this.assert.ok(this.$('input').prop('disabled'), 'The input is disabled'); }; _proto.assertNotDisabled = function assertNotDisabled() { this.assert.ok(this.$('input').is(':not(:disabled)'), 'The input is not disabled'); }; _proto.assertInputId = function assertInputId(expectedId) { this.assert.equal(this.inputID(), expectedId, 'the input id should be `expectedId`'); }; _proto.assertSingleInput = function assertSingleInput() { this.assert.equal(this.$('input').length, 1, 'A single text field was inserted'); }; _proto.assertSingleCheckbox = function assertSingleCheckbox() { this.assert.equal(this.$('input[type=checkbox]').length, 1, 'A single checkbox is added'); }; _proto.assertCheckboxIsChecked = function assertCheckboxIsChecked() { this.assert.equal(this.$input().prop('checked'), true, 'the checkbox is checked'); }; _proto.assertCheckboxIsNotChecked = function assertCheckboxIsNotChecked() { this.assert.equal(this.$input().prop('checked'), false, 'the checkbox is not checked'); }; _proto.assertValue = function assertValue(expected) { this.assert.equal(this.$input().val(), expected, "the input value should be " + expected); }; _proto.assertAttr = function assertAttr(name, expected) { this.assert.equal(this.$input().attr(name), expected, "the input " + name + " attribute has the value '" + expected + "'"); }; _proto.assertAllAttrs = function assertAllAttrs(names, expected) { var _this = this; names.forEach(function (name) { return _this.assertAttr(name, expected); }); }; _proto.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); }; _proto.triggerEvent = function triggerEvent(type, options, selector) { var event = document.createEvent('Events'); event.initEvent(type, true, true); (0, _polyfills.assign)(event, options); var element = this.$(selector || 'input')[0]; (0, _internalTestHelpers.runTask)(function () { element.dispatchEvent(event); }); }; _proto.assertTriggersNativeDOMEvents = function assertTriggersNativeDOMEvents(type) { var _this2 = this; // Defaults from EventDispatcher var events = { touchstart: 'touchStart', touchmove: 'touchMove', touchend: 'touchEnd', touchcancel: 'touchCancel', keydown: 'keyDown', keyup: 'keyUp', keypress: 'keyPress', mousedown: 'mouseDown', mouseup: 'mouseUp', contextmenu: 'contextMenu', click: 'click', dblclick: 'doubleClick', mousemove: 'mouseMove', focusin: 'focusIn', focusout: 'focusOut', mouseenter: 'mouseEnter', mouseleave: 'mouseLeave', submit: 'submit', input: 'input', change: 'change', dragstart: 'dragStart', drag: 'drag', dragenter: 'dragEnter', dragleave: 'dragLeave', dragover: 'dragOver', drop: 'drop', dragend: 'dragEnd' }; this.registerComponent('test-component', { ComponentClass: _helpers.Component.extend({ tagName: 'input', attributeBindings: ['type'] }) }); var triggered = { standard: [], custom: [] }; var actions = { didTrigger: function (id, event) { triggered[id].push(event); } }; function argsFor(id) { var args = ["id=\"" + id + "\""]; if (type) { args.push("@type=\"" + type + "\""); } Object.keys(events).forEach(function (event) { args.push("@" + events[event] + "={{action \"didTrigger\" \"" + id + "\" \"" + event + "\"}}"); }); return args.join(' '); } var template = "\n \n \n "; this.render(template, { actions: actions }); this.assert.ok(this.$('input').length === 2); var $standard = this.$('#standard'); var $custom = this.$('#custom'); this.assert.equal($standard.type, $custom.type); Object.keys(events).forEach(function (event) { _this2.triggerEvent(event, null, '#standard'); _this2.triggerEvent(event, null, '#custom'); }); this.assert.ok(triggered.standard.length > 10, 'sanity check that most events are triggered (standard)'); this.assert.ok(triggered.custom.length > 10, 'sanity check that most events are triggered (custom)'); this.assert.deepEqual(triggered.standard, triggered.custom, 'called for all events'); }; return InputRenderingTest; }(_internalTestHelpers.RenderingTestCase); (0, _internalTestHelpers.moduleFor)('Components test: ', /*#__PURE__*/ function (_InputRenderingTest) { (0, _emberBabel.inheritsLoose)(_class, _InputRenderingTest); function _class() { return _InputRenderingTest.apply(this, arguments) || this; } var _proto2 = _class.prototype; _proto2['@test a single text field is inserted into the DOM'] = function testASingleTextFieldIsInsertedIntoTheDOM() { var _this3 = this; this.render("", { value: 'hello' }); var id = this.inputID(); this.assertValue('hello'); this.assertSingleInput(); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); this.assertValue('hello'); this.assertSingleInput(); this.assertInputId(id); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.context, 'value', 'goodbye'); }); this.assertValue('goodbye'); this.assertSingleInput(); this.assertInputId(id); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.context, 'value', 'hello'); }); this.assertValue('hello'); this.assertSingleInput(); this.assertInputId(id); }; _proto2['@test default type'] = function testDefaultType() { var _this4 = this; this.render(""); this.assertAttr('type', 'text'); (0, _internalTestHelpers.runTask)(function () { return _this4.rerender(); }); this.assertAttr('type', 'text'); }; _proto2['@test dynamic attributes (HTML attribute)'] = function testDynamicAttributesHTMLAttribute() { var _this5 = this; this.render("\n ", { value: 'Original value', disabled: false, 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) (0, _internalTestHelpers.runTask)(function () { return _this5.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) (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.context, 'value', 'Updated value'); (0, _metal.set)(_this5.context, 'disabled', true); (0, _metal.set)(_this5.context, 'placeholder', 'Updated placeholder'); (0, _metal.set)(_this5.context, 'name', 'updated-name'); (0, _metal.set)(_this5.context, 'maxlength', 11); (0, _metal.set)(_this5.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) (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.context, 'value', 'Original value'); (0, _metal.set)(_this5.context, 'disabled', false); (0, _metal.set)(_this5.context, 'placeholder', 'Original placeholder'); (0, _metal.set)(_this5.context, 'name', 'original-name'); (0, _metal.set)(_this5.context, 'maxlength', 10); (0, _metal.set)(_this5.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) }; _proto2['@test dynamic attributes (named argument)'] = function testDynamicAttributesNamedArgument() { var _this6 = this; this.render("\n ", { value: 'Original value', disabled: false, 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) (0, _internalTestHelpers.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) (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this6.context, 'value', 'Updated value'); (0, _metal.set)(_this6.context, 'disabled', true); (0, _metal.set)(_this6.context, 'placeholder', 'Updated placeholder'); (0, _metal.set)(_this6.context, 'name', 'updated-name'); (0, _metal.set)(_this6.context, 'maxlength', 11); (0, _metal.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) (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this6.context, 'value', 'Original value'); (0, _metal.set)(_this6.context, 'disabled', false); (0, _metal.set)(_this6.context, 'placeholder', 'Original placeholder'); (0, _metal.set)(_this6.context, 'name', 'original-name'); (0, _metal.set)(_this6.context, 'maxlength', 10); (0, _metal.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) }; _proto2['@test static attributes (HTML attribute)'] = function testStaticAttributesHTMLAttribute() { var _this7 = this; this.render("\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) (0, _internalTestHelpers.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) }; _proto2['@test static attributes (named argument)'] = function testStaticAttributesNamedArgument() { var _this8 = this; this.render("\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) (0, _internalTestHelpers.runTask)(function () { return _this8.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) }; _proto2['@test cursor selection range'] = function testCursorSelectionRange() { var _this9 = 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("", { 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) (0, _internalTestHelpers.runTask)(function () { return _this9.rerender(); }); // this.assertSelectionRange(8, 8); //NOTE: this is (0, 0) on Firefox (TEST_SUITE=sauce) (0, _internalTestHelpers.runTask)(function () { input.selectionStart = 2; input.selectionEnd = 4; }); this.assertSelectionRange(2, 4); (0, _internalTestHelpers.runTask)(function () { return _this9.rerender(); }); this.assertSelectionRange(2, 4); // runTask(() => set(this.context, 'value', 'updated')); // // this.assertSelectionRange(7, 7); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce) // // runTask(() => set(this.context, 'value', 'original')); // // this.assertSelectionRange(8, 8); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce) }; _proto2['@test [DEPRECATED] sends an action with `` when is pressed'] = function testDEPRECATEDSendsAnActionWithInputEnterFooWhenEnterIsPressed(assert) { var _this10 = this; assert.expect(4); expectDeprecation(function () { _this10.render("", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``). (\'-top-level\' @ L1:C0) '); expectDeprecation(function () { _this10.triggerEvent('keyup', { keyCode: 13 }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``).'); }; _proto2['@test sends an action with `` when is pressed'] = function testSendsAnActionWithInputEnterActionFooWhenEnterIsPressed(assert) { assert.expect(2); this.render("", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keyup', { keyCode: 13 }); }; _proto2['@test [DEPRECATED] sends an action with `` is pressed'] = function testDEPRECATEDSendsAnActionWithInputKeyPressFooIsPressed(assert) { var _this11 = this; assert.expect(4); expectDeprecation(function () { _this11.render("", { value: 'initial', actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``). (\'-top-level\' @ L1:C0) '); expectDeprecation(function () { _this11.triggerEvent('keypress', { keyCode: 65 }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``).'); }; _proto2['@test sends an action with `` is pressed'] = function testSendsAnActionWithInputKeyPressActionFooIsPressed(assert) { assert.expect(2); this.render("", { value: 'initial', actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keypress', { keyCode: 65 }); }; _proto2['@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('parent', { ComponentClass: ParentComponent, template: "" }); this.render(""); this.triggerEvent('change'); }; _proto2['@test triggers `focus-in` when focused'] = function testTriggersFocusInWhenFocused(assert) { var _this12 = this; var wasFocused = false; this.render("", { actions: { foo: function () { wasFocused = true; } } }); (0, _internalTestHelpers.runTask)(function () { _this12.$input().focus(); }); assert.ok(wasFocused, 'action was triggered'); }; _proto2['@test sends `insert-newline` when is pressed'] = function testSendsInsertNewlineWhenEnterIsPressed(assert) { assert.expect(2); this.render("", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keyup', { keyCode: 13 }); }; _proto2['@test [DEPRECATED] sends an action with `` when is pressed'] = function testDEPRECATEDSendsAnActionWithInputEscapePressFooWhenEscapeIsPressed(assert) { var _this13 = this; assert.expect(4); expectDeprecation(function () { _this13.render("", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``). (\'-top-level\' @ L1:C0) '); expectDeprecation(function () { _this13.triggerEvent('keyup', { keyCode: 27 }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``).'); }; _proto2['@test sends an action with `` when is pressed'] = function testSendsAnActionWithInputEscapePressActionFooWhenEscapeIsPressed(assert) { assert.expect(2); this.render("", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keyup', { keyCode: 27 }); }; _proto2['@test [DEPRECATED] sends an action with `` when a key is pressed'] = function testDEPRECATEDSendsAnActionWithInputKeyDownFooWhenAKeyIsPressed(assert) { var _this14 = this; assert.expect(4); expectDeprecation(function () { _this14.render("", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``). (\'-top-level\' @ L1:C0) '); expectDeprecation(function () { _this14.triggerEvent('keydown', { keyCode: 65 }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``).'); }; _proto2['@test sends an action with `` when a key is pressed'] = function testSendsAnActionWithInputKeyDownActionFooWhenAKeyIsPressed(assert) { assert.expect(2); this.render("", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keydown', { keyCode: 65 }); }; _proto2['@test [DEPRECATED] sends an action with `` when a key is pressed'] = function testDEPRECATEDSendsAnActionWithInputKeyUpFooWhenAKeyIsPressed(assert) { var _this15 = this; assert.expect(4); expectDeprecation(function () { _this15.render("", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``). (\'-top-level\' @ L1:C0) '); expectDeprecation(function () { _this15.triggerEvent('keyup', { keyCode: 65 }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``).'); }; _proto2['@test sends an action with `` when a key is pressed'] = function testSendsAnActionWithInputKeyUpActionFooWhenAKeyIsPressed(assert) { assert.expect(2); this.render("", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keyup', { keyCode: 65 }); }; _proto2['@test GH#14727 can render a file input after having had render an input of other type'] = function testGH14727CanRenderAFileInputAfterHavingHadRenderAnInputOfOtherType() { this.render(""); this.assert.equal(this.$input()[0].type, 'text'); this.assert.equal(this.$input()[1].type, 'file'); }; _proto2['@test sends an action with `` for native DOM events'] = function testSendsAnActionWithInputEVENTActionFooForNativeDOMEvents() { this.assertTriggersNativeDOMEvents(); }; return _class; }(InputRenderingTest)); (0, _internalTestHelpers.moduleFor)('Components test: with dynamic type', /*#__PURE__*/ function (_InputRenderingTest2) { (0, _emberBabel.inheritsLoose)(_class2, _InputRenderingTest2); function _class2() { return _InputRenderingTest2.apply(this, arguments) || this; } var _proto3 = _class2.prototype; _proto3['@test a bound property can be used to determine type'] = function testABoundPropertyCanBeUsedToDetermineType() { var _this16 = this; this.render("", { type: 'password' }); this.assertAttr('type', 'password'); (0, _internalTestHelpers.runTask)(function () { return _this16.rerender(); }); this.assertAttr('type', 'password'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this16.context, 'type', 'text'); }); this.assertAttr('type', 'text'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this16.context, 'type', 'password'); }); this.assertAttr('type', 'password'); }; _proto3['@test a subexpression can be used to determine type'] = function testASubexpressionCanBeUsedToDetermineType() { var _this17 = this; this.render("", { isTruthy: true, trueType: 'text', falseType: 'password' }); this.assertAttr('type', 'text'); (0, _internalTestHelpers.runTask)(function () { return _this17.rerender(); }); this.assertAttr('type', 'text'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this17.context, 'isTruthy', false); }); this.assertAttr('type', 'password'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this17.context, 'isTruthy', true); }); this.assertAttr('type', 'text'); }; _proto3['@test GH16256 input macro does not modify params in place'] = function testGH16256InputMacroDoesNotModifyParamsInPlace() { this.registerComponent('my-input', { template: "" }); this.render("", { firstType: 'password', secondType: 'email' }); var inputs = this.element.querySelectorAll('input'); this.assert.equal(inputs.length, 2, 'there are two inputs'); this.assert.equal(inputs[0].getAttribute('type'), 'password'); this.assert.equal(inputs[1].getAttribute('type'), 'email'); }; return _class2; }(InputRenderingTest)); (0, _internalTestHelpers.moduleFor)("Components test: ", /*#__PURE__*/ function (_InputRenderingTest3) { (0, _emberBabel.inheritsLoose)(_class3, _InputRenderingTest3); function _class3() { return _InputRenderingTest3.apply(this, arguments) || this; } var _proto4 = _class3.prototype; _proto4['@test dynamic attributes (HTML attribute)'] = function testDynamicAttributesHTMLAttribute() { var _this18 = this; this.render("", { disabled: false, name: 'original-name', checked: false, tabindex: 10 }); this.assertSingleCheckbox(); this.assertNotDisabled(); this.assertAttr('name', 'original-name'); this.assertAttr('tabindex', '10'); (0, _internalTestHelpers.runTask)(function () { return _this18.rerender(); }); this.assertSingleCheckbox(); this.assertNotDisabled(); this.assertAttr('name', 'original-name'); this.assertAttr('tabindex', '10'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this18.context, 'disabled', true); (0, _metal.set)(_this18.context, 'name', 'updated-name'); (0, _metal.set)(_this18.context, 'tabindex', 11); }); this.assertSingleCheckbox(); this.assertDisabled(); this.assertAttr('name', 'updated-name'); this.assertAttr('tabindex', '11'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this18.context, 'disabled', false); (0, _metal.set)(_this18.context, 'name', 'original-name'); (0, _metal.set)(_this18.context, 'tabindex', 10); }); this.assertSingleCheckbox(); this.assertNotDisabled(); this.assertAttr('name', 'original-name'); this.assertAttr('tabindex', '10'); }; _proto4['@test dynamic attributes (named argument)'] = function testDynamicAttributesNamedArgument() { var _this19 = this; this.render("", { disabled: false, name: 'original-name', checked: false, tabindex: 10 }); this.assertSingleCheckbox(); this.assertNotDisabled(); this.assertAttr('name', 'original-name'); this.assertAttr('tabindex', '10'); (0, _internalTestHelpers.runTask)(function () { return _this19.rerender(); }); this.assertSingleCheckbox(); this.assertNotDisabled(); this.assertAttr('name', 'original-name'); this.assertAttr('tabindex', '10'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this19.context, 'disabled', true); (0, _metal.set)(_this19.context, 'name', 'updated-name'); (0, _metal.set)(_this19.context, 'tabindex', 11); }); this.assertSingleCheckbox(); this.assertDisabled(); this.assertAttr('name', 'updated-name'); this.assertAttr('tabindex', '11'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this19.context, 'disabled', false); (0, _metal.set)(_this19.context, 'name', 'original-name'); (0, _metal.set)(_this19.context, 'tabindex', 10); }); this.assertSingleCheckbox(); this.assertNotDisabled(); this.assertAttr('name', 'original-name'); this.assertAttr('tabindex', '10'); }; _proto4['@test `value` property assertion'] = function testValuePropertyAssertion() { var _this20 = this; expectAssertion(function () { _this20.render("", { value: 'value' }); }, /checkbox.+@value.+not supported.+use.+@checked.+instead/); }; _proto4['@test with a bound type'] = function testWithABoundType() { var _this21 = this; this.render("", { inputType: 'checkbox', isChecked: true }); this.assertSingleCheckbox(); this.assertCheckboxIsChecked(); (0, _internalTestHelpers.runTask)(function () { return _this21.rerender(); }); this.assertCheckboxIsChecked(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this21.context, 'isChecked', false); }); this.assertCheckboxIsNotChecked(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this21.context, 'isChecked', true); }); this.assertCheckboxIsChecked(); }; _proto4['@test native click changes check property'] = function testNativeClickChangesCheckProperty() { this.render(""); this.assertSingleCheckbox(); this.assertCheckboxIsNotChecked(); this.$input()[0].click(); this.assertCheckboxIsChecked(); this.$input()[0].click(); this.assertCheckboxIsNotChecked(); }; _proto4['@test with static values (HTML attribute)'] = function testWithStaticValuesHTMLAttribute() { var _this22 = this; this.render(""); this.assertSingleCheckbox(); this.assertCheckboxIsNotChecked(); this.assertNotDisabled(); this.assertAttr('tabindex', '10'); this.assertAttr('name', 'original-name'); (0, _internalTestHelpers.runTask)(function () { return _this22.rerender(); }); this.assertSingleCheckbox(); this.assertCheckboxIsNotChecked(); this.assertNotDisabled(); this.assertAttr('tabindex', '10'); this.assertAttr('name', 'original-name'); }; _proto4['@test with static values (named argument)'] = function testWithStaticValuesNamedArgument() { var _this23 = this; this.render(""); this.assertSingleCheckbox(); this.assertCheckboxIsNotChecked(); this.assertNotDisabled(); this.assertAttr('tabindex', '10'); this.assertAttr('name', 'original-name'); (0, _internalTestHelpers.runTask)(function () { return _this23.rerender(); }); this.assertSingleCheckbox(); this.assertCheckboxIsNotChecked(); this.assertNotDisabled(); this.assertAttr('tabindex', '10'); this.assertAttr('name', 'original-name'); }; _proto4['@test sends an action with `` for native DOM events'] = function testSendsAnActionWithInputEVENTActionFooForNativeDOMEvents() { this.assertTriggersNativeDOMEvents('checkbox'); }; return _class3; }(InputRenderingTest)); (0, _internalTestHelpers.moduleFor)("Components test: ", /*#__PURE__*/ function (_InputRenderingTest4) { (0, _emberBabel.inheritsLoose)(_class4, _InputRenderingTest4); function _class4() { return _InputRenderingTest4.apply(this, arguments) || this; } var _proto5 = _class4.prototype; _proto5['@test null values (HTML attribute)'] = function testNullValuesHTMLAttribute() { var _this24 = this; var attributes = ['disabled', 'placeholder', 'name', 'maxlength', 'size', 'tabindex']; this.render("\n ", { value: null, disabled: null, placeholder: null, name: null, maxlength: null, size: null, tabindex: null }); this.assertValue(''); this.assertAllAttrs(attributes, undefined); (0, _internalTestHelpers.runTask)(function () { return _this24.rerender(); }); this.assertValue(''); this.assertAllAttrs(attributes, undefined); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this24.context, 'disabled', true); (0, _metal.set)(_this24.context, 'value', 'Updated value'); (0, _metal.set)(_this24.context, 'placeholder', 'Updated placeholder'); (0, _metal.set)(_this24.context, 'name', 'updated-name'); (0, _metal.set)(_this24.context, 'maxlength', 11); (0, _metal.set)(_this24.context, 'size', 21); (0, _metal.set)(_this24.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'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this24.context, 'disabled', null); (0, _metal.set)(_this24.context, 'value', null); (0, _metal.set)(_this24.context, 'placeholder', null); (0, _metal.set)(_this24.context, 'name', null); (0, _metal.set)(_this24.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, _metal.set)(_this24.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); }; _proto5['@test null values (named argument)'] = function testNullValuesNamedArgument() { var _this25 = this; var attributes = ['disabled', 'placeholder', 'name', 'maxlength', 'size', 'tabindex']; this.render("\n ", { value: null, disabled: null, placeholder: null, name: null, maxlength: null, size: null, tabindex: null }); this.assertValue(''); this.assertAllAttrs(attributes, undefined); (0, _internalTestHelpers.runTask)(function () { return _this25.rerender(); }); this.assertValue(''); this.assertAllAttrs(attributes, undefined); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this25.context, 'disabled', true); (0, _metal.set)(_this25.context, 'value', 'Updated value'); (0, _metal.set)(_this25.context, 'placeholder', 'Updated placeholder'); (0, _metal.set)(_this25.context, 'name', 'updated-name'); (0, _metal.set)(_this25.context, 'maxlength', 11); (0, _metal.set)(_this25.context, 'size', 21); (0, _metal.set)(_this25.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'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this25.context, 'disabled', null); (0, _metal.set)(_this25.context, 'value', null); (0, _metal.set)(_this25.context, 'placeholder', null); (0, _metal.set)(_this25.context, 'name', null); (0, _metal.set)(_this25.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, _metal.set)(_this25.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"'] [// HTML attribute '@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"', // Named argument '@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, _internalTestHelpers.moduleFor)("[GH#15675] Components test: ", /*#__PURE__*/ function (_InputRenderingTest5) { (0, _emberBabel.inheritsLoose)(_class5, _InputRenderingTest5); function _class5() { return _InputRenderingTest5.apply(this, arguments) || this; } var _proto6 = _class5.prototype; _proto6.renderInput = function renderInput() { var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 25; this.render(""); }; _proto6['@test value over default max but below set max is kept'] = function testValueOverDefaultMaxButBelowSetMaxIsKept() { this.renderInput('25'); this.assertValue('25'); }; _proto6['@test value below default min but above set min is kept'] = function testValueBelowDefaultMinButAboveSetMinIsKept() { this.renderInput('-2'); this.assertValue('-2'); }; _proto6['@test in the valid default range is kept'] = function testInTheValidDefaultRangeIsKept() { this.renderInput('5'); this.assertValue('5'); }; _proto6['@test value above max is reset to max'] = function testValueAboveMaxIsResetToMax() { this.renderInput('55'); this.assertValue('50'); }; _proto6['@test value below min is reset to min'] = function testValueBelowMinIsResetToMin() { this.renderInput('-10'); this.assertValue('-5'); }; return _class5; }(InputRenderingTest)); }); } else { (0, _internalTestHelpers.moduleFor)('Components test: ', /*#__PURE__*/ function (_RenderingTestCase2) { (0, _emberBabel.inheritsLoose)(_class6, _RenderingTestCase2); function _class6() { return _RenderingTestCase2.apply(this, arguments) || this; } var _proto7 = _class6.prototype; _proto7['@test it is not allowed'] = function testItIsNotAllowed() { var _this26 = this; expectAssertion(function () { _this26.render(""); }, 'Invoking `{{input}}` using angle bracket syntax or `component` helper is not yet supported.'); }; return _class6; }(_internalTestHelpers.RenderingTestCase)); } }); enifed("@ember/-internals/glimmer/tests/integration/components/input-curly-test", ["ember-babel", "internal-test-helpers", "@ember/polyfills", "@ember/-internals/metal", "@ember/-internals/views", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _polyfills, _metal, _views, _helpers) { "use strict"; var InputRenderingTest = /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(InputRenderingTest, _RenderingTestCase); function InputRenderingTest() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = InputRenderingTest.prototype; _proto.$input = function $input() { return this.$('input'); }; _proto.inputID = function inputID() { return this.$input().prop('id'); }; _proto.assertDisabled = function assertDisabled() { this.assert.ok(this.$('input').prop('disabled'), 'The input is disabled'); }; _proto.assertNotDisabled = function assertNotDisabled() { this.assert.ok(this.$('input').is(':not(:disabled)'), 'The input is not disabled'); }; _proto.assertInputId = function assertInputId(expectedId) { this.assert.equal(this.inputID(), expectedId, 'the input id should be `expectedId`'); }; _proto.assertSingleInput = function assertSingleInput() { this.assert.equal(this.$('input').length, 1, 'A single text field was inserted'); }; _proto.assertSingleCheckbox = function assertSingleCheckbox() { this.assert.equal(this.$('input[type=checkbox]').length, 1, 'A single checkbox is added'); }; _proto.assertCheckboxIsChecked = function assertCheckboxIsChecked() { this.assert.equal(this.$input().prop('checked'), true, 'the checkbox is checked'); }; _proto.assertCheckboxIsNotChecked = function assertCheckboxIsNotChecked() { this.assert.equal(this.$input().prop('checked'), false, 'the checkbox is not checked'); }; _proto.assertValue = function assertValue(expected) { this.assert.equal(this.$input().val(), expected, "the input value should be " + expected); }; _proto.assertAttr = function assertAttr(name, expected) { this.assert.equal(this.$input().attr(name), expected, "the input " + name + " attribute has the value '" + expected + "'"); }; _proto.assertAllAttrs = function assertAllAttrs(names, expected) { var _this = this; names.forEach(function (name) { return _this.assertAttr(name, expected); }); }; _proto.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); }; _proto.triggerEvent = function triggerEvent(type, options) { var event = document.createEvent('Events'); event.initEvent(type, true, true); (0, _polyfills.assign)(event, options); var element = this.$input()[0]; (0, _internalTestHelpers.runTask)(function () { element.dispatchEvent(event); }); }; _proto.assertTriggersNativeDOMEvents = function assertTriggersNativeDOMEvents(type) { var _this2 = this; // Defaults from EventDispatcher var events = { touchstart: 'touchStart', touchmove: 'touchMove', touchend: 'touchEnd', touchcancel: 'touchCancel', keydown: 'keyDown', keyup: 'keyUp', keypress: 'keyPress', mousedown: 'mouseDown', mouseup: 'mouseUp', contextmenu: 'contextMenu', click: 'click', dblclick: 'doubleClick', mousemove: 'mouseMove', focusin: 'focusIn', focusout: 'focusOut', mouseenter: 'mouseEnter', mouseleave: 'mouseLeave', submit: 'submit', input: 'input', change: 'change', dragstart: 'dragStart', drag: 'drag', dragenter: 'dragEnter', dragleave: 'dragLeave', dragover: 'dragOver', drop: 'drop', dragend: 'dragEnd' }; var TestComponent = _helpers.Component.extend({ tagName: 'input' }); this.registerComponent('test-component', { ComponentClass: TestComponent }); var triggeredEvents = []; var actions = {}; Object.keys(events).forEach(function (evt) { actions["run_" + evt] = function () { triggeredEvents.push(evt); }; }); var typeAttr = type ? "type=\"" + type + "\" " : ''; var actionAttrs = Object.keys(events).map(function (evt) { return events[evt] + "=(action 'run_" + evt + "')"; }).join(' '); var template = "{{test-component " + typeAttr + actionAttrs + "}}{{input " + typeAttr + actionAttrs + "}}"; this.render(template, { actions: actions }); Object.keys(events).forEach(function (evt) { return _this2.triggerEvent(evt, null, 'input:first-of-type'); }); var normallyTriggeredEvents = [].concat(triggeredEvents); triggeredEvents.length = 0; this.assert.ok(normallyTriggeredEvents.length > 10, 'sanity check that most events are triggered'); normallyTriggeredEvents.forEach(function (evt) { return _this2.triggerEvent(evt, null, 'input:last-of-type'); }); this.assert.deepEqual(triggeredEvents, normallyTriggeredEvents, 'called for all events'); }; return InputRenderingTest; }(_internalTestHelpers.RenderingTestCase); (0, _internalTestHelpers.moduleFor)('Components test: {{input}}', /*#__PURE__*/ function (_InputRenderingTest) { (0, _emberBabel.inheritsLoose)(_class, _InputRenderingTest); function _class() { return _InputRenderingTest.apply(this, arguments) || this; } var _proto2 = _class.prototype; _proto2['@test a single text field is inserted into the DOM'] = function testASingleTextFieldIsInsertedIntoTheDOM() { var _this3 = this; this.render("{{input type=\"text\" value=value}}", { value: 'hello' }); var id = this.inputID(); this.assertValue('hello'); this.assertSingleInput(); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); this.assertValue('hello'); this.assertSingleInput(); this.assertInputId(id); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.context, 'value', 'goodbye'); }); this.assertValue('goodbye'); this.assertSingleInput(); this.assertInputId(id); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this3.context, 'value', 'hello'); }); this.assertValue('hello'); this.assertSingleInput(); this.assertInputId(id); }; _proto2['@test default type'] = function testDefaultType() { var _this4 = this; this.render("{{input}}"); this.assertAttr('type', 'text'); (0, _internalTestHelpers.runTask)(function () { return _this4.rerender(); }); this.assertAttr('type', 'text'); }; _proto2['@test dynamic attributes'] = function testDynamicAttributes() { var _this5 = 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) (0, _internalTestHelpers.runTask)(function () { return _this5.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) (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.context, 'value', 'Updated value'); (0, _metal.set)(_this5.context, 'disabled', true); (0, _metal.set)(_this5.context, 'placeholder', 'Updated placeholder'); (0, _metal.set)(_this5.context, 'name', 'updated-name'); (0, _metal.set)(_this5.context, 'maxlength', 11); (0, _metal.set)(_this5.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) (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.context, 'value', 'Original value'); (0, _metal.set)(_this5.context, 'disabled', false); (0, _metal.set)(_this5.context, 'placeholder', 'Original placeholder'); (0, _metal.set)(_this5.context, 'name', 'original-name'); (0, _metal.set)(_this5.context, 'maxlength', 10); (0, _metal.set)(_this5.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) }; _proto2['@test static attributes'] = function testStaticAttributes() { var _this6 = 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) (0, _internalTestHelpers.runTask)(function () { return _this6.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) }; _proto2['@test cursor selection range'] = function testCursorSelectionRange() { var _this7 = 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) (0, _internalTestHelpers.runTask)(function () { return _this7.rerender(); }); // this.assertSelectionRange(8, 8); //NOTE: this is (0, 0) on Firefox (TEST_SUITE=sauce) (0, _internalTestHelpers.runTask)(function () { input.selectionStart = 2; input.selectionEnd = 4; }); this.assertSelectionRange(2, 4); (0, _internalTestHelpers.runTask)(function () { return _this7.rerender(); }); this.assertSelectionRange(2, 4); // runTask(() => set(this.context, 'value', 'updated')); // // this.assertSelectionRange(7, 7); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce) // // runTask(() => set(this.context, 'value', 'original')); // // this.assertSelectionRange(8, 8); //NOTE: this fails in IE, the range is 0 -> 0 (TEST_SUITE=sauce) }; _proto2['@test [DEPRECATED] sends an action with `{{input enter="foo"}}` when is pressed'] = function testDEPRECATEDSendsAnActionWithInputEnterFooWhenEnterIsPressed(assert) { var _this8 = this; assert.expect(4); expectDeprecation(function () { _this8.render("{{input enter='foo'}}", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); }, 'Passing actions to components as strings (like `{{input enter="foo"}}`) is deprecated. Please use closure actions instead (`{{input enter=(action "foo")}}`). (\'-top-level\' @ L1:C0) '); if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { expectDeprecation(function () { _this8.triggerEvent('keyup', { keyCode: 13 }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``).'); } else { expectDeprecation(function () { _this8.triggerEvent('keyup', { keyCode: 13 }); }, 'Passing actions to components as strings (like `{{input enter="foo"}}`) is deprecated. Please use closure actions instead (`{{input enter=(action "foo")}}`).'); } }; _proto2['@test sends an action with `{{input enter=(action "foo")}}` when is pressed'] = function testSendsAnActionWithInputEnterActionFooWhenEnterIsPressed(assert) { assert.expect(2); this.render("{{input enter=(action 'foo')}}", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keyup', { keyCode: 13 }); }; _proto2['@test [DEPRECATED] sends an action with `{{input key-press="foo"}}` is pressed'] = function testDEPRECATEDSendsAnActionWithInputKeyPressFooIsPressed(assert) { var _this9 = this; assert.expect(4); expectDeprecation(function () { _this9.render("{{input value=value key-press='foo'}}", { value: 'initial', actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); }, 'Passing actions to components as strings (like `{{input key-press="foo"}}`) is deprecated. Please use closure actions instead (`{{input key-press=(action "foo")}}`). (\'-top-level\' @ L1:C0) '); if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { expectDeprecation(function () { _this9.triggerEvent('keypress', { keyCode: 65 }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``).'); } else { expectDeprecation(function () { _this9.triggerEvent('keypress', { keyCode: 65 }); }, 'Passing actions to components as strings (like `{{input key-press="foo"}}`) is deprecated. Please use closure actions instead (`{{input key-press=(action "foo")}}`).'); } }; _proto2['@test sends an action with `{{input key-press=(action "foo")}}` is pressed'] = function testSendsAnActionWithInputKeyPressActionFooIsPressed(assert) { assert.expect(2); this.render("{{input value=value key-press=(action 'foo')}}", { value: 'initial', actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keypress', { keyCode: 65 }); }; _proto2['@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'); }; _proto2['@test triggers `focus-in` when focused'] = function testTriggersFocusInWhenFocused(assert) { var _this10 = this; var wasFocused = false; this.render("{{input focus-in=(action 'foo')}}", { actions: { foo: function () { wasFocused = true; } } }); (0, _internalTestHelpers.runTask)(function () { _this10.$input().focus(); }); assert.ok(wasFocused, 'action was triggered'); }; _proto2['@test sends `insert-newline` when is pressed'] = function testSendsInsertNewlineWhenEnterIsPressed(assert) { assert.expect(2); this.render("{{input insert-newline=(action 'foo')}}", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keyup', { keyCode: 13 }); }; _proto2['@test [DEPRECATED] sends an action with `{{input escape-press="foo"}}` when is pressed'] = function testDEPRECATEDSendsAnActionWithInputEscapePressFooWhenEscapeIsPressed(assert) { var _this11 = this; assert.expect(4); expectDeprecation(function () { _this11.render("{{input escape-press='foo'}}", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); }, 'Passing actions to components as strings (like `{{input escape-press="foo"}}`) is deprecated. Please use closure actions instead (`{{input escape-press=(action "foo")}}`). (\'-top-level\' @ L1:C0) '); if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { expectDeprecation(function () { _this11.triggerEvent('keyup', { keyCode: 27 }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``).'); } else { expectDeprecation(function () { _this11.triggerEvent('keyup', { keyCode: 27 }); }, 'Passing actions to components as strings (like `{{input escape-press="foo"}}`) is deprecated. Please use closure actions instead (`{{input escape-press=(action "foo")}}`).'); } }; _proto2['@test sends an action with `{{input escape-press=(action "foo")}}` when is pressed'] = function testSendsAnActionWithInputEscapePressActionFooWhenEscapeIsPressed(assert) { assert.expect(2); this.render("{{input escape-press=(action 'foo')}}", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keyup', { keyCode: 27 }); }; _proto2['@test [DEPRECATED] sends an action with `{{input key-down="foo"}}` when a key is pressed'] = function testDEPRECATEDSendsAnActionWithInputKeyDownFooWhenAKeyIsPressed(assert) { var _this12 = this; assert.expect(4); expectDeprecation(function () { _this12.render("{{input key-down='foo'}}", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); }, 'Passing actions to components as strings (like `{{input key-down="foo"}}`) is deprecated. Please use closure actions instead (`{{input key-down=(action "foo")}}`). (\'-top-level\' @ L1:C0) '); if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { expectDeprecation(function () { _this12.triggerEvent('keydown', { keyCode: 65 }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``).'); } else { expectDeprecation(function () { _this12.triggerEvent('keydown', { keyCode: 65 }); }, 'Passing actions to components as strings (like `{{input key-down="foo"}}`) is deprecated. Please use closure actions instead (`{{input key-down=(action "foo")}}`).'); } }; _proto2['@test sends an action with `{{input key-down=(action "foo")}}` when a key is pressed'] = function testSendsAnActionWithInputKeyDownActionFooWhenAKeyIsPressed(assert) { assert.expect(2); this.render("{{input key-down=(action 'foo')}}", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keydown', { keyCode: 65 }); }; _proto2['@test [DEPRECATED] sends an action with `{{input key-up="foo"}}` when a key is pressed'] = function testDEPRECATEDSendsAnActionWithInputKeyUpFooWhenAKeyIsPressed(assert) { var _this13 = this; assert.expect(4); expectDeprecation(function () { _this13.render("{{input key-up='foo'}}", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); }, 'Passing actions to components as strings (like `{{input key-up="foo"}}`) is deprecated. Please use closure actions instead (`{{input key-up=(action "foo")}}`). (\'-top-level\' @ L1:C0) '); if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { expectDeprecation(function () { _this13.triggerEvent('keyup', { keyCode: 65 }); }, 'Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``).'); } else { expectDeprecation(function () { _this13.triggerEvent('keyup', { keyCode: 65 }); }, 'Passing actions to components as strings (like `{{input key-up="foo"}}`) is deprecated. Please use closure actions instead (`{{input key-up=(action "foo")}}`).'); } }; _proto2['@test sends an action with `{{input key-up=(action "foo")}}` when a key is pressed'] = function testSendsAnActionWithInputKeyUpActionFooWhenAKeyIsPressed(assert) { assert.expect(2); this.render("{{input key-up=(action 'foo')}}", { actions: { foo: function (value, event) { assert.ok(true, 'action was triggered'); if (_views.jQueryDisabled) { assert.notOk(event.originalEvent, 'event is not a jQuery.Event'); } else { assert.ok(event instanceof _views.jQuery.Event, 'jQuery event was passed'); } } } }); this.triggerEvent('keyup', { keyCode: 65 }); }; _proto2['@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'); }; _proto2['@test sends an action with `{{input EVENT=(action "foo")}}` for native DOM events'] = function testSendsAnActionWithInputEVENTActionFooForNativeDOMEvents() { this.assertTriggersNativeDOMEvents(); }; return _class; }(InputRenderingTest)); (0, _internalTestHelpers.moduleFor)('Components test: {{input}} with dynamic type', /*#__PURE__*/ function (_InputRenderingTest2) { (0, _emberBabel.inheritsLoose)(_class2, _InputRenderingTest2); function _class2() { return _InputRenderingTest2.apply(this, arguments) || this; } var _proto3 = _class2.prototype; _proto3['@test a bound property can be used to determine type'] = function testABoundPropertyCanBeUsedToDetermineType() { var _this14 = this; this.render("{{input type=type}}", { type: 'password' }); this.assertAttr('type', 'password'); (0, _internalTestHelpers.runTask)(function () { return _this14.rerender(); }); this.assertAttr('type', 'password'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this14.context, 'type', 'text'); }); this.assertAttr('type', 'text'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this14.context, 'type', 'password'); }); this.assertAttr('type', 'password'); }; _proto3['@test a subexpression can be used to determine type'] = function testASubexpressionCanBeUsedToDetermineType() { var _this15 = this; this.render("{{input type=(if isTruthy trueType falseType)}}", { isTruthy: true, trueType: 'text', falseType: 'password' }); this.assertAttr('type', 'text'); (0, _internalTestHelpers.runTask)(function () { return _this15.rerender(); }); this.assertAttr('type', 'text'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this15.context, 'isTruthy', false); }); this.assertAttr('type', 'password'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this15.context, 'isTruthy', true); }); this.assertAttr('type', 'text'); }; _proto3['@test GH16256 input macro does not modify params in place'] = function testGH16256InputMacroDoesNotModifyParamsInPlace() { this.registerComponent('my-input', { template: "{{input type=inputType}}" }); this.render("{{my-input inputType=firstType}}{{my-input inputType=secondType}}", { firstType: 'password', secondType: 'email' }); var inputs = this.element.querySelectorAll('input'); this.assert.equal(inputs.length, 2, 'there are two inputs'); this.assert.equal(inputs[0].getAttribute('type'), 'password'); this.assert.equal(inputs[1].getAttribute('type'), 'email'); }; return _class2; }(InputRenderingTest)); (0, _internalTestHelpers.moduleFor)("Components test: {{input type='checkbox'}}", /*#__PURE__*/ function (_InputRenderingTest3) { (0, _emberBabel.inheritsLoose)(_class3, _InputRenderingTest3); function _class3() { return _InputRenderingTest3.apply(this, arguments) || this; } var _proto4 = _class3.prototype; _proto4['@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'); (0, _internalTestHelpers.runTask)(function () { return _this16.rerender(); }); this.assertSingleCheckbox(); this.assertNotDisabled(); this.assertAttr('name', 'original-name'); this.assertAttr('tabindex', '10'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this16.context, 'disabled', true); (0, _metal.set)(_this16.context, 'name', 'updated-name'); (0, _metal.set)(_this16.context, 'tabindex', 11); }); this.assertSingleCheckbox(); this.assertDisabled(); this.assertAttr('name', 'updated-name'); this.assertAttr('tabindex', '11'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this16.context, 'disabled', false); (0, _metal.set)(_this16.context, 'name', 'original-name'); (0, _metal.set)(_this16.context, 'tabindex', 10); }); this.assertSingleCheckbox(); this.assertNotDisabled(); this.assertAttr('name', 'original-name'); this.assertAttr('tabindex', '10'); }; _proto4['@test `value` property assertion'] = function testValuePropertyAssertion() { var _this17 = this; expectAssertion(function () { _this17.render("{{input type=\"checkbox\" value=value}}", { value: 'value' }); }, /checkbox.+value.+not supported.+use.+checked.+instead/); }; _proto4['@test with a bound type'] = function testWithABoundType() { var _this18 = this; this.render("{{input type=inputType checked=isChecked}}", { inputType: 'checkbox', isChecked: true }); this.assertSingleCheckbox(); this.assertCheckboxIsChecked(); (0, _internalTestHelpers.runTask)(function () { return _this18.rerender(); }); this.assertCheckboxIsChecked(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this18.context, 'isChecked', false); }); this.assertCheckboxIsNotChecked(); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this18.context, 'isChecked', true); }); this.assertCheckboxIsChecked(); }; _proto4['@test native click changes check property'] = function testNativeClickChangesCheckProperty() { this.render("{{input type=\"checkbox\"}}"); this.assertSingleCheckbox(); this.assertCheckboxIsNotChecked(); this.$input()[0].click(); this.assertCheckboxIsChecked(); this.$input()[0].click(); this.assertCheckboxIsNotChecked(); }; _proto4['@test with static values'] = function testWithStaticValues() { 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'); (0, _internalTestHelpers.runTask)(function () { return _this19.rerender(); }); this.assertSingleCheckbox(); this.assertCheckboxIsNotChecked(); this.assertNotDisabled(); this.assertAttr('tabindex', '10'); this.assertAttr('name', 'original-name'); }; _proto4['@test sends an action with `{{input EVENT=(action "foo")}}` for native DOM events'] = function testSendsAnActionWithInputEVENTActionFooForNativeDOMEvents() { this.assertTriggersNativeDOMEvents('checkbox'); }; return _class3; }(InputRenderingTest)); (0, _internalTestHelpers.moduleFor)("Components test: {{input type='text'}}", /*#__PURE__*/ function (_InputRenderingTest4) { (0, _emberBabel.inheritsLoose)(_class4, _InputRenderingTest4); function _class4() { return _InputRenderingTest4.apply(this, arguments) || this; } var _proto5 = _class4.prototype; _proto5['@test null values'] = function testNullValues() { var _this20 = 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); (0, _internalTestHelpers.runTask)(function () { return _this20.rerender(); }); this.assertValue(''); this.assertAllAttrs(attributes, undefined); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this20.context, 'disabled', true); (0, _metal.set)(_this20.context, 'value', 'Updated value'); (0, _metal.set)(_this20.context, 'placeholder', 'Updated placeholder'); (0, _metal.set)(_this20.context, 'name', 'updated-name'); (0, _metal.set)(_this20.context, 'maxlength', 11); (0, _metal.set)(_this20.context, 'size', 21); (0, _metal.set)(_this20.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'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this20.context, 'disabled', null); (0, _metal.set)(_this20.context, 'value', null); (0, _metal.set)(_this20.context, 'placeholder', null); (0, _metal.set)(_this20.context, 'name', null); (0, _metal.set)(_this20.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, _metal.set)(_this20.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, _internalTestHelpers.moduleFor)("[GH#15675] Components test: {{input " + attrs + "}}", /*#__PURE__*/ function (_InputRenderingTest5) { (0, _emberBabel.inheritsLoose)(_class5, _InputRenderingTest5); function _class5() { return _InputRenderingTest5.apply(this, arguments) || this; } var _proto6 = _class5.prototype; _proto6.renderInput = function renderInput() { var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 25; this.render("{{input " + attrs.replace('%x', value) + "}}"); }; _proto6['@test value over default max but below set max is kept'] = function testValueOverDefaultMaxButBelowSetMaxIsKept() { this.renderInput('25'); this.assertValue('25'); }; _proto6['@test value below default min but above set min is kept'] = function testValueBelowDefaultMinButAboveSetMinIsKept() { this.renderInput('-2'); this.assertValue('-2'); }; _proto6['@test in the valid default range is kept'] = function testInTheValidDefaultRangeIsKept() { this.renderInput('5'); this.assertValue('5'); }; _proto6['@test value above max is reset to max'] = function testValueAboveMaxIsResetToMax() { this.renderInput('55'); this.assertValue('50'); }; _proto6['@test value below min is reset to min'] = function testValueBelowMinIsResetToMin() { this.renderInput('-10'); this.assertValue('-5'); }; return _class5; }(InputRenderingTest)); }); }); enifed("@ember/-internals/glimmer/tests/integration/components/instrumentation-compile-test", ["ember-babel", "internal-test-helpers", "@ember/instrumentation", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _instrumentation, _helpers) { "use strict"; (0, _internalTestHelpers.moduleFor)('Components compile instrumentation', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { var _this; _this = _RenderingTestCase.apply(this, arguments) || this; _this.resetEvents(); (0, _instrumentation.subscribe)('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; } var _proto = _class.prototype; _proto.resetEvents = function resetEvents() { this.expected = { before: [], after: [] }; this.actual = { before: [], after: [] }; }; _proto.teardown = function teardown() { this.assert.deepEqual(this.actual.before, [], 'No unexpected events (before)'); this.assert.deepEqual(this.actual.after, [], 'No unexpected events (after)'); _RenderingTestCase.prototype.teardown.call(this); (0, _instrumentation.reset)(); }; _proto['@test it should only receive an instrumentation event for initial render'] = function testItShouldOnlyReceiveAnInstrumentationEventForInitialRender() { 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'); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); this.assertEvents('after no-op rerender'); }; _proto.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(); }; _proto._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]); }); }; _proto.assertPayload = function assertPayload(payload, component) { this.assert.equal(payload.object, component._debugContainerKey, 'payload.object'); }; return _class; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/instrumentation-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/metal", "@ember/instrumentation", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _metal, _instrumentation, _helpers) { "use strict"; (0, _internalTestHelpers.moduleFor)('Components instrumentation', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { var _this; _this = _RenderingTestCase.apply(this, arguments) || this; _this.resetEvents(); (0, _instrumentation.subscribe)('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; } var _proto = _class.prototype; _proto.resetEvents = function resetEvents() { this.expected = { before: [], after: [] }; this.actual = { before: [], after: [] }; }; _proto.teardown = function teardown() { this.assert.deepEqual(this.actual.before, [], 'No unexpected events (before)'); this.assert.deepEqual(this.actual.after, [], 'No unexpected events (after)'); _RenderingTestCase.prototype.teardown.call(this); (0, _instrumentation.reset)(); }; _proto['@test zomg'] = function testZomg(assert) { assert.ok(true); }; _proto['@test it should receive an instrumentation event for both initial render and updates'] = function testItShouldReceiveAnInstrumentationEventForBothInitialRenderAndUpdates() { 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); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); this.assertEvents('after no-op rerender'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'foo', 'FOO'); }); this.assertEvents('after updating top-level'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(_this2.context, 'baz', 'BAZ'); }); this.assertEvents('after updating inner-most'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this2.context, 'bar', 'BAR'); (0, _metal.set)(_this2.context, 'bat', 'BAT'); }); this.assertEvents('after updating the rest'); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this2.context, 'foo', 'FOO'); (0, _metal.set)(_this2.context, 'bar', 'BAR'); (0, _metal.set)(_this2.context, 'baz', 'BAZ'); (0, _metal.set)(_this2.context, 'bat', 'BAT'); }); this.assertEvents('after reset'); }; _proto.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(); }; _proto._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); }); }; _proto.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; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/life-cycle-test", ["ember-babel", "internal-test-helpers", "@ember/runloop", "@ember/-internals/metal", "@ember/-internals/runtime", "@ember/-internals/views", "@ember/-internals/utils", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _runloop, _metal, _runtime, _views, _utils, _helpers) { "use strict"; function _templateObject12() { const data = _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 "]); _templateObject12 = function () { return data; }; return data; } function _templateObject11() { const data = _taggedTemplateLiteralLoose(["\n {{yield}}\n
    \n {{#nested-component nestedId=(concat itemId '-A')}}A{{/nested-component}}\n {{#nested-component nestedId=(concat itemId '-B')}}B{{/nested-component}}\n
\n "]); _templateObject11 = function () { return data; }; return data; } function _templateObject10() { const data = _taggedTemplateLiteralLoose(["\n {{#each items as |item|}}\n ", "\n {{else}}\n ", "\n {{/each}}\n "]); _templateObject10 = function () { return data; }; return data; } function _templateObject9() { const data = _taggedTemplateLiteralLoose(["\n {{#nested-item}}Nothing to see here{{/nested-item}}\n "]); _templateObject9 = function () { return data; }; return data; } function _templateObject8() { const data = _taggedTemplateLiteralLoose(["\n {{#nested-item}}Item: {{count}}{{/nested-item}}\n "]); _templateObject8 = function () { return data; }; return data; } function _templateObject7() { const data = _taggedTemplateLiteralLoose(["\n
\n Bottom: {{", "}}\n
"]); _templateObject7 = function () { return data; }; return data; } function _templateObject6() { const data = _taggedTemplateLiteralLoose(["\n
\n Middle: ", "\n
"]); _templateObject6 = function () { return data; }; return data; } function _templateObject5() { const data = _taggedTemplateLiteralLoose(["\n
\n Top: ", "\n
"]); _templateObject5 = function () { return data; }; return data; } function _templateObject4() { const data = _taggedTemplateLiteralLoose(["\n
\n ", "|\n ", "|\n ", "\n
"]); _templateObject4 = function () { return data; }; return data; } function _templateObject3() { const data = _taggedTemplateLiteralLoose(["\n
\n Website: {{", "}}\n
"]); _templateObject3 = function () { return data; }; return data; } function _templateObject2() { const data = _taggedTemplateLiteralLoose(["\n
\n Name: {{", "}}|\n ", "\n
"]); _templateObject2 = function () { return data; }; return data; } function _templateObject() { const data = _taggedTemplateLiteralLoose(["\n
\n Twitter: {{", "}}|\n ", "\n
"]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } var LifeCycleHooksTest = /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(LifeCycleHooksTest, _RenderingTestCase); function LifeCycleHooksTest() { var _this; _this = _RenderingTestCase.apply(this, arguments) || this; _this.hooks = []; _this.components = {}; _this.componentRegistry = []; _this.teardownAssertions = []; _this.viewRegistry = _this.owner.lookup('-view-registry:main'); return _this; } var _proto = LifeCycleHooksTest.prototype; _proto.afterEach = function afterEach() { _RenderingTestCase.prototype.afterEach.call(this); for (var i = 0; i < this.teardownAssertions.length; i++) { this.teardownAssertions[i](); } }; _proto.getBootOptions = function getBootOptions() { return { isInteractive: this.isInteractive }; } /* abstract */ ; /* abstract */ _proto.invocationFor = function invocationFor() /* name, namedArgs = {} */ { throw new Error('Not implemented: `invocationFor`'); } /* abstract */ ; _proto.attrFor = function attrFor() /* name */ { throw new Error('Not implemented: `attrFor`'); }; _proto.assertRegisteredViews = function assertRegisteredViews(label) { var viewRegistry = this.viewRegistry; var topLevelId = (0, _views.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'); } }; _proto.registerComponent = function registerComponent(name, _ref) { var _this2 = this; var _ref$template = _ref.template, template = _ref$template === void 0 ? null : _ref$template; var pushComponent = function (instance) { _this2.components[name] = instance; _this2.componentRegistry.push((0, _views.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, _views.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, _views.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; this._super.apply(this, arguments); 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)'); }); (0, _runloop.schedule)('afterRender', function () { _this3.isInitialRender = false; }); }, 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); } }); _RenderingTestCase.prototype.registerComponent.call(this, name, { ComponentClass: ComponentClass, template: template }); }; _proto.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(void 0, raw); }); this.assert.deepEqual(json(this.hooks), json(hooks), label); this.hooks = []; }; _proto['@test lifecycle hooks are invoked in a predictable order'] = function testLifecycleHooksAreInvokedInAPredictableOrder() { var _this4 = this; var _this$boundHelpers = this.boundHelpers, attr = _this$boundHelpers.attr, invoke = _this$boundHelpers.invoke; this.registerComponent('the-top', { template: (0, _internalTestHelpers.strip)(_templateObject(), attr('twitter'), invoke('the-middle', { name: string('Tom Dale') })) }); this.registerComponent('the-middle', { template: (0, _internalTestHelpers.strip)(_templateObject2(), attr('name'), invoke('the-bottom', { website: string('tomdale.net') })) }); this.registerComponent('the-bottom', { template: (0, _internalTestHelpers.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'); this.assertHooks({ label: 'after initial render', interactive: [// Sync hooks ['the-top', 'init'], ['the-top', 'on(init)'], ['the-top', 'didReceiveAttrs'], ['the-top', 'willRender'], ['the-top', 'willInsertElement'], ['the-middle', 'init'], ['the-middle', 'on(init)'], ['the-middle', 'didReceiveAttrs'], ['the-middle', 'willRender'], ['the-middle', 'willInsertElement'], ['the-bottom', 'init'], ['the-bottom', 'on(init)'], ['the-bottom', 'didReceiveAttrs'], ['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', 'on(init)'], ['the-top', 'didReceiveAttrs'], ['the-middle', 'init'], ['the-middle', 'on(init)'], ['the-middle', 'didReceiveAttrs'], ['the-bottom', 'init'], ['the-bottom', 'on(init)'], ['the-bottom', 'didReceiveAttrs']] }); (0, _internalTestHelpers.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: [] }); (0, _internalTestHelpers.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: [] }); (0, _internalTestHelpers.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: [] }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.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'); }); }; _proto['@test lifecycle hooks are invoked in a correct sibling order'] = function testLifecycleHooksAreInvokedInACorrectSiblingOrder() { var _this5 = this; var _this$boundHelpers2 = this.boundHelpers, attr = _this$boundHelpers2.attr, invoke = _this$boundHelpers2.invoke; this.registerComponent('the-parent', { template: (0, _internalTestHelpers.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', 'on(init)'], ['the-parent', 'didReceiveAttrs'], ['the-parent', 'willRender'], ['the-parent', 'willInsertElement'], ['the-first-child', 'init'], ['the-first-child', 'on(init)'], ['the-first-child', 'didReceiveAttrs'], ['the-first-child', 'willRender'], ['the-first-child', 'willInsertElement'], ['the-second-child', 'init'], ['the-second-child', 'on(init)'], ['the-second-child', 'didReceiveAttrs'], ['the-second-child', 'willRender'], ['the-second-child', 'willInsertElement'], ['the-last-child', 'init'], ['the-last-child', 'on(init)'], ['the-last-child', 'didReceiveAttrs'], ['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', 'on(init)'], ['the-parent', 'didReceiveAttrs'], ['the-first-child', 'init'], ['the-first-child', 'on(init)'], ['the-first-child', 'didReceiveAttrs'], ['the-second-child', 'init'], ['the-second-child', 'on(init)'], ['the-second-child', 'didReceiveAttrs'], ['the-last-child', 'init'], ['the-last-child', 'on(init)'], ['the-last-child', 'didReceiveAttrs']] }); (0, _internalTestHelpers.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: [] }); (0, _internalTestHelpers.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: [] }); (0, _internalTestHelpers.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: [] }); (0, _internalTestHelpers.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: [] }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.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'); }); }; _proto['@test passing values through attrs causes lifecycle hooks to fire if the attribute values have changed'] = function testPassingValuesThroughAttrsCausesLifecycleHooksToFireIfTheAttributeValuesHaveChanged() { var _this6 = this; var _this$boundHelpers3 = this.boundHelpers, attr = _this$boundHelpers3.attr, invoke = _this$boundHelpers3.invoke; this.registerComponent('the-top', { template: (0, _internalTestHelpers.strip)(_templateObject5(), invoke('the-middle', { twitterTop: expr(attr('twitter')) })) }); this.registerComponent('the-middle', { template: (0, _internalTestHelpers.strip)(_templateObject6(), invoke('the-bottom', { twitterMiddle: expr(attr('twitterTop')) })) }); this.registerComponent('the-bottom', { template: (0, _internalTestHelpers.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', 'on(init)'], ['the-top', 'didReceiveAttrs'], ['the-top', 'willRender'], ['the-top', 'willInsertElement'], ['the-middle', 'init'], ['the-middle', 'on(init)'], ['the-middle', 'didReceiveAttrs'], ['the-middle', 'willRender'], ['the-middle', 'willInsertElement'], ['the-bottom', 'init'], ['the-bottom', 'on(init)'], ['the-bottom', 'didReceiveAttrs'], ['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', 'on(init)'], ['the-top', 'didReceiveAttrs'], ['the-middle', 'init'], ['the-middle', 'on(init)'], ['the-middle', 'didReceiveAttrs'], ['the-bottom', 'init'], ['the-bottom', 'on(init)'], ['the-bottom', 'didReceiveAttrs']] }); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.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']] }); (0, _internalTestHelpers.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'); }); }; _proto['@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, _internalTestHelpers.strip)(_templateObject8()) }); this.registerComponent('no-items', { template: (0, _internalTestHelpers.strip)(_templateObject9()) }); this.render((0, _internalTestHelpers.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 () { var ret = [['an-item', 'init'], ['an-item', 'on(init)'], ['an-item', 'didReceiveAttrs']]; if (_this7.isInteractive) { ret.push(['an-item', 'willRender'], ['an-item', 'willInsertElement']); } ret.push(['nested-item', 'init'], ['nested-item', 'on(init)'], ['nested-item', 'didReceiveAttrs']); if (_this7.isInteractive) { ret.push(['nested-item', 'willRender'], ['nested-item', 'willInsertElement']); } return ret; }; var initialAfterRenderHooks = function () { 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'); } (0, _internalTestHelpers.runTask)(function () { return (0, _metal.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', 'on(init)'], ['no-items', 'didReceiveAttrs'], ['no-items', 'willRender'], ['no-items', 'willInsertElement'], ['nested-item', 'init'], ['nested-item', 'on(init)'], ['nested-item', 'didReceiveAttrs'], ['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', 'on(init)'], ['no-items', 'didReceiveAttrs'], ['nested-item', 'init'], ['nested-item', 'on(init)'], ['nested-item', 'didReceiveAttrs'], ['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; }(_internalTestHelpers.RenderingTestCase); var CurlyComponentsTest = /*#__PURE__*/ function (_LifeCycleHooksTest) { (0, _emberBabel.inheritsLoose)(CurlyComponentsTest, _LifeCycleHooksTest); function CurlyComponentsTest() { return _LifeCycleHooksTest.apply(this, arguments) || this; } var _proto2 = CurlyComponentsTest.prototype; _proto2.invocationFor = function invocationFor(name) { var _this8 = this; var namedArgs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var attrs = Object.keys(namedArgs).map(function (k) { return k + "=" + _this8.val(namedArgs[k]); }).join(' '); return "{{" + name + " " + attrs + "}}"; }; _proto2.attrFor = function attrFor(name) { return "" + name; } /* private */ ; _proto2.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, _internalTestHelpers.moduleFor)('Components test: interactive lifecycle hooks (curly components)', /*#__PURE__*/ function (_CurlyComponentsTest) { (0, _emberBabel.inheritsLoose)(_class, _CurlyComponentsTest); function _class() { return _CurlyComponentsTest.apply(this, arguments) || this; } (0, _emberBabel.createClass)(_class, [{ key: "isInteractive", get: function () { return true; } }]); return _class; }(CurlyComponentsTest)); (0, _internalTestHelpers.moduleFor)('Components test: non-interactive lifecycle hooks (curly components)', /*#__PURE__*/ function (_CurlyComponentsTest2) { (0, _emberBabel.inheritsLoose)(_class2, _CurlyComponentsTest2); function _class2() { return _CurlyComponentsTest2.apply(this, arguments) || this; } (0, _emberBabel.createClass)(_class2, [{ key: "isInteractive", get: function () { return false; } }]); return _class2; }(CurlyComponentsTest)); (0, _internalTestHelpers.moduleFor)('Components test: interactive lifecycle hooks (tagless curly components)', /*#__PURE__*/ function (_CurlyComponentsTest3) { (0, _emberBabel.inheritsLoose)(_class3, _CurlyComponentsTest3); function _class3() { return _CurlyComponentsTest3.apply(this, arguments) || this; } (0, _emberBabel.createClass)(_class3, [{ key: "ComponentClass", get: function () { return _helpers.Component.extend({ tagName: '' }); } }, { key: "isInteractive", get: function () { return true; } }]); return _class3; }(CurlyComponentsTest)); (0, _internalTestHelpers.moduleFor)('Components test: non-interactive lifecycle hooks (tagless curly components)', /*#__PURE__*/ function (_CurlyComponentsTest4) { (0, _emberBabel.inheritsLoose)(_class4, _CurlyComponentsTest4); function _class4() { return _CurlyComponentsTest4.apply(this, arguments) || this; } (0, _emberBabel.createClass)(_class4, [{ key: "ComponentClass", get: function () { return _helpers.Component.extend({ tagName: '' }); } }, { key: "isInteractive", get: function () { return false; } }]); return _class4; }(CurlyComponentsTest)); (0, _internalTestHelpers.moduleFor)('Run loop and lifecycle hooks', /*#__PURE__*/ function (_RenderingTestCase2) { (0, _emberBabel.inheritsLoose)(_class5, _RenderingTestCase2); function _class5() { return _RenderingTestCase2.apply(this, arguments) || this; } var _proto3 = _class5.prototype; _proto3['@test afterRender set'] = function testAfterRenderSet() { var _this10 = this; var ComponentClass = _helpers.Component.extend({ width: '5', didInsertElement: function () { var _this9 = this; (0, _runloop.schedule)('afterRender', function () { _this9.set('width', '10'); }); } }); var template = "{{width}}"; this.registerComponent('foo-bar', { ComponentClass: ComponentClass, template: template }); this.render('{{foo-bar}}'); this.assertText('10'); (0, _internalTestHelpers.runTask)(function () { return _this10.rerender(); }); this.assertText('10'); }; _proto3['@test afterRender set on parent'] = function testAfterRenderSetOnParent() { var _this12 = this; var ComponentClass = _helpers.Component.extend({ didInsertElement: function () { var _this11 = this; (0, _runloop.schedule)('afterRender', function () { var parent = _this11.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'); (0, _internalTestHelpers.runTask)(function () { return _this12.rerender(); }); this.assertText('wat'); }; _proto3['@test `willRender` can set before render (GH#14458)'] = function testWillRenderCanSetBeforeRenderGH14458() { 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, _internalTestHelpers.classes)('ember-view') } }); }; _proto3['@test that thing about destroying'] = function testThatThingAboutDestroying(assert) { var _this13 = this; var ParentDestroyedElements = []; var ChildDestroyedElements = []; var ParentComponent = _helpers.Component.extend({ willDestroyElement: function () { ParentDestroyedElements.push({ id: this.itemId, name: 'parent-component', hasParent: Boolean(this.element.parentNode), nextSibling: Boolean(this.element.nextSibling), previousSibling: Boolean(this.element.previousSibling) }); } }); var PartentTemplate = (0, _internalTestHelpers.strip)(_templateObject11()); var NestedComponent = _helpers.Component.extend({ willDestroyElement: function () { ChildDestroyedElements.push({ id: this.nestedId, name: 'nested-component', hasParent: Boolean(this.element.parentNode), nextSibling: Boolean(this.element.nextSibling), previousSibling: Boolean(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, _runtime.A)([{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }]); this.render((0, _internalTestHelpers.strip)(_templateObject12()), { items: array, model: { shouldShow: true } }); this.assertText('1AB2AB3AB4AB5AB6AB7AB'); (0, _internalTestHelpers.runTask)(function () { array.removeAt(2); array.removeAt(2); (0, _metal.set)(_this13.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 }]); }; _proto3['@test lifecycle hooks exist on the base class'] = function testLifecycleHooksExistOnTheBaseClass(assert) { // Make sure we get the finalized component prototype var prototype = _helpers.Component.proto(); assert.equal(typeof prototype.didDestroyElement, 'function', 'didDestroyElement exists'); assert.equal(typeof prototype.didInsertElement, 'function', 'didInsertElement exists'); assert.equal(typeof prototype.didReceiveAttrs, 'function', 'didReceiveAttrs exists'); assert.equal(typeof prototype.didRender, 'function', 'didRender exists'); assert.equal(typeof prototype.didUpdate, 'function', 'didUpdate exists'); assert.equal(typeof prototype.didUpdateAttrs, 'function', 'didUpdateAttrs exists'); assert.equal(typeof prototype.willClearRender, 'function', 'willClearRender exists'); assert.equal(typeof prototype.willDestroy, 'function', 'willDestroy exists'); assert.equal(typeof prototype.willDestroyElement, 'function', 'willDestroyElement exists'); assert.equal(typeof prototype.willInsertElement, 'function', 'willInsertElement exists'); assert.equal(typeof prototype.willRender, 'function', 'willRender exists'); assert.equal(typeof prototype.willUpdate, 'function', 'willUpdate exists'); }; return _class5; }(_internalTestHelpers.RenderingTestCase)); if (!_views.jQueryDisabled) { (0, _internalTestHelpers.moduleFor)('Run loop and lifecycle hooks - jQuery only', /*#__PURE__*/ function (_RenderingTestCase3) { (0, _emberBabel.inheritsLoose)(_class6, _RenderingTestCase3); function _class6() { return _RenderingTestCase3.apply(this, arguments) || this; } var _proto4 = _class6.prototype; _proto4['@test lifecycle hooks have proper access to this.$()'] = function testLifecycleHooksHaveProperAccessToThis$(assert) { assert.expect(7); var component; 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; expectDeprecation(function () { var comp = owner.lookup('component:foo-bar'); (0, _internalTestHelpers.runAppend)(comp); (0, _internalTestHelpers.runTask)(function () { return (0, _utils.tryInvoke)(component, 'destroy'); }); }, 'Using this.$() in a component has been deprecated, consider using this.element'); (0, _internalTestHelpers.runTask)(function () { return (0, _utils.tryInvoke)(component, 'destroy'); }); }; return _class6; }(_internalTestHelpers.RenderingTestCase)); } 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 = new 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)); } }); enifed("@ember/-internals/glimmer/tests/integration/components/link-to/query-params-angle-test", ["ember-babel", "@ember/controller", "@ember/-internals/runtime", "@ember/-internals/routing", "internal-test-helpers"], function (_emberBabel, _controller, _runtime, _routing, _internalTestHelpers) { "use strict"; if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { (0, _internalTestHelpers.moduleFor)(' component with query-params (rendering)', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { var _this; _this = _ApplicationTestCase.apply(this, arguments) || this; _this.add('controller:index', _controller.default.extend({ queryParams: ['foo'], foo: '123', bar: 'yes' })); return _this; } var _proto = _class.prototype; _proto['@test populates href with fully supplied query param values'] = function testPopulatesHrefWithFullySuppliedQueryParamValues() { var _this2 = this; this.addTemplate('index', "Index"); return this.visit('/').then(function () { _this2.assertComponentElement(_this2.firstChild, { tagName: 'a', attrs: { href: '/?bar=NAW&foo=456' }, content: 'Index' }); }); }; _proto['@test populates href with partially supplied query param values, but omits if value is default value'] = function testPopulatesHrefWithPartiallySuppliedQueryParamValuesButOmitsIfValueIsDefaultValue() { var _this3 = this; this.addTemplate('index', "Index"); return this.visit('/').then(function () { _this3.assertComponentElement(_this3.firstChild, { tagName: 'a', attrs: { href: '/', class: (0, _internalTestHelpers.classes)('ember-view active') }, content: 'Index' }); }); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)(' component with query params (routing)', /*#__PURE__*/ function (_ApplicationTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _ApplicationTestCase2); function _class2() { var _this4; _this4 = _ApplicationTestCase2.call(this) || this; var indexProperties = { foo: '123', bar: 'abc' }; _this4.add('controller:index', _controller.default.extend({ queryParams: ['foo', 'bar', 'abool'], foo: indexProperties.foo, bar: indexProperties.bar, boundThing: 'OMG', abool: true })); _this4.add('controller:about', _controller.default.extend({ queryParams: ['baz', 'bat'], baz: 'alex', bat: 'borf' })); _this4.indexProperties = indexProperties; return _this4; } var _proto2 = _class2.prototype; _proto2.shouldNotBeActive = function shouldNotBeActive(assert, selector) { this.checkActive(assert, selector, false); }; _proto2.shouldBeActive = function shouldBeActive(assert, selector) { this.checkActive(assert, selector, true); }; _proto2.getController = function getController(name) { return this.applicationInstance.lookup("controller:" + name); }; _proto2.checkActive = function checkActive(assert, selector, active) { var classList = this.$(selector)[0].className; assert.equal(classList.indexOf('active') > -1, active, selector + ' active should be ' + active.toString()); }; _proto2["@test doesn't update controller QP properties on current route when invoked"] = function (assert) { var _this5 = this; this.addTemplate('index', "Index"); return this.visit('/').then(function () { _this5.click('#the-link'); var indexController = _this5.getController('index'); assert.deepEqual(indexController.getProperties('foo', 'bar'), _this5.indexProperties, 'controller QP properties do not update'); }); }; _proto2["@test doesn't update controller QP properties on current route when invoked (empty query-params obj)"] = function (assert) { var _this6 = this; this.addTemplate('index', "Index"); return this.visit('/').then(function () { _this6.click('#the-link'); var indexController = _this6.getController('index'); assert.deepEqual(indexController.getProperties('foo', 'bar'), _this6.indexProperties, 'controller QP properties do not update'); }); }; _proto2["@test doesn't update controller QP properties on current route when invoked (empty query-params obj, inferred route)"] = function (assert) { var _this7 = this; this.addTemplate('index', "Index"); return this.visit('/').then(function () { _this7.click('#the-link'); var indexController = _this7.getController('index'); assert.deepEqual(indexController.getProperties('foo', 'bar'), _this7.indexProperties, 'controller QP properties do not update'); }); }; _proto2['@test updates controller QP properties on current route when invoked'] = function testUpdatesControllerQPPropertiesOnCurrentRouteWhenInvoked(assert) { var _this8 = this; this.addTemplate('index', "\n \n Index\n \n "); return this.visit('/').then(function () { _this8.click('#the-link'); var indexController = _this8.getController('index'); assert.deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); }); }; _proto2['@test updates controller QP properties on current route when invoked (inferred route)'] = function testUpdatesControllerQPPropertiesOnCurrentRouteWhenInvokedInferredRoute(assert) { var _this9 = this; this.addTemplate('index', "\n \n Index\n \n "); return this.visit('/').then(function () { _this9.click('#the-link'); var indexController = _this9.getController('index'); assert.deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); }); }; _proto2['@test updates controller QP properties on other route after transitioning to that route'] = function testUpdatesControllerQPPropertiesOnOtherRouteAfterTransitioningToThatRoute(assert) { var _this10 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "\n \n About\n \n "); return this.visit('/').then(function () { var theLink = _this10.$('#the-link'); assert.equal(theLink.attr('href'), '/about?baz=lol'); (0, _internalTestHelpers.runTask)(function () { return _this10.click('#the-link'); }); var aboutController = _this10.getController('about'); assert.deepEqual(aboutController.getProperties('baz', 'bat'), { baz: 'lol', bat: 'borf' }, 'about controller QP properties updated'); }); }; _proto2['@test supplied QP properties can be bound'] = function testSuppliedQPPropertiesCanBeBound(assert) { var _this11 = this; this.addTemplate('index', "\n \n Index\n \n "); return this.visit('/').then(function () { var indexController = _this11.getController('index'); var theLink = _this11.$('#the-link'); assert.equal(theLink.attr('href'), '/?foo=OMG'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('boundThing', 'ASL'); }); assert.equal(theLink.attr('href'), '/?foo=ASL'); }); }; _proto2['@test supplied QP properties can be bound (booleans)'] = function testSuppliedQPPropertiesCanBeBoundBooleans(assert) { var _this12 = this; this.addTemplate('index', "\n \n Index\n \n "); return this.visit('/').then(function () { var indexController = _this12.getController('index'); var theLink = _this12.$('#the-link'); assert.equal(theLink.attr('href'), '/?abool=OMG'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('boundThing', false); }); assert.equal(theLink.attr('href'), '/?abool=false'); _this12.click('#the-link'); assert.deepEqual(indexController.getProperties('foo', 'bar', 'abool'), { foo: '123', bar: 'abc', abool: false }, 'bound bool QP properties update'); }); }; _proto2['@test href updates when unsupplied controller QP props change'] = function testHrefUpdatesWhenUnsuppliedControllerQPPropsChange(assert) { var _this13 = this; this.addTemplate('index', "\n \n Index\n \n "); return this.visit('/').then(function () { var indexController = _this13.getController('index'); var theLink = _this13.$('#the-link'); assert.equal(theLink.attr('href'), '/?foo=lol'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('bar', 'BORF'); }); assert.equal(theLink.attr('href'), '/?bar=BORF&foo=lol'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('foo', 'YEAH'); }); assert.equal(theLink.attr('href'), '/?bar=BORF&foo=lol'); }); }; _proto2['@test The component with only query params always transitions to the current route with the query params applied'] = function testTheLinkToComponentWithOnlyQueryParamsAlwaysTransitionsToTheCurrentRouteWithTheQueryParamsApplied(assert) { var _this14 = this; // Test harness for bug #12033 this.addTemplate('cars', "\n Create new car\n Page 2\n {{outlet}}\n "); this.addTemplate('cars.create', "Close create form"); this.router.map(function () { this.route('cars', function () { this.route('create'); }); }); this.add('controller:cars', _controller.default.extend({ queryParams: ['page'], page: 1 })); return this.visit('/cars/create').then(function () { var router = _this14.appRouter; var carsController = _this14.getController('cars'); assert.equal(router.currentRouteName, 'cars.create'); (0, _internalTestHelpers.runTask)(function () { return _this14.click('#close-link'); }); assert.equal(router.currentRouteName, 'cars.index'); assert.equal(router.get('url'), '/cars'); assert.equal(carsController.get('page'), 1, 'The page query-param is 1'); (0, _internalTestHelpers.runTask)(function () { return _this14.click('#page2-link'); }); assert.equal(router.currentRouteName, 'cars.index', 'The active route is still cars'); assert.equal(router.get('url'), '/cars?page=2', 'The url has been updated'); assert.equal(carsController.get('page'), 2, 'The query params have been updated'); }); }; _proto2['@test the component applies activeClass when query params are not changed'] = function testTheLinkToComponentAppliesActiveClassWhenQueryParamsAreNotChanged(assert) { var _this15 = this; this.addTemplate('index', "\n Index\n Index\n Index\n "); this.addTemplate('search', "\n Index\n Index\n Index\n Index\n Index\n Index\n Index\n {{outlet}}\n "); this.addTemplate('search.results', "\n Index\n Index\n Index\n Index\n Index\n Index\n Index\n "); this.router.map(function () { this.route('search', function () { this.route('results'); }); }); this.add('controller:search', _controller.default.extend({ queryParams: ['search', 'archive'], search: '', archive: false })); this.add('controller:search.results', _controller.default.extend({ queryParams: ['sort', 'showDetails'], sort: 'title', showDetails: true })); return this.visit('/').then(function () { _this15.shouldNotBeActive(assert, '#cat-link'); _this15.shouldNotBeActive(assert, '#dog-link'); return _this15.visit('/?foo=cat'); }).then(function () { _this15.shouldBeActive(assert, '#cat-link'); _this15.shouldNotBeActive(assert, '#dog-link'); return _this15.visit('/?foo=dog'); }).then(function () { _this15.shouldBeActive(assert, '#dog-link'); _this15.shouldNotBeActive(assert, '#cat-link'); _this15.shouldBeActive(assert, '#change-nothing'); return _this15.visit('/search?search=same'); }).then(function () { _this15.shouldBeActive(assert, '#same-search'); _this15.shouldNotBeActive(assert, '#change-search'); _this15.shouldNotBeActive(assert, '#same-search-add-archive'); _this15.shouldNotBeActive(assert, '#only-add-archive'); _this15.shouldNotBeActive(assert, '#remove-one'); return _this15.visit('/search?search=same&archive=true'); }).then(function () { _this15.shouldBeActive(assert, '#both-same'); _this15.shouldNotBeActive(assert, '#change-one'); return _this15.visit('/search/results?search=same&sort=title&showDetails=true'); }).then(function () { _this15.shouldBeActive(assert, '#same-sort-child-only'); _this15.shouldBeActive(assert, '#same-search-parent-only'); _this15.shouldNotBeActive(assert, '#change-search-parent-only'); _this15.shouldBeActive(assert, '#same-search-same-sort-child-and-parent'); _this15.shouldNotBeActive(assert, '#same-search-different-sort-child-and-parent'); _this15.shouldNotBeActive(assert, '#change-search-same-sort-child-and-parent'); }); }; _proto2['@test the component applies active class when query-param is a number'] = function testTheLinkToComponentAppliesActiveClassWhenQueryParamIsANumber(assert) { var _this16 = this; this.addTemplate('index', "\n \n Index\n \n "); this.add('controller:index', _controller.default.extend({ queryParams: ['page'], page: 1, pageNumber: 5 })); return this.visit('/').then(function () { _this16.shouldNotBeActive(assert, '#page-link'); return _this16.visit('/?page=5'); }).then(function () { _this16.shouldBeActive(assert, '#page-link'); }); }; _proto2['@test the component applies active class when query-param is an array'] = function testTheLinkToComponentAppliesActiveClassWhenQueryParamIsAnArray(assert) { var _this17 = this; this.addTemplate('index', "\n Index\n Index\n Index\n "); this.add('controller:index', _controller.default.extend({ queryParams: ['pages'], pages: [], pagesArray: [1, 2], biggerArray: [1, 2, 3], emptyArray: [] })); return this.visit('/').then(function () { _this17.shouldNotBeActive(assert, '#array-link'); return _this17.visit('/?pages=%5B1%2C2%5D'); }).then(function () { _this17.shouldBeActive(assert, '#array-link'); _this17.shouldNotBeActive(assert, '#bigger-link'); _this17.shouldNotBeActive(assert, '#empty-link'); return _this17.visit('/?pages=%5B2%2C1%5D'); }).then(function () { _this17.shouldNotBeActive(assert, '#array-link'); _this17.shouldNotBeActive(assert, '#bigger-link'); _this17.shouldNotBeActive(assert, '#empty-link'); return _this17.visit('/?pages=%5B1%2C2%2C3%5D'); }).then(function () { _this17.shouldBeActive(assert, '#bigger-link'); _this17.shouldNotBeActive(assert, '#array-link'); _this17.shouldNotBeActive(assert, '#empty-link'); }); }; _proto2['@test the component applies active class to the parent route'] = function testTheLinkToComponentAppliesActiveClassToTheParentRoute(assert) { var _this18 = this; this.router.map(function () { this.route('parent', function () { this.route('child'); }); }); this.addTemplate('application', "\n Parent\n Child\n Parent\n {{outlet}}\n "); this.add('controller:parent.child', _controller.default.extend({ queryParams: ['foo'], foo: 'bar' })); return this.visit('/').then(function () { _this18.shouldNotBeActive(assert, '#parent-link'); _this18.shouldNotBeActive(assert, '#parent-child-link'); _this18.shouldNotBeActive(assert, '#parent-link-qp'); return _this18.visit('/parent/child?foo=dog'); }).then(function () { _this18.shouldBeActive(assert, '#parent-link'); _this18.shouldNotBeActive(assert, '#parent-link-qp'); }); }; _proto2['@test The component disregards query-params in activeness computation when current-when is specified'] = function testTheLinkToComponentDisregardsQueryParamsInActivenessComputationWhenCurrentWhenIsSpecified(assert) { var _this19 = this; var appLink; this.router.map(function () { this.route('parent'); }); this.addTemplate('application', "\n \n Parent\n \n {{outlet}}\n "); this.addTemplate('parent', "\n \n Parent\n \n {{outlet}}\n "); this.add('controller:parent', _controller.default.extend({ queryParams: ['page'], page: 1 })); return this.visit('/').then(function () { appLink = _this19.$('#app-link'); assert.equal(appLink.attr('href'), '/parent'); _this19.shouldNotBeActive(assert, '#app-link'); return _this19.visit('/parent?page=2'); }).then(function () { appLink = _this19.$('#app-link'); var router = _this19.appRouter; assert.equal(appLink.attr('href'), '/parent'); _this19.shouldBeActive(assert, '#app-link'); assert.equal(_this19.$('#parent-link').attr('href'), '/parent'); _this19.shouldBeActive(assert, '#parent-link'); var parentController = _this19.getController('parent'); assert.equal(parentController.get('page'), 2); (0, _internalTestHelpers.runTask)(function () { return parentController.set('page', 3); }); assert.equal(router.get('location.path'), '/parent?page=3'); _this19.shouldBeActive(assert, '#app-link'); _this19.shouldBeActive(assert, '#parent-link'); (0, _internalTestHelpers.runTask)(function () { return _this19.click('#app-link'); }); assert.equal(router.get('location.path'), '/parent'); }); }; _proto2['@test the component default query params while in active transition regression test'] = function testTheLinkToComponentDefaultQueryParamsWhileInActiveTransitionRegressionTest(assert) { var _this20 = this; this.router.map(function () { this.route('foos'); this.route('bars'); }); var foos = _runtime.RSVP.defer(); var bars = _runtime.RSVP.defer(); this.addTemplate('application', "\n Foos\n Baz Foos\n Quux Bars\n "); this.add('controller:foos', _controller.default.extend({ queryParams: ['status'], baz: false })); this.add('route:foos', _routing.Route.extend({ model: function () { return foos.promise; } })); this.add('controller:bars', _controller.default.extend({ queryParams: ['status'], quux: false })); this.add('route:bars', _routing.Route.extend({ model: function () { return bars.promise; } })); return this.visit('/').then(function () { var router = _this20.appRouter; var foosLink = _this20.$('#foos-link'); var barsLink = _this20.$('#bars-link'); var bazLink = _this20.$('#baz-foos-link'); assert.equal(foosLink.attr('href'), '/foos'); assert.equal(bazLink.attr('href'), '/foos?baz=true'); assert.equal(barsLink.attr('href'), '/bars?quux=true'); assert.equal(router.get('location.path'), '/'); _this20.shouldNotBeActive(assert, '#foos-link'); _this20.shouldNotBeActive(assert, '#baz-foos-link'); _this20.shouldNotBeActive(assert, '#bars-link'); (0, _internalTestHelpers.runTask)(function () { return barsLink.click(); }); _this20.shouldNotBeActive(assert, '#bars-link'); (0, _internalTestHelpers.runTask)(function () { return foosLink.click(); }); _this20.shouldNotBeActive(assert, '#foos-link'); (0, _internalTestHelpers.runTask)(function () { return foos.resolve(); }); assert.equal(router.get('location.path'), '/foos'); _this20.shouldBeActive(assert, '#foos-link'); }); }; return _class2; }(_internalTestHelpers.ApplicationTestCase)); } }); enifed("@ember/-internals/glimmer/tests/integration/components/link-to/query-params-curly-test", ["ember-babel", "@ember/controller", "@ember/-internals/runtime", "@ember/-internals/routing", "internal-test-helpers"], function (_emberBabel, _controller, _runtime, _routing, _internalTestHelpers) { "use strict"; (0, _internalTestHelpers.moduleFor)('{{link-to}} component with query-params (rendering)', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { var _this; _this = _ApplicationTestCase.apply(this, arguments) || this; _this.add('controller:index', _controller.default.extend({ queryParams: ['foo'], foo: '123', bar: 'yes' })); return _this; } var _proto = _class.prototype; _proto['@test populates href with fully supplied query param values'] = function testPopulatesHrefWithFullySuppliedQueryParamValues() { var _this2 = this; this.addTemplate('index', "{{#link-to 'index' (query-params foo='456' bar='NAW')}}Index{{/link-to}}"); return this.visit('/').then(function () { _this2.assertComponentElement(_this2.firstChild, { tagName: 'a', attrs: { href: '/?bar=NAW&foo=456' }, content: 'Index' }); }); }; _proto['@test populates href with partially supplied query param values, but omits if value is default value'] = function testPopulatesHrefWithPartiallySuppliedQueryParamValuesButOmitsIfValueIsDefaultValue() { var _this3 = this; this.addTemplate('index', "{{#link-to 'index' (query-params foo='123')}}Index{{/link-to}}"); return this.visit('/').then(function () { _this3.assertComponentElement(_this3.firstChild, { tagName: 'a', attrs: { href: '/', class: (0, _internalTestHelpers.classes)('ember-view active') }, content: 'Index' }); }); }; _proto['@feature(ember-glimmer-angle-bracket-built-ins) `(query-params)` must be used in conjunction with `{{link-to}}'] = function featureEmberGlimmerAngleBracketBuiltInsQueryParamsMustBeUsedInConjunctionWithLinkTo() { var _this4 = this; this.addTemplate('index', "{{#let (query-params foo='456' bar='NAW') as |qp|}}{{link-to 'Index' 'index' qp}}{{/let}}"); return expectAssertion(function () { return _this4.visit('/'); }, /The `\(query-params\)` helper can only be used when invoking the `{{link-to}}` component\./); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)('{{link-to}} component with query params (routing)', /*#__PURE__*/ function (_ApplicationTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _ApplicationTestCase2); function _class2() { var _this5; _this5 = _ApplicationTestCase2.apply(this, arguments) || this; var indexProperties = { foo: '123', bar: 'abc' }; _this5.add('controller:index', _controller.default.extend({ queryParams: ['foo', 'bar', 'abool'], foo: indexProperties.foo, bar: indexProperties.bar, boundThing: 'OMG', abool: true })); _this5.add('controller:about', _controller.default.extend({ queryParams: ['baz', 'bat'], baz: 'alex', bat: 'borf' })); _this5.indexProperties = indexProperties; return _this5; } var _proto2 = _class2.prototype; _proto2.shouldNotBeActive = function shouldNotBeActive(assert, selector) { this.checkActive(assert, selector, false); }; _proto2.shouldBeActive = function shouldBeActive(assert, selector) { this.checkActive(assert, selector, true); }; _proto2.getController = function getController(name) { return this.applicationInstance.lookup("controller:" + name); }; _proto2.checkActive = function checkActive(assert, selector, active) { var classList = this.$(selector)[0].className; assert.equal(classList.indexOf('active') > -1, active, selector + ' active should be ' + active.toString()); }; _proto2["@test doesn't update controller QP properties on current route when invoked"] = function (assert) { var _this6 = this; this.addTemplate('index', "{{#link-to 'index' id='the-link'}}Index{{/link-to}}"); return this.visit('/').then(function () { _this6.click('#the-link'); var indexController = _this6.getController('index'); assert.deepEqual(indexController.getProperties('foo', 'bar'), _this6.indexProperties, 'controller QP properties do not update'); }); }; _proto2["@test doesn't update controller QP properties on current route when invoked (empty query-params obj)"] = function (assert) { var _this7 = this; this.addTemplate('index', "{{#link-to 'index' (query-params) id='the-link'}}Index{{/link-to}}"); return this.visit('/').then(function () { _this7.click('#the-link'); var indexController = _this7.getController('index'); assert.deepEqual(indexController.getProperties('foo', 'bar'), _this7.indexProperties, 'controller QP properties do not update'); }); }; _proto2["@test doesn't update controller QP properties on current route when invoked (empty query-params obj, inferred route)"] = function (assert) { var _this8 = this; this.addTemplate('index', "{{#link-to (query-params) id='the-link'}}Index{{/link-to}}"); return this.visit('/').then(function () { _this8.click('#the-link'); var indexController = _this8.getController('index'); assert.deepEqual(indexController.getProperties('foo', 'bar'), _this8.indexProperties, 'controller QP properties do not update'); }); }; _proto2['@test updates controller QP properties on current route when invoked'] = function testUpdatesControllerQPPropertiesOnCurrentRouteWhenInvoked(assert) { var _this9 = this; this.addTemplate('index', "\n {{#link-to 'index' (query-params foo='456') id=\"the-link\"}}\n Index\n {{/link-to}}\n "); return this.visit('/').then(function () { _this9.click('#the-link'); var indexController = _this9.getController('index'); assert.deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); }); }; _proto2['@test updates controller QP properties on current route when invoked (inferred route)'] = function testUpdatesControllerQPPropertiesOnCurrentRouteWhenInvokedInferredRoute(assert) { var _this10 = this; this.addTemplate('index', "\n {{#link-to (query-params foo='456') id=\"the-link\"}}\n Index\n {{/link-to}}\n "); return this.visit('/').then(function () { _this10.click('#the-link'); var indexController = _this10.getController('index'); assert.deepEqual(indexController.getProperties('foo', 'bar'), { foo: '456', bar: 'abc' }, 'controller QP properties updated'); }); }; _proto2['@test updates controller QP properties on other route after transitioning to that route'] = function testUpdatesControllerQPPropertiesOnOtherRouteAfterTransitioningToThatRoute(assert) { var _this11 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "\n {{#link-to 'about' (query-params baz='lol') id='the-link'}}\n About\n {{/link-to}}\n "); return this.visit('/').then(function () { var theLink = _this11.$('#the-link'); assert.equal(theLink.attr('href'), '/about?baz=lol'); (0, _internalTestHelpers.runTask)(function () { return _this11.click('#the-link'); }); var aboutController = _this11.getController('about'); assert.deepEqual(aboutController.getProperties('baz', 'bat'), { baz: 'lol', bat: 'borf' }, 'about controller QP properties updated'); }); }; _proto2['@test supplied QP properties can be bound'] = function testSuppliedQPPropertiesCanBeBound(assert) { var _this12 = this; this.addTemplate('index', "{{#link-to (query-params foo=boundThing) id='the-link'}}Index{{/link-to}}"); return this.visit('/').then(function () { var indexController = _this12.getController('index'); var theLink = _this12.$('#the-link'); assert.equal(theLink.attr('href'), '/?foo=OMG'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('boundThing', 'ASL'); }); assert.equal(theLink.attr('href'), '/?foo=ASL'); }); }; _proto2['@test supplied QP properties can be bound (booleans)'] = function testSuppliedQPPropertiesCanBeBoundBooleans(assert) { var _this13 = this; this.addTemplate('index', "\n {{#link-to (query-params abool=boundThing) id='the-link'}}\n Index\n {{/link-to}}\n "); return this.visit('/').then(function () { var indexController = _this13.getController('index'); var theLink = _this13.$('#the-link'); assert.equal(theLink.attr('href'), '/?abool=OMG'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('boundThing', false); }); assert.equal(theLink.attr('href'), '/?abool=false'); _this13.click('#the-link'); assert.deepEqual(indexController.getProperties('foo', 'bar', 'abool'), { foo: '123', bar: 'abc', abool: false }, 'bound bool QP properties update'); }); }; _proto2['@test href updates when unsupplied controller QP props change'] = function testHrefUpdatesWhenUnsuppliedControllerQPPropsChange(assert) { var _this14 = this; this.addTemplate('index', "{{#link-to (query-params foo='lol') id='the-link'}}Index{{/link-to}}"); return this.visit('/').then(function () { var indexController = _this14.getController('index'); var theLink = _this14.$('#the-link'); assert.equal(theLink.attr('href'), '/?foo=lol'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('bar', 'BORF'); }); assert.equal(theLink.attr('href'), '/?bar=BORF&foo=lol'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('foo', 'YEAH'); }); assert.equal(theLink.attr('href'), '/?bar=BORF&foo=lol'); }); }; _proto2['@test The {{link-to}} with only query params always transitions to the current route with the query params applied'] = function testTheLinkToWithOnlyQueryParamsAlwaysTransitionsToTheCurrentRouteWithTheQueryParamsApplied(assert) { var _this15 = this; // Test harness for bug #12033 this.addTemplate('cars', "\n {{#link-to 'cars.create' id='create-link'}}Create new car{{/link-to}}\n {{#link-to (query-params page='2') id='page2-link'}}Page 2{{/link-to}}\n {{outlet}}\n "); this.addTemplate('cars.create', "{{#link-to 'cars' id='close-link'}}Close create form{{/link-to}}"); this.router.map(function () { this.route('cars', function () { this.route('create'); }); }); this.add('controller:cars', _controller.default.extend({ queryParams: ['page'], page: 1 })); return this.visit('/cars/create').then(function () { var router = _this15.appRouter; var carsController = _this15.getController('cars'); assert.equal(router.currentRouteName, 'cars.create'); (0, _internalTestHelpers.runTask)(function () { return _this15.click('#close-link'); }); assert.equal(router.currentRouteName, 'cars.index'); assert.equal(router.get('url'), '/cars'); assert.equal(carsController.get('page'), 1, 'The page query-param is 1'); (0, _internalTestHelpers.runTask)(function () { return _this15.click('#page2-link'); }); assert.equal(router.currentRouteName, 'cars.index', 'The active route is still cars'); assert.equal(router.get('url'), '/cars?page=2', 'The url has been updated'); assert.equal(carsController.get('page'), 2, 'The query params have been updated'); }); }; _proto2['@test the {{link-to}} applies activeClass when query params are not changed'] = function testTheLinkToAppliesActiveClassWhenQueryParamsAreNotChanged(assert) { var _this16 = this; this.addTemplate('index', "\n {{#link-to (query-params foo='cat') id='cat-link'}}Index{{/link-to}}\n {{#link-to (query-params foo='dog') id='dog-link'}}Index{{/link-to}}\n {{#link-to 'index' id='change-nothing'}}Index{{/link-to}}\n "); this.addTemplate('search', "\n {{#link-to (query-params search='same') id='same-search'}}Index{{/link-to}}\n {{#link-to (query-params search='change') id='change-search'}}Index{{/link-to}}\n {{#link-to (query-params search='same' archive=true) id='same-search-add-archive'}}Index{{/link-to}}\n {{#link-to (query-params archive=true) id='only-add-archive'}}Index{{/link-to}}\n {{#link-to (query-params search='same' archive=true) id='both-same'}}Index{{/link-to}}\n {{#link-to (query-params search='different' archive=true) id='change-one'}}Index{{/link-to}}\n {{#link-to (query-params search='different' archive=false) id='remove-one'}}Index{{/link-to}}\n {{outlet}}\n "); this.addTemplate('search.results', "\n {{#link-to (query-params sort='title') id='same-sort-child-only'}}Index{{/link-to}}\n {{#link-to (query-params search='same') id='same-search-parent-only'}}Index{{/link-to}}\n {{#link-to (query-params search='change') id='change-search-parent-only'}}Index{{/link-to}}\n {{#link-to (query-params search='same' sort='title') id='same-search-same-sort-child-and-parent'}}Index{{/link-to}}\n {{#link-to (query-params search='same' sort='author') id='same-search-different-sort-child-and-parent'}}Index{{/link-to}}\n {{#link-to (query-params search='change' sort='title') id='change-search-same-sort-child-and-parent'}}Index{{/link-to}}\n {{#link-to (query-params foo='dog') id='dog-link'}}Index{{/link-to}}\n "); this.router.map(function () { this.route('search', function () { this.route('results'); }); }); this.add('controller:search', _controller.default.extend({ queryParams: ['search', 'archive'], search: '', archive: false })); this.add('controller:search.results', _controller.default.extend({ queryParams: ['sort', 'showDetails'], sort: 'title', showDetails: true })); return this.visit('/').then(function () { _this16.shouldNotBeActive(assert, '#cat-link'); _this16.shouldNotBeActive(assert, '#dog-link'); return _this16.visit('/?foo=cat'); }).then(function () { _this16.shouldBeActive(assert, '#cat-link'); _this16.shouldNotBeActive(assert, '#dog-link'); return _this16.visit('/?foo=dog'); }).then(function () { _this16.shouldBeActive(assert, '#dog-link'); _this16.shouldNotBeActive(assert, '#cat-link'); _this16.shouldBeActive(assert, '#change-nothing'); return _this16.visit('/search?search=same'); }).then(function () { _this16.shouldBeActive(assert, '#same-search'); _this16.shouldNotBeActive(assert, '#change-search'); _this16.shouldNotBeActive(assert, '#same-search-add-archive'); _this16.shouldNotBeActive(assert, '#only-add-archive'); _this16.shouldNotBeActive(assert, '#remove-one'); return _this16.visit('/search?search=same&archive=true'); }).then(function () { _this16.shouldBeActive(assert, '#both-same'); _this16.shouldNotBeActive(assert, '#change-one'); return _this16.visit('/search/results?search=same&sort=title&showDetails=true'); }).then(function () { _this16.shouldBeActive(assert, '#same-sort-child-only'); _this16.shouldBeActive(assert, '#same-search-parent-only'); _this16.shouldNotBeActive(assert, '#change-search-parent-only'); _this16.shouldBeActive(assert, '#same-search-same-sort-child-and-parent'); _this16.shouldNotBeActive(assert, '#same-search-different-sort-child-and-parent'); _this16.shouldNotBeActive(assert, '#change-search-same-sort-child-and-parent'); }); }; _proto2['@test the {{link-to}} applies active class when query-param is a number'] = function testTheLinkToAppliesActiveClassWhenQueryParamIsANumber(assert) { var _this17 = this; this.addTemplate('index', "\n {{#link-to (query-params page=pageNumber) id='page-link'}}\n Index\n {{/link-to}}\n "); this.add('controller:index', _controller.default.extend({ queryParams: ['page'], page: 1, pageNumber: 5 })); return this.visit('/').then(function () { _this17.shouldNotBeActive(assert, '#page-link'); return _this17.visit('/?page=5'); }).then(function () { _this17.shouldBeActive(assert, '#page-link'); }); }; _proto2['@test the {{link-to}} applies active class when query-param is an array'] = function testTheLinkToAppliesActiveClassWhenQueryParamIsAnArray(assert) { var _this18 = this; this.addTemplate('index', "\n {{#link-to (query-params pages=pagesArray) id='array-link'}}Index{{/link-to}}\n {{#link-to (query-params pages=biggerArray) id='bigger-link'}}Index{{/link-to}}\n {{#link-to (query-params pages=emptyArray) id='empty-link'}}Index{{/link-to}}\n "); this.add('controller:index', _controller.default.extend({ queryParams: ['pages'], pages: [], pagesArray: [1, 2], biggerArray: [1, 2, 3], emptyArray: [] })); return this.visit('/').then(function () { _this18.shouldNotBeActive(assert, '#array-link'); return _this18.visit('/?pages=%5B1%2C2%5D'); }).then(function () { _this18.shouldBeActive(assert, '#array-link'); _this18.shouldNotBeActive(assert, '#bigger-link'); _this18.shouldNotBeActive(assert, '#empty-link'); return _this18.visit('/?pages=%5B2%2C1%5D'); }).then(function () { _this18.shouldNotBeActive(assert, '#array-link'); _this18.shouldNotBeActive(assert, '#bigger-link'); _this18.shouldNotBeActive(assert, '#empty-link'); return _this18.visit('/?pages=%5B1%2C2%2C3%5D'); }).then(function () { _this18.shouldBeActive(assert, '#bigger-link'); _this18.shouldNotBeActive(assert, '#array-link'); _this18.shouldNotBeActive(assert, '#empty-link'); }); }; _proto2['@test the {{link-to}} component applies active class to the parent route'] = function testTheLinkToComponentAppliesActiveClassToTheParentRoute(assert) { var _this19 = this; this.router.map(function () { this.route('parent', function () { this.route('child'); }); }); this.addTemplate('application', "\n {{#link-to 'parent' id='parent-link'}}Parent{{/link-to}}\n {{#link-to 'parent.child' id='parent-child-link'}}Child{{/link-to}}\n {{#link-to 'parent' (query-params foo=cat) id='parent-link-qp'}}Parent{{/link-to}}\n {{outlet}}\n "); this.add('controller:parent.child', _controller.default.extend({ queryParams: ['foo'], foo: 'bar' })); return this.visit('/').then(function () { _this19.shouldNotBeActive(assert, '#parent-link'); _this19.shouldNotBeActive(assert, '#parent-child-link'); _this19.shouldNotBeActive(assert, '#parent-link-qp'); return _this19.visit('/parent/child?foo=dog'); }).then(function () { _this19.shouldBeActive(assert, '#parent-link'); _this19.shouldNotBeActive(assert, '#parent-link-qp'); }); }; _proto2['@test The {{link-to}} component disregards query-params in activeness computation when current-when is specified'] = function testTheLinkToComponentDisregardsQueryParamsInActivenessComputationWhenCurrentWhenIsSpecified(assert) { var _this20 = this; var appLink; this.router.map(function () { this.route('parent'); }); this.addTemplate('application', "\n {{#link-to 'parent' (query-params page=1) current-when='parent' id='app-link'}}\n Parent\n {{/link-to}}\n {{outlet}}\n "); this.addTemplate('parent', "\n {{#link-to 'parent' (query-params page=1) current-when='parent' id='parent-link'}}\n Parent\n {{/link-to}}\n {{outlet}}\n "); this.add('controller:parent', _controller.default.extend({ queryParams: ['page'], page: 1 })); return this.visit('/').then(function () { appLink = _this20.$('#app-link'); assert.equal(appLink.attr('href'), '/parent'); _this20.shouldNotBeActive(assert, '#app-link'); return _this20.visit('/parent?page=2'); }).then(function () { appLink = _this20.$('#app-link'); var router = _this20.appRouter; assert.equal(appLink.attr('href'), '/parent'); _this20.shouldBeActive(assert, '#app-link'); assert.equal(_this20.$('#parent-link').attr('href'), '/parent'); _this20.shouldBeActive(assert, '#parent-link'); var parentController = _this20.getController('parent'); assert.equal(parentController.get('page'), 2); (0, _internalTestHelpers.runTask)(function () { return parentController.set('page', 3); }); assert.equal(router.get('location.path'), '/parent?page=3'); _this20.shouldBeActive(assert, '#app-link'); _this20.shouldBeActive(assert, '#parent-link'); (0, _internalTestHelpers.runTask)(function () { return _this20.click('#app-link'); }); assert.equal(router.get('location.path'), '/parent'); }); }; _proto2['@test {{link-to}} default query params while in active transition regression test'] = function testLinkToDefaultQueryParamsWhileInActiveTransitionRegressionTest(assert) { var _this21 = this; this.router.map(function () { this.route('foos'); this.route('bars'); }); var foos = _runtime.RSVP.defer(); var bars = _runtime.RSVP.defer(); this.addTemplate('application', "\n {{link-to 'Foos' 'foos' id='foos-link'}}\n {{link-to 'Baz Foos' 'foos' (query-params baz=true) id='baz-foos-link'}}\n {{link-to 'Quux Bars' 'bars' (query-params quux=true) id='bars-link'}}\n "); this.add('controller:foos', _controller.default.extend({ queryParams: ['status'], baz: false })); this.add('route:foos', _routing.Route.extend({ model: function () { return foos.promise; } })); this.add('controller:bars', _controller.default.extend({ queryParams: ['status'], quux: false })); this.add('route:bars', _routing.Route.extend({ model: function () { return bars.promise; } })); return this.visit('/').then(function () { var router = _this21.appRouter; var foosLink = _this21.$('#foos-link'); var barsLink = _this21.$('#bars-link'); var bazLink = _this21.$('#baz-foos-link'); assert.equal(foosLink.attr('href'), '/foos'); assert.equal(bazLink.attr('href'), '/foos?baz=true'); assert.equal(barsLink.attr('href'), '/bars?quux=true'); assert.equal(router.get('location.path'), '/'); _this21.shouldNotBeActive(assert, '#foos-link'); _this21.shouldNotBeActive(assert, '#baz-foos-link'); _this21.shouldNotBeActive(assert, '#bars-link'); (0, _internalTestHelpers.runTask)(function () { return barsLink.click(); }); _this21.shouldNotBeActive(assert, '#bars-link'); (0, _internalTestHelpers.runTask)(function () { return foosLink.click(); }); _this21.shouldNotBeActive(assert, '#foos-link'); (0, _internalTestHelpers.runTask)(function () { return foos.resolve(); }); assert.equal(router.get('location.path'), '/foos'); _this21.shouldBeActive(assert, '#foos-link'); }); }; _proto2['@test [GH#17869] it does not cause shadowing assertion with `hash` local variable'] = function testGH17869ItDoesNotCauseShadowingAssertionWithHashLocalVariable() { var _this22 = this; this.router.map(function () { this.route('post', { path: '/post/:id' }); }); this.add('controller:post', _controller.default.extend({ queryParams: ['showComments'], showComments: true })); this.addTemplate('index', "\n {{#let (hash id=\"1\" title=\"Hello World!\" body=\"Lorem ipsum dolor sit amet...\") as |hash|}}\n {{#link-to \"post\" hash (query-params showComments=false)}}View Post{{/link-to}}\n {{/let}}\n "); return this.visit('/').then(function () { _this22.assertComponentElement(_this22.element.firstElementChild, { tagName: 'a', attrs: { href: '/post/1?showComments=false', class: (0, _internalTestHelpers.classes)('ember-view') }, content: 'View Post' }); }); }; return _class2; }(_internalTestHelpers.ApplicationTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/link-to/rendering-angle-test", ["ember-babel", "internal-test-helpers", "@ember/controller", "@ember/-internals/metal", "@ember/-internals/glimmer"], function (_emberBabel, _internalTestHelpers, _controller, _metal, _glimmer) { "use strict"; if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { (0, _internalTestHelpers.moduleFor)(' component (rendering tests)', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { return _ApplicationTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto["@test throws a useful error if you invoke it wrong"] = function (assert) { var _this = this; assert.expect(1); this.addTemplate('application', "Index"); expectAssertion(function () { _this.visit('/'); }, /You must provide at least one of the `@route`, `@model`, `@models` or `@query` argument to ``/); }; _proto['@test should be able to be inserted in DOM when the router is not present'] = function testShouldBeAbleToBeInsertedInDOMWhenTheRouterIsNotPresent() { var _this2 = this; this.addTemplate('application', "Go to Index"); return this.visit('/').then(function () { _this2.assertText('Go to Index'); }); }; _proto['@test re-renders when title changes'] = function testReRendersWhenTitleChanges() { var _this3 = this; var controller; this.addTemplate('application', "{{title}}"); this.add('controller:application', _controller.default.extend({ init: function () { this._super.apply(this, arguments); controller = this; }, title: 'foo' })); return this.visit('/').then(function () { _this3.assertText('foo'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(controller, 'title', 'bar'); }); _this3.assertText('bar'); }); }; _proto['@test re-computes active class when params change'] = function testReComputesActiveClassWhenParamsChange(assert) { var _this4 = this; var controller; this.addTemplate('application', 'foo'); this.add('controller:application', _controller.default.extend({ init: function () { this._super.apply(this, arguments); controller = this; }, routeName: 'index' })); this.router.map(function () { this.route('bar', { path: '/bar' }); }); return this.visit('/bar').then(function () { assert.equal(_this4.firstChild.classList.contains('active'), false); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(controller, 'routeName', 'bar'); }); assert.equal(_this4.firstChild.classList.contains('active'), true); }); }; _proto['@test able to safely extend the built-in component and use the normal path'] = function testAbleToSafelyExtendTheBuiltInComponentAndUseTheNormalPath() { var _this5 = this; this.addComponent('custom-link-to', { ComponentClass: _glimmer.LinkComponent.extend() }); this.addTemplate('application', "{{title}}"); this.add('controller:application', _controller.default.extend({ title: 'Hello' })); return this.visit('/').then(function () { _this5.assertText('Hello'); }); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)(' component (rendering tests, without router)', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class2, _RenderingTestCase); function _class2() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto2 = _class2.prototype; _proto2['@test should be able to be inserted in DOM when the router is not present - block'] = function testShouldBeAbleToBeInsertedInDOMWhenTheRouterIsNotPresentBlock() { this.render("Go to Index"); this.assertText('Go to Index'); }; return _class2; }(_internalTestHelpers.RenderingTestCase)); } }); enifed("@ember/-internals/glimmer/tests/integration/components/link-to/rendering-curly-test", ["ember-babel", "internal-test-helpers", "@ember/controller", "@ember/-internals/metal", "@ember/-internals/glimmer"], function (_emberBabel, _internalTestHelpers, _controller, _metal, _glimmer) { "use strict"; (0, _internalTestHelpers.moduleFor)('{{link-to}} component (rendering tests)', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { return _ApplicationTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto["@feature(ember-glimmer-angle-bracket-built-ins) throws a useful error if you invoke it wrong"] = function (assert) { var _this = this; assert.expect(1); expectAssertion(function () { _this.addTemplate('application', "{{#link-to id='the-link'}}Index{{/link-to}}"); }, /You must provide one or more parameters to the `{{link-to}}` component\. \('my-app\/templates\/application\.hbs' @ L1:C0\)/); }; _proto["@feature(!ember-glimmer-angle-bracket-built-ins) throws a useful error if you invoke it wrong"] = function (assert) { var _this2 = this; assert.expect(1); this.addTemplate('application', "{{#link-to id='the-link'}}Index{{/link-to}}"); expectAssertion(function () { _this2.visit('/'); }, /You must provide one or more parameters to the link-to component/); }; _proto['@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'); }); }; _proto['@test re-renders when title changes'] = function testReRendersWhenTitleChanges() { var _this4 = this; var controller; this.addTemplate('application', "{{link-to title 'index'}}"); this.add('controller:application', _controller.default.extend({ init: function () { this._super.apply(this, arguments); controller = this; }, title: 'foo' })); return this.visit('/').then(function () { _this4.assertText('foo'); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(controller, 'title', 'bar'); }); _this4.assertText('bar'); }); }; _proto['@test re-computes active class when params change'] = function testReComputesActiveClassWhenParamsChange(assert) { var _this5 = this; var controller; this.addTemplate('application', '{{link-to "foo" routeName}}'); this.add('controller:application', _controller.default.extend({ init: function () { this._super.apply(this, arguments); controller = this; }, routeName: 'index' })); this.router.map(function () { this.route('bar', { path: '/bar' }); }); return this.visit('/bar').then(function () { assert.equal(_this5.firstChild.classList.contains('active'), false); (0, _internalTestHelpers.runTask)(function () { return (0, _metal.set)(controller, 'routeName', 'bar'); }); assert.equal(_this5.firstChild.classList.contains('active'), true); }); }; _proto['@test escaped inline form (double curlies) escapes link title'] = function testEscapedInlineFormDoubleCurliesEscapesLinkTitle() { var _this6 = this; this.addTemplate('application', "{{link-to title 'index'}}"); this.add('controller:application', _controller.default.extend({ title: 'blah' })); return this.visit('/').then(function () { _this6.assertText('blah'); }); }; _proto['@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', _controller.default.extend({ title: 'blah' })); return this.visit('/').then(function () { _this7.assertText('blah'); assert.equal(_this7.$('b').length, 1); }); }; _proto['@test able to safely extend the built-in component and use the normal path'] = function testAbleToSafelyExtendTheBuiltInComponentAndUseTheNormalPath() { var _this8 = this; this.addComponent('custom-link-to', { ComponentClass: _glimmer.LinkComponent.extend() }); this.addTemplate('application', "{{#custom-link-to 'index'}}{{title}}{{/custom-link-to}}"); this.add('controller:application', _controller.default.extend({ title: 'Hello' })); return this.visit('/').then(function () { _this8.assertText('Hello'); }); }; _proto['@test [GH#13432] able to safely extend the built-in component and invoke it inline'] = function testGH13432AbleToSafelyExtendTheBuiltInComponentAndInvokeItInline() { var _this9 = this; this.addComponent('custom-link-to', { ComponentClass: _glimmer.LinkComponent.extend() }); this.addTemplate('application', "{{custom-link-to title 'index'}}"); this.add('controller:application', _controller.default.extend({ title: 'Hello' })); return this.visit('/').then(function () { _this9.assertText('Hello'); }); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)('{{link-to}} component (rendering tests, without router)', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class2, _RenderingTestCase); function _class2() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto2 = _class2.prototype; _proto2['@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'); }; _proto2['@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 _class2; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test", ["ember-babel", "internal-test-helpers", "@ember/controller", "@ember/-internals/runtime", "@ember/-internals/metal", "@ember/instrumentation", "@ember/-internals/routing"], function (_emberBabel, _internalTestHelpers, _controller, _runtime, _metal, _instrumentation, _routing) { "use strict"; /* eslint-disable no-inner-declarations */ // ^^^ remove after unflagging EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { // IE includes the host name function normalizeUrl(url) { return url.replace(/https?:\/\/[^\/]+/, ''); } function shouldNotBeActive(assert, element) { checkActive(assert, element, false); } function shouldBeActive(assert, element) { checkActive(assert, element, true); } function checkActive(assert, element, active) { var classList = element.attr('class'); assert.equal(classList.indexOf('active') > -1, active, element + " active should be " + active); } (0, _internalTestHelpers.moduleFor)(' component (routing tests)', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { var _this; _this = _ApplicationTestCase.call(this) || this; _this.router.map(function () { this.route('about'); }); _this.addTemplate('index', "\n

Home

\n About\n Self\n "); _this.addTemplate('about', "\n

About

\n Home\n Self\n "); return _this; } var _proto = _class.prototype; _proto['@test The component navigates into the named route'] = function testTheLinkToComponentNavigatesIntoTheNamedRoute(assert) { var _this2 = this; return this.visit('/').then(function () { assert.equal(_this2.$('h3.home').length, 1, 'The home template was rendered'); assert.equal(_this2.$('#self-link.active').length, 1, 'The self-link was rendered with active class'); assert.equal(_this2.$('#about-link:not(.active)').length, 1, 'The other link was rendered without active class'); return _this2.click('#about-link'); }).then(function () { assert.equal(_this2.$('h3.about').length, 1, 'The about template was rendered'); assert.equal(_this2.$('#self-link.active').length, 1, 'The self-link was rendered with active class'); assert.equal(_this2.$('#home-link:not(.active)').length, 1, 'The other link was rendered without active class'); }); }; _proto["@test the component doesn't add an href when the tagName isn't 'a'"] = function (assert) { var _this3 = this; this.addTemplate('index', "About"); return this.visit('/').then(function () { assert.equal(_this3.$('#about-link').attr('href'), undefined, 'there is no href attribute'); }); }; _proto["@test the component applies a 'disabled' class when disabled"] = function (assert) { var _this4 = this; this.addTemplate('index', "\n About\n About\n "); this.add('controller:index', _controller.default.extend({ shouldDisable: true, dynamicDisabledWhen: 'shouldDisable' })); return this.visit('/').then(function () { assert.equal(_this4.$('#about-link-static.disabled').length, 1, 'The static link is disabled when its disabledWhen is true'); assert.equal(_this4.$('#about-link-dynamic.disabled').length, 1, 'The dynamic link is disabled when its disabledWhen is true'); var controller = _this4.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return controller.set('dynamicDisabledWhen', false); }); assert.equal(_this4.$('#about-link-dynamic.disabled').length, 0, 'The dynamic link is re-enabled when its disabledWhen becomes false'); }); }; _proto["@test the component doesn't apply a 'disabled' class if disabledWhen is not provided"] = function (assert) { var _this5 = this; this.addTemplate('index', "About"); return this.visit('/').then(function () { assert.ok(!_this5.$('#about-link').hasClass('disabled'), 'The link is not disabled if disabledWhen not provided'); }); }; _proto["@test the component supports a custom disabledClass"] = function (assert) { var _this6 = this; this.addTemplate('index', "About"); return this.visit('/').then(function () { assert.equal(_this6.$('#about-link.do-not-want').length, 1, 'The link can apply a custom disabled class'); }); }; _proto["@test the component supports a custom disabledClass set via bound param"] = function (assert) { var _this7 = this; this.addTemplate('index', "About"); this.add('controller:index', _controller.default.extend({ disabledClass: 'do-not-want' })); return this.visit('/').then(function () { assert.equal(_this7.$('#about-link.do-not-want').length, 1, 'The link can apply a custom disabled class via bound param'); }); }; _proto["@test the component does not respond to clicks when disabledWhen"] = function (assert) { var _this8 = this; this.addTemplate('index', "About"); return this.visit('/').then(function () { return _this8.click('#about-link'); }).then(function () { assert.equal(_this8.$('h3.about').length, 0, 'Transitioning did not occur'); }); }; _proto["@test the component does not respond to clicks when disabled"] = function (assert) { var _this9 = this; this.addTemplate('index', "About"); return this.visit('/').then(function () { return _this9.click('#about-link'); }).then(function () { assert.equal(_this9.$('h3.about').length, 0, 'Transitioning did not occur'); }); }; _proto["@test the component responds to clicks according to its disabledWhen bound param"] = function (assert) { var _this10 = this; this.addTemplate('index', "About"); this.add('controller:index', _controller.default.extend({ disabledWhen: true })); return this.visit('/').then(function () { return _this10.click('#about-link'); }).then(function () { assert.equal(_this10.$('h3.about').length, 0, 'Transitioning did not occur'); var controller = _this10.applicationInstance.lookup('controller:index'); controller.set('disabledWhen', false); return (0, _internalTestHelpers.runLoopSettled)(); }).then(function () { return _this10.click('#about-link'); }).then(function () { assert.equal(_this10.$('h3.about').length, 1, 'Transitioning did occur when disabledWhen became false'); }); }; _proto["@test The component supports a custom activeClass"] = function (assert) { var _this11 = this; this.addTemplate('index', "\n

Home

\n About\n Self\n "); return this.visit('/').then(function () { assert.equal(_this11.$('h3.home').length, 1, 'The home template was rendered'); assert.equal(_this11.$('#self-link.zomg-active').length, 1, 'The self-link was rendered with active class'); assert.equal(_this11.$('#about-link:not(.active)').length, 1, 'The other link was rendered without active class'); }); }; _proto["@test The component supports a custom activeClass from a bound param"] = function (assert) { var _this12 = this; this.addTemplate('index', "\n

Home

\n About\n Self\n "); this.add('controller:index', _controller.default.extend({ activeClass: 'zomg-active' })); return this.visit('/').then(function () { assert.equal(_this12.$('h3.home').length, 1, 'The home template was rendered'); assert.equal(_this12.$('#self-link.zomg-active').length, 1, 'The self-link was rendered with active class'); assert.equal(_this12.$('#about-link:not(.active)').length, 1, 'The other link was rendered without active class'); }); } // See https://github.com/emberjs/ember.js/issues/17771 ; _proto["@skip The component supports 'classNameBindings' with custom values [GH #11699]"] = function (assert) { var _this13 = this; this.addTemplate('index', "\n

Home

\n About\n "); this.add('controller:index', _controller.default.extend({ foo: false })); return this.visit('/').then(function () { assert.equal(_this13.$('#about-link.foo-is-false').length, 1, 'The about-link was rendered with the falsy class'); var controller = _this13.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return controller.set('foo', true); }); assert.equal(_this13.$('#about-link.foo-is-true').length, 1, 'The about-link was rendered with the truthy class after toggling the property'); }); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)(' component (routing tests - location hooks)', /*#__PURE__*/ function (_ApplicationTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _ApplicationTestCase2); function _class2() { var _this14; _this14 = _ApplicationTestCase2.call(this) || this; _this14.updateCount = 0; _this14.replaceCount = 0; var testContext = (0, _emberBabel.assertThisInitialized)(_this14); _this14.add('location:none', _routing.NoneLocation.extend({ setURL: function () { testContext.updateCount++; return this._super.apply(this, arguments); }, replaceURL: function () { testContext.replaceCount++; return this._super.apply(this, arguments); } })); _this14.router.map(function () { this.route('about'); }); _this14.addTemplate('index', "\n

Home

\n About\n Self\n "); _this14.addTemplate('about', "\n

About

\n Home\n Self\n "); return _this14; } var _proto2 = _class2.prototype; _proto2.visit = function visit() { var _this15 = this; return _ApplicationTestCase2.prototype.visit.apply(this, arguments).then(function () { _this15.updateCountAfterVisit = _this15.updateCount; _this15.replaceCountAfterVisit = _this15.replaceCount; }); }; _proto2['@test The component supports URL replacement'] = function testTheLinkToComponentSupportsURLReplacement(assert) { var _this16 = this; this.addTemplate('index', "\n

Home

\n About\n "); return this.visit('/').then(function () { return _this16.click('#about-link'); }).then(function () { assert.equal(_this16.updateCount, _this16.updateCountAfterVisit, 'setURL should not be called'); assert.equal(_this16.replaceCount, _this16.replaceCountAfterVisit + 1, 'replaceURL should be called once'); }); }; _proto2['@test The component supports URL replacement via replace=boundTruthyThing'] = function testTheLinkToComponentSupportsURLReplacementViaReplaceBoundTruthyThing(assert) { var _this17 = this; this.addTemplate('index', "\n

Home

\n About\n "); this.add('controller:index', _controller.default.extend({ boundTruthyThing: true })); return this.visit('/').then(function () { return _this17.click('#about-link'); }).then(function () { assert.equal(_this17.updateCount, _this17.updateCountAfterVisit, 'setURL should not be called'); assert.equal(_this17.replaceCount, _this17.replaceCountAfterVisit + 1, 'replaceURL should be called once'); }); }; _proto2['@test The component supports setting replace=boundFalseyThing'] = function testTheLinkToComponentSupportsSettingReplaceBoundFalseyThing(assert) { var _this18 = this; this.addTemplate('index', "\n

Home

\n About\n "); this.add('controller:index', _controller.default.extend({ boundFalseyThing: false })); return this.visit('/').then(function () { return _this18.click('#about-link'); }).then(function () { assert.equal(_this18.updateCount, _this18.updateCountAfterVisit + 1, 'setURL should be called'); assert.equal(_this18.replaceCount, _this18.replaceCountAfterVisit, 'replaceURL should not be called'); }); }; return _class2; }(_internalTestHelpers.ApplicationTestCase)); if (false /* EMBER_IMPROVED_INSTRUMENTATION */ ) { (0, _internalTestHelpers.moduleFor)('The component with EMBER_IMPROVED_INSTRUMENTATION', /*#__PURE__*/ function (_ApplicationTestCase3) { (0, _emberBabel.inheritsLoose)(_class3, _ApplicationTestCase3); function _class3() { var _this19; _this19 = _ApplicationTestCase3.call(this) || this; _this19.router.map(function () { this.route('about'); }); _this19.addTemplate('index', "\n

Home

\n About\n Self\n "); _this19.addTemplate('about', "\n

About

\n Home\n Self\n "); return _this19; } var _proto3 = _class3.prototype; _proto3.beforeEach = function beforeEach() { return this.visit('/'); }; _proto3.afterEach = function afterEach() { (0, _instrumentation.reset)(); return _ApplicationTestCase3.prototype.afterEach.call(this); }; _proto3['@test The component fires an interaction event'] = function testTheLinkToComponentFiresAnInteractionEvent(assert) { assert.expect(2); (0, _instrumentation.subscribe)('interaction.link-to', { before: function () { assert.ok(true, 'instrumentation subscriber was called'); }, after: function () { assert.ok(true, 'instrumentation subscriber was called'); } }); return this.click('#about-link'); }; _proto3['@test The component interaction event includes the route name'] = function testTheLinkToComponentInteractionEventIncludesTheRouteName(assert) { assert.expect(2); (0, _instrumentation.subscribe)('interaction.link-to', { before: function (name, timestamp, _ref) { var routeName = _ref.routeName; assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name'); }, after: function (name, timestamp, _ref2) { var routeName = _ref2.routeName; assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name'); } }); return this.click('#about-link'); }; _proto3['@test The component interaction event includes the transition in the after hook'] = function testTheLinkToComponentInteractionEventIncludesTheTransitionInTheAfterHook(assert) { assert.expect(1); (0, _instrumentation.subscribe)('interaction.link-to', { before: function () {}, after: function (name, timestamp, _ref3) { var transition = _ref3.transition; assert.equal(transition.targetName, 'about', 'instrumentation subscriber was passed route name'); } }); return this.click('#about-link'); }; return _class3; }(_internalTestHelpers.ApplicationTestCase)); } (0, _internalTestHelpers.moduleFor)('The component - nested routes and link-to arguments', /*#__PURE__*/ function (_ApplicationTestCase4) { (0, _emberBabel.inheritsLoose)(_class4, _ApplicationTestCase4); function _class4() { return _ApplicationTestCase4.apply(this, arguments) || this; } var _proto4 = _class4.prototype; _proto4['@test The component supports leaving off .index for nested routes'] = function testTheLinkToComponentSupportsLeavingOffIndexForNestedRoutes(assert) { var _this20 = this; this.router.map(function () { this.route('about', function () { this.route('item'); }); }); this.addTemplate('about', "

About

{{outlet}}"); this.addTemplate('about.index', "
Index
"); this.addTemplate('about.item', "
About
"); return this.visit('/about/item').then(function () { assert.equal(normalizeUrl(_this20.$('#item a').attr('href')), '/about'); }); }; _proto4["@test The component supports custom, nested, current-when"] = function (assert) { var _this21 = this; this.router.map(function () { this.route('index', { path: '/' }, function () { this.route('about'); }); this.route('item'); }); this.addTemplate('index', "

Home

{{outlet}}"); this.addTemplate('index.about', "ITEM"); return this.visit('/about').then(function () { assert.equal(_this21.$('#other-link.active').length, 1, 'The link is active since current-when is a parent route'); }); }; _proto4["@test The component does not disregard current-when when it is given explicitly for a route"] = function (assert) { var _this22 = this; this.router.map(function () { this.route('index', { path: '/' }, function () { this.route('about'); }); this.route('items', function () { this.route('item'); }); }); this.addTemplate('index', "

Home

{{outlet}}"); this.addTemplate('index.about', "ITEM"); return this.visit('/about').then(function () { assert.equal(_this22.$('#other-link.active').length, 1, 'The link is active when current-when is given for explicitly for a route'); }); }; _proto4['@test The component does not disregard current-when when it is set via a bound param'] = function testTheLinkToComponentDoesNotDisregardCurrentWhenWhenItIsSetViaABoundParam(assert) { var _this23 = this; this.router.map(function () { this.route('index', { path: '/' }, function () { this.route('about'); }); this.route('items', function () { this.route('item'); }); }); this.add('controller:index.about', _controller.default.extend({ currentWhen: 'index' })); this.addTemplate('index', "

Home

{{outlet}}"); this.addTemplate('index.about', "ITEM"); return this.visit('/about').then(function () { assert.equal(_this23.$('#other-link.active').length, 1, 'The link is active when current-when is given for explicitly for a route'); }); }; _proto4['@test The component supports multiple current-when routes'] = function testTheLinkToComponentSupportsMultipleCurrentWhenRoutes(assert) { var _this24 = this; this.router.map(function () { this.route('index', { path: '/' }, function () { this.route('about'); }); this.route('item'); this.route('foo'); }); this.addTemplate('index', "

Home

{{outlet}}"); this.addTemplate('index.about', "ITEM"); this.addTemplate('item', "ITEM"); this.addTemplate('foo', "ITEM"); return this.visit('/about').then(function () { assert.equal(_this24.$('#link1.active').length, 1, 'The link is active since current-when contains the parent route'); return _this24.visit('/item'); }).then(function () { assert.equal(_this24.$('#link2.active').length, 1, 'The link is active since you are on the active route'); return _this24.visit('/foo'); }).then(function () { assert.equal(_this24.$('#link3.active').length, 0, 'The link is not active since current-when does not contain the active route'); }); }; _proto4['@test The component supports boolean values for current-when'] = function testTheLinkToComponentSupportsBooleanValuesForCurrentWhen(assert) { var _this25 = this; this.router.map(function () { this.route('index', { path: '/' }, function () { this.route('about'); }); this.route('item'); }); this.addTemplate('index.about', "\n ITEM\n ITEM\n "); this.add('controller:index.about', _controller.default.extend({ isCurrent: false })); return this.visit('/about').then(function () { assert.ok(_this25.$('#about-link').hasClass('active'), 'The link is active since current-when is true'); assert.notOk(_this25.$('#index-link').hasClass('active'), 'The link is not active since current-when is false'); var controller = _this25.applicationInstance.lookup('controller:index.about'); (0, _internalTestHelpers.runTask)(function () { return controller.set('isCurrent', true); }); assert.ok(_this25.$('#index-link').hasClass('active'), 'The link is active since current-when is true'); }); }; _proto4['@test The component defaults to bubbling'] = function testTheLinkToComponentDefaultsToBubbling(assert) { var _this26 = this; this.addTemplate('about', "\n
\n About\n
\n {{outlet}}\n "); this.addTemplate('about.contact', "

Contact

"); this.router.map(function () { this.route('about', function () { this.route('contact'); }); }); var hidden = 0; this.add('route:about', _routing.Route.extend({ actions: { hide: function () { hidden++; } } })); return this.visit('/about').then(function () { return _this26.click('#about-contact'); }).then(function () { assert.equal(_this26.$('#contact').text(), 'Contact', 'precond - the link worked'); assert.equal(hidden, 1, 'The link bubbles'); }); }; _proto4["@test The component supports bubbles=false"] = function (assert) { var _this27 = this; this.addTemplate('about', "\n
\n \n About\n \n
\n {{outlet}}\n "); this.addTemplate('about.contact', "

Contact

"); this.router.map(function () { this.route('about', function () { this.route('contact'); }); }); var hidden = 0; this.add('route:about', _routing.Route.extend({ actions: { hide: function () { hidden++; } } })); return this.visit('/about').then(function () { return _this27.click('#about-contact'); }).then(function () { assert.equal(_this27.$('#contact').text(), 'Contact', 'precond - the link worked'); assert.equal(hidden, 0, "The link didn't bubble"); }); }; _proto4["@test The component supports bubbles=boundFalseyThing"] = function (assert) { var _this28 = this; this.addTemplate('about', "\n
\n \n About\n \n
\n {{outlet}}\n "); this.addTemplate('about.contact', "

Contact

"); this.add('controller:about', _controller.default.extend({ boundFalseyThing: false })); this.router.map(function () { this.route('about', function () { this.route('contact'); }); }); var hidden = 0; this.add('route:about', _routing.Route.extend({ actions: { hide: function () { hidden++; } } })); return this.visit('/about').then(function () { return _this28.click('#about-contact'); }).then(function () { assert.equal(_this28.$('#contact').text(), 'Contact', 'precond - the link worked'); assert.equal(hidden, 0, "The link didn't bubble"); }); }; _proto4["@test The component moves into the named route with context"] = function (assert) { var _this29 = this; this.router.map(function () { this.route('about'); this.route('item', { path: '/item/:id' }); }); this.addTemplate('about', "\n

List

\n
    \n {{#each model as |person|}}\n
  • \n \n {{person.name}}\n \n
  • \n {{/each}}\n
\n Home\n "); this.addTemplate('item', "\n

Item

\n

{{model.name}}

\n Home\n "); this.addTemplate('index', "\n

Home

\n About\n "); this.add('route:about', _routing.Route.extend({ model: function () { return [{ id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, { id: 'erik', name: 'Erik Brynroflsson' }]; } })); return this.visit('/about').then(function () { assert.equal(_this29.$('h3.list').length, 1, 'The home template was rendered'); assert.equal(normalizeUrl(_this29.$('#home-link').attr('href')), '/', 'The home link points back at /'); return _this29.click('#yehuda'); }).then(function () { assert.equal(_this29.$('h3.item').length, 1, 'The item template was rendered'); assert.equal(_this29.$('p').text(), 'Yehuda Katz', 'The name is correct'); return _this29.click('#home-link'); }).then(function () { return _this29.click('#about-link'); }).then(function () { assert.equal(normalizeUrl(_this29.$('li a#yehuda').attr('href')), '/item/yehuda'); assert.equal(normalizeUrl(_this29.$('li a#tom').attr('href')), '/item/tom'); assert.equal(normalizeUrl(_this29.$('li a#erik').attr('href')), '/item/erik'); return _this29.click('#erik'); }).then(function () { assert.equal(_this29.$('h3.item').length, 1, 'The item template was rendered'); assert.equal(_this29.$('p').text(), 'Erik Brynroflsson', 'The name is correct'); }); }; _proto4["@test The component binds some anchor html tag common attributes"] = function (assert) { var _this30 = this; this.addTemplate('index', "\n

Home

\n \n Self\n \n "); return this.visit('/').then(function () { var link = _this30.$('#self-link'); assert.equal(link.attr('title'), 'title-attr', 'The self-link contains title attribute'); assert.equal(link.attr('rel'), 'rel-attr', 'The self-link contains rel attribute'); assert.equal(link.attr('tabindex'), '-1', 'The self-link contains tabindex attribute'); }); }; _proto4["@test The component supports 'target' attribute"] = function (assert) { var _this31 = this; this.addTemplate('index', "\n

Home

\n Self\n "); return this.visit('/').then(function () { var link = _this31.$('#self-link'); assert.equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); }); }; _proto4["@test The component supports 'target' attribute specified as a bound param"] = function (assert) { var _this32 = this; this.addTemplate('index', "\n

Home

\n Self\n "); this.add('controller:index', _controller.default.extend({ boundLinkTarget: '_blank' })); return this.visit('/').then(function () { var link = _this32.$('#self-link'); assert.equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); }); }; _proto4["@test the component calls preventDefault"] = function (assert) { var _this33 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "About"); return this.visit('/').then(function () { assertNav({ prevented: true }, function () { return _this33.$('#about-link').click(); }, assert); }); }; _proto4["@test the component does not call preventDefault if '@preventDefault={{false}}' is passed as an option"] = function (assert) { var _this34 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "About"); return this.visit('/').then(function () { assertNav({ prevented: false }, function () { return _this34.$('#about-link').trigger('click'); }, assert); }); }; _proto4["@test the component does not call preventDefault if '@preventDefault={{boundFalseyThing}}' is passed as an option"] = function (assert) { var _this35 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "About"); this.add('controller:index', _controller.default.extend({ boundFalseyThing: false })); return this.visit('/').then(function () { assertNav({ prevented: false }, function () { return _this35.$('#about-link').trigger('click'); }, assert); }); }; _proto4["@test The component does not call preventDefault if 'target' attribute is provided"] = function (assert) { var _this36 = this; this.addTemplate('index', "\n

Home

\n Self\n "); return this.visit('/').then(function () { assertNav({ prevented: false }, function () { return _this36.$('#self-link').click(); }, assert); }); }; _proto4["@test The component should preventDefault when 'target = _self'"] = function (assert) { var _this37 = this; this.addTemplate('index', "\n

Home

\n Self\n "); return this.visit('/').then(function () { assertNav({ prevented: true }, function () { return _this37.$('#self-link').click(); }, assert); }); }; _proto4["@test The component should not transition if target is not equal to _self or empty"] = function (assert) { var _this38 = this; this.addTemplate('index', "\n \n About\n \n "); this.router.map(function () { this.route('about'); }); return this.visit('/').then(function () { return _this38.click('#about-link'); }).then(function () { expectDeprecation(function () { var currentRouteName = _this38.applicationInstance.lookup('controller:application').get('currentRouteName'); assert.notEqual(currentRouteName, 'about', 'link-to should not transition if target is not equal to _self or empty'); }, 'Accessing `currentRouteName` on `controller:application` is deprecated, use the `currentRouteName` property on `service:router` instead.'); }); }; _proto4["@test The component accepts string/numeric arguments"] = function (assert) { var _this39 = this; this.router.map(function () { this.route('filter', { path: '/filters/:filter' }); this.route('post', { path: '/post/:post_id' }); this.route('repo', { path: '/repo/:owner/:name' }); }); this.add('controller:filter', _controller.default.extend({ filter: 'unpopular', repo: { owner: 'ember', name: 'ember.js' }, post_id: 123 })); this.addTemplate('filter', "\n

{{filter}}

\n Unpopular\n Unpopular\n Post\n Post\n Repo\n "); return this.visit('/filters/popular').then(function () { assert.equal(normalizeUrl(_this39.$('#link').attr('href')), '/filters/unpopular'); assert.equal(normalizeUrl(_this39.$('#path-link').attr('href')), '/filters/unpopular'); assert.equal(normalizeUrl(_this39.$('#post-path-link').attr('href')), '/post/123'); assert.equal(normalizeUrl(_this39.$('#post-number-link').attr('href')), '/post/123'); assert.equal(normalizeUrl(_this39.$('#repo-object-link').attr('href')), '/repo/ember/ember.js'); }); }; _proto4["@test Issue 4201 - Shorthand for route.index shouldn't throw errors about context arguments"] = function (assert) { var _this40 = this; assert.expect(2); this.router.map(function () { this.route('lobby', function () { this.route('index', { path: ':lobby_id' }); this.route('list'); }); }); this.add('route:lobby.index', _routing.Route.extend({ model: function (params) { assert.equal(params.lobby_id, 'foobar'); return params.lobby_id; } })); this.addTemplate('lobby.index', "Lobby"); this.addTemplate('lobby.list', "Lobby"); return this.visit('/lobby/list').then(function () { return _this40.click('#lobby-link'); }).then(function () { return shouldBeActive(assert, _this40.$('#lobby-link')); }); }; _proto4["@test Quoteless route param performs property lookup"] = function (assert) { var _this41 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "\n string\n path\n "); this.add('controller:index', _controller.default.extend({ foo: 'index' })); var assertEquality = function (href) { assert.equal(normalizeUrl(_this41.$('#string-link').attr('href')), '/'); assert.equal(normalizeUrl(_this41.$('#path-link').attr('href')), href); }; return this.visit('/').then(function () { assertEquality('/'); var controller = _this41.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return controller.set('foo', 'about'); }); assertEquality('/about'); }); }; _proto4["@test The component refreshes href element when one of params changes"] = function (assert) { var _this42 = this; this.router.map(function () { this.route('post', { path: '/posts/:post_id' }); }); var post = { id: '1' }; var secondPost = { id: '2' }; this.addTemplate('index', "post"); this.add('controller:index', _controller.default.extend()); return this.visit('/').then(function () { var indexController = _this42.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('post', post); }); assert.equal(normalizeUrl(_this42.$('#post').attr('href')), '/posts/1', 'precond - Link has rendered href attr properly'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('post', secondPost); }); assert.equal(_this42.$('#post').attr('href'), '/posts/2', 'href attr was updated after one of the params had been changed'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('post', null); }); assert.equal(_this42.$('#post').attr('href'), '#', 'href attr becomes # when one of the arguments in nullified'); }); }; _proto4["@test The component is active when a route is active"] = function (assert) { var _this43 = this; this.router.map(function () { this.route('about', function () { this.route('item'); }); }); this.addTemplate('about', "\n
\n About\n Item\n {{outlet}}\n
\n "); return this.visit('/about').then(function () { assert.equal(_this43.$('#about-link.active').length, 1, 'The about route link is active'); assert.equal(_this43.$('#item-link.active').length, 0, 'The item route link is inactive'); return _this43.visit('/about/item'); }).then(function () { assert.equal(_this43.$('#about-link.active').length, 1, 'The about route link is active'); assert.equal(_this43.$('#item-link.active').length, 1, 'The item route link is active'); }); }; _proto4["@test The component works in an #each'd array of string route names"] = function (assert) { var _this44 = this; this.router.map(function () { this.route('foo'); this.route('bar'); this.route('rar'); }); this.add('controller:index', _controller.default.extend({ routeNames: (0, _runtime.A)(['foo', 'bar', 'rar']), route1: 'bar', route2: 'foo' })); this.addTemplate('index', "\n {{#each routeNames as |routeName|}}\n {{routeName}}\n {{/each}}\n {{#each routeNames as |r|}}\n {{r}}\n {{/each}}\n a\n b\n "); var linksEqual = function (links, expected) { assert.equal(links.length, expected.length, 'Has correct number of links'); var idx; for (idx = 0; idx < links.length; idx++) { var href = _this44.$(links[idx]).attr('href'); // Old IE includes the whole hostname as well assert.equal(href.slice(-expected[idx].length), expected[idx], "Expected link to be '" + expected[idx] + "', but was '" + href + "'"); } }; return this.visit('/').then(function () { linksEqual(_this44.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/bar', '/foo']); var indexController = _this44.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('route1', 'rar'); }); linksEqual(_this44.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']); (0, _internalTestHelpers.runTask)(function () { return indexController.routeNames.shiftObject(); }); linksEqual(_this44.$('a'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']); }); }; _proto4["@test the component throws a useful error if you invoke it wrong"] = function (assert) { var _this45 = this; assert.expect(1); this.router.map(function () { this.route('post', { path: 'post/:post_id' }); }); this.addTemplate('application', "Post"); assert.throws(function () { _this45.visit('/'); }, /(You attempted to generate a link for the "post" route, but did not pass the models required for generating its dynamic segments.|You must provide param `post_id` to `generate`)/); return (0, _internalTestHelpers.runLoopSettled)(); }; _proto4["@test the component does not throw an error if its route has exited"] = function (assert) { var _this46 = this; assert.expect(0); this.router.map(function () { this.route('post', { path: 'post/:post_id' }); }); this.addTemplate('application', "\n Home\n Default Post\n {{#if currentPost}}\n Current Post\n {{/if}}\n "); this.add('controller:application', _controller.default.extend({ defaultPost: { id: 1 }, postController: (0, _controller.inject)('post'), currentPost: (0, _metal.alias)('postController.model') })); this.add('controller:post', _controller.default.extend()); this.add('route:post', _routing.Route.extend({ model: function () { return { id: 2 }; }, serialize: function (model) { return { post_id: model.id }; } })); return this.visit('/').then(function () { return _this46.click('#default-post-link'); }).then(function () { return _this46.click('#home-link'); }).then(function () { return _this46.click('#current-post-link'); }).then(function () { return _this46.click('#home-link'); }); }; _proto4["@test the component's active property respects changing parent route context"] = function (assert) { var _this47 = this; this.router.map(function () { this.route('things', { path: '/things/:name' }, function () { this.route('other'); }); }); this.addTemplate('application', "\n OMG\n LOL\n "); return this.visit('/things/omg').then(function () { shouldBeActive(assert, _this47.$('#omg-link')); shouldNotBeActive(assert, _this47.$('#lol-link')); return _this47.visit('/things/omg/other'); }).then(function () { shouldBeActive(assert, _this47.$('#omg-link')); shouldNotBeActive(assert, _this47.$('#lol-link')); }); }; _proto4["@test the component populates href with default query param values even without query-params object"] = function (assert) { var _this48 = this; this.add('controller:index', _controller.default.extend({ queryParams: ['foo'], foo: '123' })); this.addTemplate('index', "Index"); return this.visit('/').then(function () { assert.equal(_this48.$('#the-link').attr('href'), '/', 'link has right href'); }); }; _proto4["@test the component populates href with default query param values with empty query-params object"] = function (assert) { var _this49 = this; this.add('controller:index', _controller.default.extend({ queryParams: ['foo'], foo: '123' })); this.addTemplate('index', "Index"); return this.visit('/').then(function () { assert.equal(_this49.$('#the-link').attr('href'), '/', 'link has right href'); }); }; _proto4["@test the component with only query-params and a block updates when route changes"] = function (assert) { var _this50 = this; this.router.map(function () { this.route('about'); }); this.add('controller:application', _controller.default.extend({ queryParams: ['foo', 'bar'], foo: '123', bar: 'yes' })); this.addTemplate('application', "Index"); return this.visit('/').then(function () { assert.equal(_this50.$('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); return _this50.visit('/about'); }).then(function () { assert.equal(_this50.$('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href'); }); }; _proto4['@test [GH#17018] passing model to with `hash` helper works'] = function testGH17018PassingModelToLinkToWithHashHelperWorks() { var _this51 = this; this.router.map(function () { this.route('post', { path: '/posts/:post_id' }); }); this.add('route:index', _routing.Route.extend({ model: function () { return _runtime.RSVP.hash({ user: { name: 'Papa Smurf' } }); } })); this.addTemplate('index', "Post"); this.addTemplate('post', 'Post: {{this.model.user.name}}'); return this.visit('/').then(function () { _this51.assertComponentElement(_this51.firstChild, { tagName: 'a', attrs: { href: '/posts/someId' }, content: 'Post' }); return _this51.click('a'); }).then(function () { _this51.assertText('Post: Papa Smurf'); }); }; _proto4["@test The component can use dynamic params"] = function (assert) { var _this52 = this; this.router.map(function () { this.route('foo', { path: 'foo/:some/:thing' }); this.route('bar', { path: 'bar/:some/:thing/:else' }); }); this.add('controller:index', _controller.default.extend({ init: function () { this._super.apply(this, arguments); this.dynamicLinkParams = ['foo', 'one', 'two']; } })); this.addTemplate('index', "\n

Home

\n Dynamic\n "); return this.visit('/').then(function () { var link = _this52.$('#dynamic-link'); assert.equal(link.attr('href'), '/foo/one/two'); var controller = _this52.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { controller.set('dynamicLinkParams', ['bar', 'one', 'two', 'three']); }); assert.equal(link.attr('href'), '/bar/one/two/three'); }); }; _proto4["@test GJ: to a parent root model hook which performs a 'transitionTo' has correct active class #13256"] = function (assert) { var _this53 = this; assert.expect(1); this.router.map(function () { this.route('parent', function () { this.route('child'); }); }); this.add('route:parent', _routing.Route.extend({ afterModel: function () { this.transitionTo('parent.child'); } })); this.addTemplate('application', "Parent"); return this.visit('/').then(function () { return _this53.click('#parent-link'); }).then(function () { shouldBeActive(assert, _this53.$('#parent-link')); }); }; return _class4; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)('The component - loading states and warnings', /*#__PURE__*/ function (_ApplicationTestCase5) { (0, _emberBabel.inheritsLoose)(_class5, _ApplicationTestCase5); function _class5() { return _ApplicationTestCase5.apply(this, arguments) || this; } var _proto5 = _class5.prototype; _proto5["@test with null/undefined dynamic parameters are put in a loading state"] = function (assert) { var _this54 = this; assert.expect(19); var warningMessage = 'This link is in an inactive loading state because at least one of its models currently has a null/undefined value, or the provided route name is invalid.'; this.router.map(function () { this.route('thing', { path: '/thing/:thing_id' }); this.route('about'); }); this.addTemplate('index', "\n \n string\n \n \n string\n \n "); this.add('controller:index', _controller.default.extend({ destinationRoute: null, routeContext: null, loadingClass: 'i-am-loading' })); this.add('route:about', _routing.Route.extend({ activate: function () { assert.ok(true, 'About was entered'); } })); function assertLinkStatus(link, url) { if (url) { assert.equal(normalizeUrl(link.attr('href')), url, 'loaded link-to has expected href'); assert.ok(!link.hasClass('i-am-loading'), 'loaded linkComponent has no loadingClass'); } else { assert.equal(normalizeUrl(link.attr('href')), '#', "unloaded link-to has href='#'"); assert.ok(link.hasClass('i-am-loading'), 'loading linkComponent has loadingClass'); } } var contextLink, staticLink, controller; return this.visit('/').then(function () { contextLink = _this54.$('#context-link'); staticLink = _this54.$('#static-link'); controller = _this54.applicationInstance.lookup('controller:index'); assertLinkStatus(contextLink); assertLinkStatus(staticLink); return expectWarning(function () { return _this54.click(contextLink[0]); }, warningMessage); }).then(function () { // Set the destinationRoute (context is still null). (0, _internalTestHelpers.runTask)(function () { return controller.set('destinationRoute', 'thing'); }); assertLinkStatus(contextLink); // Set the routeContext to an id (0, _internalTestHelpers.runTask)(function () { return controller.set('routeContext', '456'); }); assertLinkStatus(contextLink, '/thing/456'); // Test that 0 isn't interpreted as falsy. (0, _internalTestHelpers.runTask)(function () { return controller.set('routeContext', 0); }); assertLinkStatus(contextLink, '/thing/0'); // Set the routeContext to an object (0, _internalTestHelpers.runTask)(function () { controller.set('routeContext', { id: 123 }); }); assertLinkStatus(contextLink, '/thing/123'); // Set the destinationRoute back to null. (0, _internalTestHelpers.runTask)(function () { return controller.set('destinationRoute', null); }); assertLinkStatus(contextLink); return expectWarning(function () { return _this54.click(staticLink[0]); }, warningMessage); }).then(function () { (0, _internalTestHelpers.runTask)(function () { return controller.set('secondRoute', 'about'); }); assertLinkStatus(staticLink, '/about'); // Click the now-active link return _this54.click(staticLink[0]); }); }; return _class5; }(_internalTestHelpers.ApplicationTestCase)); function assertNav(options, callback, assert) { var nav = false; function check(event) { assert.equal(event.defaultPrevented, options.prevented, "expected defaultPrevented=" + options.prevented); nav = true; event.preventDefault(); } try { document.addEventListener('click', check); callback(); } finally { document.removeEventListener('click', check); assert.ok(nav, 'Expected a link to be clicked'); } } } }); enifed("@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test", ["ember-babel", "internal-test-helpers", "@ember/controller", "@ember/-internals/runtime", "@ember/-internals/metal", "@ember/instrumentation", "@ember/-internals/routing"], function (_emberBabel, _internalTestHelpers, _controller, _runtime, _metal, _instrumentation, _routing) { "use strict"; // IE includes the host name function normalizeUrl(url) { return url.replace(/https?:\/\/[^\/]+/, ''); } function shouldNotBeActive(assert, element) { checkActive(assert, element, false); } function shouldBeActive(assert, element) { checkActive(assert, element, true); } function checkActive(assert, element, active) { var classList = element.attr('class'); assert.equal(classList.indexOf('active') > -1, active, element + " active should be " + active); } (0, _internalTestHelpers.moduleFor)('{{link-to}} component (routing tests)', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { var _this; _this = _ApplicationTestCase.call(this) || this; _this.router.map(function () { this.route('about'); }); _this.addTemplate('index', "\n

Home

\n {{#link-to 'about' id='about-link'}}About{{/link-to}}\n {{#link-to 'index' id='self-link'}}Self{{/link-to}}\n "); _this.addTemplate('about', "\n

About

\n {{#link-to 'index' id='home-link'}}Home{{/link-to}}\n {{#link-to 'about' id='self-link'}}Self{{/link-to}}\n "); return _this; } var _proto = _class.prototype; _proto['@test The {{link-to}} component navigates into the named route'] = function testTheLinkToComponentNavigatesIntoTheNamedRoute(assert) { var _this2 = this; return this.visit('/').then(function () { assert.equal(_this2.$('h3.home').length, 1, 'The home template was rendered'); assert.equal(_this2.$('#self-link.active').length, 1, 'The self-link was rendered with active class'); assert.equal(_this2.$('#about-link:not(.active)').length, 1, 'The other link was rendered without active class'); return _this2.click('#about-link'); }).then(function () { assert.equal(_this2.$('h3.about').length, 1, 'The about template was rendered'); assert.equal(_this2.$('#self-link.active').length, 1, 'The self-link was rendered with active class'); assert.equal(_this2.$('#home-link:not(.active)').length, 1, 'The other link was rendered without active class'); }); }; _proto["@test the {{link-to}} component doesn't add an href when the tagName isn't 'a'"] = function (assert) { var _this3 = this; this.addTemplate('index', "{{#link-to 'about' id='about-link' tagName='div'}}About{{/link-to}}"); return this.visit('/').then(function () { assert.equal(_this3.$('#about-link').attr('href'), undefined, 'there is no href attribute'); }); }; _proto["@test the {{link-to}} component applies a 'disabled' class when disabled"] = function (assert) { var _this4 = this; this.addTemplate('index', "\n {{#link-to \"about\" id=\"about-link-static\" disabledWhen=\"shouldDisable\"}}About{{/link-to}}\n {{#link-to \"about\" id=\"about-link-dynamic\" disabledWhen=dynamicDisabledWhen}}About{{/link-to}}\n "); this.add('controller:index', _controller.default.extend({ shouldDisable: true, dynamicDisabledWhen: 'shouldDisable' })); return this.visit('/').then(function () { assert.equal(_this4.$('#about-link-static.disabled').length, 1, 'The static link is disabled when its disabledWhen is true'); assert.equal(_this4.$('#about-link-dynamic.disabled').length, 1, 'The dynamic link is disabled when its disabledWhen is true'); var controller = _this4.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return controller.set('dynamicDisabledWhen', false); }); assert.equal(_this4.$('#about-link-dynamic.disabled').length, 0, 'The dynamic link is re-enabled when its disabledWhen becomes false'); }); }; _proto["@test the {{link-to}} component doesn't apply a 'disabled' class if disabledWhen is not provided"] = function (assert) { var _this5 = this; this.addTemplate('index', "{{#link-to \"about\" id=\"about-link\"}}About{{/link-to}}"); return this.visit('/').then(function () { assert.ok(!_this5.$('#about-link').hasClass('disabled'), 'The link is not disabled if disabledWhen not provided'); }); }; _proto["@test the {{link-to}} component supports a custom disabledClass"] = function (assert) { var _this6 = this; this.addTemplate('index', "{{#link-to \"about\" id=\"about-link\" disabledWhen=true disabledClass=\"do-not-want\"}}About{{/link-to}}"); return this.visit('/').then(function () { assert.equal(_this6.$('#about-link.do-not-want').length, 1, 'The link can apply a custom disabled class'); }); }; _proto["@test the {{link-to}} component supports a custom disabledClass set via bound param"] = function (assert) { var _this7 = this; this.addTemplate('index', "{{#link-to \"about\" id=\"about-link\" disabledWhen=true disabledClass=disabledClass}}About{{/link-to}}"); this.add('controller:index', _controller.default.extend({ disabledClass: 'do-not-want' })); return this.visit('/').then(function () { assert.equal(_this7.$('#about-link.do-not-want').length, 1, 'The link can apply a custom disabled class via bound param'); }); }; _proto["@test the {{link-to}} component does not respond to clicks when disabledWhen"] = function (assert) { var _this8 = this; this.addTemplate('index', "{{#link-to \"about\" id=\"about-link\" disabledWhen=true}}About{{/link-to}}"); return this.visit('/').then(function () { return _this8.click('#about-link'); }).then(function () { assert.equal(_this8.$('h3.about').length, 0, 'Transitioning did not occur'); }); }; _proto["@test the {{link-to}} component does not respond to clicks when disabled"] = function (assert) { var _this9 = this; this.addTemplate('index', "{{#link-to \"about\" id=\"about-link\" disabled=true}}About{{/link-to}}"); return this.visit('/').then(function () { return _this9.click('#about-link'); }).then(function () { assert.equal(_this9.$('h3.about').length, 0, 'Transitioning did not occur'); }); }; _proto["@test the {{link-to}} component responds to clicks according to its disabledWhen bound param"] = function (assert) { var _this10 = this; this.addTemplate('index', "{{#link-to \"about\" id=\"about-link\" disabledWhen=disabledWhen}}About{{/link-to}}"); this.add('controller:index', _controller.default.extend({ disabledWhen: true })); return this.visit('/').then(function () { return _this10.click('#about-link'); }).then(function () { assert.equal(_this10.$('h3.about').length, 0, 'Transitioning did not occur'); var controller = _this10.applicationInstance.lookup('controller:index'); controller.set('disabledWhen', false); return (0, _internalTestHelpers.runLoopSettled)(); }).then(function () { return _this10.click('#about-link'); }).then(function () { assert.equal(_this10.$('h3.about').length, 1, 'Transitioning did occur when disabledWhen became false'); }); }; _proto["@test The {{link-to}} component supports a custom activeClass"] = function (assert) { var _this11 = this; this.addTemplate('index', "\n

Home

\n {{#link-to 'about' id='about-link'}}About{{/link-to}}\n {{#link-to 'index' id='self-link' activeClass='zomg-active'}}Self{{/link-to}}\n "); return this.visit('/').then(function () { assert.equal(_this11.$('h3.home').length, 1, 'The home template was rendered'); assert.equal(_this11.$('#self-link.zomg-active').length, 1, 'The self-link was rendered with active class'); assert.equal(_this11.$('#about-link:not(.active)').length, 1, 'The other link was rendered without active class'); }); }; _proto["@test The {{link-to}} component supports a custom activeClass from a bound param"] = function (assert) { var _this12 = this; this.addTemplate('index', "\n

Home

\n {{#link-to 'about' id='about-link'}}About{{/link-to}}\n {{#link-to 'index' id='self-link' activeClass=activeClass}}Self{{/link-to}}\n "); this.add('controller:index', _controller.default.extend({ activeClass: 'zomg-active' })); return this.visit('/').then(function () { assert.equal(_this12.$('h3.home').length, 1, 'The home template was rendered'); assert.equal(_this12.$('#self-link.zomg-active').length, 1, 'The self-link was rendered with active class'); assert.equal(_this12.$('#about-link:not(.active)').length, 1, 'The other link was rendered without active class'); }); }; _proto["@test The {{link-to}} component supports 'classNameBindings' with custom values [GH #11699]"] = function (assert) { var _this13 = this; this.addTemplate('index', "\n

Home

\n {{#link-to 'about' id='about-link' classNameBindings='foo:foo-is-true:foo-is-false'}}About{{/link-to}}\n "); this.add('controller:index', _controller.default.extend({ foo: false })); return this.visit('/').then(function () { assert.equal(_this13.$('#about-link.foo-is-false').length, 1, 'The about-link was rendered with the falsy class'); var controller = _this13.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return controller.set('foo', true); }); assert.equal(_this13.$('#about-link.foo-is-true').length, 1, 'The about-link was rendered with the truthy class after toggling the property'); }); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)('{{link-to}} component (routing tests - location hooks)', /*#__PURE__*/ function (_ApplicationTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _ApplicationTestCase2); function _class2() { var _this14; _this14 = _ApplicationTestCase2.call(this) || this; _this14.updateCount = 0; _this14.replaceCount = 0; var testContext = (0, _emberBabel.assertThisInitialized)(_this14); _this14.add('location:none', _routing.NoneLocation.extend({ setURL: function () { testContext.updateCount++; return this._super.apply(this, arguments); }, replaceURL: function () { testContext.replaceCount++; return this._super.apply(this, arguments); } })); _this14.router.map(function () { this.route('about'); }); _this14.addTemplate('index', "\n

Home

\n {{#link-to 'about' id='about-link'}}About{{/link-to}}\n {{#link-to 'index' id='self-link'}}Self{{/link-to}}\n "); _this14.addTemplate('about', "\n

About

\n {{#link-to 'index' id='home-link'}}Home{{/link-to}}\n {{#link-to 'about' id='self-link'}}Self{{/link-to}}\n "); return _this14; } var _proto2 = _class2.prototype; _proto2.visit = function visit() { var _this15 = this; return _ApplicationTestCase2.prototype.visit.apply(this, arguments).then(function () { _this15.updateCountAfterVisit = _this15.updateCount; _this15.replaceCountAfterVisit = _this15.replaceCount; }); }; _proto2['@test The {{link-to}} component supports URL replacement'] = function testTheLinkToComponentSupportsURLReplacement(assert) { var _this16 = this; this.addTemplate('index', "\n

Home

\n {{#link-to 'about' id='about-link' replace=true}}About{{/link-to}}\n "); return this.visit('/').then(function () { return _this16.click('#about-link'); }).then(function () { assert.equal(_this16.updateCount, _this16.updateCountAfterVisit, 'setURL should not be called'); assert.equal(_this16.replaceCount, _this16.replaceCountAfterVisit + 1, 'replaceURL should be called once'); }); }; _proto2['@test The {{link-to}} component supports URL replacement via replace=boundTruthyThing'] = function testTheLinkToComponentSupportsURLReplacementViaReplaceBoundTruthyThing(assert) { var _this17 = this; this.addTemplate('index', "\n

Home

\n {{#link-to 'about' id='about-link' replace=boundTruthyThing}}About{{/link-to}}\n "); this.add('controller:index', _controller.default.extend({ boundTruthyThing: true })); return this.visit('/').then(function () { return _this17.click('#about-link'); }).then(function () { assert.equal(_this17.updateCount, _this17.updateCountAfterVisit, 'setURL should not be called'); assert.equal(_this17.replaceCount, _this17.replaceCountAfterVisit + 1, 'replaceURL should be called once'); }); }; _proto2['@test The {{link-to}} component supports setting replace=boundFalseyThing'] = function testTheLinkToComponentSupportsSettingReplaceBoundFalseyThing(assert) { var _this18 = this; this.addTemplate('index', "\n

Home

\n {{#link-to 'about' id='about-link' replace=boundFalseyThing}}About{{/link-to}}\n "); this.add('controller:index', _controller.default.extend({ boundFalseyThing: false })); return this.visit('/').then(function () { return _this18.click('#about-link'); }).then(function () { assert.equal(_this18.updateCount, _this18.updateCountAfterVisit + 1, 'setURL should be called'); assert.equal(_this18.replaceCount, _this18.replaceCountAfterVisit, 'replaceURL should not be called'); }); }; return _class2; }(_internalTestHelpers.ApplicationTestCase)); if (false /* EMBER_IMPROVED_INSTRUMENTATION */ ) { (0, _internalTestHelpers.moduleFor)('The {{link-to}} component with EMBER_IMPROVED_INSTRUMENTATION', /*#__PURE__*/ function (_ApplicationTestCase3) { (0, _emberBabel.inheritsLoose)(_class3, _ApplicationTestCase3); function _class3() { var _this19; _this19 = _ApplicationTestCase3.call(this) || this; _this19.router.map(function () { this.route('about'); }); _this19.addTemplate('index', "\n

Home

\n {{#link-to 'about' id='about-link'}}About{{/link-to}}\n {{#link-to 'index' id='self-link'}}Self{{/link-to}}\n "); _this19.addTemplate('about', "\n

About

\n {{#link-to 'index' id='home-link'}}Home{{/link-to}}\n {{#link-to 'about' id='self-link'}}Self{{/link-to}}\n "); return _this19; } var _proto3 = _class3.prototype; _proto3.beforeEach = function beforeEach() { return this.visit('/'); }; _proto3.afterEach = function afterEach() { (0, _instrumentation.reset)(); return _ApplicationTestCase3.prototype.afterEach.call(this); }; _proto3['@test The {{link-to}} component fires an interaction event'] = function testTheLinkToComponentFiresAnInteractionEvent(assert) { assert.expect(2); (0, _instrumentation.subscribe)('interaction.link-to', { before: function () { assert.ok(true, 'instrumentation subscriber was called'); }, after: function () { assert.ok(true, 'instrumentation subscriber was called'); } }); return this.click('#about-link'); }; _proto3['@test The {{link-to}} component interaction event includes the route name'] = function testTheLinkToComponentInteractionEventIncludesTheRouteName(assert) { assert.expect(2); (0, _instrumentation.subscribe)('interaction.link-to', { before: function (name, timestamp, _ref) { var routeName = _ref.routeName; assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name'); }, after: function (name, timestamp, _ref2) { var routeName = _ref2.routeName; assert.equal(routeName, 'about', 'instrumentation subscriber was passed route name'); } }); return this.click('#about-link'); }; _proto3['@test The {{link-to}} component interaction event includes the transition in the after hook'] = function testTheLinkToComponentInteractionEventIncludesTheTransitionInTheAfterHook(assert) { assert.expect(1); (0, _instrumentation.subscribe)('interaction.link-to', { before: function () {}, after: function (name, timestamp, _ref3) { var transition = _ref3.transition; assert.equal(transition.targetName, 'about', 'instrumentation subscriber was passed route name'); } }); return this.click('#about-link'); }; return _class3; }(_internalTestHelpers.ApplicationTestCase)); } (0, _internalTestHelpers.moduleFor)('The {{link-to}} component - nested routes and link-to arguments', /*#__PURE__*/ function (_ApplicationTestCase4) { (0, _emberBabel.inheritsLoose)(_class4, _ApplicationTestCase4); function _class4() { return _ApplicationTestCase4.apply(this, arguments) || this; } var _proto4 = _class4.prototype; _proto4['@test The {{link-to}} component supports leaving off .index for nested routes'] = function testTheLinkToComponentSupportsLeavingOffIndexForNestedRoutes(assert) { var _this20 = this; this.router.map(function () { this.route('about', function () { this.route('item'); }); }); this.addTemplate('about', "

About

{{outlet}}"); this.addTemplate('about.index', "
Index
"); this.addTemplate('about.item', "
{{#link-to 'about'}}About{{/link-to}}
"); return this.visit('/about/item').then(function () { assert.equal(normalizeUrl(_this20.$('#item a').attr('href')), '/about'); }); }; _proto4["@test The {{link-to}} component supports custom, nested, current-when"] = function (assert) { var _this21 = this; this.router.map(function () { this.route('index', { path: '/' }, function () { this.route('about'); }); this.route('item'); }); this.addTemplate('index', "

Home

{{outlet}}"); this.addTemplate('index.about', "{{#link-to 'item' id='other-link' current-when='index'}}ITEM{{/link-to}}"); return this.visit('/about').then(function () { assert.equal(_this21.$('#other-link.active').length, 1, 'The link is active since current-when is a parent route'); }); }; _proto4["@test The {{link-to}} component does not disregard current-when when it is given explicitly for a route"] = function (assert) { var _this22 = this; this.router.map(function () { this.route('index', { path: '/' }, function () { this.route('about'); }); this.route('items', function () { this.route('item'); }); }); this.addTemplate('index', "

Home

{{outlet}}"); this.addTemplate('index.about', "{{#link-to 'items' id='other-link' current-when='index'}}ITEM{{/link-to}}"); return this.visit('/about').then(function () { assert.equal(_this22.$('#other-link.active').length, 1, 'The link is active when current-when is given for explicitly for a route'); }); }; _proto4['@test The {{link-to}} component does not disregard current-when when it is set via a bound param'] = function testTheLinkToComponentDoesNotDisregardCurrentWhenWhenItIsSetViaABoundParam(assert) { var _this23 = this; this.router.map(function () { this.route('index', { path: '/' }, function () { this.route('about'); }); this.route('items', function () { this.route('item'); }); }); this.add('controller:index.about', _controller.default.extend({ currentWhen: 'index' })); this.addTemplate('index', "

Home

{{outlet}}"); this.addTemplate('index.about', "{{#link-to 'items' id='other-link' current-when=currentWhen}}ITEM{{/link-to}}"); return this.visit('/about').then(function () { assert.equal(_this23.$('#other-link.active').length, 1, 'The link is active when current-when is given for explicitly for a route'); }); }; _proto4['@test The {{link-to}} component supports multiple current-when routes'] = function testTheLinkToComponentSupportsMultipleCurrentWhenRoutes(assert) { var _this24 = this; this.router.map(function () { this.route('index', { path: '/' }, function () { this.route('about'); }); this.route('item'); this.route('foo'); }); this.addTemplate('index', "

Home

{{outlet}}"); this.addTemplate('index.about', "{{#link-to 'item' id='link1' current-when='item index'}}ITEM{{/link-to}}"); this.addTemplate('item', "{{#link-to 'item' id='link2' current-when='item index'}}ITEM{{/link-to}}"); this.addTemplate('foo', "{{#link-to 'item' id='link3' current-when='item index'}}ITEM{{/link-to}}"); return this.visit('/about').then(function () { assert.equal(_this24.$('#link1.active').length, 1, 'The link is active since current-when contains the parent route'); return _this24.visit('/item'); }).then(function () { assert.equal(_this24.$('#link2.active').length, 1, 'The link is active since you are on the active route'); return _this24.visit('/foo'); }).then(function () { assert.equal(_this24.$('#link3.active').length, 0, 'The link is not active since current-when does not contain the active route'); }); }; _proto4['@test The {{link-to}} component supports boolean values for current-when'] = function testTheLinkToComponentSupportsBooleanValuesForCurrentWhen(assert) { var _this25 = this; this.router.map(function () { this.route('index', { path: '/' }, function () { this.route('about'); }); this.route('item'); }); this.addTemplate('index.about', "\n {{#link-to 'index' id='index-link' current-when=isCurrent}}index{{/link-to}}\n {{#link-to 'item' id='about-link' current-when=true}}ITEM{{/link-to}}\n "); this.add('controller:index.about', _controller.default.extend({ isCurrent: false })); return this.visit('/about').then(function () { assert.ok(_this25.$('#about-link').hasClass('active'), 'The link is active since current-when is true'); assert.notOk(_this25.$('#index-link').hasClass('active'), 'The link is not active since current-when is false'); var controller = _this25.applicationInstance.lookup('controller:index.about'); (0, _internalTestHelpers.runTask)(function () { return controller.set('isCurrent', true); }); assert.ok(_this25.$('#index-link').hasClass('active'), 'The link is active since current-when is true'); }); }; _proto4['@test The {{link-to}} component defaults to bubbling'] = function testTheLinkToComponentDefaultsToBubbling(assert) { var _this26 = this; this.addTemplate('about', "\n
\n {{#link-to 'about.contact' id='about-contact'}}About{{/link-to}}\n
\n {{outlet}}\n "); this.addTemplate('about.contact', "

Contact

"); this.router.map(function () { this.route('about', function () { this.route('contact'); }); }); var hidden = 0; this.add('route:about', _routing.Route.extend({ actions: { hide: function () { hidden++; } } })); return this.visit('/about').then(function () { return _this26.click('#about-contact'); }).then(function () { assert.equal(_this26.$('#contact').text(), 'Contact', 'precond - the link worked'); assert.equal(hidden, 1, 'The link bubbles'); }); }; _proto4["@test The {{link-to}} component supports bubbles=false"] = function (assert) { var _this27 = this; this.addTemplate('about', "\n
\n {{#link-to 'about.contact' id='about-contact' bubbles=false}}\n About\n {{/link-to}}\n
\n {{outlet}}\n "); this.addTemplate('about.contact', "

Contact

"); this.router.map(function () { this.route('about', function () { this.route('contact'); }); }); var hidden = 0; this.add('route:about', _routing.Route.extend({ actions: { hide: function () { hidden++; } } })); return this.visit('/about').then(function () { return _this27.click('#about-contact'); }).then(function () { assert.equal(_this27.$('#contact').text(), 'Contact', 'precond - the link worked'); assert.equal(hidden, 0, "The link didn't bubble"); }); }; _proto4["@test The {{link-to}} component supports bubbles=boundFalseyThing"] = function (assert) { var _this28 = this; this.addTemplate('about', "\n
\n {{#link-to 'about.contact' id='about-contact' bubbles=boundFalseyThing}}\n About\n {{/link-to}}\n
\n {{outlet}}\n "); this.addTemplate('about.contact', "

Contact

"); this.add('controller:about', _controller.default.extend({ boundFalseyThing: false })); this.router.map(function () { this.route('about', function () { this.route('contact'); }); }); var hidden = 0; this.add('route:about', _routing.Route.extend({ actions: { hide: function () { hidden++; } } })); return this.visit('/about').then(function () { return _this28.click('#about-contact'); }).then(function () { assert.equal(_this28.$('#contact').text(), 'Contact', 'precond - the link worked'); assert.equal(hidden, 0, "The link didn't bubble"); }); }; _proto4["@test The {{link-to}} component moves into the named route with context"] = function (assert) { var _this29 = this; this.router.map(function () { this.route('about'); this.route('item', { path: '/item/:id' }); }); this.addTemplate('about', "\n

List

\n
    \n {{#each model as |person|}}\n
  • \n {{#link-to 'item' person id=person.id}}\n {{person.name}}\n {{/link-to}}\n
  • \n {{/each}}\n
\n {{#link-to 'index' id='home-link'}}Home{{/link-to}}\n "); this.addTemplate('item', "\n

Item

\n

{{model.name}}

\n {{#link-to 'index' id='home-link'}}Home{{/link-to}}\n "); this.addTemplate('index', "\n

Home

\n {{#link-to 'about' id='about-link'}}About{{/link-to}}\n "); this.add('route:about', _routing.Route.extend({ model: function () { return [{ id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, { id: 'erik', name: 'Erik Brynroflsson' }]; } })); return this.visit('/about').then(function () { assert.equal(_this29.$('h3.list').length, 1, 'The home template was rendered'); assert.equal(normalizeUrl(_this29.$('#home-link').attr('href')), '/', 'The home link points back at /'); return _this29.click('#yehuda'); }).then(function () { assert.equal(_this29.$('h3.item').length, 1, 'The item template was rendered'); assert.equal(_this29.$('p').text(), 'Yehuda Katz', 'The name is correct'); return _this29.click('#home-link'); }).then(function () { return _this29.click('#about-link'); }).then(function () { assert.equal(normalizeUrl(_this29.$('li a#yehuda').attr('href')), '/item/yehuda'); assert.equal(normalizeUrl(_this29.$('li a#tom').attr('href')), '/item/tom'); assert.equal(normalizeUrl(_this29.$('li a#erik').attr('href')), '/item/erik'); return _this29.click('#erik'); }).then(function () { assert.equal(_this29.$('h3.item').length, 1, 'The item template was rendered'); assert.equal(_this29.$('p').text(), 'Erik Brynroflsson', 'The name is correct'); }); }; _proto4["@test The {{link-to}} component binds some anchor html tag common attributes"] = function (assert) { var _this30 = this; this.addTemplate('index', "\n

Home

\n {{#link-to 'index' id='self-link' title='title-attr' rel='rel-attr' tabindex='-1'}}\n Self\n {{/link-to}}\n "); return this.visit('/').then(function () { var link = _this30.$('#self-link'); assert.equal(link.attr('title'), 'title-attr', 'The self-link contains title attribute'); assert.equal(link.attr('rel'), 'rel-attr', 'The self-link contains rel attribute'); assert.equal(link.attr('tabindex'), '-1', 'The self-link contains tabindex attribute'); }); }; _proto4["@test The {{link-to}} component supports 'target' attribute"] = function (assert) { var _this31 = this; this.addTemplate('index', "\n

Home

\n {{#link-to 'index' id='self-link' target='_blank'}}Self{{/link-to}}\n "); return this.visit('/').then(function () { var link = _this31.$('#self-link'); assert.equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); }); }; _proto4["@test The {{link-to}} component supports 'target' attribute specified as a bound param"] = function (assert) { var _this32 = this; this.addTemplate('index', "

Home

{{#link-to 'index' id='self-link' target=boundLinkTarget}}Self{{/link-to}}"); this.add('controller:index', _controller.default.extend({ boundLinkTarget: '_blank' })); return this.visit('/').then(function () { var link = _this32.$('#self-link'); assert.equal(link.attr('target'), '_blank', 'The self-link contains `target` attribute'); }); }; _proto4["@test the {{link-to}} component calls preventDefault"] = function (assert) { var _this33 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "{{#link-to 'about' id='about-link'}}About{{/link-to}}"); return this.visit('/').then(function () { assertNav({ prevented: true }, function () { return _this33.$('#about-link').click(); }, assert); }); }; _proto4["@test the {{link-to}} component does not call preventDefault if 'preventDefault=false' is passed as an option"] = function (assert) { var _this34 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "{{#link-to 'about' id='about-link' preventDefault=false}}About{{/link-to}}"); return this.visit('/').then(function () { assertNav({ prevented: false }, function () { return _this34.$('#about-link').trigger('click'); }, assert); }); }; _proto4["@test the {{link-to}} component does not call preventDefault if 'preventDefault=boundFalseyThing' is passed as an option"] = function (assert) { var _this35 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "{{#link-to 'about' id='about-link' preventDefault=boundFalseyThing}}About{{/link-to}}"); this.add('controller:index', _controller.default.extend({ boundFalseyThing: false })); return this.visit('/').then(function () { assertNav({ prevented: false }, function () { return _this35.$('#about-link').trigger('click'); }, assert); }); }; _proto4["@test The {{link-to}} component does not call preventDefault if 'target' attribute is provided"] = function (assert) { var _this36 = this; this.addTemplate('index', "\n

Home

\n {{#link-to 'index' id='self-link' target='_blank'}}Self{{/link-to}}\n "); return this.visit('/').then(function () { assertNav({ prevented: false }, function () { return _this36.$('#self-link').click(); }, assert); }); }; _proto4["@test The {{link-to}} component should preventDefault when 'target = _self'"] = function (assert) { var _this37 = this; this.addTemplate('index', "\n

Home

\n {{#link-to 'index' id='self-link' target='_self'}}Self{{/link-to}}\n "); return this.visit('/').then(function () { assertNav({ prevented: true }, function () { return _this37.$('#self-link').click(); }, assert); }); }; _proto4["@test The {{link-to}} component should not transition if target is not equal to _self or empty"] = function (assert) { var _this38 = this; this.addTemplate('index', "\n {{#link-to 'about' id='about-link' replace=true target='_blank'}}\n About\n {{/link-to}}\n "); this.router.map(function () { this.route('about'); }); return this.visit('/').then(function () { return _this38.click('#about-link'); }).then(function () { expectDeprecation(function () { var currentRouteName = _this38.applicationInstance.lookup('controller:application').get('currentRouteName'); assert.notEqual(currentRouteName, 'about', 'link-to should not transition if target is not equal to _self or empty'); }, 'Accessing `currentRouteName` on `controller:application` is deprecated, use the `currentRouteName` property on `service:router` instead.'); }); }; _proto4["@test The {{link-to}} component accepts string/numeric arguments"] = function (assert) { var _this39 = this; this.router.map(function () { this.route('filter', { path: '/filters/:filter' }); this.route('post', { path: '/post/:post_id' }); this.route('repo', { path: '/repo/:owner/:name' }); }); this.add('controller:filter', _controller.default.extend({ filter: 'unpopular', repo: { owner: 'ember', name: 'ember.js' }, post_id: 123 })); this.addTemplate('filter', "\n

{{filter}}

\n {{#link-to \"filter\" \"unpopular\" id=\"link\"}}Unpopular{{/link-to}}\n {{#link-to \"filter\" filter id=\"path-link\"}}Unpopular{{/link-to}}\n {{#link-to \"post\" post_id id=\"post-path-link\"}}Post{{/link-to}}\n {{#link-to \"post\" 123 id=\"post-number-link\"}}Post{{/link-to}}\n {{#link-to \"repo\" repo id=\"repo-object-link\"}}Repo{{/link-to}}\n "); return this.visit('/filters/popular').then(function () { assert.equal(normalizeUrl(_this39.$('#link').attr('href')), '/filters/unpopular'); assert.equal(normalizeUrl(_this39.$('#path-link').attr('href')), '/filters/unpopular'); assert.equal(normalizeUrl(_this39.$('#post-path-link').attr('href')), '/post/123'); assert.equal(normalizeUrl(_this39.$('#post-number-link').attr('href')), '/post/123'); assert.equal(normalizeUrl(_this39.$('#repo-object-link').attr('href')), '/repo/ember/ember.js'); }); }; _proto4["@test Issue 4201 - Shorthand for route.index shouldn't throw errors about context arguments"] = function (assert) { var _this40 = this; assert.expect(2); this.router.map(function () { this.route('lobby', function () { this.route('index', { path: ':lobby_id' }); this.route('list'); }); }); this.add('route:lobby.index', _routing.Route.extend({ model: function (params) { assert.equal(params.lobby_id, 'foobar'); return params.lobby_id; } })); this.addTemplate('lobby.index', "{{#link-to 'lobby' 'foobar' id='lobby-link'}}Lobby{{/link-to}}"); this.addTemplate('lobby.list', "{{#link-to 'lobby' 'foobar' id='lobby-link'}}Lobby{{/link-to}}"); return this.visit('/lobby/list').then(function () { return _this40.click('#lobby-link'); }).then(function () { return shouldBeActive(assert, _this40.$('#lobby-link')); }); }; _proto4["@test Quoteless route param performs property lookup"] = function (assert) { var _this41 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "\n {{#link-to 'index' id='string-link'}}string{{/link-to}}\n {{#link-to foo id='path-link'}}path{{/link-to}}\n "); this.add('controller:index', _controller.default.extend({ foo: 'index' })); var assertEquality = function (href) { assert.equal(normalizeUrl(_this41.$('#string-link').attr('href')), '/'); assert.equal(normalizeUrl(_this41.$('#path-link').attr('href')), href); }; return this.visit('/').then(function () { assertEquality('/'); var controller = _this41.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return controller.set('foo', 'about'); }); assertEquality('/about'); }); }; _proto4["@test The {{link-to}} component refreshes href element when one of params changes"] = function (assert) { var _this42 = this; this.router.map(function () { this.route('post', { path: '/posts/:post_id' }); }); var post = { id: '1' }; var secondPost = { id: '2' }; this.addTemplate('index', "{{#link-to \"post\" post id=\"post\"}}post{{/link-to}}"); this.add('controller:index', _controller.default.extend()); return this.visit('/').then(function () { var indexController = _this42.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('post', post); }); assert.equal(normalizeUrl(_this42.$('#post').attr('href')), '/posts/1', 'precond - Link has rendered href attr properly'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('post', secondPost); }); assert.equal(_this42.$('#post').attr('href'), '/posts/2', 'href attr was updated after one of the params had been changed'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('post', null); }); assert.equal(_this42.$('#post').attr('href'), '#', 'href attr becomes # when one of the arguments in nullified'); }); }; _proto4["@test The {{link-to}} component is active when a route is active"] = function (assert) { var _this43 = this; this.router.map(function () { this.route('about', function () { this.route('item'); }); }); this.addTemplate('about', "\n
\n {{#link-to 'about' id='about-link'}}About{{/link-to}}\n {{#link-to 'about.item' id='item-link'}}Item{{/link-to}}\n {{outlet}}\n
\n "); return this.visit('/about').then(function () { assert.equal(_this43.$('#about-link.active').length, 1, 'The about route link is active'); assert.equal(_this43.$('#item-link.active').length, 0, 'The item route link is inactive'); return _this43.visit('/about/item'); }).then(function () { assert.equal(_this43.$('#about-link.active').length, 1, 'The about route link is active'); assert.equal(_this43.$('#item-link.active').length, 1, 'The item route link is active'); }); }; _proto4["@test The {{link-to}} component works in an #each'd array of string route names"] = function (assert) { var _this44 = this; this.router.map(function () { this.route('foo'); this.route('bar'); this.route('rar'); }); this.add('controller:index', _controller.default.extend({ routeNames: (0, _runtime.A)(['foo', 'bar', 'rar']), route1: 'bar', route2: 'foo' })); this.addTemplate('index', "\n {{#each routeNames as |routeName|}}\n {{#link-to routeName}}{{routeName}}{{/link-to}}\n {{/each}}\n {{#each routeNames as |r|}}\n {{#link-to r}}{{r}}{{/link-to}}\n {{/each}}\n {{#link-to route1}}a{{/link-to}}\n {{#link-to route2}}b{{/link-to}}\n "); var linksEqual = function (links, expected) { assert.equal(links.length, expected.length, 'Has correct number of links'); var idx; for (idx = 0; idx < links.length; idx++) { var href = _this44.$(links[idx]).attr('href'); // Old IE includes the whole hostname as well assert.equal(href.slice(-expected[idx].length), expected[idx], "Expected link to be '" + expected[idx] + "', but was '" + href + "'"); } }; return this.visit('/').then(function () { linksEqual(_this44.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/bar', '/foo']); var indexController = _this44.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return indexController.set('route1', 'rar'); }); linksEqual(_this44.$('a'), ['/foo', '/bar', '/rar', '/foo', '/bar', '/rar', '/rar', '/foo']); (0, _internalTestHelpers.runTask)(function () { return indexController.routeNames.shiftObject(); }); linksEqual(_this44.$('a'), ['/bar', '/rar', '/bar', '/rar', '/rar', '/foo']); }); }; _proto4["@test The non-block form {{link-to}} component moves into the named route"] = function (assert) { var _this45 = this; assert.expect(3); this.router.map(function () { this.route('contact'); }); this.addTemplate('index', "\n

Home

\n {{link-to 'Contact us' 'contact' id='contact-link'}}\n {{#link-to 'index' id='self-link'}}Self{{/link-to}}\n "); this.addTemplate('contact', "\n

Contact

\n {{link-to 'Home' 'index' id='home-link'}}\n {{link-to 'Self' 'contact' id='self-link'}}\n "); return this.visit('/').then(function () { return _this45.click('#contact-link'); }).then(function () { assert.equal(_this45.$('h3.contact').length, 1, 'The contact template was rendered'); assert.equal(_this45.$('#self-link.active').length, 1, 'The self-link was rendered with active class'); assert.equal(_this45.$('#home-link:not(.active)').length, 1, 'The other link was rendered without active class'); }); }; _proto4["@test The non-block form {{link-to}} component updates the link text when it is a binding"] = function (assert) { var _this46 = this; assert.expect(8); this.router.map(function () { this.route('contact'); }); this.add('controller:index', _controller.default.extend({ contactName: 'Jane' })); this.addTemplate('index', "\n

Home

\n {{link-to contactName 'contact' id='contact-link'}}\n {{#link-to 'index' id='self-link'}}Self{{/link-to}}\n "); this.addTemplate('contact', "\n

Contact

\n {{link-to 'Home' 'index' id='home-link'}}\n {{link-to 'Self' 'contact' id='self-link'}}\n "); return this.visit('/').then(function () { assert.equal(_this46.$('#contact-link').text(), 'Jane', 'The link title is correctly resolved'); var controller = _this46.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return controller.set('contactName', 'Joe'); }); assert.equal(_this46.$('#contact-link').text(), 'Joe', 'The link title is correctly updated when the bound property changes'); (0, _internalTestHelpers.runTask)(function () { return controller.set('contactName', 'Robert'); }); assert.equal(_this46.$('#contact-link').text(), 'Robert', 'The link title is correctly updated when the bound property changes a second time'); return _this46.click('#contact-link'); }).then(function () { assert.equal(_this46.$('h3.contact').length, 1, 'The contact template was rendered'); assert.equal(_this46.$('#self-link.active').length, 1, 'The self-link was rendered with active class'); assert.equal(_this46.$('#home-link:not(.active)').length, 1, 'The other link was rendered without active class'); return _this46.click('#home-link'); }).then(function () { assert.equal(_this46.$('h3.home').length, 1, 'The index template was rendered'); assert.equal(_this46.$('#contact-link').text(), 'Robert', 'The link title is correctly updated when the route changes'); }); }; _proto4["@test The non-block form {{link-to}} component moves into the named route with context"] = function (assert) { var _this47 = this; assert.expect(5); this.router.map(function () { this.route('item', { path: '/item/:id' }); }); this.add('route:index', _routing.Route.extend({ model: function () { return [{ id: 'yehuda', name: 'Yehuda Katz' }, { id: 'tom', name: 'Tom Dale' }, { id: 'erik', name: 'Erik Brynroflsson' }]; } })); this.addTemplate('index', "\n

Home

\n
    \n {{#each model as |person|}}\n
  • \n {{link-to person.name 'item' person id=person.id}}\n
  • \n {{/each}}\n
\n "); this.addTemplate('item', "\n

Item

\n

{{model.name}}

\n {{#link-to 'index' id='home-link'}}Home{{/link-to}}\n "); return this.visit('/').then(function () { return _this47.click('#yehuda'); }).then(function () { assert.equal(_this47.$('h3.item').length, 1, 'The item template was rendered'); assert.equal(_this47.$('p').text(), 'Yehuda Katz', 'The name is correct'); return _this47.click('#home-link'); }).then(function () { assert.equal(normalizeUrl(_this47.$('li a#yehuda').attr('href')), '/item/yehuda'); assert.equal(normalizeUrl(_this47.$('li a#tom').attr('href')), '/item/tom'); assert.equal(normalizeUrl(_this47.$('li a#erik').attr('href')), '/item/erik'); }); }; _proto4["@test The non-block form {{link-to}} performs property lookup"] = function (assert) { var _this48 = this; this.router.map(function () { this.route('about'); }); this.addTemplate('index', "\n {{link-to 'string' 'index' id='string-link'}}\n {{link-to path foo id='path-link'}}\n "); this.add('controller:index', _controller.default.extend({ foo: 'index' })); return this.visit('/').then(function () { var assertEquality = function (href) { assert.equal(normalizeUrl(_this48.$('#string-link').attr('href')), '/'); assert.equal(normalizeUrl(_this48.$('#path-link').attr('href')), href); }; assertEquality('/'); var controller = _this48.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { return controller.set('foo', 'about'); }); assertEquality('/about'); }); }; _proto4["@test The non-block form {{link-to}} protects against XSS"] = function (assert) { var _this49 = this; this.addTemplate('application', "{{link-to display 'index' id='link'}}"); this.add('controller:application', _controller.default.extend({ display: 'blahzorz' })); return this.visit('/').then(function () { assert.equal(_this49.$('#link').text(), 'blahzorz'); var controller = _this49.applicationInstance.lookup('controller:application'); (0, _internalTestHelpers.runTask)(function () { return controller.set('display', 'BLAMMO'); }); assert.equal(_this49.$('#link').text(), 'BLAMMO'); assert.equal(_this49.$('b').length, 0); }); }; _proto4["@test the {{link-to}} component throws a useful error if you invoke it wrong"] = function (assert) { var _this50 = this; assert.expect(1); this.router.map(function () { this.route('post', { path: 'post/:post_id' }); }); this.addTemplate('application', "{{#link-to 'post'}}Post{{/link-to}}"); assert.throws(function () { _this50.visit('/'); }, /(You attempted to define a `\{\{link-to "post"\}\}` but did not pass the parameters required for generating its dynamic segments.|You must provide param `post_id` to `generate`)/); return (0, _internalTestHelpers.runLoopSettled)(); }; _proto4["@test the {{link-to}} component does not throw an error if its route has exited"] = function (assert) { var _this51 = this; assert.expect(0); this.router.map(function () { this.route('post', { path: 'post/:post_id' }); }); this.addTemplate('application', "\n {{#link-to 'index' id='home-link'}}Home{{/link-to}}\n {{#link-to 'post' defaultPost id='default-post-link'}}Default Post{{/link-to}}\n {{#if currentPost}}\n {{#link-to 'post' currentPost id='current-post-link'}}Current Post{{/link-to}}\n {{/if}}\n "); this.add('controller:application', _controller.default.extend({ defaultPost: { id: 1 }, postController: (0, _controller.inject)('post'), currentPost: (0, _metal.alias)('postController.model') })); this.add('controller:post', _controller.default.extend()); this.add('route:post', _routing.Route.extend({ model: function () { return { id: 2 }; }, serialize: function (model) { return { post_id: model.id }; } })); return this.visit('/').then(function () { return _this51.click('#default-post-link'); }).then(function () { return _this51.click('#home-link'); }).then(function () { return _this51.click('#current-post-link'); }).then(function () { return _this51.click('#home-link'); }); }; _proto4["@test {{link-to}} active property respects changing parent route context"] = function (assert) { var _this52 = this; this.router.map(function () { this.route('things', { path: '/things/:name' }, function () { this.route('other'); }); }); this.addTemplate('application', "\n {{link-to 'OMG' 'things' 'omg' id='omg-link'}}\n {{link-to 'LOL' 'things' 'lol' id='lol-link'}}\n "); return this.visit('/things/omg').then(function () { shouldBeActive(assert, _this52.$('#omg-link')); shouldNotBeActive(assert, _this52.$('#lol-link')); return _this52.visit('/things/omg/other'); }).then(function () { shouldBeActive(assert, _this52.$('#omg-link')); shouldNotBeActive(assert, _this52.$('#lol-link')); }); }; _proto4["@test {{link-to}} populates href with default query param values even without query-params object"] = function (assert) { var _this53 = this; this.add('controller:index', _controller.default.extend({ queryParams: ['foo'], foo: '123' })); this.addTemplate('index', "{{#link-to 'index' id='the-link'}}Index{{/link-to}}"); return this.visit('/').then(function () { assert.equal(_this53.$('#the-link').attr('href'), '/', 'link has right href'); }); }; _proto4["@test {{link-to}} populates href with default query param values with empty query-params object"] = function (assert) { var _this54 = this; this.add('controller:index', _controller.default.extend({ queryParams: ['foo'], foo: '123' })); this.addTemplate('index', "{{#link-to 'index' (query-params) id='the-link'}}Index{{/link-to}}"); return this.visit('/').then(function () { assert.equal(_this54.$('#the-link').attr('href'), '/', 'link has right href'); }); }; _proto4["@test {{link-to}} with only query-params and a block updates when route changes"] = function (assert) { var _this55 = this; this.router.map(function () { this.route('about'); }); this.add('controller:application', _controller.default.extend({ queryParams: ['foo', 'bar'], foo: '123', bar: 'yes' })); this.addTemplate('application', "{{#link-to (query-params foo='456' bar='NAW') id='the-link'}}Index{{/link-to}}"); return this.visit('/').then(function () { assert.equal(_this55.$('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); return _this55.visit('/about'); }).then(function () { assert.equal(_this55.$('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href'); }); }; _proto4["@test Block-less {{link-to}} with only query-params updates when route changes"] = function (assert) { var _this56 = this; this.router.map(function () { this.route('about'); }); this.add('controller:application', _controller.default.extend({ queryParams: ['foo', 'bar'], foo: '123', bar: 'yes' })); this.addTemplate('application', "{{link-to \"Index\" (query-params foo='456' bar='NAW') id='the-link'}}"); return this.visit('/').then(function () { assert.equal(_this56.$('#the-link').attr('href'), '/?bar=NAW&foo=456', 'link has right href'); return _this56.visit('/about'); }).then(function () { assert.equal(_this56.$('#the-link').attr('href'), '/about?bar=NAW&foo=456', 'link has right href'); }); }; _proto4['@test [GH#17018] passing model to link-to with `hash` helper works'] = function testGH17018PassingModelToLinkToWithHashHelperWorks() { var _this57 = this; this.router.map(function () { this.route('post', { path: '/posts/:post_id' }); }); this.add('route:index', _routing.Route.extend({ model: function () { return _runtime.RSVP.hash({ user: { name: 'Papa Smurf' } }); } })); this.addTemplate('index', "{{link-to 'Post' 'post' (hash id=\"someId\" user=this.model.user)}}"); this.addTemplate('post', 'Post: {{this.model.user.name}}'); return this.visit('/').then(function () { _this57.assertComponentElement(_this57.firstChild, { tagName: 'a', attrs: { href: '/posts/someId' }, content: 'Post' }); return _this57.click('a'); }).then(function () { _this57.assertText('Post: Papa Smurf'); }); }; _proto4["@test The {{link-to}} component can use dynamic params"] = function (assert) { var _this58 = this; this.router.map(function () { this.route('foo', { path: 'foo/:some/:thing' }); this.route('bar', { path: 'bar/:some/:thing/:else' }); }); this.add('controller:index', _controller.default.extend({ init: function () { this._super.apply(this, arguments); this.dynamicLinkParams = ['foo', 'one', 'two']; } })); this.addTemplate('index', "\n

Home

\n {{#link-to params=dynamicLinkParams id=\"dynamic-link\"}}Dynamic{{/link-to}}\n "); return this.visit('/').then(function () { var link = _this58.$('#dynamic-link'); assert.equal(link.attr('href'), '/foo/one/two'); var controller = _this58.applicationInstance.lookup('controller:index'); (0, _internalTestHelpers.runTask)(function () { controller.set('dynamicLinkParams', ['bar', 'one', 'two', 'three']); }); assert.equal(link.attr('href'), '/bar/one/two/three'); }); }; _proto4["@test GJ: {{link-to}} to a parent root model hook which performs a 'transitionTo' has correct active class #13256"] = function (assert) { var _this59 = this; assert.expect(1); this.router.map(function () { this.route('parent', function () { this.route('child'); }); }); this.add('route:parent', _routing.Route.extend({ afterModel: function () { this.transitionTo('parent.child'); } })); this.addTemplate('application', "{{link-to 'Parent' 'parent' id='parent-link'}}"); return this.visit('/').then(function () { return _this59.click('#parent-link'); }).then(function () { shouldBeActive(assert, _this59.$('#parent-link')); }); }; return _class4; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)('The {{link-to}} component - loading states and warnings', /*#__PURE__*/ function (_ApplicationTestCase5) { (0, _emberBabel.inheritsLoose)(_class5, _ApplicationTestCase5); function _class5() { return _ApplicationTestCase5.apply(this, arguments) || this; } var _proto5 = _class5.prototype; _proto5["@test {{link-to}} with null/undefined dynamic parameters are put in a loading state"] = function (assert) { var _this60 = this; assert.expect(19); var warningMessage; if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { warningMessage = 'This link is in an inactive loading state because at least one of its models currently has a null/undefined value, or the provided route name is invalid.'; } else { warningMessage = 'This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.'; } this.router.map(function () { this.route('thing', { path: '/thing/:thing_id' }); this.route('about'); }); this.addTemplate('index', "\n {{#link-to destinationRoute routeContext loadingClass='i-am-loading' id='context-link'}}\n string\n {{/link-to}}\n {{#link-to secondRoute loadingClass=loadingClass id='static-link'}}\n string\n {{/link-to}}\n "); this.add('controller:index', _controller.default.extend({ destinationRoute: null, routeContext: null, loadingClass: 'i-am-loading' })); this.add('route:about', _routing.Route.extend({ activate: function () { assert.ok(true, 'About was entered'); } })); function assertLinkStatus(link, url) { if (url) { assert.equal(normalizeUrl(link.attr('href')), url, 'loaded link-to has expected href'); assert.ok(!link.hasClass('i-am-loading'), 'loaded linkComponent has no loadingClass'); } else { assert.equal(normalizeUrl(link.attr('href')), '#', "unloaded link-to has href='#'"); assert.ok(link.hasClass('i-am-loading'), 'loading linkComponent has loadingClass'); } } var contextLink, staticLink, controller; return this.visit('/').then(function () { contextLink = _this60.$('#context-link'); staticLink = _this60.$('#static-link'); controller = _this60.applicationInstance.lookup('controller:index'); assertLinkStatus(contextLink); assertLinkStatus(staticLink); return expectWarning(function () { return _this60.click(contextLink[0]); }, warningMessage); }).then(function () { // Set the destinationRoute (context is still null). (0, _internalTestHelpers.runTask)(function () { return controller.set('destinationRoute', 'thing'); }); assertLinkStatus(contextLink); // Set the routeContext to an id (0, _internalTestHelpers.runTask)(function () { return controller.set('routeContext', '456'); }); assertLinkStatus(contextLink, '/thing/456'); // Test that 0 isn't interpreted as falsy. (0, _internalTestHelpers.runTask)(function () { return controller.set('routeContext', 0); }); assertLinkStatus(contextLink, '/thing/0'); // Set the routeContext to an object (0, _internalTestHelpers.runTask)(function () { controller.set('routeContext', { id: 123 }); }); assertLinkStatus(contextLink, '/thing/123'); // Set the destinationRoute back to null. (0, _internalTestHelpers.runTask)(function () { return controller.set('destinationRoute', null); }); assertLinkStatus(contextLink); return expectWarning(function () { return _this60.click(staticLink[0]); }, warningMessage); }).then(function () { (0, _internalTestHelpers.runTask)(function () { return controller.set('secondRoute', 'about'); }); assertLinkStatus(staticLink, '/about'); // Click the now-active link return _this60.click(staticLink[0]); }); }; return _class5; }(_internalTestHelpers.ApplicationTestCase)); function assertNav(options, callback, assert) { var nav = false; function check(event) { assert.equal(event.defaultPrevented, options.prevented, "expected defaultPrevented=" + options.prevented); nav = true; event.preventDefault(); } try { document.addEventListener('click', check); callback(); } finally { document.removeEventListener('click', check); assert.ok(nav, 'Expected a link to be clicked'); } } }); enifed("@ember/-internals/glimmer/tests/integration/components/link-to/transitioning-classes-angle-test", ["ember-babel", "@ember/-internals/runtime", "@ember/-internals/routing", "internal-test-helpers"], function (_emberBabel, _runtime, _routing, _internalTestHelpers) { "use strict"; /* eslint-disable no-inner-declarations */ // ^^^ remove after unflagging EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { function assertHasClass(assert, selector, label) { var testLabel = selector.attr('id') + " should have class " + label; assert.equal(selector.hasClass(label), true, testLabel); } function assertHasNoClass(assert, selector, label) { var testLabel = selector.attr('id') + " should not have class " + label; assert.equal(selector.hasClass(label), false, testLabel); } (0, _internalTestHelpers.moduleFor)(' component: .transitioning-in .transitioning-out CSS classes', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { var _this2; _this2 = _ApplicationTestCase.call(this) || this; _this2.aboutDefer = _runtime.RSVP.defer(); _this2.otherDefer = _runtime.RSVP.defer(); _this2.newsDefer = _runtime.RSVP.defer(); var _this = (0, _emberBabel.assertThisInitialized)(_this2); _this2.router.map(function () { this.route('about'); this.route('other'); this.route('news'); }); _this2.add('route:about', _routing.Route.extend({ model: function () { return _this.aboutDefer.promise; } })); _this2.add('route:other', _routing.Route.extend({ model: function () { return _this.otherDefer.promise; } })); _this2.add('route:news', _routing.Route.extend({ model: function () { return _this.newsDefer.promise; } })); _this2.addTemplate('application', "\n {{outlet}}\n Index\n About\n Other\n News\n "); return _this2; } var _proto = _class.prototype; _proto.beforeEach = function beforeEach() { return this.visit('/'); }; _proto.afterEach = function afterEach() { _ApplicationTestCase.prototype.afterEach.call(this); this.aboutDefer = null; this.otherDefer = null; this.newsDefer = null; }; _proto['@test while a transition is underway'] = function testWhileATransitionIsUnderway(assert) { var _this3 = this; var $index = this.$('#index-link'); var $about = this.$('#about-link'); var $other = this.$('#other-link'); $about.click(); assertHasClass(assert, $index, 'active'); assertHasNoClass(assert, $about, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); (0, _internalTestHelpers.runTask)(function () { return _this3.aboutDefer.resolve(); }); assertHasNoClass(assert, $index, 'active'); assertHasClass(assert, $about, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); }; _proto['@test while a transition is underway with activeClass is false'] = function testWhileATransitionIsUnderwayWithActiveClassIsFalse(assert) { var _this4 = this; var $index = this.$('#index-link'); var $news = this.$('#news-link'); var $other = this.$('#other-link'); $news.click(); assertHasClass(assert, $index, 'active'); assertHasNoClass(assert, $news, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasClass(assert, $news, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $news, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); (0, _internalTestHelpers.runTask)(function () { return _this4.newsDefer.resolve(); }); assertHasNoClass(assert, $index, 'active'); assertHasNoClass(assert, $news, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $news, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $news, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)(" component: .transitioning-in .transitioning-out CSS classes - nested link-to's", /*#__PURE__*/ function (_ApplicationTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _ApplicationTestCase2); function _class2() { var _this5; _this5 = _ApplicationTestCase2.call(this) || this; _this5.aboutDefer = _runtime.RSVP.defer(); _this5.otherDefer = _runtime.RSVP.defer(); var _this = (0, _emberBabel.assertThisInitialized)(_this5); _this5.router.map(function () { this.route('parent-route', function () { this.route('about'); this.route('other'); }); }); _this5.add('route:parent-route.about', _routing.Route.extend({ model: function () { return _this.aboutDefer.promise; } })); _this5.add('route:parent-route.other', _routing.Route.extend({ model: function () { return _this.otherDefer.promise; } })); _this5.addTemplate('application', "\n {{outlet}}\n \n Index\n \n \n About\n \n \n Other\n \n "); return _this5; } var _proto2 = _class2.prototype; _proto2.beforeEach = function beforeEach() { return this.visit('/'); }; _proto2.resolveAbout = function resolveAbout() { var _this6 = this; return (0, _internalTestHelpers.runTask)(function () { _this6.aboutDefer.resolve(); _this6.aboutDefer = _runtime.RSVP.defer(); }); }; _proto2.resolveOther = function resolveOther() { var _this7 = this; return (0, _internalTestHelpers.runTask)(function () { _this7.otherDefer.resolve(); _this7.otherDefer = _runtime.RSVP.defer(); }); }; _proto2.teardown = function teardown() { _ApplicationTestCase2.prototype.teardown.call(this); this.aboutDefer = null; this.otherDefer = null; }; _proto2["@test while a transition is underway with nested link-to's"] = function (assert) { // TODO undo changes to this test but currently this test navigates away if navigation // outlet is not stable and the second $about.click() is triggered. var $about = this.$('#about-link'); $about.click(); var $index = this.$('#index-link'); $about = this.$('#about-link'); var $other = this.$('#other-link'); assertHasClass(assert, $index, 'active'); assertHasNoClass(assert, $about, 'active'); assertHasNoClass(assert, $about, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); this.resolveAbout(); $index = this.$('#index-link'); $about = this.$('#about-link'); $other = this.$('#other-link'); assertHasNoClass(assert, $index, 'active'); assertHasClass(assert, $about, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); $other.click(); $index = this.$('#index-link'); $about = this.$('#about-link'); $other = this.$('#other-link'); assertHasNoClass(assert, $index, 'active'); assertHasClass(assert, $about, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $about, 'ember-transitioning-in'); assertHasClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); this.resolveOther(); $index = this.$('#index-link'); $about = this.$('#about-link'); $other = this.$('#other-link'); assertHasNoClass(assert, $index, 'active'); assertHasNoClass(assert, $about, 'active'); assertHasClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); $about.click(); $index = this.$('#index-link'); $about = this.$('#about-link'); $other = this.$('#other-link'); assertHasNoClass(assert, $index, 'active'); assertHasNoClass(assert, $about, 'active'); assertHasClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasClass(assert, $other, 'ember-transitioning-out'); this.resolveAbout(); $index = this.$('#index-link'); $about = this.$('#about-link'); $other = this.$('#other-link'); assertHasNoClass(assert, $index, 'active'); assertHasClass(assert, $about, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); }; return _class2; }(_internalTestHelpers.ApplicationTestCase)); } }); enifed("@ember/-internals/glimmer/tests/integration/components/link-to/transitioning-classes-curly-test", ["ember-babel", "@ember/-internals/runtime", "@ember/-internals/routing", "internal-test-helpers"], function (_emberBabel, _runtime, _routing, _internalTestHelpers) { "use strict"; function assertHasClass(assert, selector, label) { var testLabel = selector.attr('id') + " should have class " + label; assert.equal(selector.hasClass(label), true, testLabel); } function assertHasNoClass(assert, selector, label) { var testLabel = selector.attr('id') + " should not have class " + label; assert.equal(selector.hasClass(label), false, testLabel); } (0, _internalTestHelpers.moduleFor)('{{link-to}} component: .transitioning-in .transitioning-out CSS classes', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class, _ApplicationTestCase); function _class() { var _this2; _this2 = _ApplicationTestCase.call(this) || this; _this2.aboutDefer = _runtime.RSVP.defer(); _this2.otherDefer = _runtime.RSVP.defer(); _this2.newsDefer = _runtime.RSVP.defer(); var _this = (0, _emberBabel.assertThisInitialized)(_this2); _this2.router.map(function () { this.route('about'); this.route('other'); this.route('news'); }); _this2.add('route:about', _routing.Route.extend({ model: function () { return _this.aboutDefer.promise; } })); _this2.add('route:other', _routing.Route.extend({ model: function () { return _this.otherDefer.promise; } })); _this2.add('route:news', _routing.Route.extend({ model: function () { return _this.newsDefer.promise; } })); _this2.addTemplate('application', "\n {{outlet}}\n {{link-to 'Index' 'index' id='index-link'}}\n {{link-to 'About' 'about' id='about-link'}}\n {{link-to 'Other' 'other' id='other-link'}}\n {{link-to 'News' 'news' activeClass=false id='news-link'}}\n "); return _this2; } var _proto = _class.prototype; _proto.beforeEach = function beforeEach() { return this.visit('/'); }; _proto.afterEach = function afterEach() { _ApplicationTestCase.prototype.afterEach.call(this); this.aboutDefer = null; this.otherDefer = null; this.newsDefer = null; }; _proto['@test while a transition is underway'] = function testWhileATransitionIsUnderway(assert) { var _this3 = this; var $index = this.$('#index-link'); var $about = this.$('#about-link'); var $other = this.$('#other-link'); $about.click(); assertHasClass(assert, $index, 'active'); assertHasNoClass(assert, $about, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); (0, _internalTestHelpers.runTask)(function () { return _this3.aboutDefer.resolve(); }); assertHasNoClass(assert, $index, 'active'); assertHasClass(assert, $about, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); }; _proto['@test while a transition is underway with activeClass is false'] = function testWhileATransitionIsUnderwayWithActiveClassIsFalse(assert) { var _this4 = this; var $index = this.$('#index-link'); var $news = this.$('#news-link'); var $other = this.$('#other-link'); $news.click(); assertHasClass(assert, $index, 'active'); assertHasNoClass(assert, $news, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasClass(assert, $news, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $news, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); (0, _internalTestHelpers.runTask)(function () { return _this4.newsDefer.resolve(); }); assertHasNoClass(assert, $index, 'active'); assertHasNoClass(assert, $news, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $news, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $news, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); }; return _class; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)("{{link-to}} component: .transitioning-in .transitioning-out CSS classes - nested link-to's", /*#__PURE__*/ function (_ApplicationTestCase2) { (0, _emberBabel.inheritsLoose)(_class2, _ApplicationTestCase2); function _class2() { var _this5; _this5 = _ApplicationTestCase2.call(this) || this; _this5.aboutDefer = _runtime.RSVP.defer(); _this5.otherDefer = _runtime.RSVP.defer(); var _this = (0, _emberBabel.assertThisInitialized)(_this5); _this5.router.map(function () { this.route('parent-route', function () { this.route('about'); this.route('other'); }); }); _this5.add('route:parent-route.about', _routing.Route.extend({ model: function () { return _this.aboutDefer.promise; } })); _this5.add('route:parent-route.other', _routing.Route.extend({ model: function () { return _this.otherDefer.promise; } })); _this5.addTemplate('application', "\n {{outlet}}\n {{#link-to 'index' tagName='li'}}\n {{link-to 'Index' 'index' id='index-link'}}\n {{/link-to}}\n {{#link-to 'parent-route.about' tagName='li'}}\n {{link-to 'About' 'parent-route.about' id='about-link'}}\n {{/link-to}}\n {{#link-to 'parent-route.other' tagName='li'}}\n {{link-to 'Other' 'parent-route.other' id='other-link'}}\n {{/link-to}}\n "); return _this5; } var _proto2 = _class2.prototype; _proto2.beforeEach = function beforeEach() { return this.visit('/'); }; _proto2.resolveAbout = function resolveAbout() { var _this6 = this; return (0, _internalTestHelpers.runTask)(function () { _this6.aboutDefer.resolve(); _this6.aboutDefer = _runtime.RSVP.defer(); }); }; _proto2.resolveOther = function resolveOther() { var _this7 = this; return (0, _internalTestHelpers.runTask)(function () { _this7.otherDefer.resolve(); _this7.otherDefer = _runtime.RSVP.defer(); }); }; _proto2.teardown = function teardown() { _ApplicationTestCase2.prototype.teardown.call(this); this.aboutDefer = null; this.otherDefer = null; }; _proto2["@test while a transition is underway with nested link-to's"] = function (assert) { // TODO undo changes to this test but currently this test navigates away if navigation // outlet is not stable and the second $about.click() is triggered. var $about = this.$('#about-link'); $about.click(); var $index = this.$('#index-link'); $about = this.$('#about-link'); var $other = this.$('#other-link'); assertHasClass(assert, $index, 'active'); assertHasNoClass(assert, $about, 'active'); assertHasNoClass(assert, $about, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); this.resolveAbout(); $index = this.$('#index-link'); $about = this.$('#about-link'); $other = this.$('#other-link'); assertHasNoClass(assert, $index, 'active'); assertHasClass(assert, $about, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); $other.click(); $index = this.$('#index-link'); $about = this.$('#about-link'); $other = this.$('#other-link'); assertHasNoClass(assert, $index, 'active'); assertHasClass(assert, $about, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $about, 'ember-transitioning-in'); assertHasClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); this.resolveOther(); $index = this.$('#index-link'); $about = this.$('#about-link'); $other = this.$('#other-link'); assertHasNoClass(assert, $index, 'active'); assertHasNoClass(assert, $about, 'active'); assertHasClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); $about.click(); $index = this.$('#index-link'); $about = this.$('#about-link'); $other = this.$('#other-link'); assertHasNoClass(assert, $index, 'active'); assertHasNoClass(assert, $about, 'active'); assertHasClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasClass(assert, $other, 'ember-transitioning-out'); this.resolveAbout(); $index = this.$('#index-link'); $about = this.$('#about-link'); $other = this.$('#other-link'); assertHasNoClass(assert, $index, 'active'); assertHasClass(assert, $about, 'active'); assertHasNoClass(assert, $other, 'active'); assertHasNoClass(assert, $index, 'ember-transitioning-in'); assertHasNoClass(assert, $about, 'ember-transitioning-in'); assertHasNoClass(assert, $other, 'ember-transitioning-in'); assertHasNoClass(assert, $index, 'ember-transitioning-out'); assertHasNoClass(assert, $about, 'ember-transitioning-out'); assertHasNoClass(assert, $other, 'ember-transitioning-out'); }; return _class2; }(_internalTestHelpers.ApplicationTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/local-lookup-test", ["ember-babel", "internal-test-helpers", "ember-template-compiler", "@ember/-internals/glimmer", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _emberTemplateCompiler, _glimmer, _helpers) { "use strict"; var LocalLookupTest = /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(LocalLookupTest, _RenderingTestCase); function LocalLookupTest() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = LocalLookupTest.prototype; _proto['@test it can lookup a local template'] = function testItCanLookupALocalTemplate() { var _this = 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'); (0, _internalTestHelpers.runTask)(function () { return _this.rerender(); }); this.assertText('Nested template says: Hi!', 'Re-render works'); }; _proto['@test tagless blockless component can lookup local template'] = function testTaglessBlocklessComponentCanLookupLocalTemplate() { var _this2 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); this.assertText('Nested template says: Hi!', 'Re-render works'); }; _proto['@test it can lookup a local component template'] = function testItCanLookupALocalComponentTemplate() { var _this3 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); this.assertText('Nested template says: Hi!', 'Re-render works'); }; _proto['@test it can local lookup a dynamic component'] = function testItCanLocalLookupADynamicComponent() { var _this4 = 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?'); (0, _internalTestHelpers.runTask)(function () { return _this4.rerender(); }); this.assertText('yall finished or yall done?'); }; _proto['@test it can local lookup a dynamic component from a dynamic component'] = function testItCanLocalLookupADynamicComponentFromADynamicComponent() { var _this5 = 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?'); (0, _internalTestHelpers.runTask)(function () { return _this5.rerender(); }); this.assertText('yall finished or yall done?'); }; _proto['@test it can local lookup a dynamic component from a passed named argument'] = function testItCanLocalLookupADynamicComponentFromAPassedNamedArgument() { var _this6 = 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?'); (0, _internalTestHelpers.runTask)(function () { return _this6.rerender(); }); this.assertText('yall finished or yall done?'); }; _proto['@test it can local lookup a re-wrapped dynamic component from a passed named argument'] = function testItCanLocalLookupAReWrappedDynamicComponentFromAPassedNamedArgument() { var _this7 = 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?'); (0, _internalTestHelpers.runTask)(function () { return _this7.rerender(); }); this.assertText('yall finished or yall done?'); }; _proto['@test it can nest local lookups of dynamic components from a passed named argument'] = function testItCanNestLocalLookupsOfDynamicComponentsFromAPassedNamedArgument() { 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}}{{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?'); (0, _internalTestHelpers.runTask)(function () { return _this8.rerender(); }); this.assertText('yall finished or yall done?'); }; _proto['@test it can switch from local to global lookups of dynamic components from a passed named argument'] = function testItCanSwitchFromLocalToGlobalLookupsOfDynamicComponentsFromAPassedNamedArgument() { var _this9 = 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?'); (0, _internalTestHelpers.runTask)(function () { return _this9.context.set('bar', 'global-bar'); }); (0, _internalTestHelpers.runTask)(function () { return _this9.rerender(); }); this.assertText('yall finished or yall ready?'); }; _proto['@test it can lookup a local helper'] = function testItCanLookupALocalHelper() { var _this10 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this10.rerender(); }); this.assertText('Who dat? Who dis?', 'Re-render works'); }; _proto['@test it overrides global helper lookup'] = function testItOverridesGlobalHelperLookup() { var _this11 = 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'); (0, _internalTestHelpers.runTask)(function () { return _this11.rerender(); }); this.assertText('Who dat? Who dis? I dunno', 'Re-render works'); }; _proto['@test lookup without match issues standard assertion (with local helper name)'] = function testLookupWithoutMatchIssuesStandardAssertionWithLocalHelperName() { var _this12 = this; this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' }); expectAssertion(function () { _this12.render('{{x-outer}}'); }, /A component or helper named "x-inner" could not be found/); }; _proto['@test overrides global lookup'] = function testOverridesGlobalLookup() { var _this13 = 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!'); (0, _internalTestHelpers.runTask)(function () { return _this13.rerender(); }); this.assertText('Nested template says (from global): Hi! Nested template says (from local): Hi! Nested template says (from local): Hi!'); }; return LocalLookupTest; }(_internalTestHelpers.RenderingTestCase); // first run these tests with expandLocalLookup function buildResolver() { var resolver = { resolve: function () {}, expandLocalLookup: function (fullName, sourceFullName) { if (!sourceFullName) { return null; } 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]; sourceName = sourceName.replace('my-app/', ''); if (sourceType === 'template' && sourceName.slice(0, 21) === 'templates/components/') { sourceName = sourceName.slice(21); } name = name.replace('my-app/', ''); if (type === 'template' && name.slice(0, 11) === 'components/') { name = name.slice(11); sourceName = "components/" + sourceName; } sourceName = sourceName.replace('.hbs', ''); var result = type + ":" + sourceName + "/" + name; return result; } }; return resolver; } (0, _internalTestHelpers.moduleFor)('Components test: local lookup with expandLocalLookup feature', /*#__PURE__*/ function (_LocalLookupTest) { (0, _emberBabel.inheritsLoose)(_class, _LocalLookupTest); function _class() { return _LocalLookupTest.apply(this, arguments) || this; } var _proto2 = _class.prototype; _proto2.getResolver = function getResolver() { return buildResolver(); }; return _class; }(LocalLookupTest)); if (false /* EMBER_MODULE_UNIFICATION */ ) { var LocalLookupTestResolver = /*#__PURE__*/ function (_ModuleBasedTestResol) { (0, _emberBabel.inheritsLoose)(LocalLookupTestResolver, _ModuleBasedTestResol); function LocalLookupTestResolver() { return _ModuleBasedTestResol.apply(this, arguments) || this; } var _proto3 = LocalLookupTestResolver.prototype; _proto3.expandLocalLookup = function expandLocalLookup(specifier, source) { if (source && source.indexOf('components/') !== -1) { var namespace = source.split('components/')[1]; var _specifier$split = specifier.split(':'), type = _specifier$split[0], name = _specifier$split[1]; name = name.replace('components/', ''); namespace = namespace.replace('.hbs', ''); return type + ":" + (type === 'template' ? 'components/' : '') + namespace + "/" + name; } return _ModuleBasedTestResol.prototype.expandLocalLookup.call(this, specifier, source); }; 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, _internalTestHelpers.moduleFor)('Components test: local lookup with resolution referrer', /*#__PURE__*/ function (_LocalLookupTest2) { (0, _emberBabel.inheritsLoose)(_class2, _LocalLookupTest2); function _class2() { return _LocalLookupTest2.apply(this, arguments) || this; } var _proto4 = _class2.prototype; _proto4.getResolver = function getResolver() { return new LocalLookupTestResolver(); }; _proto4.registerComponent = function registerComponent(name, _ref) { var _ref$ComponentClass = _ref.ComponentClass, ComponentClass = _ref$ComponentClass === void 0 ? _helpers.Component : _ref$ComponentClass, _ref$template = _ref.template, template = _ref$template === void 0 ? 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: "my-name/templates/components/" + name + ".hbs" })); } }; _proto4.registerTemplate = function registerTemplate(name, template) { var resolver = this.resolver; if (typeof template === 'string') { resolver.add("template:" + name, this.compile(template, { moduleName: "my-name/templates/" + name + ".hbs" })); } else { throw new Error("Registered template \"" + name + "\" must be a string"); } }; _proto4.registerHelper = function registerHelper(name, funcOrClassBody) { var resolver = this.resolver; var type = typeof funcOrClassBody; if (type === 'function') { resolver.add("helper:" + name, (0, _glimmer.helper)(funcOrClassBody)); } else if (type === 'object' && type !== null) { resolver.add("helper:" + name, _glimmer.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)); } if (false /* EMBER_MODULE_UNIFICATION */ ) { (0, _internalTestHelpers.moduleFor)('Components test: local lookup with resolution referrer (MU)', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class3, _ApplicationTestCase); function _class3() { return _ApplicationTestCase.apply(this, arguments) || this; } var _proto5 = _class3.prototype; _proto5['@test Ensure that the same specifier with two sources does not share a cache key'] = function testEnsureThatTheSameSpecifierWithTwoSourcesDoesNotShareACacheKey(assert) { var _this14 = this; this.add({ specifier: 'template:components/x-not-shared', source: 'template:my-app/templates/components/x-top.hbs' }, (0, _emberTemplateCompiler.compile)('child-x-not-shared')); this.add({ specifier: 'template:components/x-top', source: 'template:my-app/templates/application.hbs' }, (0, _emberTemplateCompiler.compile)('top-level-x-top ({{x-not-shared}})', { moduleName: 'my-app/templates/components/x-top.hbs' })); this.add({ specifier: 'template:components/x-not-shared', source: 'template:my-app/templates/application.hbs' }, (0, _emberTemplateCompiler.compile)('top-level-x-not-shared')); this.addTemplate('application', '{{x-not-shared}} {{x-top}} {{x-not-shared}} {{x-top}}'); return this.visit('/').then(function () { assert.equal(_this14.element.textContent, 'top-level-x-not-shared top-level-x-top (child-x-not-shared) top-level-x-not-shared top-level-x-top (child-x-not-shared)'); }); }; return _class3; }(_internalTestHelpers.ApplicationTestCase)); } }); enifed("@ember/-internals/glimmer/tests/integration/components/namespaced-lookup-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/glimmer"], function (_emberBabel, _internalTestHelpers, _glimmer) { "use strict"; if (false /* EMBER_MODULE_UNIFICATION */ ) { (0, _internalTestHelpers.moduleFor)('Namespaced lookup', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = _class.prototype; _proto['@test it can render a namespaced component'] = function testItCanRenderANamespacedComponent() { var _this = this; this.addTemplate({ specifier: 'template:components/my-component', namespace: 'my-addon' }, 'namespaced template {{myProp}}'); this.add({ specifier: 'component:my-component', namespace: 'my-addon' }, _glimmer.Component.extend({ myProp: 'My property' })); this.addComponent('x-outer', { template: '{{my-addon::my-component}}' }); this.render('{{x-outer}}'); this.assertText('namespaced template My property'); (0, _internalTestHelpers.runTask)(function () { return _this.rerender(); }); this.assertText('namespaced template My property'); }; _proto['@test it can render a nested namespaced component'] = function testItCanRenderANestedNamespacedComponent() { var _this2 = this; this.addTemplate({ specifier: 'template:components/my-component', namespace: 'second-addon' }, 'second namespaced template'); this.addTemplate({ specifier: 'template:components/my-component', namespace: 'first-addon' }, 'first namespaced template - {{second-addon::my-component}}'); this.addComponent('x-outer', { template: '{{first-addon::my-component}}' }); this.render('{{x-outer}}'); this.assertText('first namespaced template - second namespaced template'); (0, _internalTestHelpers.runTask)(function () { return _this2.rerender(); }); this.assertText('first namespaced template - second namespaced template'); }; _proto['@test it can render a nested un-namespaced component'] = function testItCanRenderANestedUnNamespacedComponent() { var _this3 = this; this.addTemplate({ specifier: 'template:components/addon-component', source: 'template:first-addon/src/ui/components/my-component.hbs' }, 'un-namespaced addon template'); this.addTemplate({ specifier: 'template:components/my-component', moduleName: 'first-addon/src/ui/components/my-component.hbs', namespace: 'first-addon' }, '{{addon-component}}'); this.addComponent('x-outer', { template: '{{first-addon::my-component}}' }); this.render('{{x-outer}}'); this.assertText('un-namespaced addon template'); (0, _internalTestHelpers.runTask)(function () { return _this3.rerender(); }); this.assertText('un-namespaced addon template'); }; _proto['@test it can render a namespaced main component'] = function testItCanRenderANamespacedMainComponent() { var _this4 = this; this.addTemplate({ specifier: 'template:components/addon-component', soruce: 'template:first-addon/src/ui/components/main.hbs' }, 'Nested namespaced component'); this.addTemplate({ specifier: 'template:components/first-addon', moduleName: 'first-addon/src/ui/components/main.hbs' }, '{{addon-component}}'); this.addComponent('x-outer', { template: '{{first-addon}}' }); this.render('{{x-outer}}'); this.assertText('Nested namespaced component'); (0, _internalTestHelpers.runTask)(function () { return _this4.rerender(); }); this.assertText('Nested namespaced component'); }; _proto['@test it does not render a main component when using a namespace'] = function testItDoesNotRenderAMainComponentWhenUsingANamespace() { var _this5 = this; this.addTemplate({ specifier: 'template:components/main', namespace: 'my-addon' }, 'namespaced template {{myProp}}'); this.add({ specifier: 'component:main', namespace: 'my-addon' }, _glimmer.Component.extend({ myProp: 'My property' })); this.add({ specifier: 'helper:my-addon', namespace: 'empty-namespace' }, (0, _glimmer.helper)(function () { return 'my helper'; })); this.render('{{empty-namespace::my-addon}}'); this.assertText('my helper'); // component should be not found (0, _internalTestHelpers.runTask)(function () { return _this5.rerender(); }); this.assertText('my helper'); }; _proto['@test it renders a namespaced helper'] = function testItRendersANamespacedHelper() { var _this6 = this; this.add({ specifier: 'helper:my-helper', namespace: 'my-namespace' }, (0, _glimmer.helper)(function () { return 'my helper'; })); this.render('{{my-namespace::my-helper}}'); this.assertText('my helper'); (0, _internalTestHelpers.runTask)(function () { return _this6.rerender(); }); this.assertText('my helper'); }; return _class; }(_internalTestHelpers.RenderingTestCase)); } }); enifed("@ember/-internals/glimmer/tests/integration/components/render-to-element-test", [], function () { "use strict"; }); enifed("@ember/-internals/glimmer/tests/integration/components/target-action-test", ["ember-babel", "internal-test-helpers", "@ember/polyfills", "@ember/-internals/metal", "@ember/controller", "@ember/-internals/runtime", "@ember/-internals/routing", "@ember/-internals/glimmer/tests/utils/helpers"], function (_emberBabel, _internalTestHelpers, _polyfills, _metal, _controller, _runtime, _routing, _helpers) { "use strict"; function _templateObject() { const data = _taggedTemplateLiteralLoose(["\n {{#component-a}}\n {{component-b bar=\"derp\"}}\n {{/component-a}}\n "]); _templateObject = function () { return data; }; return data; } function _taggedTemplateLiteralLoose(strings, raw) { if (!raw) { raw = strings.slice(0); } strings.raw = raw; return strings; } function expectSendActionDeprecation(fn) { expectDeprecation(fn, /You called (.*).sendAction\((.*)\) but Component#sendAction is deprecated. Please use closure actions instead./); } (0, _internalTestHelpers.moduleFor)('Components test: sendAction', /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(_class, _RenderingTestCase); function _class() { var _this; _this = _RenderingTestCase.apply(this, arguments) || this; _this.actionCounts = {}; _this.sendCount = 0; _this.actionArguments = null; var self = (0, _emberBabel.assertThisInitialized)(_this); _this.registerComponent('action-delegate', { ComponentClass: _helpers.Component.extend({ init: function () { this._super(); self.delegate = this; this.name = 'action-delegate'; } }) }); return _this; } var _proto = _class.prototype; _proto.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, _polyfills.assign)(context, { send: function (actionName) { root.sendCount++; root.actionCounts[actionName] = root.actionCounts[actionName] || 0; root.actionCounts[actionName]++; for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } root.actionArguments = args; } }); this.render(template, context); }; _proto.assertSendCount = function assertSendCount(count) { this.assert.equal(this.sendCount, count, "Send was called " + count + " time(s)"); }; _proto.assertNamedSendCount = function assertNamedSendCount(actionName, count) { this.assert.equal(this.actionCounts[actionName], count, "An action named '" + actionName + "' was sent " + count + " times"); }; _proto.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); }; _proto['@test Calling sendAction on a component without an action defined does nothing'] = function testCallingSendActionOnAComponentWithoutAnActionDefinedDoesNothing() { var _this2 = this; this.renderDelegate(); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { return _this2.delegate.sendAction(); }); }); this.assertSendCount(0); }; _proto['@test Calling sendAction on a component with an action defined calls send on the controller'] = function testCallingSendActionOnAComponentWithAnActionDefinedCallsSendOnTheController() { var _this3 = this; this.renderDelegate(); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this3.delegate, 'action', 'addItem'); _this3.delegate.sendAction(); }); }); this.assertSendCount(1); this.assertNamedSendCount('addItem', 1); }; _proto['@test Calling sendAction on a component with a function calls the function'] = function testCallingSendActionOnAComponentWithAFunctionCallsTheFunction() { var _this4 = this; this.assert.expect(2); this.renderDelegate(); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this4.delegate, 'action', function () { return _this4.assert.ok(true, 'function is called'); }); _this4.delegate.sendAction(); }); }); }; _proto['@test Calling sendAction on a component with a function calls the function with arguments'] = function testCallingSendActionOnAComponentWithAFunctionCallsTheFunctionWithArguments() { var _this5 = this; this.assert.expect(2); var argument = {}; this.renderDelegate(); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this5.delegate, 'action', function (actualArgument) { _this5.assert.deepEqual(argument, actualArgument, 'argument is passed'); }); _this5.delegate.sendAction('action', argument); }); }); } // TODO consolidate these next 2 tests ; _proto['@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 }); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { return _this6.delegate.sendAction(); }); }); this.assertSendCount(0); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this6.context, 'playing', 'didStartPlaying'); }); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { _this6.delegate.sendAction('playing'); }); }); this.assertSendCount(1); this.assertNamedSendCount('didStartPlaying', 1); }; _proto['@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 }); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { return _this7.delegate.sendAction('playing'); }); }); this.assertSendCount(0); (0, _internalTestHelpers.runTask)(function () { return _this7.delegate.attrs.playing.update('didStartPlaying'); }); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { return _this7.delegate.sendAction('playing'); }); }); this.assertSendCount(1); this.assertNamedSendCount('didStartPlaying', 1); }; _proto["@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; expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this8.delegate, 'playing', 'didStartPlaying'); component.sendAction('playing'); }); }); this.assertSendCount(1); this.assertNamedSendCount('didStartPlaying', 1); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { return component.sendAction('playing'); }); }); this.assertSendCount(2); this.assertNamedSendCount('didStartPlaying', 2); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(component, 'action', 'didDoSomeBusiness'); component.sendAction(); }); }); this.assertSendCount(3); this.assertNamedSendCount('didDoSomeBusiness', 1); }; _proto['@test Calling sendAction when the action name is not a string raises an exception'] = function testCallingSendActionWhenTheActionNameIsNotAStringRaisesAnException() { var _this9 = this; this.renderDelegate(); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this9.delegate, 'action', {}); (0, _metal.set)(_this9.delegate, 'playing', {}); }); expectSendActionDeprecation(function () { expectAssertion(function () { return _this9.delegate.sendAction(); }); }); expectSendActionDeprecation(function () { expectAssertion(function () { return _this9.delegate.sendAction('playing'); }); }); }; _proto['@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' }; expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { (0, _metal.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'); expectSendActionDeprecation(function () { (0, _internalTestHelpers.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'); }; _proto['@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, _internalTestHelpers.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; this.registerComponent('component-b', { ComponentClass: _helpers.Component.extend({ init: function () { this._super.apply(this, arguments); innerChild = this; this.name = 'component-b'; } }) }); this.renderDelegate(); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { return innerChild.sendAction('bar', 'something special'); }); }); }; _proto['@test asserts if called on a destroyed component'] = function testAssertsIfCalledOnADestroyedComponent() { var _this11 = this; var component; this.registerComponent('rip-alley', { ComponentClass: _helpers.Component.extend({ init: function () { this._super(); component = this; }, toString: function () { return 'component:rip-alley'; } }) }); this.render('{{#if shouldRender}}{{rip-alley}}{{/if}}', { shouldRender: true }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this11.context, 'shouldRender', false); }); expectAssertion(function () { component.sendAction('trigger-me-dead'); }, "Attempted to call .sendAction() with the action 'trigger-me-dead' on the destroyed object 'component:rip-alley'."); }; return _class; }(_internalTestHelpers.RenderingTestCase)); (0, _internalTestHelpers.moduleFor)('Components test: sendAction to a controller', /*#__PURE__*/ function (_ApplicationTestCase) { (0, _emberBabel.inheritsLoose)(_class2, _ApplicationTestCase); function _class2() { return _ApplicationTestCase.apply(this, arguments) || this; } var _proto2 = _class2.prototype; _proto2["@test sendAction should trigger an action on the parent component's controller if it exists"] = function testSendActionShouldTriggerAnActionOnTheParentComponentSControllerIfItExists(assert) { var _this12 = this; assert.expect(20); var component; 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', _controller.default.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', _routing.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', _routing.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', _routing.Route.extend({})); this.add('controller:c.d', _controller.default.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', _routing.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 () { expectSendActionDeprecation(function () { return component.sendAction('poke', 'top'); }); }).then(function () { _this12.assertText('a'); return _this12.visit('/b'); }).then(function () { expectSendActionDeprecation(function () { return component.sendAction('poke', 'top no controller'); }); }).then(function () { _this12.assertText('b'); return _this12.visit('/c'); }).then(function () { expectSendActionDeprecation(function () { component.sendAction('poke', 'top with nested no controller'); }); }).then(function () { _this12.assertText('c'); return _this12.visit('/c/d'); }).then(function () { expectSendActionDeprecation(function () { return component.sendAction('poke', 'nested'); }); }).then(function () { _this12.assertText('c.d'); return _this12.visit('/c/e'); }).then(function () { expectSendActionDeprecation(function () { return component.sendAction('poke', 'nested no controller'); }); }).then(function () { return _this12.assertText('c.e'); }); }; _proto2["@test sendAction should not trigger an action in an outlet's controller if a parent component handles it"] = function testSendActionShouldNotTriggerAnActionInAnOutletSControllerIfAParentComponentHandlesIt(assert) { assert.expect(2); var component; 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', _controller.default.extend({ send: function () { throw new Error('controller action should not be called'); } })); return this.visit('/').then(function () { expectSendActionDeprecation(function () { return component.sendAction('poke'); }); }); }; return _class2; }(_internalTestHelpers.ApplicationTestCase)); (0, _internalTestHelpers.moduleFor)('Components test: sendAction of a closure action', /*#__PURE__*/ function (_RenderingTestCase2) { (0, _emberBabel.inheritsLoose)(_class3, _RenderingTestCase2); function _class3() { return _RenderingTestCase2.apply(this, arguments) || this; } var _proto3 = _class3.prototype; _proto3['@test action should be called'] = function testActionShouldBeCalled(assert) { assert.expect(2); var component; 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}}'); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { return component.sendAction('submitAction'); }); }); }; _proto3['@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; var actualArgs; 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 = Array.prototype.slice.call(arguments); } } }), template: "{{inner-component innerSubmit=(action (action \"outerSubmit\" \"" + first + "\") \"" + second + "\" third)}}" }); this.render('{{outer-component}}'); expectSendActionDeprecation(function () { (0, _internalTestHelpers.runTask)(function () { return innerComponent.sendAction('innerSubmit', fourth); }); }); this.assert.deepEqual(actualArgs, [first, second, third, fourth], 'action has the correct args'); }; return _class3; }(_internalTestHelpers.RenderingTestCase)); (0, _internalTestHelpers.moduleFor)('Components test: send', /*#__PURE__*/ function (_RenderingTestCase3) { (0, _emberBabel.inheritsLoose)(_class4, _RenderingTestCase3); function _class4() { return _RenderingTestCase3.apply(this, arguments) || this; } var _proto4 = _class4.prototype; _proto4['@test sending to undefined actions triggers an error'] = function testSendingToUndefinedActionsTriggersAnError(assert) { assert.expect(2); var component; 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}}'); (0, _internalTestHelpers.runTask)(function () { return component.send('foo', 'bar'); }); expectAssertion(function () { return component.send('baz', 'bar'); }, /had no action handler for: baz/); }; _proto4['@test `send` will call send from a target if it is defined'] = function testSendWillCallSendFromATargetIfItIsDefined() { var _this13 = this; var component; var target = { send: function (message, payload) { _this13.assert.equal('foo', message); _this13.assert.equal('baz', payload); } }; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ init: function () { this._super(); component = this; }, target: target }) }); this.render('{{foo-bar}}'); (0, _internalTestHelpers.runTask)(function () { return component.send('foo', 'baz'); }); }; _proto4['@test a handled action can be bubbled to the target for continued processing'] = function testAHandledActionCanBeBubbledToTheTargetForContinuedProcessing() { var _this14 = this; this.assert.expect(2); var component; this.registerComponent('foo-bar', { ComponentClass: _helpers.Component.extend({ init: function () { this._super.apply(this, arguments); component = this; }, actions: { poke: function () { _this14.assert.ok(true, 'component action called'); return true; } }, target: _controller.default.extend({ actions: { poke: function () { _this14.assert.ok(true, 'action bubbled to controller'); } } }).create() }) }); this.render('{{foo-bar poke="poke"}}'); (0, _internalTestHelpers.runTask)(function () { return component.send('poke'); }); }; _proto4["@test action can be handled by a superclass' actions object"] = function testActionCanBeHandledByASuperclassActionsObject(assert) { this.assert.expect(4); var component; var SuperComponent = _helpers.Component.extend({ actions: { foo: function () { assert.ok(true, 'foo'); }, bar: function (msg) { assert.equal(msg, 'HELLO'); } } }); var BarViewMixin = _metal.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}}'); (0, _internalTestHelpers.runTask)(function () { component.send('foo'); component.send('bar', 'HELLO'); component.send('baz'); }); }; _proto4['@test actions cannot be provided at create time'] = function testActionsCannotBeProvidedAtCreateTime(assert) { this.registerComponent('foo-bar', _helpers.Component.extend()); var ComponentFactory = this.owner.factoryFor('component:foo-bar'); expectAssertion(function () { ComponentFactory.create({ actions: { foo: function () { assert.ok(true, 'foo'); } } }); }, /`actions` must be provided at extend time, not at create time/); // but should be OK on an object that doesn't mix in Ember.ActionHandler _runtime.Object.create({ actions: ['foo'] }); }; _proto4['@test asserts if called on a destroyed component'] = function testAssertsIfCalledOnADestroyedComponent() { var _this15 = this; var component; this.registerComponent('rip-alley', { ComponentClass: _helpers.Component.extend({ init: function () { this._super(); component = this; }, toString: function () { return 'component:rip-alley'; } }) }); this.render('{{#if shouldRender}}{{rip-alley}}{{/if}}', { shouldRender: true }); (0, _internalTestHelpers.runTask)(function () { (0, _metal.set)(_this15.context, 'shouldRender', false); }); expectAssertion(function () { component.send('trigger-me-dead'); }, "Attempted to call .send() with the action 'trigger-me-dead' on the destroyed object 'component:rip-alley'."); }; return _class4; }(_internalTestHelpers.RenderingTestCase)); }); enifed("@ember/-internals/glimmer/tests/integration/components/template-only-components-test", ["ember-babel", "internal-test-helpers", "@ember/-internals/environment"], function (_emberBabel, _internalTestHelpers, _environment) { "use strict"; var TemplateOnlyComponentsTest = /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(TemplateOnlyComponentsTest, _RenderingTestCase); function TemplateOnlyComponentsTest() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = TemplateOnlyComponentsTest.prototype; _proto.registerComponent = function registerComponent(name, template) { _RenderingTestCase.prototype.registerComponent.call(this, name, { template: template, ComponentClass: null }); }; return TemplateOnlyComponentsTest; }(_internalTestHelpers.RenderingTestCase); (0, _internalTestHelpers.moduleFor)('Components test: template-only components (glimmer components)', /*#__PURE__*/ function (_TemplateOnlyComponen) { (0, _emberBabel.inheritsLoose)(_class, _TemplateOnlyComponen); function _class() { var _this; _this = _TemplateOnlyComponen.apply(this, arguments) || this; _this._TEMPLATE_ONLY_GLIMMER_COMPONENTS = _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS; _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = true; return _this; } var _proto2 = _class.prototype; _proto2.teardown = function teardown() { _TemplateOnlyComponen.prototype.teardown.call(this); _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = this._TEMPLATE_ONLY_GLIMMER_COMPONENTS; }; _proto2['@test it can render a template-only component'] = function testItCanRenderATemplateOnlyComponent() { this.registerComponent('foo-bar', 'hello'); this.render('{{foo-bar}}'); this.assertInnerHTML('hello'); this.assertStableRerender(); }; _proto2['@test it can render named arguments'] = function testItCanRenderNamedArguments() { var _this2 = this; this.registerComponent('foo-bar', '|{{@foo}}|{{@bar}}|'); this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', bar: 'bar' }); this.assertInnerHTML('|foo|bar|'); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return _this2.context.set('foo', 'FOO'); }); this.assertInnerHTML('|FOO|bar|'); (0, _internalTestHelpers.runTask)(function () { return _this2.context.set('bar', 'BAR'); }); this.assertInnerHTML('|FOO|BAR|'); (0, _internalTestHelpers.runTask)(function () { return _this2.context.setProperties({ foo: 'foo', bar: 'bar' }); }); this.assertInnerHTML('|foo|bar|'); }; _proto2['@test it does not reflected arguments as properties'] = function testItDoesNotReflectedArgumentsAsProperties() { var _this3 = this; this.registerComponent('foo-bar', '|{{foo}}|{{this.bar}}|'); this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', bar: 'bar' }); this.assertInnerHTML('|||'); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return _this3.context.set('foo', 'FOO'); }); this.assertInnerHTML('|||'); (0, _internalTestHelpers.runTask)(function () { return _this3.context.set('bar', null); }); this.assertInnerHTML('|||'); (0, _internalTestHelpers.runTask)(function () { return _this3.context.setProperties({ foo: 'foo', bar: 'bar' }); }); this.assertInnerHTML('|||'); }; _proto2['@test it does not have curly component features'] = function testItDoesNotHaveCurlyComponentFeatures() { var _this4 = this; this.registerComponent('foo-bar', 'hello'); this.render('{{foo-bar tagName="p" class=class}}', { class: 'foo bar' }); this.assertInnerHTML('hello'); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return _this4.context.set('class', 'foo'); }); this.assertInnerHTML('hello'); (0, _internalTestHelpers.runTask)(function () { return _this4.context.set('class', null); }); this.assertInnerHTML('hello'); (0, _internalTestHelpers.runTask)(function () { return _this4.context.set('class', 'foo bar'); }); this.assertInnerHTML('hello'); }; _proto2['@test it has the correct bounds'] = function testItHasTheCorrectBounds() { var _this5 = this; this.registerComponent('foo-bar', 'hello'); this.render('outside {{#if this.isShowing}}before {{foo-bar}} after{{/if}} outside', { isShowing: true }); this.assertInnerHTML('outside before hello after outside'); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return _this5.context.set('isShowing', false); }); this.assertInnerHTML('outside outside'); (0, _internalTestHelpers.runTask)(function () { return _this5.context.set('isShowing', null); }); this.assertInnerHTML('outside outside'); (0, _internalTestHelpers.runTask)(function () { return _this5.context.set('isShowing', true); }); this.assertInnerHTML('outside before hello after outside'); }; return _class; }(TemplateOnlyComponentsTest)); (0, _internalTestHelpers.moduleFor)('Components test: template-only components (curly components)', /*#__PURE__*/ function (_TemplateOnlyComponen2) { (0, _emberBabel.inheritsLoose)(_class2, _TemplateOnlyComponen2); function _class2() { var _this6; _this6 = _TemplateOnlyComponen2.apply(this, arguments) || this; _this6._TEMPLATE_ONLY_GLIMMER_COMPONENTS = _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS; _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = false; return _this6; } var _proto3 = _class2.prototype; _proto3.teardown = function teardown() { _TemplateOnlyComponen2.prototype.teardown.call(this); _environment.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS = this._TEMPLATE_ONLY_GLIMMER_COMPONENTS; }; _proto3['@test it can render a template-only component'] = function testItCanRenderATemplateOnlyComponent() { this.registerComponent('foo-bar', 'hello'); this.render('{{foo-bar}}'); this.assertComponentElement(this.firstChild, { content: 'hello' }); this.assertStableRerender(); }; _proto3['@test it can render named arguments'] = function testItCanRenderNamedArguments() { var _this7 = this; this.registerComponent('foo-bar', '|{{@foo}}|{{@bar}}|'); this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', bar: 'bar' }); this.assertComponentElement(this.firstChild, { content: '|foo|bar|' }); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return _this7.context.set('foo', 'FOO'); }); this.assertComponentElement(this.firstChild, { content: '|FOO|bar|' }); (0, _internalTestHelpers.runTask)(function () { return _this7.context.set('bar', 'BAR'); }); this.assertComponentElement(this.firstChild, { content: '|FOO|BAR|' }); (0, _internalTestHelpers.runTask)(function () { return _this7.context.setProperties({ foo: 'foo', bar: 'bar' }); }); this.assertComponentElement(this.firstChild, { content: '|foo|bar|' }); }; _proto3['@test it renders named arguments as reflected properties'] = function testItRendersNamedArgumentsAsReflectedProperties() { var _this8 = this; this.registerComponent('foo-bar', '|{{foo}}|{{this.bar}}|'); this.render('{{foo-bar foo=foo bar=bar}}', { foo: 'foo', bar: 'bar' }); this.assertComponentElement(this.firstChild, { content: '|foo|bar|' }); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return _this8.context.set('foo', 'FOO'); }); this.assertComponentElement(this.firstChild, { content: '|FOO|bar|' }); (0, _internalTestHelpers.runTask)(function () { return _this8.context.set('bar', null); }); this.assertComponentElement(this.firstChild, { content: '|FOO||' }); (0, _internalTestHelpers.runTask)(function () { return _this8.context.setProperties({ foo: 'foo', bar: 'bar' }); }); this.assertComponentElement(this.firstChild, { content: '|foo|bar|' }); }; _proto3['@test it has curly component features'] = function testItHasCurlyComponentFeatures() { var _this9 = this; this.registerComponent('foo-bar', 'hello'); this.render('{{foo-bar tagName="p" class=class}}', { class: 'foo bar' }); this.assertComponentElement(this.firstChild, { tagName: 'p', attrs: { class: (0, _internalTestHelpers.classes)('foo bar ember-view') }, content: 'hello' }); this.assertStableRerender(); (0, _internalTestHelpers.runTask)(function () { return _this9.context.set('class', 'foo'); }); this.assertComponentElement(this.firstChild, { tagName: 'p', attrs: { class: (0, _internalTestHelpers.classes)('foo ember-view') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this9.context.set('class', null); }); this.assertComponentElement(this.firstChild, { tagName: 'p', attrs: { class: (0, _internalTestHelpers.classes)('ember-view') }, content: 'hello' }); (0, _internalTestHelpers.runTask)(function () { return _this9.context.set('class', 'foo bar'); }); this.assertComponentElement(this.firstChild, { tagName: 'p', attrs: { class: (0, _internalTestHelpers.classes)('foo bar ember-view') }, content: 'hello' }); }; return _class2; }(TemplateOnlyComponentsTest)); }); enifed("@ember/-internals/glimmer/tests/integration/components/textarea-angle-test", ["ember-babel", "internal-test-helpers", "@ember/polyfills", "@ember/-internals/metal"], function (_emberBabel, _internalTestHelpers, _polyfills, _metal) { "use strict"; if (true /* EMBER_GLIMMER_ANGLE_BRACKET_BUILT_INS */ ) { var TextAreaRenderingTest = /*#__PURE__*/ function (_RenderingTestCase) { (0, _emberBabel.inheritsLoose)(TextAreaRenderingTest, _RenderingTestCase); function TextAreaRenderingTest() { return _RenderingTestCase.apply(this, arguments) || this; } var _proto = TextAreaRenderingTest.prototype; _proto.assertTextArea = function assertTextArea() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, attrs = _ref.attrs, value = _ref.value; var mergedAttrs = (0, _polyfills.assign)({ class: (0, _internalTestHelpers.classes)('ember-view ember-text-area') }, attrs); this.assertComponentElement(this.firstChild, { tagName: 'textarea', attrs: mergedAttrs }); if (value) { this.assert.strictEqual(value, this.firstChild.value); } }; _proto.triggerEvent = function triggerEvent(type) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var event = document.createEvent('Events'); event.initEvent(type, true, true); (0, _polyfills.assign)(event, options); this.firstChild.dispatchEvent(event); }; return TextAreaRenderingTest; }(_internalTestHelpers.RenderingTestCase); var BoundTextAreaAttributes = /*#__PURE__*/ function () { function BoundTextAreaAttributes(cases) { this.cases = cases; } var _proto2 = BoundTextAreaAttributes.prototype; _proto2.generate = function generate(_ref2) { var _ref3; var attribute = _ref2.attribute, first = _ref2.first, second = _ref2.second; return _ref3 = {}, _ref3["@test " + attribute + " (HTML attribute)"] = function () { var _attrs, _this = this, _attrs2, _attrs3; this.render("