Sha256: 9d1e32ffb4c486415ad414f592dad5e549b68b679a4b732e07ea969037ceb29b

Contents?: true

Size: 1.19 KB

Versions: 185

Compression:

Stored size: 1.19 KB

Contents

import Triplet from './pythagorean-triplet';

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

  xtest('calculates the product', () => {
    expect(new Triplet(3, 4, 5).product()).toBe(60);
  });

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

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

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

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

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

Version data entries

185 entries across 185 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.179 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.178 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.177 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.176 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.175 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.174 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.173 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.172 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.171 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.170 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.169 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.167 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.166 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.165 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.164 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.163 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.162 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.161 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js
trackler-2.2.1.160 tracks/ecmascript/exercises/pythagorean-triplet/pythagorean-triplet.spec.js