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');
|
|
|
|
|
|
|
|
// Mimic how we expect this to be required
|
2020-04-07 11:26:01 +03:00
|
|
|
const {zipFolder, extract} = 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
|
|
|
|
2020-03-20 22:59:15 +03:00
|
|
|
const cleanUp = () => {
|
|
|
|
fs.removeSync(symlinkPath);
|
|
|
|
fs.removeSync(zipDestination);
|
|
|
|
fs.removeSync(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');
|
|
|
|
|
2020-03-20 22:59:15 +03:00
|
|
|
cleanUp();
|
2017-12-15 00:07:53 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
after(function () {
|
2020-03-20 22:59:15 +03:00
|
|
|
cleanUp();
|
2017-12-15 00:07:53 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('ensure symlinks work', function (done) {
|
|
|
|
fs.symlink(folderToSymlink, symlinkPath);
|
|
|
|
|
2020-04-07 11:26:01 +03:00
|
|
|
zipFolder(symlinkPath, zipDestination)
|
|
|
|
.then(() => {
|
|
|
|
extract(zipDestination, {dir: unzipDestination})
|
|
|
|
.then(() => {
|
|
|
|
fs.readdir(unzipDestination, function (err, files) {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
files.length.should.eql(16);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2017-12-15 00:07:53 +03:00
|
|
|
return done(err);
|
2020-04-07 11:26:01 +03:00
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
return done(err);
|
2017-12-15 00:07:53 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|