Sha256: 4053f9aeb8a0bcd5509de0275b61d9e654bb9284d46c4154baa162f25e0b257d

Contents?: true

Size: 829 Bytes

Versions: 3

Compression:

Stored size: 829 Bytes

Contents

import { AbstractTestCase } from 'internal-test-helpers';
import { runArrayTests } from '../helpers/array';

class ReduceTests extends AbstractTestCase {
  '@test collects a summary value from an enumeration'() {
    let obj = this.newObject([1, 2, 3]);
    let res = obj.reduce((previousValue, item) => previousValue + item, 0);
    this.assert.equal(res, 6);
  }

  '@test passes index of item to callback'() {
    let obj = this.newObject([1, 2, 3]);
    let res = obj.reduce((previousValue, item, index) => previousValue + index, 0);
    this.assert.equal(res, 3);
  }

  '@test passes enumerable object to callback'() {
    let obj = this.newObject([1, 2, 3]);
    let res = obj.reduce((previousValue, item, index, enumerable) => enumerable, 0);
    this.assert.equal(res, obj);
  }
}

runArrayTests('reduce', ReduceTests);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/-internals/runtime/tests/array/reduce-test.js
discourse-ember-source-3.5.1.1 dist/es/ember-runtime/tests/array/reduce-test.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-runtime/tests/array/reduce-test.js