Skip to content

Commit

Permalink
Failing tests for emberjs#12083
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Aug 13, 2015
1 parent 197289a commit dadcaaf
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions packages/ember-runtime/tests/system/array_proxy/length_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import ArrayProxy from 'ember-runtime/system/array_proxy';
import Object from 'ember-runtime/system/object';
import { observer } from 'ember-metal/mixin';
import { computed } from 'ember-metal/computed';
import { A as a } from 'ember-runtime/system/native_array';

QUnit.module('Ember.ArrayProxy - content change (length)');

QUnit.test('asdfasdf', function() {
var aCalled, bCalled, cCalled, dCalled, eCalled;

aCalled = bCalled = cCalled = dCalled = eCalled = 0;

var obj = Object.extend({
colors: computed.reads('model'),
length: computed.reads('colors.length'),

a: observer('length', function() {
aCalled++;
}),

b: observer('colors.length', function() {
bCalled++;
}),

c: observer('colors.content.length', function() {
cCalled++;
}),

d: observer('colors.[]', function() {
dCalled++;
}),

e: observer('colors.content.[]', function() {
eCalled++;
})
}).create();

obj.set('model', ArrayProxy.create({
content: a([
'red',
'yellow',
'blue'
])
})
);

equal(obj.get('colors.content.length'), 3);
equal(obj.get('colors.length'), 3);
equal(obj.get('length'), 3);

equal(aCalled, 1, 'expected observer `length` to be called ONCE');
equal(bCalled, 1, 'expected observer `colors.length` to be called ONCE');
equal(cCalled, 1, 'expected observer `colors.content.length` to be called ONCE');
equal(dCalled, 1, 'expected observer `colors.[]` to be called ONCE');
equal(eCalled, 1, 'expected observer `colors.content.[]` to be called ONCE');

obj.get('colors').pushObjects([
'green',
'red'
]);

equal(obj.get('colors.content.length'), 5);
equal(obj.get('colors.length'), 5);
equal(obj.get('length'), 5);

equal(aCalled, 2, 'expected observer `length` to be called TWICE');
equal(bCalled, 2, 'expected observer `colors.length` to be called TWICE');
equal(cCalled, 2, 'expected observer `colors.content.length` to be called TWICE');
equal(dCalled, 2, 'expected observer `colors.[]` to be called TWICE');
equal(eCalled, 2, 'expected observer `colors.content.[]` to be called TWICE');
});

0 comments on commit dadcaaf

Please sign in to comment.