dimanche 12 juillet 2015

Jasmine unit testin current context or this var

I have been looking in to this article for Jasmine unit testing. I found this example:

describe("Episode", function() {
  beforeEach(function() {
    this.episode = new Backbone.Model({
      title: "Hollywood - Part 2"
    });
  });

  it("should expose an attribute", function() {
    expect(this.episode.get("title"))
      .toEqual("Hollywood - Part 2");
  });
});

This example is using this.episode in beforeEachand it. As far as I know JS doesn't work like this. this.episode doesn't work in describe block at all?

Aucun commentaire:

Enregistrer un commentaire