kbc-paths
Version:
Qt standard paths - translate & resolve in node - only partial support
159 lines (137 loc) • 3.91 kB
JavaScript
;
const chai = require('chai');
const assert = chai.assert;
const QtPaths = require('../lib/index.js');
const qp = new QtPaths;
const testPlatforms = ['darwin', 'linux', 'win32'];
// Supported
// 'HomeLocation',
// 'DesktopLocation',
// 'DocumentsLocation',
// 'MusicLocation',
// 'MoviesLocation',
// 'PicturesLocation',
// 'DownloadLocation',
// 'RuntimeLocation'
const testUser = 'Admin';
const dataSource = {
DocumentsExtended: {
win32: {
pathValue: `C:\\Users\\${testUser}\\Documents\\Pracovné veci`,
qtpath: '{DocumentsLocation}/Pracovné veci'
},
linux: {
pathValue: `/home/${testUser}/Documents/Pracovné veci`,
qtpath: '{DocumentsLocation}/Pracovné veci'
},
darwin: {
pathValue: `/Users/${testUser}/Documents/Pracovné veci`,
qtpath: '{DocumentsLocation}/Pracovné veci'
}
},
HomeExtended: {
win32: {
pathValue: `C:\\Users\\${testUser}\\MRP`,
qtpath: '{HomeLocation}/MRP'
},
linux: {
pathValue: `/home/${testUser}/MRP`,
qtpath: '{HomeLocation}/MRP'
},
darwin: {
pathValue: `/Users/${testUser}/MRP`,
qtpath: '{HomeLocation}/MRP'
}
},
DesktopExtended: {
win32: {
pathValue: `C:\\Users\\${testUser}\\Desktop\\Staré maily`,
qtpath: '{DesktopLocation}/Staré maily'
},
linux: {
pathValue: `/home/${testUser}/Desktop/Staré maily`,
qtpath: '{DesktopLocation}/Staré maily'
},
darwin: {
pathValue: `/Users/${testUser}/Desktop/Staré maily`,
qtpath: '{DesktopLocation}/Staré maily'
},
},
Desktop: {
win32: {
pathValue: `C:\\Users\\${testUser}\\Desktop`,
qtpath: '{DesktopLocation}'
},
linux: {
pathValue: `/home/${testUser}/Desktop`,
qtpath: '{DesktopLocation}'
},
darwin: {
pathValue: `/Users/${testUser}/Desktop`,
qtpath: '{DesktopLocation}'
},
}
};
const runtimeDataSource = {
RuntimeLocation: {
win32: {
pathValue: `C:\\Users\\${testUser}`,
qtpath: '{RuntimeLocation}'
},
linux: {
pathValue: `/home/${testUser}`,
qtpath: '{RuntimeLocation}'
},
darwin: {
pathValue: `/Users/${testUser}`,
qtpath: '{RuntimeLocation}'
},
},
RuntimeLocationExtended: {
win32: {
pathValue: `C:\\Users\\${testUser}\\MRP`,
qtpath: '{RuntimeLocation}/MRP'
},
linux: {
pathValue: `/home/${testUser}/MRP`,
qtpath: '{RuntimeLocation}/MRP'
},
darwin: {
pathValue: `/Users/${testUser}/MRP`,
qtpath: '{RuntimeLocation}/MRP'
}
},
};
Object.keys(dataSource).map(label => {
describe(`testing ${label}`, () => {
testPlatforms.map(tPlatform => {
it(`${tPlatform} - from_qt_path ${dataSource[label][tPlatform].qtpath}
resolves to ${dataSource[label][tPlatform].pathValue} `, () => {
assert.equal(
qp.from_qt_path(dataSource[label][tPlatform].qtpath, 'Admin', tPlatform),
dataSource[label][tPlatform].pathValue
);
});
it(`${tPlatform} - to_qt_path ${dataSource[label][tPlatform].pathValue}
translates to ${dataSource[label][tPlatform].qtpath}`, () => {
assert.equal(
qp.to_qt_path(dataSource[label][tPlatform].pathValue, 'Admin', tPlatform),
dataSource[label][tPlatform].qtpath
);
});
});
});
});
Object.keys(runtimeDataSource).map(label=>{
describe(`testing ${label}`, () => {
testPlatforms.map(tPlatform => {
it(`${tPlatform} - from_qt_path ${runtimeDataSource[label][tPlatform].qtpath}
resolves to ${runtimeDataSource[label][tPlatform].pathValue} `, () => {
assert.equal(
qp.from_qt_path(runtimeDataSource[label][tPlatform].qtpath, 'Admin', tPlatform),
runtimeDataSource[label][tPlatform].pathValue
);
});
});
});
});