-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollection-test.js
79 lines (63 loc) · 3.7 KB
/
collection-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var { createCollection, createTrack,reviewTrack, addTrack,getTotalDuration, findTracksByArtist } = require("./collection")
var assert = require('chai').assert;
describe('Spotify collections', function() {
it.skip('should create a collection', function() {
var chillHits = createCollection('Chill Hits', 'A collection of relaxing songs');
assert.equal(chillHits.name, 'Chill Hits');
assert.equal(chillHits.description, 'A collection of relaxing songs');
assert.deepEqual(chillHits.tracks, []);
});
it.skip('should create track', function() {
var track1 = createTrack('Sunset', 'The Midnight', 270);
assert.deepEqual(track1.title,'Sunset');
assert.deepEqual(track1.duration,270);
assert.deepEqual(track1.artist, 'The Midnight')
});
it.skip("should return default if nothing is passed", function(){
var emptyTrack = createTrack()
assert.deepEqual(emptyTrack, {title:'unknown',artist:'unknown', duration:0, });
})
it.skip('should only appreciate the talent of Red Hot Chili Peppers', function() {
var track1 = createTrack('Californication', 'Red Hot Chili Peppers', 321);
var track2 = createTrack('Otherside', 'Red Hot Chili Peppers', 255);
var track3 = createTrack('Beautiful Day', 'U2', 246);
var review1 = reviewTrack(track1);
var review2 = reviewTrack(track2);
var review3 = reviewTrack(track3);
assert.equal(review1, 'The song Californication rules!');
assert.equal(review2, 'The song Otherside rules!');
assert.equal(review3, 'I wish this was a Red Hot Chili Peppers song.');
});
it.skip('should add one track to a collection', function() {
var chillHits = createCollection('Chill Hits', 'A collection of relaxing songs');
var track1 = createTrack('Sunset', 'The Midnight', 270);
var chillHitsWith1Track = addTrack(chillHits, track1);
assert.deepEqual(chillHitsWith1Track.tracks, [track1]);
});
it.skip('should add tracks to a collection', function() {
var chillHits = createCollection('Chill Hits', 'A collection of relaxing songs');
var track1 = createTrack('Sunset', 'The Midnight', 270);
var track2 = createTrack('Dreaming', 'Small Sails', 215);
var chillHitsWith1Track = addTrack(chillHits, track1);
var chillHitsWith2Track = addTrack(chillHitsWith1Track, track2);
assert.deepEqual(chillHitsWith2Track.tracks, [track1, track2]);
});
it.skip('should calculate the total duration of a collection', function() {
var chillHits = createCollection('Chill Hits', 'A collection of relaxing songs');
var track1 = createTrack('Sunset', 'The Midnight', 270);
var track2 = createTrack('Dreaming', 'Small Sails', 215);
var chillHitsWith1Track = addTrack(chillHits, track1);
var chillHitsWith2Track = addTrack(chillHitsWith1Track, track2);
assert.equal(getTotalDuration(chillHitsWith2Track), 485);
});
it.skip('should find tracks by artist in a collection', function() {
var chillHits = createCollection('Chill Hits', 'A collection of relaxing songs');
var track1 = createTrack('Sunset', 'The Midnight', 270);
var track2 = createTrack('Dreaming', 'Small Sails', 215);
var track3 = createTrack('Lonely Night', 'The Midnight', 190);
var chillHitsWith1Track = addTrack(chillHits, track1);
var chillHitsWith2Track = addTrack(chillHitsWith1Track, track2);
var chillHitsWith3Track = addTrack(chillHitsWith2Track, track3);
assert.deepEqual(findTracksByArtist(chillHitsWith3Track, 'The Midnight'), [track1, track3]);
});
})