O'Reilly logo

Jasmine JavaScript Testing by Paulo Ragonha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required