Fix path-oriented unit test on Windows

This commit is contained in:
Scott Nonnenberg 2018-05-31 14:09:41 -07:00
parent 7c3325f55e
commit 068cce61e6
1 changed files with 8 additions and 3 deletions

View File

@ -217,17 +217,22 @@ describe('Attachments', () => {
});
describe('createAbsolutePathGetter', () => {
const isWindows = process.platform === 'win32';
it('combines root and relative path', () => {
const root = '/tmp';
const root = isWindows ? 'C:\\temp' : '/tmp';
const relative = 'ab/abcdef';
const pathGetter = Attachments.createAbsolutePathGetter(root);
const absolutePath = pathGetter(relative);
assert.strictEqual(absolutePath, '/tmp/ab/abcdef');
assert.strictEqual(
absolutePath,
isWindows ? 'C:\\temp\\ab\\abcdef' : '/tmp/ab/abcdef'
);
});
it('throws if relative path goes higher than root', () => {
const root = '/tmp';
const root = isWindows ? 'C:\\temp' : 'tmp';
const relative = '../../ab/abcdef';
const pathGetter = Attachments.createAbsolutePathGetter(root);