2017-07-31 03:48:00 -04:00
|
|
|
var should = require('should'), // jshint ignore:line
|
|
|
|
path = require('path'),
|
|
|
|
fs = require('fs-extra'),
|
2017-10-31 12:11:59 +01:00
|
|
|
extract = require('extract-zip'),
|
2017-07-31 03:48:00 -04:00
|
|
|
utils = require('../../../server/utils');
|
|
|
|
|
|
|
|
describe('Utils: zip-folder', function () {
|
|
|
|
const symlinkPath = path.join(__dirname, '..', '..', 'utils', 'fixtures', 'themes', 'theme-symlink'),
|
|
|
|
folderToSymlink = path.join(__dirname, '..', '..', 'utils', 'fixtures', 'themes', 'casper'),
|
|
|
|
zipDestination = path.join(__dirname, '..', '..', 'utils', 'fixtures', 'themes', 'theme-symlink.zip'),
|
|
|
|
unzipDestination = path.join(__dirname, '..', '..', 'utils', 'fixtures', 'themes', 'theme-symlink-unzipped');
|
|
|
|
|
|
|
|
before(function () {
|
|
|
|
fs.removeSync(symlinkPath);
|
|
|
|
fs.removeSync(zipDestination);
|
|
|
|
fs.removeSync(unzipDestination);
|
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
|
|
|
fs.removeSync(symlinkPath);
|
|
|
|
fs.removeSync(zipDestination);
|
|
|
|
fs.removeSync(unzipDestination);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('ensure symlinks work', function (done) {
|
|
|
|
fs.symlink(folderToSymlink, symlinkPath);
|
|
|
|
|
|
|
|
utils.zipFolder(symlinkPath, zipDestination, function (err) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
extract(zipDestination, {dir: unzipDestination}, function (err) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
fs.readdir(unzipDestination, function (err, files) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
2017-09-21 16:05:35 +02:00
|
|
|
files.length.should.eql(12);
|
2017-07-31 03:48:00 -04:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|