Fix path-oriented unit test on Windows
This commit is contained in:
parent
7c3325f55e
commit
068cce61e6
1 changed files with 8 additions and 3 deletions
|
@ -217,17 +217,22 @@ describe('Attachments', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('createAbsolutePathGetter', () => {
|
describe('createAbsolutePathGetter', () => {
|
||||||
|
const isWindows = process.platform === 'win32';
|
||||||
|
|
||||||
it('combines root and relative path', () => {
|
it('combines root and relative path', () => {
|
||||||
const root = '/tmp';
|
const root = isWindows ? 'C:\\temp' : '/tmp';
|
||||||
const relative = 'ab/abcdef';
|
const relative = 'ab/abcdef';
|
||||||
const pathGetter = Attachments.createAbsolutePathGetter(root);
|
const pathGetter = Attachments.createAbsolutePathGetter(root);
|
||||||
const absolutePath = pathGetter(relative);
|
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', () => {
|
it('throws if relative path goes higher than root', () => {
|
||||||
const root = '/tmp';
|
const root = isWindows ? 'C:\\temp' : 'tmp';
|
||||||
const relative = '../../ab/abcdef';
|
const relative = '../../ab/abcdef';
|
||||||
const pathGetter = Attachments.createAbsolutePathGetter(root);
|
const pathGetter = Attachments.createAbsolutePathGetter(root);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue