Updated paths & tests to work in new pkg structure

- added export to index.js
- fixed all paths to match the new structure
- replaced should with testUtils
- moved code from describe block into before
This commit is contained in:
Hannah Wolfe 2020-03-20 16:35:13 +00:00
parent 43d0629346
commit 099a93d4a4
3 changed files with 20 additions and 20 deletions

View File

@ -0,0 +1,3 @@
module.exports = {
zipFolder: require('./lib/zip-folder')
};

View File

@ -1,10 +0,0 @@
// Switch these lines once there are useful utils
// const testUtils = require('./utils');
require('./utils');
describe('Hello world', function () {
it('Runs a test', function () {
// TODO: Write me!
'hello'.should.eql('hello');
});
});

View File

@ -1,16 +1,23 @@
var should = require('should'),
path = require('path'),
fs = require('fs-extra'),
extract = require('extract-zip'),
fsLib = require('../../../../server/lib/fs');
// 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('../');
describe('lib/fs: read csv', 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');
let symlinkPath, folderToSymlink, zipDestination, 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');
fs.removeSync(symlinkPath);
fs.removeSync(zipDestination);
fs.removeSync(unzipDestination);
@ -25,7 +32,7 @@ describe('lib/fs: read csv', function () {
it('ensure symlinks work', function (done) {
fs.symlink(folderToSymlink, symlinkPath);
fsLib.zipFolder(symlinkPath, zipDestination, function (err) {
zipFolder(symlinkPath, zipDestination, function (err) {
if (err) {
return done(err);
}