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

var fs = require('fs');
var fileExists = require('../src/fileExists');
var convert = require('../src/convert');

describe('convert', function() {
	
	describe('on success', function() {
		var results;
		beforeEach(function(done) {
			this.timeout(50000);
			convert('test/anchor.jpg', 'test/anchor.mp3', 'test/output.mp4', function(err, data) {
				if (data) {
					results = data;
				}
				done();
			});
		});
		
		afterEach(function() {
			if(fileExists('test/output.mp4')) {
				fs.unlink('test/output.mp4');
			}
		});

		it('should create output.mp4', function () {
			expect(fileExists('test/output.mp4')).to.equal(true);
			expect(results).to.be.true;
		});
	});
	
	describe('on error', function() {
		var results, error;
		beforeEach(function(done) {
			this.timeout(50000);
			convert('test/ss', 'test/error.mp3', 'test/outputError.mp4', function(err, data) {
				results = data;
				error = err;
				done();
			});
		});

		it('should not create outputError.mp4', function () {
			expect(results).to.be.false;
			expect(error).to.not.be.null;
		});
	});
	
	
	
	
});