'use strict';

// Load chai
const chai = require('chai');
const expect = chai.expect;

// Load our module
const utils = require('../../../app/libs/utils');

describe('Function "metadata"', () => {

  it('should export a function', () => {
    expect(utils.metadata).to.be.a('function');
  });

});

@@ -8,16 +8,68 @@
 rict';%0A%0A
+// Load requirements%0Aconst path = require('path');%0A%0A
 // Load 
@@ -73,16 +73,16 @@
 ad chai%0A
-
 const ch
@@ -130,16 +130,55 @@
 .expect;
+%0Achai.use(require('chai-as-promised'));
 %0A%0A// Loa
@@ -323,16 +323,16 @@
 () =%3E %7B%0A
-
     expe
@@ -378,12 +378,1397 @@
 %0A  %7D);%0A%0A
+  it('should return a promise', () =%3E %7B%0A%0A    let metadataResult = utils.metadata();%0A%0A    return expect(metadataResult).to.be.a('promise')%0A                                 .and.to.eventually.be.rejected;%0A  %7D);%0A%0A  it('should resolve with an object', (done) =%3E %7B%0A%0A    let file = path.resolve('./test/data/task/metadata/Castle.S01E01.mp4');%0A%0A    utils.metadata(file).then((result) =%3E %7B%0A      expect(result).to.be.an('object');%0A      return done();%0A    %7D).catch((err) =%3E %7B%0A      return done(err);%0A    %7D);%0A  %7D);%0A%0A  it('should reject without a valid file argument', (done) =%3E %7B%0A%0A    utils.metadata().then((result) =%3E %7B%0A      return done(false);%0A    %7D).catch((err) =%3E %7B%0A      expect(err).to.match(/No file provided/ig);%0A      return done();%0A    %7D);%0A  %7D);%0A%0A  it('should reject when given a non-existent file path', (done) =%3E %7B%0A%0A    let file = path.resolve('./not-a-real-file.mp4');%0A%0A    utils.metadata(file).then((result) =%3E %7B%0A      return done(false);%0A    %7D).catch((err) =%3E %7B%0A      expect(err).to.match(/does not exist/ig);%0A      return done();%0A    %7D);%0A  %7D);%0A%0A  it('should reject when given an invalid input file', (done) =%3E %7B%0A%0A    let file = path.resolve('./test/data/task/listing/invalid file.ext');%0A%0A    utils.metadata(file).then((result) =%3E %7B%0A      return done(false);%0A    %7D).catch((err) =%3E %7B%0A      expect(err).to.match(/ffprobe exited with code 1/ig);%0A      return done();%0A    %7D);%0A  %7D);%0A%0A
 %7D);%0A

Add test coverage to utils metadata