From 17a041068be6ef7e03b33f5e488e95e41e7deba2 Mon Sep 17 00:00:00 2001 From: Aleksandr Kanunnikov Date: Wed, 18 Nov 2020 21:36:03 +0300 Subject: [PATCH] broken test for 19279 (cherry picked from commit 4b5c19db6160da058967aad134f4b4c05775ec01) --- .../-internals/metal/tests/alias_test.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/@ember/-internals/metal/tests/alias_test.js b/packages/@ember/-internals/metal/tests/alias_test.js index 4410748bf89..2d2c7ed1bc4 100644 --- a/packages/@ember/-internals/metal/tests/alias_test.js +++ b/packages/@ember/-internals/metal/tests/alias_test.js @@ -8,7 +8,7 @@ import { removeObserver, tagForProperty, } from '..'; -import { Object as EmberObject } from '@ember/-internals/runtime'; +import { Object as EmberObject, A } from '@ember/-internals/runtime'; import { moduleFor, AbstractTestCase, runLoopSettled } from 'internal-test-helpers'; import { destroy } from '@glimmer/runtime'; import { valueForTag, validateTag } from '@glimmer/validator'; @@ -68,6 +68,27 @@ moduleFor( assert.equal(count, 1); } + ['@test nested aliases should trigger computed property invalidation [GH#19279]'](assert) { + const AttributeModel = EmberObject.extend({ + countAdditives: alias('additives.length'), + additives: A() + }); + + const RootModel = EmberObject.extend({ + allAdditives: computed('metaAttributes.@each.countAdditives', function(){ + return this.metaAttributes.reduce((acc, el)=>{ + return acc.concat(el.additives); + }, []); + }), + metaAttributes: A([AttributeModel.create()]) + }); + + let model = RootModel.create(); + assert.equal(model.allAdditives.length, 0); + model.metaAttributes[0].additives.pushObject('foo'); + assert.equal(model.allAdditives.length, 1); + } + async [`@test inheriting an observer of the alias from the prototype then redefining the alias on the instance to another property dependent on same key does not call the observer twice`](assert) {