mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added tests for CLI .json config reading
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -55,7 +55,7 @@ export class CLIUtils {
|
||||
try {
|
||||
config = __non_webpack_require__(configPath);
|
||||
} catch (e) {
|
||||
throw new ReferenceError('Given config path must be a valid file path');
|
||||
throw new ReferenceError('Given config path must be a valid `.js` or `.json` file path');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"compact": true,
|
||||
"selfDefending": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
@@ -36,23 +36,46 @@ describe('CLIUtils', () => {
|
||||
|
||||
describe('getUserConfig (configPath: string): Object', () => {
|
||||
describe('variant #1: valid config file path', () => {
|
||||
const configDirName: string = 'test/fixtures';
|
||||
const configFileName: string = 'config.js';
|
||||
const configFilePath: string = `../../../${configDirName}/${configFileName}`;
|
||||
const expectedResult: TInputOptions = {
|
||||
compact: true,
|
||||
selfDefending: false,
|
||||
sourceMap: true
|
||||
};
|
||||
describe('variant #1: js file with config', () => {
|
||||
const configDirName: string = 'test/fixtures';
|
||||
const configFileName: string = 'config.js';
|
||||
const configFilePath: string = `../../../${configDirName}/${configFileName}`;
|
||||
const expectedResult: TInputOptions = {
|
||||
compact: true,
|
||||
selfDefending: false,
|
||||
sourceMap: true
|
||||
};
|
||||
|
||||
let result: Object;
|
||||
let result: Object;
|
||||
|
||||
before(() => {
|
||||
result = CLIUtils.getUserConfig(configFilePath);
|
||||
before(() => {
|
||||
result = CLIUtils.getUserConfig(configFilePath);
|
||||
});
|
||||
|
||||
it('should return object with user configuration', () => {
|
||||
assert.deepEqual(result, expectedResult);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return object with user configuration', () => {
|
||||
assert.deepEqual(result, expectedResult);
|
||||
describe('variant #2: json file with config', () => {
|
||||
const configDirName: string = 'test/fixtures';
|
||||
const configFileName: string = 'config.json';
|
||||
const configFilePath: string = `../../../${configDirName}/${configFileName}`;
|
||||
const expectedResult: TInputOptions = {
|
||||
compact: true,
|
||||
selfDefending: false,
|
||||
sourceMap: true
|
||||
};
|
||||
|
||||
let result: Object;
|
||||
|
||||
before(() => {
|
||||
result = CLIUtils.getUserConfig(configFilePath);
|
||||
});
|
||||
|
||||
it('should return object with user configuration', () => {
|
||||
assert.deepEqual(result, expectedResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user