Skip to content

Commit

Permalink
removeUserTracks can now pass IDs and Spotify URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiemoore committed Sep 17, 2014
1 parent 58c27dd commit 6a5ce09
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dist/angular-spotify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/angular-spotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@
};

NgSpotify.prototype.removeUserTracks = function (tracks) {
tracks = angular.isString(tracks) ? tracks.split(',') : tracks;
angular.forEach(tracks, function (value, index) {
tracks[index] = value.indexOf('spotify:') > -1 ? value.split(':')[2] : value;
});
return this.api('/me/tracks', 'DELETE', {
ids: tracks.toString()
}, null, {
Expand Down
16 changes: 16 additions & 0 deletions test/spec/angular-spotify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,22 @@ describe('angular-spotify', function () {
});
});

it('should be able to pass Spotify URIs', function () {
spyOn(Spotify, 'api');

Spotify.setAuthToken('TESTING');

Spotify.removeUserTracks(['spotify:track:0udZHhCi7p1YzMlvI4fXoK','spotify:track:3SF5puV5eb6bgRSxBeMOk9']);

expect(Spotify.api).toHaveBeenCalled();
expect(Spotify.api).toHaveBeenCalledWith('/me/tracks', 'DELETE', {
ids: '0udZHhCi7p1YzMlvI4fXoK,3SF5puV5eb6bgRSxBeMOk9'
}, null, {
'Authorization': 'Bearer TESTING',
'Content-Type': 'application/json'
});
});

});

});
Expand Down

0 comments on commit 6a5ce09

Please sign in to comment.