Sha256: 6f1155101fe5cd88862261ddac73eaaa58e0f58fe25915102c876e3b93279299

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

import { AbstractTestCase } from 'internal-test-helpers';
import { runArrayTests, newFixture } from '../helpers/array';
import { get } from '@ember/-internals/metal';

class ReverseObjectsTests extends AbstractTestCase {
  '@test [A,B,C].reverseObjects() => [] + notify'() {
    let before = newFixture(3);
    let after = [before[2], before[1], before[0]];
    let obj = this.newObject(before);
    let observer = this.newObserver(obj, '[]', '@each', 'length', 'firstObject', 'lastObject');

    obj.getProperties('firstObject', 'lastObject'); /* Prime the cache */

    this.assert.equal(obj.reverseObjects(), obj, 'return self');

    this.assert.deepEqual(this.toArray(obj), after, 'post item results');
    this.assert.equal(get(obj, 'length'), after.length, 'length');

    this.assert.equal(observer.timesCalled('[]'), 1, 'should have notified [] once');
    this.assert.equal(observer.timesCalled('@each'), 0, 'should not have notified @each once');
    this.assert.equal(observer.timesCalled('length'), 0, 'should have notified length once');
    this.assert.equal(
      observer.timesCalled('firstObject'),
      1,
      'should have notified firstObject once'
    );
    this.assert.equal(
      observer.timesCalled('lastObject'),
      1,
      'should have notified lastObject once'
    );
  }
}

runArrayTests('reverseObjects', ReverseObjectsTests, 'MutableArray', 'NativeArray', 'ArrayProxy');

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/-internals/runtime/tests/mutable-array/reverseObjects-test.js