var chai = require('chai');
var expect = chai.expect;

var path = require('path');
var albumInfo = require('../src/albumInfo');

describe('albumInfo', function() {
	
	describe('on success', function() {
		var results;
		beforeEach(function(done) {
			albumInfo('test', function(err, data) {
				if (data) {
					results = data;
				} else {
					console.log(err);
				}
				done();
			});
		});

		it('should get album info object', function () {
			expect(results).to.have.property('artist', 'Less Than Jake');
			expect(results).to.have.property('album', 'Short Music for Short People');
			expect(results).to.have.property('albumArt', path.join('test', 'folder.jpg'));
			expect(results).to.have.property('tracks');
			expect(results.tracks).to.have.length(2);
		});
	});
	
	describe('on success without album art', function() {
		var results, error;
		beforeEach(function(done) {
			albumInfo('test/album', function(err, data) {
				results = data;
				error = err;
				done();
			});
		});

		it('should get album info object', function () {
			expect(results).to.have.property('artist', 'Less Than Jake');
			expect(results).to.have.property('album', 'Short Music for Short People');
			expect(results).to.have.property('albumArt', path.resolve('src', 'default.jpg'));
			expect(results).to.have.property('tracks');
			expect(results.tracks).to.have.length(1);
		});
	});
	
	describe('on error', function() {
		var results, error;
		beforeEach(function(done) {
			albumInfo('test/ss', function(err, data) {
				results = data;
				error = err;
				done();
			});
		});

		it('should throw error', function () {
			expect(results).to.be.null;
			expect(error).to.not.be.null;
		});
	});
});
var chai = require('chai');
var expect = chai.expect;

var path = require('path');
var albumInfo = require('../src/albumInfo');

describe('albumInfo', function() {
	
	describe('on success', function() {
		var results;
		beforeEach(function(done) {
			this.timeout(50000);
			albumInfo('test', function(err, data) {
				if (data) {
					results = data;
				} else {
					console.log(err);
				}
				done();
			});
		});

		it('should get album info object', function () {
			expect(results).to.have.property('artist', 'Less Than Jake');
			expect(results).to.have.property('album', 'Short Music for Short People');
			expect(results).to.have.property('albumArt', path.join('test', 'folder.jpg'));
			expect(results).to.have.property('tracks');
			expect(results.tracks).to.have.length(2);
		});
	});
	
	describe('on success without album art', function() {
		var results, error;
		beforeEach(function(done) {
			this.timeout(50000);
			albumInfo('test/album', function(err, data) {
				results = data;
				error = err;
				done();
			});
		});

		it('should get album info object', function () {
			expect(results).to.have.property('artist', 'Less Than Jake');
			expect(results).to.have.property('album', 'Short Music for Short People');
			expect(results).to.have.property('albumArt', path.resolve('src', 'default.jpg'));
			expect(results).to.have.property('tracks');
			expect(results.tracks).to.have.length(1);
		});
	});
	
	describe('on error', function() {
		var results, error;
		beforeEach(function(done) {
			this.timeout(50000);
			albumInfo('test/ss', function(err, data) {
				results = data;
				error = err;
				done();
			});
		});

		it('should throw error', function () {
			expect(results).to.be.null;
			expect(error).to.not.be.null;
		});
	});
});
fix to make albumInfo-spec pass