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,

Get Jasmine JavaScript Testing - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.