<!DOCTYPE html>
<html>

<head>
  <link data-require="jasmine@2.4.1" data-semver="2.4.1" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.css" />
  <script data-require="jasmine@2.4.1" data-semver="2.4.1" src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.js"></script>
  <script data-require="jasmine@2.4.1" data-semver="2.4.1" src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine-html.js"></script>
  <script data-require="jasmine@2.4.1" data-semver="2.4.1" src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/boot.js"></script>
  <script src="car.js"></script>
  <script src="car.spec.js"></script>
</head>

<body>
  <h1>Hello Jasmine!</h1>
</body>

</html>
Car = (function () {
  function Car (engine) {
    this.engine = engine;
  }

  Car.prototype.drive = function (speed) {
    this._lastSpeed = speed;
    return 'Car with ' + this.engine + ' engine ' + 
      'drives at ' + speed + ' km/h.';
  }

  Object.defineProperty(Car.prototype, 'lastSpeed', {
    get: function () { 
      return this._lastSpeed ? this._lastSpeed : 0; 
    },
    enumerable: false,
    configurable: true
  });

  return Car;
})();
'use strict';

describe('Car class', function () {
  it('should return car engine name', function() {
    var car = new Car('V8');
  
    expect(car.engine).toBe('V8');
  });
  
  it('should return information about vehicle engine and speed', function () {
    var car = new Car('V8');
    
    var message = car.drive(120);
  
    expect(message).toBe('Car with V8 engine drives at 120 km/h.');
  });
  
  describe('lastSpeed property', function () {
    it('should return 0 when car have never driven', function () {
      var car = new Car('V8');
    
      expect(car.lastSpeed).toBe(0);
    });
    
    it('should return car last speed', function () {
      var car = new Car('V8');
      
      car.drive(80);
    
      expect(car.lastSpeed).toBe(80);
    });
  });
});