javascript - Why are my Jasmine specs saying 'No specs found' - Stack Overflow

My Javascript function isfunction Investment (params) {var params = params || {};this.stock = params.st

My Javascript function is

function Investment (params) {
  var params = params || {};
  this.stock = params.stock;
  this.shares = params.shares
  this.cost = params.cost
};

My spec is

describe("Investment", function() {

  beforeEach(function() {
    this.stock = new Stock();
    this.investment = new Investment({
      stock: this.stock,
      shares: 100
      cost: 2000
    });
  });

  it("should be a stock", function() {
    expect(this.investment.stock).toBe(this.stock);
  });

  it("should have the invested shares quantity", function() {
    expect(this.investment.shares).toEqual(100);
  });

  it("should have a cost", function() {
    expect(this.investment.cost).toEqual(2000);
  });
});

My Javascript function is

function Investment (params) {
  var params = params || {};
  this.stock = params.stock;
  this.shares = params.shares
  this.cost = params.cost
};

My spec is

describe("Investment", function() {

  beforeEach(function() {
    this.stock = new Stock();
    this.investment = new Investment({
      stock: this.stock,
      shares: 100
      cost: 2000
    });
  });

  it("should be a stock", function() {
    expect(this.investment.stock).toBe(this.stock);
  });

  it("should have the invested shares quantity", function() {
    expect(this.investment.shares).toEqual(100);
  });

  it("should have a cost", function() {
    expect(this.investment.cost).toEqual(2000);
  });
});
Share Improve this question asked Aug 30, 2016 at 11:32 Michael DurrantMichael Durrant 96.7k101 gold badges347 silver badges531 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

The spec is missing a ma after one of the parameters and so should be:

beforeEach(function() {
  this.stock = new Stock();
  this.investment = new Investment({
    stock: this.stock,
    shares: 100,  <-- needs a ma here
    cost: 2000
  });
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744262092a4565685.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信