Sha256: 83bbbd9b4dfe64799ea05eaabcbea4e68365c0ae5cc1fdaa3e9f230f5ce02670

Contents?: true

Size: 1.31 KB

Versions: 141

Compression:

Stored size: 1.31 KB

Contents

var accumulate = require('./accumulate');

describe('accumulate()', function () {
  it('accumulation empty', function () {
    var accumulator = function (e) { return e * e; };
    expect(accumulate([], accumulator)).toEqual([]);
  });

  xit('accumulate squares', function () {
    var accumulator = function (number) {
      return number * number;
    };

    var result = accumulate([1, 2, 3], accumulator);

    expect(result).toEqual([1, 4, 9]);
  });

  xit('accumulate upcases', function () {
    var accumulator = function (word) {
      return word.toUpperCase();
    };

    var result = accumulate('hello world'.split(/\s/), accumulator);

    expect(result).toEqual(['HELLO', 'WORLD']);
  });

  xit('accumulate reversed strings', function () {
    var accumulator = function (word) {
      return word.split('').reverse().join('');
    };

    var result = accumulate('the quick brown fox etc'.split(/\s/), accumulator);

    expect(result).toEqual(['eht', 'kciuq', 'nworb', 'xof', 'cte']);
  });

  xit('accumulate recursively', function () {
    var result = accumulate('a b c'.split(/\s/), function (char) {
      return accumulate('1 2 3'.split(/\s/), function (digit) {
        return char + digit;
      });
    });

    expect(result).toEqual([['a1', 'a2', 'a3'], ['b1', 'b2', 'b3'], ['c1', 'c2', 'c3']]);
  });
});

Version data entries

141 entries across 141 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.118 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.117 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.116 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.115 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.114 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.113 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.111 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.110 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.109 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.108 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.107 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.106 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.105 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.104 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.103 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.102 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.101 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.100 tracks/javascript/exercises/accumulate/accumulate.spec.js
trackler-2.2.1.99 tracks/javascript/exercises/accumulate/accumulate.spec.js