2020-03-20 19:35:13 +03:00
|
|
|
// Switch these lines once there are useful utils
|
|
|
|
// const testUtils = require('./utils');
|
|
|
|
require('./utils');
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
const extract = require('extract-zip');
|
|
|
|
|
|
|
|
// Mimic how we expect this to be required
|
|
|
|
const {zipFolder} = require('../');
|
2017-12-15 00:07:53 +03:00
|
|
|
|
|
|
|
describe('lib/fs: read csv', function () {
|
2020-03-20 19:35:13 +03:00
|
|
|
let symlinkPath, folderToSymlink, zipDestination, unzipDestination;
|
2017-12-15 00:07:53 +03:00
|
|
|
|
|
|
|
before(function () {
|
2020-03-20 19:35:13 +03:00
|
|
|
symlinkPath = path.join(__dirname, 'fixtures', 'theme-symlink');
|
|
|
|
folderToSymlink = path.join(__dirname, 'fixtures', 'test-theme');
|
|
|
|
zipDestination = path.join(__dirname, 'fixtures', 'theme-symlink.zip');
|
|
|
|
unzipDestination = path.join(__dirname, 'fixtures', 'theme-symlink-unzipped');
|
|
|
|
|
2017-12-15 00:07:53 +03:00
|
|
|
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);
|
|
|
|
|
2020-03-20 19:35:13 +03:00
|
|
|
zipFolder(symlinkPath, zipDestination, function (err) {
|
2017-12-15 00:07:53 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-08-12 17:31:08 +03:00
|
|
|
files.length.should.eql(16);
|
2017-12-15 00:07:53 +03:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|