lundi 29 août 2016

Unit test /integration for unzip file

I'm using the following open source for unzip the files which is working OK. http://ift.tt/1tEw1dX

Now I want to create some unit test/integration test for it to see that the file was saved,the problem is that the process is trowing events and I don't know for sure when the process end,any idea how to solve this? ex

var DecompressZip = require('decompress-zip');
var unzipper = new DecompressZip(filename)

unzipper.on('error', function (err) {
    console.log('Caught an error');
});

unzipper.on('extract', function (log) {
    console.log('Finished extracting');
});

unzipper.on('progress', function (fileIndex, fileCount) {
    console.log('Extracted file ' + (fileIndex + 1) + ' of ' + fileCount);
});

unzipper.extract({
    path: 'some/path',
    filter: function (file) {
        return file.type !== "SymbolicLink";
    }
});

I use mocha & chai as test framework.

Aucun commentaire:

Enregistrer un commentaire