|
@@ -307,202 +307,316 @@ describe('obfuscatedCodeFileUtils', () => {
|
|
|
|
|
|
describe('getOutputSourceMapPath', () => {
|
|
|
describe('Variant #1: output code path is a file path', () => {
|
|
|
- const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js.map');
|
|
|
-
|
|
|
- let outputSourceMapPath: string;
|
|
|
-
|
|
|
- before(() => {
|
|
|
- const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
- rawInputPath,
|
|
|
- {
|
|
|
- output: rawOutputPath
|
|
|
- }
|
|
|
- );
|
|
|
- outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath);
|
|
|
- });
|
|
|
-
|
|
|
- it('should return output path for source map', () => {
|
|
|
- assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- describe('Variant #2: output code path is a directory path and source map file name is not set', () => {
|
|
|
- const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join(tmpDirectoryPath, 'output');
|
|
|
-
|
|
|
- let testFunc: () => string;
|
|
|
-
|
|
|
- before(() => {
|
|
|
- const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
- rawInputPath,
|
|
|
- {
|
|
|
- output: rawOutputPath
|
|
|
- }
|
|
|
- );
|
|
|
- testFunc = () => obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath);
|
|
|
- });
|
|
|
-
|
|
|
- it('should throw an error if output code path is a directory path and source map file name is not set', () => {
|
|
|
- assert.throws(testFunc, Error);
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- describe('Variant #3: output code path with dot', () => {
|
|
|
- const rawInputPath: string = path.join(tmpDirectoryPath, 'input.with.dot', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join(tmpDirectoryPath, 'output.with.dot', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join(tmpDirectoryPath, 'output.with.dot', 'test-output.js');
|
|
|
- const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output.with.dot', 'test-output.js.map');
|
|
|
-
|
|
|
- let outputSourceMapPath: string;
|
|
|
+ describe('Variant #1: file path with directory', () => {
|
|
|
+ describe('Variant #1: source map file name is not set', () => {
|
|
|
+ describe('Variant #1: base output code path', () => {
|
|
|
+ const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js.map');
|
|
|
+
|
|
|
+ let outputSourceMapPath: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- before(() => {
|
|
|
- const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
- rawInputPath,
|
|
|
- {
|
|
|
- output: rawOutputPath
|
|
|
- }
|
|
|
- );
|
|
|
- outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath);
|
|
|
- });
|
|
|
+ describe('Variant #2: output code path with dot', () => {
|
|
|
+ const rawInputPath: string = path.join(tmpDirectoryPath, 'input.with.dot', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join(tmpDirectoryPath, 'output.with.dot', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join(tmpDirectoryPath, 'output.with.dot', 'test-output.js');
|
|
|
+ const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output.with.dot', 'test-output.js.map');
|
|
|
+
|
|
|
+ let outputSourceMapPath: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- it('should return output path for source map', () => {
|
|
|
- assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
- });
|
|
|
- });
|
|
|
+ describe('Variant #2: source map file name is set', () => {
|
|
|
+ describe('Variant #1: source map file name without extension is set', () => {
|
|
|
+ const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const sourceMapFileName: string = 'foo';
|
|
|
+ const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
+
|
|
|
+ let outputSourceMapPath: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- describe('Variant #4: source map file name without extension is set', () => {
|
|
|
- const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const sourceMapFileName: string = 'foo';
|
|
|
- const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
+ describe('Variant #2: source map file name with wrong extension is set', () => {
|
|
|
+ const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const sourceMapFileName: string = 'foo.js';
|
|
|
+ const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
+
|
|
|
+ let outputSourceMapPath: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- let outputSourceMapPath: string;
|
|
|
+ describe('Variant #3: source map file name with valid extension is set', () => {
|
|
|
+ const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const sourceMapFileName: string = 'foo.js.map';
|
|
|
+ const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
+
|
|
|
+ let outputSourceMapPath: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- before(() => {
|
|
|
- const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
- rawInputPath,
|
|
|
- {
|
|
|
- output: rawOutputPath
|
|
|
- }
|
|
|
- );
|
|
|
- outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
- });
|
|
|
+ describe('Variant #4: source map file name contains directories', () => {
|
|
|
+ const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const sourceMapFileName: string = path.join('parent', 'foo.js.map');
|
|
|
+ const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'parent', 'foo.js.map');
|
|
|
+
|
|
|
+ let outputSourceMapPath: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- it('should return output path for source map', () => {
|
|
|
- assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ describe('Variant #5: output code path with dot', () => {
|
|
|
+ const rawInputPath: string = path.join(tmpDirectoryPath, 'input.with.dot', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join(tmpDirectoryPath, 'output.with.dot', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join(tmpDirectoryPath, 'output.with.dot', 'test-output.js');
|
|
|
+ const sourceMapFileName: string = path.join('parent', 'foo.js.map');
|
|
|
+ const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output.with.dot', 'parent', 'foo.js.map');
|
|
|
+
|
|
|
+ let outputSourceMapPath: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
-
|
|
|
- describe('Variant #5: output code path is a directory path and source map file name without extension is set', () => {
|
|
|
- const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join(tmpDirectoryPath, 'output');
|
|
|
- const sourceMapFileName: string = 'foo';
|
|
|
- const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
|
|
|
- let outputSourceMapPath: string;
|
|
|
+ describe('Variant #2: file path without directory', () => {
|
|
|
+ describe('Variant #1: source map file name is not set', () => {
|
|
|
+ describe('Variant #1: base output code path', () => {
|
|
|
+ const rawInputPath: string = 'test-input.js';
|
|
|
+ const rawOutputPath: string = 'test-output.js';
|
|
|
+ const outputCodePath: string = 'test-output.js';
|
|
|
+ const expectedOutputSourceMapPath: string = 'test-output.js.map';
|
|
|
+
|
|
|
+ let outputSourceMapPath: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- before(() => {
|
|
|
- const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
- rawInputPath,
|
|
|
- {
|
|
|
- output: rawOutputPath
|
|
|
- }
|
|
|
- );
|
|
|
- outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
+ describe('Variant #2: source map file name is set', () => {
|
|
|
+ describe('Variant #1: base output code path', () => {
|
|
|
+ const rawInputPath: string = 'test-input.js';
|
|
|
+ const rawOutputPath: string = 'test-output.js';
|
|
|
+ const outputCodePath: string = 'test-output.js';
|
|
|
+ const outputSourceMapFileName: string = 'test-output-source-map';
|
|
|
+ const expectedOutputSourceMapPath: string = 'test-output-source-map.js.map';
|
|
|
+
|
|
|
+ let outputSourceMapPath: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(
|
|
|
+ outputCodePath,
|
|
|
+ outputSourceMapFileName
|
|
|
+ );
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
- it('should return output path for source map', () => {
|
|
|
- assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
- });
|
|
|
- });
|
|
|
+ describe('Variant #10: Win32 environment', () => {
|
|
|
+ describe('Variant #1: source map file name is a file name without extension', () => {
|
|
|
+ const rawInputPath: string = path.join('C:\\', tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const sourceMapFileName: string = path.join('foo');
|
|
|
+ const expectedOutputSourceMapPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
|
|
|
- describe('Variant #6: source map file name with wrong extension is set', () => {
|
|
|
- const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const sourceMapFileName: string = 'foo.js';
|
|
|
- const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
+ let outputSourceMapPath: string;
|
|
|
|
|
|
- let outputSourceMapPath: string;
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
+ });
|
|
|
|
|
|
- before(() => {
|
|
|
- const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
- rawInputPath,
|
|
|
- {
|
|
|
- output: rawOutputPath
|
|
|
- }
|
|
|
- );
|
|
|
- outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
- });
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- it('should return output path for source map', () => {
|
|
|
- assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
- });
|
|
|
- });
|
|
|
+ describe('Variant #2: source map file name is a file name with an extension', () => {
|
|
|
+ const rawInputPath: string = path.join('C:\\', tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const sourceMapFileName: string = path.join('foo.js.map');
|
|
|
+ const expectedOutputSourceMapPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
|
|
|
- describe('Variant #7: source map file name with valid extension is set', () => {
|
|
|
- const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const sourceMapFileName: string = 'foo.js.map';
|
|
|
- const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
-
|
|
|
- let outputSourceMapPath: string;
|
|
|
+ let outputSourceMapPath: string;
|
|
|
|
|
|
- before(() => {
|
|
|
- const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
- rawInputPath,
|
|
|
- {
|
|
|
- output: rawOutputPath
|
|
|
- }
|
|
|
- );
|
|
|
- outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
- });
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
+ });
|
|
|
|
|
|
- it('should return output path for source map', () => {
|
|
|
- assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
- });
|
|
|
- });
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
- describe('Variant #8: source map file name is a path', () => {
|
|
|
- const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const sourceMapFileName: string = path.join('parent', 'foo.js.map');
|
|
|
- const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'parent', 'foo.js.map');
|
|
|
+ describe('Variant #3: output path and win32 path in source map file name', () => {
|
|
|
+ const rawInputPath: string = path.join('C:\\', tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const sourceMapFileName: string = path.join('C:\\', 'parent', 'foo.js.map');
|
|
|
+ const expectedOutputSourceMapPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'parent', 'foo.js.map');
|
|
|
|
|
|
- let outputSourceMapPath: string;
|
|
|
+ let outputSourceMapPath: string;
|
|
|
|
|
|
- before(() => {
|
|
|
- const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
- rawInputPath,
|
|
|
- {
|
|
|
- output: rawOutputPath
|
|
|
- }
|
|
|
- );
|
|
|
- outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
- });
|
|
|
+ before(() => {
|
|
|
+ const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
|
+ rawInputPath,
|
|
|
+ {
|
|
|
+ output: rawOutputPath
|
|
|
+ }
|
|
|
+ );
|
|
|
+ outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
+ });
|
|
|
|
|
|
- it('should return output path for source map', () => {
|
|
|
- assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ it('should return output path for source map', () => {
|
|
|
+ assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe('Variant #9: Win32 environment', () => {
|
|
|
- describe('Variant #1: output code path is a directory path', () => {
|
|
|
- const rawInputPath: string = path.join('C:\\', tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join('C:\\', tmpDirectoryPath, 'output');
|
|
|
- const sourceMapFileName: string = path.join('foo');
|
|
|
- const expectedOutputSourceMapPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
+ describe(`Variant #2: output code path is a directory path`, () => {
|
|
|
+ describe('Variant #1: source map file name is not set', () => {
|
|
|
+ const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join(tmpDirectoryPath, 'output');
|
|
|
|
|
|
- let outputSourceMapPath: string;
|
|
|
+ let testFunc: () => string;
|
|
|
|
|
|
before(() => {
|
|
|
const obfuscatedCodeFileUtils: ObfuscatedCodeFileUtils = new ObfuscatedCodeFileUtils(
|
|
@@ -511,20 +625,20 @@ describe('obfuscatedCodeFileUtils', () => {
|
|
|
output: rawOutputPath
|
|
|
}
|
|
|
);
|
|
|
- outputSourceMapPath = obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath, sourceMapFileName);
|
|
|
+ testFunc = () => obfuscatedCodeFileUtils.getOutputSourceMapPath(outputCodePath);
|
|
|
});
|
|
|
|
|
|
- it('should return output path for source map', () => {
|
|
|
- assert.equal(outputSourceMapPath, expectedOutputSourceMapPath);
|
|
|
+ it('should throw an error if output code path is a directory path and source map file name is not set', () => {
|
|
|
+ assert.throws(testFunc, Error);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe('Variant #2: source map file name is a file name without extension', () => {
|
|
|
- const rawInputPath: string = path.join('C:\\', tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const sourceMapFileName: string = path.join('foo');
|
|
|
- const expectedOutputSourceMapPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
+ describe('Variant #2: source map file name without extension is set', () => {
|
|
|
+ const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join(tmpDirectoryPath, 'output');
|
|
|
+ const sourceMapFileName: string = 'foo';
|
|
|
+ const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
|
|
|
let outputSourceMapPath: string;
|
|
|
|
|
@@ -543,12 +657,12 @@ describe('obfuscatedCodeFileUtils', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe('Variant #3: source map file name is a file name with an extension', () => {
|
|
|
- const rawInputPath: string = path.join('C:\\', tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
- const rawOutputPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const sourceMapFileName: string = path.join('foo.js.map');
|
|
|
- const expectedOutputSourceMapPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
+ describe('Variant #2: source map file name with extension is set', () => {
|
|
|
+ const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
+ const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
+ const outputCodePath: string = path.join(tmpDirectoryPath, 'output');
|
|
|
+ const sourceMapFileName: string = 'foo.js.map';
|
|
|
+ const expectedOutputSourceMapPath: string = path.join(tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
|
|
|
let outputSourceMapPath: string;
|
|
|
|
|
@@ -567,12 +681,12 @@ describe('obfuscatedCodeFileUtils', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe('Variant #4: output path and win32 path in source map file name', () => {
|
|
|
+ describe('Variant #3: Win32 environment', () => {
|
|
|
const rawInputPath: string = path.join('C:\\', tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
const rawOutputPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const outputCodePath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
- const sourceMapFileName: string = path.join('C:\\', 'parent', 'foo.js.map');
|
|
|
- const expectedOutputSourceMapPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'parent', 'foo.js.map');
|
|
|
+ const outputCodePath: string = path.join('C:\\', tmpDirectoryPath, 'output');
|
|
|
+ const sourceMapFileName: string = path.join('foo');
|
|
|
+ const expectedOutputSourceMapPath: string = path.join('C:\\', tmpDirectoryPath, 'output', 'foo.js.map');
|
|
|
|
|
|
let outputSourceMapPath: string;
|
|
|
|
|
@@ -592,7 +706,7 @@ describe('obfuscatedCodeFileUtils', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe('Variant #10: empty paths', () => {
|
|
|
+ describe('Variant #3: empty paths', () => {
|
|
|
const rawInputPath: string = path.join(tmpDirectoryPath, 'input', 'test-input.js');
|
|
|
const rawOutputPath: string = path.join(tmpDirectoryPath, 'output', 'test-output.js');
|
|
|
|