-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a failing test for #12475. It appears that `obj.set('array', [a1, a2, a3])` fails to install contentKey observers on the new array value so that the subsequent changes to `foo` are ignored.
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { get } from 'ember-metal/property_get'; | |
import { set } from 'ember-metal/property_set'; | ||
import { addObserver } from 'ember-metal/observer'; | ||
import { observer } from 'ember-metal/mixin'; | ||
import { computed } from 'ember-metal/computed'; | ||
import { | ||
sum, | ||
min, | ||
|
@@ -427,6 +428,28 @@ QUnit.test('properties values can be replaced', function() { | |
deepEqual(obj.get('a1bs').mapBy('name'), ['item1'], 'properties can be filtered by matching value'); | ||
}); | ||
|
||
QUnit.test('responds to change of property value on element after replacing array', function() { | ||
let a1 = { foo: true, id: 1 }; | ||
let a2 = { foo: true, id: 2 }; | ||
let a3 = { foo: true, id: 4 }; | ||
|
||
obj = EmberObject.extend({ | ||
a: computed('[email protected]', function() { | ||
return this.get('array').filter(elt => elt.foo).reduce(((a,b) => a + b.id), 0); | ||
}) | ||
}).create({ | ||
array: emberA([a1, a2]) | ||
}); | ||
|
||
deepEqual(obj.get('a'), 3, 'value is correct initially'); | ||
set(a1, 'foo', false); | ||
deepEqual(obj.get('a'), 2, 'responds to change of property on element'); | ||
obj.set('array', [a1, a2, a3]); | ||
deepEqual(obj.get('a'), 6, 'responds to content array change'); | ||
set(a1, 'foo', true); | ||
deepEqual(obj.get('a'), 7, 'still responds to change of property on element'); | ||
}); | ||
|
||
[ | ||
['uniq', uniq], | ||
['union', union] | ||
|