all files / three-point/ test.js

100% Statements 16/16
100% Branches 0/0
100% Functions 5/5
100% Lines 16/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                                              
import 'should';
import ThreePoint from './source';
 
describe('three-point', () => {
  it('should calculate optimistic, pessimistic, expected estimates', () => {
    const estimate = new ThreePoint([{
      optimistic: 4,
      pessimistic: 16,
      likely: 8,
    }]);
 
    estimate.expected.should.equal(8.7);
    estimate.optimistic.should.equal(5.4);
    estimate.pessimistic.should.equal(12);
  });
 
  it('should allow confidence to be customised', () => {
    const estimate = new ThreePoint([{
      optimistic: 4,
      pessimistic: 16,
      likely: 8,
    }], 0.997);
 
    estimate.expected.should.equal(8.7);
    estimate.optimistic.should.equal(2.7);
    estimate.pessimistic.should.equal(14.6);
  });
 
  it('should accept only numeric values for items', () => {
    (() => {
      new ThreePoint([{ // eslint-disable-line no-new
        optimistic: 'fail',
        pessimistic: 16,
        likely: 8,
      }]);
    }).should.throw();
  });
});