mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
d3459271bf
- the symlink test has been failing for some time because recent minors of Node 12 produce different size zip files - we were checking that the produced zip is a specific size, but we basically just want to check it's smaller than the original folder - this commit updates the test with the size of the original folder, found by running `du -b test/fixtures/test-theme/`
67 lines
2.1 KiB
JavaScript
67 lines
2.1 KiB
JavaScript
// Switch these lines once there are useful utils
|
|
// const testUtils = require('./utils');
|
|
require('./utils');
|
|
|
|
const path = require('path');
|
|
const fs = require('fs-extra');
|
|
const {hashElement} = require('folder-hash');
|
|
|
|
// Mimic how we expect this to be required
|
|
const {compress, extract} = require('../');
|
|
|
|
describe('Compress and Extract should be opposite functions', function () {
|
|
let symlinkPath, folderToSymlink, zipDestination, unzipDestination;
|
|
|
|
const cleanUp = () => {
|
|
fs.removeSync(symlinkPath);
|
|
fs.removeSync(zipDestination);
|
|
fs.removeSync(unzipDestination);
|
|
};
|
|
|
|
before(function () {
|
|
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');
|
|
|
|
cleanUp();
|
|
});
|
|
|
|
after(function () {
|
|
cleanUp();
|
|
});
|
|
|
|
it('ensure symlinks work', function (done) {
|
|
fs.symlink(folderToSymlink, symlinkPath);
|
|
|
|
let originalHash;
|
|
|
|
hashElement(symlinkPath)
|
|
.then((_originalHash) => {
|
|
originalHash = _originalHash;
|
|
return compress(symlinkPath, zipDestination);
|
|
})
|
|
.then((res) => {
|
|
res.should.be.an.Object().with.properties('path', 'size');
|
|
res.path.should.eql(zipDestination);
|
|
res.size.should.be.below(619618);
|
|
|
|
return extract(zipDestination, unzipDestination);
|
|
})
|
|
.then((res) => {
|
|
res.should.be.an.Object().with.properties('path');
|
|
res.path.should.eql(unzipDestination);
|
|
|
|
return hashElement(unzipDestination);
|
|
})
|
|
.then((extractedHash) => {
|
|
originalHash.children.toString().should.eql(extractedHash.children.toString());
|
|
|
|
done();
|
|
})
|
|
.catch((err) => {
|
|
return done(err);
|
|
});
|
|
});
|
|
});
|