<commit_before>var SpotifyWebApi = require('../src/spotify-web-api'),
    should = require('should')
    fs = require('fs');

'use strict';

describe('Spotify Web API', function() {
  this.timeout(5000);

  it('should set clientId, clientSecret and redirectUri', function() {
    var credentials = {
      clientId : 'someClientId',
      clientSecret : 'someClientSecret',
      redirectUri : 'myRedirectUri',
      accessToken :'my<PASSWORD>',
      refreshToken :'<PASSWORD>'
    };

    var api = new SpotifyWebApi(credentials);

    api.getCredentials().clientId.should.equal(credentials.clientId);
    api.getCredentials().clientSecret.should.equal(credentials.clientSecret);
    api.getCredentials().redirectUri.should.equal(credentials.redirectUri);
    api.getCredentials().accessToken.should.equal(credentials.accessToken);
    api.getCredentials().refreshToken.should.equal(credentials.refreshToken);
  });

  it("should retrieve track metadata", function(done) {
    var api = new SpotifyWebApi();
    api.getTrack('3Qm86XLflmIXVm1wcwkgDK')
      .then(function(data) {
        done();
      }, function(err) {
        done(err);
      });
  });

  it("should fail for non existing track id", function(done) {
    var api = new SpotifyWebApi();
    api.getTrack('idontexist')
      .then(function(data) {
        done(new Error('Should have failed'));
      }, function(err) {
        'non existing id'.should.equal(err.error.description);
        done();
      });
  });

  it('should fail for empty track id', function(done) {
    var api = new SpotifyWebApi();
    api.getTrack()
      .then(function(data) {
        done(new Error('Should have failed'));
      }, function(err) {;
        done();
      });
  });

  it("should retrieve metadata for several tracks", function(done) {
    var api = new SpotifyWebApi();
    api.getTracks(['0eGsygTp906u18L0Oimnem', '1lDWb6b6ieDQ2xT7ewTC3G'])
      .then(function(data) {
        done();
      }, function(err) {
        done(err);
      });
  });

  it("should retrieve metadata for an album", function(done) {
    var api = new SpotifyWebApi();
    api.getAlbum('0sNOF9WDwhWunNAHPD3Baj')
      .then(function(data) {
        ('spotify:album:0sNOF9WDwhWunNAHPD3Baj').should.equal(data.uri);
        done();<commit_msg>Update test to reflect changes in error response<commit_after>var SpotifyWebApi = require('../src/spotify-web-api'),
    should = require('should')
    fs = require('fs');

'use strict';

describe('Spotify Web API', function() {
  this.timeout(5000);

  it('should set clientId, clientSecret and redirectUri', function() {
    var credentials = {
      clientId : 'someClientId',
      clientSecret : 'someClientSecret',
      redirectUri : 'myRedirectUri',
      accessToken :'<PASSWORD>',
      refreshToken :'<PASSWORD>'
    };

    var api = new SpotifyWebApi(credentials);

    api.getCredentials().clientId.should.equal(credentials.clientId);
    api.getCredentials().clientSecret.should.equal(credentials.clientSecret);
    api.getCredentials().redirectUri.should.equal(credentials.redirectUri);
    api.getCredentials().accessToken.should.equal(credentials.accessToken);
    api.getCredentials().refreshToken.should.equal(credentials.refreshToken);
  });

  it("should retrieve track metadata", function(done) {
    var api = new SpotifyWebApi();
    api.getTrack('3Qm86XLflmIXVm1wcwkgDK')
      .then(function(data) {
        done();
      }, function(err) {
        done(err);
      });
  });

  it("should fail for non existing track id", function(done) {
    var api = new SpotifyWebApi();
    api.getTrack('idontexist')
      .then(function(data) {
        done(new Error('Should have failed'));
      }, function(err) {
        'non existing id'.should.equal(err.error.message);
        done();
      });
  });

  it('should fail for empty track id', function(done) {
    var api = new SpotifyWebApi();
    api.getTrack()
      .then(function(data) {
        done(new Error('Should have failed'));
      }, function(err) {;
        done();
      });
  });

  it("should retrieve metadata for several tracks", function(done) {
    var api = new SpotifyWebApi();
    api.getTracks(['0eGsygTp906u18L0Oimnem', '1lDWb6b6ieDQ2xT7ewTC3G'])
      .then(function(data) {
        done();
      }, function(err) {
        done(err);
      });
  });

  it("should retrieve metadata for an album", function(done) {
    var api = new SpotifyWebApi();
    api.getAlbum('0sNOF9WDwhWunNAHPD3Baj')
      .then(function(data) {
        ('spotify:album:0sNOF9WDwhWunNAHPD3Baj').should.equal(data.uri);
        done();
{'fraction_non_alphanumeric': 0.14848682778140648, 'fraction_numerical': 0.011757021554539516, 'mean_word_length': 3.28544776119403, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6504539', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1444, 'n_words': 266}