Setup and teardown

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

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

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

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); ...

Get Jasmine JavaScript Testing now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.