
/**
 * WPCOM module
 */

var WPCOM = require('../');
var Site = require('../lib/site');
var Media = require('../lib/media');
var util = require('./util');
var assert = require('assert');

/**
 * Testing data
 */

var test = require('./data');

/**
 * WPCOM instance
 */

describe('WPCOM#Site#Media', function(){

  // Create a new_media before to start the tests

  var new_media;
  before(function(done){
    util.addMedia(function(err, media) {
      if (err) throw err;

      new_media = media;
      done();
    });
  });

  describe('sync', function(){

    it('should create an `Media` instance from `Site`', function(){
      var media = WPCOM().site().media();
      assert.ok(media instanceof Media);
    });

  });

  describe('async', function(){

    describe('media.get()', function(){

      it('should get added media', function(done){
        var site = util.private_site();
        var media = site.media(test.media_id);

        media.get(function(err, info){
          if (err) throw err;

          assert.equal(3, info.id);
          done();
        });
      });

    });

  });

});

@@ -145,24 +145,48 @@
 ('./util');%0A
+var fs = require('fs');%0A
 var assert =
@@ -1110,23 +1110,693 @@
 ;%0A%0A    %7D);%0A%0A
+    describe('media.addFiles(%5Bfs%5D)', function()%7B%0A%0A      it('should create a new media from a file', function(done)%7B%0A        var site = util.private_site();%0A%0A        // pass streams%0A        var files = %5B%5D;%0A        for (var i = 0; i %3C test.new_media_data.files.length; i++) %7B%0A          files.push(fs.createReadStream(test.new_media_data.files%5Bi%5D));%0A        %7D%0A%0A        site%0A        .media()%0A        .addFiles(files, function(err, data)%7B%0A          if (err) throw err;%0A%0A          assert.ok(data);%0A          assert.ok(data.media instanceof Array);%0A          assert.equal(test.new_media_data.files.length, data.media.length);%0A          done();%0A        %7D);%0A%0A      %7D);%0A%0A    %7D);%0A%0A
   %7D);%0A%0A%7D);%0A

add media.addFiles() test