'use strict';

const chai = require('chai');
const expect = chai.expect;
const tmp = require('tmp');
const fs = require('fs');

const Client = require('../../lib/Client');
const putioClient = new Client('ECGUYX6W');

describe('directory listing', function() {
    this.timeout(5000);


    it('should return all files', (done) => {
        putioClient.file.list({parent_id: 285681349}, (err, results) => {
            expect(err).to.not.exist;
            expect(results.files).to.be.an('array');
            done();
        });
    });

    it('should return all events', (done) => {
        putioClient.file.events((err, results) => {
            expect(err).to.not.exist;
            expect(results.events).to.be.an('array');
            done();
        });
    });

    it('should download a file', (done) => {
        tmp.file({prefix: 'putio-int-', postfix: '.pdf', keep: true}, (err, path, fd, cleanupCallback) => {
            if(err) {
                return done(err);
            }

            const write = putioClient.file.download({file_id: 395101035})
                .pipe(fs.createWriteStream(path));

            write.on('finish', done);
        });
    });

});

@@ -161,24 +161,104 @@
 b/Client');%0A
+// The integration tests are disabled because they need a paying PUT.io account%0A
 const putioC
@@ -298,16 +298,21 @@
 describe
+.skip
 ('direct
@@ -363,17 +363,16 @@
 5000);%0A%0A
-%0A
     it('
@@ -506,33 +506,40 @@
 ect(err).to.
-not.exist
+equal(undefined)
 ;%0A          
@@ -752,17 +752,24 @@
 .to.
-not.exist
+equal(undefined)
 ;%0A  
@@ -924,16 +924,27 @@
 p.file(%7B
+%0A          
 prefix: 
@@ -956,16 +956,26 @@
 o-int-',
+%0A         
  postfix
@@ -983,16 +983,26 @@
  '.pdf',
+%0A         
  keep: t
@@ -1004,16 +1004,25 @@
 ep: true
+%0A        
 %7D, (err,
@@ -1309,13 +1309,12 @@
     %7D);%0A
-%0A
 %7D);%0A

Disable int tests