Sha256: b7b84ed4eaa04d52547ed22ecd0f8617da3c85d2c16ee4a45fccab9e2a94bd22

Contents?: true

Size: 1.61 KB

Versions: 94

Compression:

Stored size: 1.61 KB

Contents

describe("Player", function() {
  var Player = require('../../lib/jasmine_examples/Player');
  var Song = require('../../lib/jasmine_examples/Song');
  var player;
  var song;

  beforeEach(function() {
    player = new Player();
    song = new Song();
  });

  it("should be able to play a Song", function() {
    player.play(song);
    expect(player.currentlyPlayingSong).toEqual(song);

    //demonstrates use of custom matcher
    expect(player).toBePlaying(song);
  });

  describe("when song has been paused", function() {
    beforeEach(function() {
      player.play(song);
      player.pause();
    });

    it("should indicate that the song is currently paused", function() {
      expect(player.isPlaying).toBeFalsy();

      // demonstrates use of 'not' with a custom matcher
      expect(player).not.toBePlaying(song);
    });

    it("should be possible to resume", function() {
      player.resume();
      expect(player.isPlaying).toBeTruthy();
      expect(player.currentlyPlayingSong).toEqual(song);
    });
  });

  // demonstrates use of spies to intercept and test method calls
  it("tells the current song if the user has made it a favorite", function() {
    spyOn(song, 'persistFavoriteStatus');

    player.play(song);
    player.makeFavorite();

    expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
  });

  //demonstrates use of expected exceptions
  describe("#resume", function() {
    it("should throw an exception if song is already playing", function() {
      player.play(song);

      expect(function() {
        player.resume();
      }).toThrowError("song is already playing");
    });
  });
});

Version data entries

94 entries across 78 versions & 4 rubygems

Version Path
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
jasmine-core-3.99.0 ./lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
jasmine-core-3.10.1 ./lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
jasmine-core-3.10.0 ./lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
jasmine-core-3.9.0 ./lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
jasmine-core-3.8.0 ./lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/jasmine-core-2.99.2/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
jasmine-core-3.7.1 ./lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js
jasmine-core-3.7.0 ./lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js