All files / test LineTest.js

96.55% Statements 28/29
50% Branches 1/2
100% Functions 9/9
96.55% Lines 28/29

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 40 41 42 43 44 45 46    1x 1x       1x 1x   1x   1x 1x 1x 1x   1x 1x 1x 1x       1x 1x 1x 1x   1x 1x 1x   1x 1x 1x   1x 1x 1x 1x 1x        
let expect;
 
Eif (typeof require !== 'undefined') { // Execution in node
  expect = require('chai').expect;
} else { // Execution in browser
  expect = chai.expect;
}
import Line from '../scripts/Line.js';
import Point from '../scripts/Point.js';
 
describe('Clase Line tests', ()=>{
 
  describe('Comportamiento del constructor', ()=>{
    it('Debería generar un objeto Line', () => {
      let LineTest = new Line();
      expect(LineTest).to.be.a('Object');
    });
    it('Debería tener los siguientes atriburos miembro:', () => {
      let LineTest = new Line();
      expect(LineTest).to.have.property('start');
      expect(LineTest).to.have.property('end');
    });
  });
 
  describe('Métodos de la clase', () => {
    it ('Tiene que tener un método para poder dibujar una linea', () => {
      let LineTest = new Line();
      expect(LineTest.baseDraw).to.exist;
    });
    it ('draw tiene que poder ser ejecutado sin errores', () => {
      let LineTest = new Line();
      expect(LineTest.draw()).not.to.throw;
    });
    it ('Tiene que tener un método para poder calcular la longitud de la recta', () => {
      let LineTest = new Line();
      expect(LineTest.length).to.exist;
    });
    it ('Tiene que devolver correctamente la longitud de la recta', () => {
      let pointA = new Point(0,0);
      let pointB = new Point(10,0);
      let LineTest = new Line(pointA, pointB);
      expect(LineTest.length()).to.eql(10);
    });
 
  });
});