Book Image

Jasmine JavaScript Testing Update

By : Paulo Vitor Zacharias Ragonha
Book Image

Jasmine JavaScript Testing Update

By: Paulo Vitor Zacharias Ragonha

Overview of this book

Table of Contents (15 chapters)

Setup and teardown


There are three more acceptance criteria to be implemented. The next in the list is as follows:

"Given an investment, it should have the invested shares' quantity."

Writing it should be as simple as the previous spec was. In the InvestmentSpec.js file inside the spec folder, you can translate this new criterion into a new spec called should have the invested shares' quantity, as follows:

describe("Investment", function() {
  it("should be of a stock", function() {
    var stock = new Stock();
    var investment = new Investment({
      stock: stock,
      shares: 100
    });
    expect(investment.stock).toBe(stock);
  });

  it("should have the invested shares' quantity", function() {
    var stock = new Stock();
    var investment = new Investment({
      stock: stock,
      shares: 100
    });
    expect(investment.shares).toEqual(100);
  });
});

You can see that apart from having written the new spec, we have also changed the call to the Investment constructor to support...