Permalink
Browse files

added test for track loading

  • Loading branch information...
1 parent da87237 commit ac8669ef6e0670d4509170204933abb749932b75 @rsms rsms committed Jul 20, 2010
Showing with 46 additions and 0 deletions.
  1. +46 −0 test/test-track-lookup.js
View
@@ -0,0 +1,46 @@
+require('./test');
+
+createSession(function (session) {
+ var refs = 0;
+ function decref() {
+ if (--refs === 0)
+ session.logout(assert.ifError);
+ }
+
+ var malformedLink = 'foo:bar';
+ var albumLink = 'spotify:album:5UfXvVB6oMHgnuT25R5jAs';
+ var trackLink = 'spotify:track:01gCUID7bHTcp6JzeTfpIe';
+
+ // fail by exception with a malformed link
+ assert.throws(function(){
+ session.getTrackByLink(malformedLink);
+ }, Error);
+
+ // fail by callback error with a malformed link
+ refs++;
+ session.getTrackByLink(malformedLink, function(err) {
+ assert.ok(err instanceof Error);
+ decref();
+ });
+
+ // fail by exception with a non-track link
+ assert.throws(function(){
+ session.getTrackByLink(albumLink);
+ }, Error);
+
+ // fail by callback error with a non-track link
+ refs++;
+ session.getTrackByLink(albumLink, function(err) {
+ assert.ok(err instanceof Error);
+ decref();
+ });
+
+ // succeed with loading a track
+ refs++;
+ session.getTrackByLink(trackLink, function(err, track) {
+ assert.ok(track instanceof spotify.Track);
+ assert.strictEqual(track.loaded, true);
+ decref();
+ });
+
+});

0 comments on commit ac8669e

Please sign in to comment.