Sha256: 12c80b4d4329e135617cf4ec633d1f6d6f7d2277eb99ac714da97024962c5156

Contents?: true

Size: 1.49 KB

Versions: 174

Compression:

Stored size: 1.49 KB

Contents

describe("Player", function() {
  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();
      }).toThrow("song is already playing");
    });
  });
});

Version data entries

174 entries across 137 versions & 20 rubygems

Version Path
rhoconnect-client-7.6.0 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
evergreen-1.3.0 lib/jasmine/lib/jasmine-core/example/spec/PlayerSpec.js
rhoconnect-client-7.5.1 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-7.4.1 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-7.1.17 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-6.2.0 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-6.0.11 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-5.5.18 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-5.5.17 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-5.5.15 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-5.5.0.22 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-5.5.2 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-5.5.0.7 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-5.5.0.3 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
rhoconnect-client-5.5.0 ./rhoconnect-client/JavaScript/war/test/spec/samples/PlayerSpec.js
testingbot-0.1.7 lib/testingbot/jasmine/spec/javascripts/PlayerSpec.js
testingbot-0.1.7 lib/testingbot/jasmine/test/spec/javascripts/PlayerSpec.js
testingbot-0.1.6 lib/testingbot/jasmine/spec/javascripts/PlayerSpec.js
testingbot-0.1.6 lib/testingbot/jasmine/test/spec/javascripts/PlayerSpec.js
rearview-1.2.3-jruby public/rearview-src/vendor/jasmine/spec/PlayerSpec.js