forked from stranger2626/js-unit-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileDataManager.js
More file actions
48 lines (39 loc) · 1.25 KB
/
fileDataManager.js
File metadata and controls
48 lines (39 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict';
const path = require('path');
class fileDataManager{
byExtension (fileName) {
const loadFile = {
'.json': this.loadJsonFile,
'.csv': this.loadCsvFile,
'.yml': this.loadYmlFile,
'.xlsx': this.loadXlsxFile,
'.properties': this.loadPropertiesFile
};
let ext = path.extname(fileName);
return loadFile[ext](fileName);
};
loadPropertiesFile (fileName){
//TODO: implement me
// probably you want to use https://www.npmjs.com/package/properties
return 'data from properties file';
}
loadCsvFile (fileName){
//TODO: implement me
// probably you want to use https://www.npmjs.com/package/node-csv
return 'data from csv file';
}
loadJsonFile (fileName){
return require(path.resolve(fileName));
}
loadYmlFile (fileName){
//TODO: implement me
// probably you want to use https://www.npmjs.com/package/js-yaml
return 'data from yml file';
}
loadXlsxFile (fileName){
//TODO: implement me
// probably you want to use https://www.npmjs.com/package/xlsx
return 'data from xlsx file';
}
}
module.exports = new fileDataManager();