var fs = require('fs'),
    _ = require('lodash'),
    sinon = require('sinon');

describe('File uploads', function () {
    var testrun;

    before(function (done) {
        this.run({
            fileResolver: fs,
            collection: {
                item: [{
                    event: [{
                        listen: 'test',
                        script: {
                            exec: [
                                'var file = JSON.parse(responseBody).files[\'upload-file.json\'];',
                                // eslint-disable-next-line max-len
                                'tests[\'File contents are valid\'] = _.startsWith(file, \'data:application/octet-stream;base64,\');'
                            ]
                        }
                    }],
                    request: {
                        url: 'https://postman-echo.com/post',
                        method: 'POST',
                        body: {
                            mode: 'formdata',
                            formdata: [{
                                key: 'file',
                                src: 'test/fixtures/upload-file.json',
                                type: 'file'
                            }]
                        }
                    }
                }, {
                    request: {
                        url: 'https://postman-echo.com/post',
                        method: 'POST',
                        body: {
                            mode: 'file',
                            file: {
                                src: 'test/fixtures/upload-file.json'
                            }
                        }
                    }
                }]
            }
        }, function (err, results) {
            testrun = results;
            done(err);
        });
    });

    it('should complete the run', function () {
        expect(testrun).be.ok();
        sinon.assert.calledOnce(testrun.start);
        sinon.assert.calledOnce(testrun.done);
        sinon.assert.calledWith(testrun.done.getCall(0), null);
    });

    it('should run the test script successfully', function () {
        var assertions = testrun.assertion.getCall(0).args[1];
        sinon.assert.calledTwice(testrun.test);
        sinon.assert.calledWith(testrun.test.getCall(0), null);
        expect(assertions[0]).to.have.property('name', 'File contents are valid');
        expect(assertions[0]).to.have.property('passed', true);
    });

    it('should upload the files in binary and formdata mode correctly', function () {
        sinon.assert.calledTwice(testrun.request);

        sinon.assert.calledWith(testrun.request.getCall(0), null);
        expect(_.find(testrun.request.getCall(0).args[3].headers.members, {key: 'content-length'}))
            .to.have.property('value', 253);

        sinon.assert.calledWith(testrun.request.getCall(1), null);
        expect(_.find(testrun.request.getCall(1).args[3].headers.members, {key: 'content-length'}))
            .to.have.property('value', 33);
    });
});

@@ -40,24 +40,61 @@
 ('lodash'),%0A
+    expect = require('chai').expect,%0A
     sinon = 
@@ -1945,15 +1945,16 @@
 un).
+to.
 be.ok
-()
 ;%0A  
@@ -2395,29 +2395,40 @@
 .to.
-have.property('
+deep.include(%7B%0A            
 name
-',
+:
  'Fi
@@ -2449,18 +2449,17 @@
 e valid'
-);
+,
 %0A       
@@ -2463,61 +2463,34 @@
     
-expect(assertions%5B0%5D).to.have.property('
+    
 passed
-',
+:
  true
+%0A        %7D
 );%0A 

Update integration/sanity/file-uploads tests to chai