Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,58 @@
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();
}).toThrowError("song is already playing");
});
});
});
@@ -0,0 +1,15 @@
beforeEach(function () {
jasmine.addMatchers({
toBePlaying: function () {
return {
compare: function (actual, expected) {
var player = actual;

return {
pass: player.currentlyPlayingSong === expected && player.isPlaying
};
}
};
}
});
});
@@ -0,0 +1,22 @@
function Player() {
}
Player.prototype.play = function(song) {
this.currentlyPlayingSong = song;
this.isPlaying = true;
};

Player.prototype.pause = function() {
this.isPlaying = false;
};

Player.prototype.resume = function() {
if (this.isPlaying) {
throw new Error("song is already playing");
}

this.isPlaying = true;
};

Player.prototype.makeFavorite = function() {
this.currentlyPlayingSong.persistFavoriteStatus(true);
};
@@ -0,0 +1,7 @@
function Song() {
}

Song.prototype.persistFavoriteStatus = function(value) {
// something complicated
throw new Error("not yet implemented");
};
@@ -8,6 +8,9 @@ module.exports = function(router, User, passport, Breather, Course, Task, Commen
});


router.get('/test', function(req, res, next) {
res.render('test', {title: 'Test'});
});

router.post('/register', function(req, res, next){

@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.3.4</title>

<link rel="shortcut icon" type="image/png" href="../jasmine/lib/jasmine-2.3.4/jasmine_favicon.png">
<link rel="stylesheet" href="jasmine/lib/jasmine-2.3.4/jasmine.css">

<script src="/jasmine/lib/jasmine-2.3.4/jasmine.js"></script>
<script src="/jasmine/lib/jasmine-2.3.4/jasmine-html.js"></script>
<script src="/jasmine/lib/jasmine-2.3.4/boot.js"></script>

<!-- include source files here... -->
<script src="/jasmine/src/Player.js"></script>
<script src="/jasmine/src/Song.js"></script>

<!-- include spec files here... -->
<script src="/jasmine/spec/SpecHelper.js"></script>
<script src="/jasmine/spec/PlayerSpec.js"></script>

</head>

<body>
</body>
</html>