sorry i ever left you dear mocha node:test has two major issues: * --bail does not work and requires strange modules and incantations. I was able to work around this with a custom module. * the test reporter reports _after_ the suite is run. this makes debugging really hard. the debugs that we print all happen before the test suite summary. poor design overall.
82 lines
3.3 KiB
JavaScript
82 lines
3.3 KiB
JavaScript
import { describe, it } from 'mocha';
|
|
import DataLayout from '../datalayout.js';
|
|
import assert from 'node:assert/strict';
|
|
|
|
|
|
describe('DataLayout', function () {
|
|
describe('no dirMap', function () {
|
|
const BOX_DATA_DIR = '/home/yellowtent/boxdata/box';
|
|
const dataLayout = new DataLayout(BOX_DATA_DIR, []);
|
|
|
|
it('localRoot', function () {
|
|
assert.equal(dataLayout.localRoot(), BOX_DATA_DIR);
|
|
});
|
|
|
|
it('getBasename', function () {
|
|
assert.equal(dataLayout.getBasename(), 'box');
|
|
});
|
|
|
|
it('localPaths', function () {
|
|
assert.deepEqual(dataLayout.localPaths(), [ BOX_DATA_DIR ]);
|
|
});
|
|
|
|
it('toLocalPath', function () {
|
|
assert.equal(dataLayout.toLocalPath('./s1'), `${BOX_DATA_DIR}/s1`);
|
|
assert.equal(dataLayout.toLocalPath('./s1/'), `${BOX_DATA_DIR}/s1/`);
|
|
assert.equal(dataLayout.toLocalPath('./s1/s2'), `${BOX_DATA_DIR}/s1/s2`);
|
|
});
|
|
|
|
it('toRemotePath', function () {
|
|
assert.equal(dataLayout.toRemotePath(`${BOX_DATA_DIR}`), './');
|
|
assert.equal(dataLayout.toRemotePath(`${BOX_DATA_DIR}/s1`), './s1');
|
|
assert.equal(dataLayout.toRemotePath(`${BOX_DATA_DIR}/s1/`), './s1/');
|
|
assert.equal(dataLayout.toRemotePath(`${BOX_DATA_DIR}/s1/s2`), './s1/s2');
|
|
});
|
|
});
|
|
|
|
describe('with dirMap', function () {
|
|
const APP_DATA_DIR = '/home/yellowtent/appsdata/appid';
|
|
const EXT_DIR = '/srv/hsb';
|
|
const dataLayout = new DataLayout(APP_DATA_DIR, [ { localDir: EXT_DIR, remoteDir: 'data' }]);
|
|
|
|
it('localRoot', function () {
|
|
assert.equal(dataLayout.localRoot(), APP_DATA_DIR);
|
|
});
|
|
|
|
it('getBasename', function () {
|
|
assert.equal(dataLayout.getBasename(), 'appid');
|
|
});
|
|
|
|
it('localPaths', function () {
|
|
assert.deepEqual(dataLayout.localPaths(), [ APP_DATA_DIR, '/srv/hsb' ]);
|
|
});
|
|
|
|
it('toLocalPath - root', function () {
|
|
assert.equal(dataLayout.toLocalPath('./s1'), `${APP_DATA_DIR}/s1`);
|
|
assert.equal(dataLayout.toLocalPath('./s1/'), `${APP_DATA_DIR}/s1/`);
|
|
assert.equal(dataLayout.toLocalPath('./s1/s2'), `${APP_DATA_DIR}/s1/s2`);
|
|
});
|
|
|
|
it('toLocalPath - extdir', function () {
|
|
assert.equal(dataLayout.toLocalPath('./data/s1'), `${EXT_DIR}/s1`);
|
|
assert.equal(dataLayout.toLocalPath('./data/s1/'), `${EXT_DIR}/s1/`);
|
|
assert.equal(dataLayout.toLocalPath('./data/s1/s2'), `${EXT_DIR}/s1/s2`);
|
|
});
|
|
|
|
it('toRemotePath - root', function () {
|
|
assert.equal(dataLayout.toRemotePath(`${APP_DATA_DIR}`), './');
|
|
assert.equal(dataLayout.toRemotePath(`${APP_DATA_DIR}/s1`), './s1');
|
|
assert.equal(dataLayout.toRemotePath(`${APP_DATA_DIR}/s1/`), './s1/');
|
|
assert.equal(dataLayout.toRemotePath(`${APP_DATA_DIR}/s1/s2`), './s1/s2');
|
|
});
|
|
|
|
it('toRemotePath - extdir', function () {
|
|
assert.equal(dataLayout.toRemotePath(`${EXT_DIR}`), './data/');
|
|
assert.equal(dataLayout.toRemotePath(`${EXT_DIR}/s1`), './data/s1');
|
|
assert.equal(dataLayout.toRemotePath(`${EXT_DIR}/s1/`), './data/s1/');
|
|
assert.equal(dataLayout.toRemotePath(`${EXT_DIR}/s1/s2`), './data/s1/s2');
|
|
});
|
|
});
|
|
|
|
});
|