Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f366c67
commit 0628278
Showing
5 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# COLLECTIONS | ||
|
||
@app = window.app ? {} | ||
|
||
class Albums extends Backbone.Collection | ||
model: window.app.Album | ||
url: '/api/albums' | ||
|
||
class Playlist extends Albums | ||
isFirstAlbum: (index) -> | ||
index == 0 | ||
isLastAlbum: (index) -> | ||
index == (@models.length - 1) | ||
|
||
|
||
@app.Albums = Albums | ||
@app.Playlist = Playlist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
app = window.app ? {} | ||
|
||
albumData = [{ | ||
"title": "Album A" | ||
"artist": "Artist A" | ||
"tracks": [{"title": "Track A", "url": "/music/Album A Track A.mp3" },{ "title": "Track B", "url": "/music/Album A Track B.mp3" }] | ||
},{ | ||
"title": "Album B" | ||
"artist": "Artist B" | ||
"tracks": [{"title": "Track A", "url": "/music/Album B Track A.mp3" },{ "title": "Track B", "url": "/music/Album B Track B.mp3" }] | ||
}] | ||
|
||
describe "Playlist", -> | ||
beforeEach -> | ||
@playlist = new app.Playlist | ||
@playlist.add(albumData[0]) | ||
|
||
it "has models", -> | ||
expect(@playlist.models.length).toEqual(1) | ||
|
||
it "identifies first album as first", -> | ||
expect(@playlist.isFirstAlbum(0)).toBeTruthy() | ||
|
||
it "rejects non-first album as first", -> | ||
expect(@playlist.isFirstAlbum(1)).toBeFalsy() | ||
|
||
it "identifies last album as last", -> | ||
@playlist.add(albumData[1]) | ||
console.log(@playlist) | ||
expect(@playlist.isLastAlbum(1)).toBeTruthy() | ||
|
||
it "rejects non-last album as last", -> | ||
@playlist.add(albumData[1]) | ||
expect(@playlist.isLastAlbum(0)).toBeFalsy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters