Sha256: 3e8166ab9ada71788868b6dc70eb943453bdc0367190d8b65fc3d5574f06271f

Contents?: true

Size: 1.31 KB

Versions: 255

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

255 entries across 255 versions & 1 rubygems

Version Path
trackler-2.2.1.37 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.36 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.35 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.34 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.33 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.32 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.31 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.30 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.29 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.28 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.27 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.26 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.25 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.24 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.23 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.22 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.21 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.20 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.19 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.18 tracks/javascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js