All files / test RectangleTest.js

97.06% Statements 33/34
50% Branches 1/2
100% Functions 11/11
97.06% Lines 33/34

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 47 48 49 50 51 52 53    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 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 Rectangle from '../scripts/Rectangle.js';
import Point from '../scripts/Point.js';
 
describe('Clase Rectangle tests', ()=>{
 
  describe('Comportamiento del constructor', ()=>{
    it('Debería generar un objeto Rectangle', () => {
      let RectangleTest = new Rectangle();
      expect(RectangleTest).to.be.a('Object');
    });
    it('Debería tener los siguientes atriburos miembro:', () => {
      let RectangleTest = new Rectangle();
      expect(RectangleTest).to.have.property('start');
      expect(RectangleTest).to.have.property('width');
      expect(RectangleTest).to.have.property('height');
    });
  });
 
  describe('Métodos de la clase', () => {
    it ('Tiene que tener un método para poder dibujar un rectángulo', () => {
      let RectangleTest = new Rectangle();
      expect(RectangleTest.baseDraw).to.exist;
    });
    it ('draw tiene que poder ser ejecutado sin errores', () => {
      let RectangleTest = new Rectangle();
      expect(RectangleTest.draw()).not.to.throw;
    });
    it ('Tiene que tener un método para calcular el área', () => {
      let RectangleTest = new Rectangle();
      expect(RectangleTest.area).to.exist;
    });
    it ('El método que calcula el área tiene que funcionar', () => {
      let RectangleTest = new Rectangle(new Point(), 10, 10);
      expect(RectangleTest.area()).to.eql(100);
    });
    it ('Tiene que tener un método para calcular el perímetro', () => {
      let RectangleTest = new Rectangle();
      expect(RectangleTest.area).to.exist;
    });
    it ('El método que calcula el perímetro tiene que funcionar', () => {
      let RectangleTest = new Rectangle(new Point(), 10, 10);
      expect(RectangleTest.perimeter()).to.eql(20);
    });
  });
});