run(function() { obj = EmberObject.extend({ min: computedMin('items') }).create({ items: Ember.A([1,2,3]) }); });
run(function() { obj = EmberObject.createWithMixins({ items: Ember.A([1,2,3]), min: computedMin('items') }); });
QUnit.test('max recomputes when the current max is removed', function() { equal(obj.get('max'), 3, 'precond - max is initially correct'); obj.get('items').removeObject(2); equal(obj.get('max'), 3, 'max is unchanged when a non-max item is removed'); obj.get('items').removeObject(3); equal(obj.get('max'), 1, 'max is recomputed when the current max is removed'); }); QUnit.module('min', { setup() { obj = EmberObject.extend({ min: min('items') }).create({ items: emberA([1, 2, 3]) }); }, teardown() { run(obj, 'destroy'); } }); QUnit.test('min is readOnly', function() { QUnit.throws(function() { obj.set('min', 1); }, /Cannot set read-only property "min" on object:/); });