diff --git a/lib/jasmine-core/example/node_example/lib/jasmine_examples/Player.js b/lib/jasmine-core/example/node_example/lib/jasmine_examples/Player.js index fe95f8946..8a7bfbdc3 100644 --- a/lib/jasmine-core/example/node_example/lib/jasmine_examples/Player.js +++ b/lib/jasmine-core/example/node_example/lib/jasmine_examples/Player.js @@ -1,24 +1,24 @@ -function Player() { -} -Player.prototype.play = function(song) { - this.currentlyPlayingSong = song; - this.isPlaying = true; -}; - -Player.prototype.pause = function() { - this.isPlaying = false; -}; +class Player { + play(song) { + this.currentlyPlayingSong = song; + this.isPlaying = true; + } -Player.prototype.resume = function() { - if (this.isPlaying) { - throw new Error("song is already playing"); + pause() { + this.isPlaying = false; } - this.isPlaying = true; -}; + resume() { + if (this.isPlaying) { + throw new Error('song is already playing'); + } -Player.prototype.makeFavorite = function() { - this.currentlyPlayingSong.persistFavoriteStatus(true); -}; + this.isPlaying = true; + } + + makeFavorite() { + this.currentlyPlayingSong.persistFavoriteStatus(true); + } +} module.exports = Player; diff --git a/lib/jasmine-core/example/node_example/lib/jasmine_examples/Song.js b/lib/jasmine-core/example/node_example/lib/jasmine_examples/Song.js index 3415bb821..f2757786f 100644 --- a/lib/jasmine-core/example/node_example/lib/jasmine_examples/Song.js +++ b/lib/jasmine-core/example/node_example/lib/jasmine_examples/Song.js @@ -1,9 +1,8 @@ -function Song() { +class Song { + persistFavoriteStatus(value) { + // something complicated + throw new Error('not yet implemented'); + } } -Song.prototype.persistFavoriteStatus = function(value) { - // something complicated - throw new Error("not yet implemented"); -}; - module.exports = Song; diff --git a/lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples/SpecHelper.js b/lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples/SpecHelper.js index 578b3e862..cc04bd8db 100644 --- a/lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples/SpecHelper.js +++ b/lib/jasmine-core/example/node_example/spec/helpers/jasmine_examples/SpecHelper.js @@ -3,11 +3,11 @@ beforeEach(function () { toBePlaying: function () { return { compare: function (actual, expected) { - var player = actual; + const player = actual; return { pass: player.currentlyPlayingSong === expected && player.isPlaying - } + }; } }; } diff --git a/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js b/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js index 80f149e3a..fa96ccc46 100644 --- a/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js +++ b/lib/jasmine-core/example/node_example/spec/jasmine_examples/PlayerSpec.js @@ -1,36 +1,37 @@ -describe("Player", function() { - var Player = require('../../lib/jasmine_examples/Player'); - var Song = require('../../lib/jasmine_examples/Song'); - var player; - var song; +const Player = require('../../lib/jasmine_examples/Player'); +const Song = require('../../lib/jasmine_examples/Song'); + +describe('Player', function() { + let player; + let song; beforeEach(function() { player = new Player(); song = new Song(); }); - it("should be able to play a Song", function() { + it('should be able to play a Song', function() { player.play(song); expect(player.currentlyPlayingSong).toEqual(song); - //demonstrates use of custom matcher + // demonstrates use of custom matcher expect(player).toBePlaying(song); }); - describe("when song has been paused", function() { + describe('when song has been paused', function() { beforeEach(function() { player.play(song); player.pause(); }); - it("should indicate that the song is currently paused", function() { + 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() { + it('should be possible to resume', function() { player.resume(); expect(player.isPlaying).toBeTruthy(); expect(player.currentlyPlayingSong).toEqual(song); @@ -38,7 +39,7 @@ describe("Player", function() { }); // demonstrates use of spies to intercept and test method calls - it("tells the current song if the user has made it a favorite", function() { + it('tells the current song if the user has made it a favorite', function() { spyOn(song, 'persistFavoriteStatus'); player.play(song); @@ -48,13 +49,13 @@ describe("Player", function() { }); //demonstrates use of expected exceptions - describe("#resume", function() { - it("should throw an exception if song is already playing", function() { + 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"); + }).toThrowError('song is already playing'); }); }); }); diff --git a/lib/jasmine-core/example/spec/PlayerSpec.js b/lib/jasmine-core/example/spec/PlayerSpec.js index f17521fde..9617c4f4d 100644 --- a/lib/jasmine-core/example/spec/PlayerSpec.js +++ b/lib/jasmine-core/example/spec/PlayerSpec.js @@ -1,34 +1,34 @@ -describe("Player", function() { - var player; - var song; +describe('Player', function() { + let player; + let song; beforeEach(function() { player = new Player(); song = new Song(); }); - it("should be able to play a Song", function() { + it('should be able to play a Song', function() { player.play(song); expect(player.currentlyPlayingSong).toEqual(song); - //demonstrates use of custom matcher + // demonstrates use of custom matcher expect(player).toBePlaying(song); }); - describe("when song has been paused", function() { + describe('when song has been paused', function() { beforeEach(function() { player.play(song); player.pause(); }); - it("should indicate that the song is currently paused", function() { + 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() { + it('should be possible to resume', function() { player.resume(); expect(player.isPlaying).toBeTruthy(); expect(player.currentlyPlayingSong).toEqual(song); @@ -36,7 +36,7 @@ describe("Player", function() { }); // demonstrates use of spies to intercept and test method calls - it("tells the current song if the user has made it a favorite", function() { + it('tells the current song if the user has made it a favorite', function() { spyOn(song, 'persistFavoriteStatus'); player.play(song); @@ -46,13 +46,13 @@ describe("Player", function() { }); //demonstrates use of expected exceptions - describe("#resume", function() { - it("should throw an exception if song is already playing", function() { + 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"); + }).toThrowError('song is already playing'); }); }); }); diff --git a/lib/jasmine-core/example/spec/SpecHelper.js b/lib/jasmine-core/example/spec/SpecHelper.js index 126752d1e..cc04bd8db 100644 --- a/lib/jasmine-core/example/spec/SpecHelper.js +++ b/lib/jasmine-core/example/spec/SpecHelper.js @@ -3,7 +3,7 @@ beforeEach(function () { toBePlaying: function () { return { compare: function (actual, expected) { - var player = actual; + const player = actual; return { pass: player.currentlyPlayingSong === expected && player.isPlaying diff --git a/lib/jasmine-core/example/src/Player.js b/lib/jasmine-core/example/src/Player.js index 118519669..f2fae6f7c 100644 --- a/lib/jasmine-core/example/src/Player.js +++ b/lib/jasmine-core/example/src/Player.js @@ -1,22 +1,22 @@ -function Player() { -} -Player.prototype.play = function(song) { - this.currentlyPlayingSong = song; - this.isPlaying = true; -}; - -Player.prototype.pause = function() { - this.isPlaying = false; -}; +class Player { + play(song) { + this.currentlyPlayingSong = song; + this.isPlaying = true; + } -Player.prototype.resume = function() { - if (this.isPlaying) { - throw new Error("song is already playing"); + pause() { + this.isPlaying = false; } - this.isPlaying = true; -}; + resume() { + if (this.isPlaying) { + throw new Error('song is already playing'); + } -Player.prototype.makeFavorite = function() { - this.currentlyPlayingSong.persistFavoriteStatus(true); -}; + this.isPlaying = true; + } + + makeFavorite() { + this.currentlyPlayingSong.persistFavoriteStatus(true); + } +} diff --git a/lib/jasmine-core/example/src/Song.js b/lib/jasmine-core/example/src/Song.js index 02527cb16..8914793b0 100644 --- a/lib/jasmine-core/example/src/Song.js +++ b/lib/jasmine-core/example/src/Song.js @@ -1,7 +1,6 @@ -function Song() { +class Song { + persistFavoriteStatus(value) { + // something complicated + throw new Error('not yet implemented'); + } } - -Song.prototype.persistFavoriteStatus = function(value) { - // something complicated - throw new Error("not yet implemented"); -};