Skip to content

Commit 8e234fa

Browse files
committed
Fix extend function
1 parent 28f8174 commit 8e234fa

File tree

5 files changed

+74
-3
lines changed

5 files changed

+74
-3
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "spotify-web-api-js",
33
"description": "A client-side JS wrapper for the Spotify Web API",
4-
"version": "0.4.1",
4+
"version": "0.4.2",
55
"homepage": "https://github.com/JMPerez/spotify-web-api-js",
66
"author": {
77
"name": "José M. Pérez"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "spotify-web-api-js",
33
"description": "A client-side JS wrapper for the Spotify Web API",
4-
"version": "0.4.1",
4+
"version": "0.4.2",
55
"homepage": "https://github.com/JMPerez/spotify-web-api-js",
66
"author": {
77
"name": "José M. Pérez"

src/spotify-web-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var SpotifyWebApi = (function() {
3232
} else if (typeof options === 'function') {
3333
cb = options;
3434
}
35-
_extend(requestData.params, opt);
35+
requestData.params = _extend(requestData.params, opt);
3636
return _performRequest(requestData, cb);
3737
};
3838

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"href" : "https://api.spotify.com/v1/artists/5YyScSZOuBHpoFhGvHFedc/albums?offset=0&limit=2&album_type=single,album,compilation,appears_on",
3+
"items" : [ {
4+
"album_type" : "album",
5+
"available_markets" : [ ],
6+
"external_urls" : {
7+
"spotify" : "https://open.spotify.com/album/45P1TztZZFbxpmMNuQdR21"
8+
},
9+
"href" : "https://api.spotify.com/v1/albums/45P1TztZZFbxpmMNuQdR21",
10+
"id" : "45P1TztZZFbxpmMNuQdR21",
11+
"images" : [ {
12+
"height" : 640,
13+
"url" : "https://i.scdn.co/image/54533347f41c7d0afaa3e51f127ec93ea5e70311",
14+
"width" : 640
15+
}, {
16+
"height" : 300,
17+
"url" : "https://i.scdn.co/image/23e03d404f2b2e203022240d0b555b0ef953c757",
18+
"width" : 300
19+
}, {
20+
"height" : 64,
21+
"url" : "https://i.scdn.co/image/92cc17359e1c3f4a2faf42ff8dfc98390c9550b4",
22+
"width" : 64
23+
} ],
24+
"name" : "Mas de Cien Amaneceres",
25+
"type" : "album",
26+
"uri" : "spotify:album:45P1TztZZFbxpmMNuQdR21"
27+
}, {
28+
"album_type" : "album",
29+
"available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ],
30+
"external_urls" : {
31+
"spotify" : "https://open.spotify.com/album/6M9uDidhgXknM1AIO5Pkb4"
32+
},
33+
"href" : "https://api.spotify.com/v1/albums/6M9uDidhgXknM1AIO5Pkb4",
34+
"id" : "6M9uDidhgXknM1AIO5Pkb4",
35+
"images" : [ {
36+
"height" : 640,
37+
"url" : "https://i.scdn.co/image/abe64732d0d16bef25dd27e35870dae76fb9eafb",
38+
"width" : 640
39+
}, {
40+
"height" : 300,
41+
"url" : "https://i.scdn.co/image/9e47cff4b5dc38ab6fb836ea3109e8046cad4d2b",
42+
"width" : 300
43+
}, {
44+
"height" : 64,
45+
"url" : "https://i.scdn.co/image/c8cd3b5e20281000e28682f2fc5313cf21b594f6",
46+
"width" : 64
47+
} ],
48+
"name" : "Mas de Cien Amaneceres",
49+
"type" : "album",
50+
"uri" : "spotify:album:6M9uDidhgXknM1AIO5Pkb4"
51+
} ],
52+
"limit" : 2,
53+
"next" : "https://api.spotify.com/v1/artists/5YyScSZOuBHpoFhGvHFedc/albums?offset=2&limit=2&album_type=single,album,compilation,appears_on",
54+
"offset" : 0,
55+
"previous" : null,
56+
"total" : 33
57+
}

tests/js/spec/test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('Basic tests', function() {
2424
artist: loadFixture('artist'),
2525
artists: loadFixture('artists'),
2626
artist_albums: loadFixture('artist_albums'),
27+
artist_albums_limit_2: loadFixture('artist_albums_limit_2'),
2728
artist_related_artists: loadFixture('artist_related_artists'),
2829
artist_top_tracks: loadFixture('artist_top_tracks'),
2930
search_album: loadFixture('search_album'),
@@ -144,6 +145,19 @@ describe('Basic tests', function() {
144145
expect(that.requests[0].url).to.equal('https://api.spotify.com/v1/artists/5YyScSZOuBHpoFhGvHFedc/albums');
145146
});
146147

148+
it('should get 2 artist\'s albums', function() {
149+
var callback = sinon.spy();
150+
var api = new SpotifyWebApi();
151+
api.getArtistAlbums('5YyScSZOuBHpoFhGvHFedc', {limit: 2}, callback);
152+
that.requests[0].respond(200,
153+
{'Content-Type':'application/json'},
154+
JSON.stringify(that.fixtures.artist_albums)
155+
);
156+
expect(callback.calledWith(null, that.fixtures.artist_albums_limit_2)).to.be.ok;
157+
expect(that.requests).to.have.length(1);
158+
expect(that.requests[0].url).to.equal('https://api.spotify.com/v1/artists/5YyScSZOuBHpoFhGvHFedc/albums?limit=2');
159+
});
160+
147161
it('should get an artist\'s top tracks', function() {
148162
var callback = sinon.spy();
149163
var api = new SpotifyWebApi();

0 commit comments

Comments
 (0)