Sha256: f4f9a7122172505799a24060cee01b25ee869c86819d6d48187d784f7a3a9760

Contents?: true

Size: 1.31 KB

Versions: 141

Compression:

Stored size: 1.31 KB

Contents

var Triplet = require('./pythagorean-triplet');

describe('Triplet', function () {
  it('calculates the sum', function () {
    expect(new Triplet(3, 4, 5).sum()).toBe(12);
  });

  xit('calculates the product', function () {
    expect(new Triplet(3, 4, 5).product()).toBe(60);
  });

  xit('can recognize a pythagorean triplet', function () {
    expect(new Triplet(3, 4, 5).isPythagorean()).toBe(true);
  });

  xit('can recognize a non pythagorean triplet', function () {
    expect(new Triplet(5, 6, 7).isPythagorean()).toBe(false);
  });

  xit('can make triplets up to 10', function () {
    var triplets = Triplet.where({ maxFactor: 10 });
    var products = triplets.sort().map( function (triplet) {
      return triplet.product();
    });
    expect(products).toEqual([60, 480]);
  });

  xit('can make triplets 11 through 20', function () {
    var triplets = Triplet.where({ minFactor: 11, maxFactor: 20 });
    var products = triplets.sort().map( function (triplet) {
      return triplet.product();
    });
    expect(products).toEqual([3840]);
  });

  xit('can filter on sum', function () {
    var triplets = Triplet.where({ sum: 180, maxFactor: 100 });
    var products = triplets.sort().map( function (triplet) {
      return triplet.product();
    });
    expect(products).toEqual([118080, 168480, 202500]);
  });
});

Version data entries

141 entries across 141 versions & 1 rubygems

Version Path
trackler-2.2.1.78 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.77 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.76 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.75 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.74 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.73 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.72 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.71 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.70 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.69 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.68 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.67 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.66 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.65 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.64 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.63 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.62 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.61 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.60 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.59 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js