Skip to content

Commit

Permalink
adds a failing test for 12475
Browse files Browse the repository at this point in the history
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
ef4 committed Jan 18, 2016
1 parent 551a231 commit ba3d5ff
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit ba3d5ff

Please sign in to comment.