<commit_before>var path = require("path"),
    fs = require("fs"),
    WritableStream = require("stream").Writable,
    waitOn = require("wait-on");

var SOURCE_FILENAME = path.resolve(__dirname, "../testContents/alrighty.jpg");

function waitOnFile(filename) {
    return new Promise(function(resolve, reject) {
        waitOn(
            {
                resources: [ filename ],
                interval: 50,
                timeout: 500,
                window: 0
            }, function(err) {
                if (err) {
                    return reject(err);
                }
                return resolve();
            }
        );
    });
}

describe("createWriteStream", function() {

    beforeEach(function() {
        this.client = createWebDAVClient(
            "http://localhost:9988/webdav/server",
            createWebDAVServer.test.username,
            createWebDAVServer.test.password
        );
        clean();
        this.server = createWebDAVServer();
        return this.server.start();
    });

    afterEach(function() {
        return this.server.stop();
    });

    it("writes the file to the remote", function() {
        var targetFile = path.resolve(__dirname, "../testContents/alrighty2.jpg");
        var writeStream = this.client.createWriteStream("/alrighty2.jpg"),
            readStream = fs.createReadStream(SOURCE_FILENAME);
        expect(writeStream instanceof WritableStream).to.be.true;
        return new Promise(function(resolve, reject) {
            writeStream.on("end", function() {
                // stupid stream needs time to close probably..
                waitOnFile(targetFile)
                    .then(resolve, reject);
            });
            writeStream.on("error", reject);
            readStream.pipe(writeStream);
        });
    });

});<commit_msg>Change Writable steam instance test to check for PassThrough instead<commit_after>var path = require("path"),
    fs = require("fs"),
    PassThrough = require("stream").PassThrough,
    waitOn = require("wait-on");

var SOURCE_FILENAME = path.resolve(__dirname, "../testContents/alrighty.jpg");

function waitOnFile(filename) {
    return new Promise(function(resolve, reject) {
        waitOn(
            {
                resources: [ filename ],
                interval: 50,
                timeout: 500,
                window: 0
            }, function(err) {
                if (err) {
                    return reject(err);
                }
                return resolve();
            }
        );
    });
}

describe("createWriteStream", function() {

    beforeEach(function() {
        this.client = createWebDAVClient(
            "http://localhost:9988/webdav/server",
            createWebDAVServer.test.username,
            createWebDAVServer.test.password
        );
        clean();
        this.server = createWebDAVServer();
        return this.server.start();
    });

    afterEach(function() {
        return this.server.stop();
    });

    it("writes the file to the remote", function() {
        var targetFile = path.resolve(__dirname, "../testContents/alrighty2.jpg");
        var writeStream = this.client.createWriteStream("/alrighty2.jpg"),
            readStream = fs.createReadStream(SOURCE_FILENAME);
        expect(writeStream instanceof PassThrough).to.be.true;
        return new Promise(function(resolve, reject) {
            writeStream.on("end", function() {
                // stupid stream needs time to close probably..
                waitOnFile(targetFile)
                    .then(resolve, reject);
            });
            writeStream.on("error", reject);
            readStream.pipe(writeStream);
        });
    });

});
{'fraction_non_alphanumeric': 0.12351672060409924, 'fraction_numerical': 0.006472491909385114, 'mean_word_length': 1.8751937984496123, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6943490', 'n_tokens_mistral': 1000, 'n_tokens_neox': 943, 'n_words': 187}