1 describe("Player", function() {
5 beforeEach(function() {
10 it("should be able to play a Song", function() {
12 expect(player.currentlyPlayingSong).toEqual(song);
14 //demonstrates use of custom matcher
15 expect(player).toBePlaying(song);
18 describe("when song has been paused", function() {
19 beforeEach(function() {
24 it("should indicate that the song is currently paused", function() {
25 expect(player.isPlaying).toBeFalsy();
27 // demonstrates use of 'not' with a custom matcher
28 expect(player).not.toBePlaying(song);
31 it("should be possible to resume", function() {
33 expect(player.isPlaying).toBeTruthy();
34 expect(player.currentlyPlayingSong).toEqual(song);
38 // demonstrates use of spies to intercept and test method calls
39 it("tells the current song if the user has made it a favorite", function() {
40 spyOn(song, 'persistFavoriteStatus');
43 player.makeFavorite();
45 expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
48 //demonstrates use of expected exceptions
49 describe("#resume", function() {
50 it("should throw an exception if song is already playing", function() {
55 }).toThrow("song is already playing");