mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Slightly changed tests structure
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';
|
||||
|
||||
describe('`domainLock` validation', () => {
|
||||
describe('IsAllowedForObfuscationTarget', () => {
|
||||
describe('Variant #1: positive validation', () => {
|
||||
describe('Variant #1: obfuscation target: `browser`', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
domainLock: ['www.example.com'],
|
||||
target: ObfuscationTarget.Browser
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `browser`', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: obfuscation target: `node` and default value', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
domainLock: [],
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `node` and value is default', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: negative validation', () => {
|
||||
const expectedError: string = 'This option allowed only for obfuscation targets';
|
||||
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
domainLock: ['www.example.com'],
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not pass validation when obfuscation target is `node` and value is not default', () => {
|
||||
assert.throws(testFunc, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { ObfuscationTarget } from '../../../../../src/enums/ObfuscationTarget';
|
||||
|
||||
describe('`domainLock` IsAllowedForObfuscationTarget validator', () => {
|
||||
describe('Variant #1: positive validation', () => {
|
||||
describe('Variant #1: obfuscation target: `browser`', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
domainLock: ['www.example.com'],
|
||||
target: ObfuscationTarget.Browser
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `browser`', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: obfuscation target: `node` and default value', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
domainLock: [],
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `node` and value is default', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: negative validation', () => {
|
||||
const expectedError: string = 'This option allowed only for obfuscation targets';
|
||||
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
domainLock: ['www.example.com'],
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not pass validation when obfuscation target is `node` and value is not default', () => {
|
||||
assert.throws(testFunc, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';
|
||||
|
||||
describe('`sourceMapBaseUrl` validation', () => {
|
||||
describe('IsAllowedForObfuscationTarget', () => {
|
||||
describe('Variant #1: positive validation', () => {
|
||||
describe('Variant #1: obfuscation target: `browser`', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapBaseUrl: 'http://www.example.com',
|
||||
target: ObfuscationTarget.Browser
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `browser`', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: obfuscation target: `node` and default value', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapBaseUrl: '',
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `node` and value is default', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: negative validation', () => {
|
||||
const expectedError: string = 'This option allowed only for obfuscation targets';
|
||||
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapBaseUrl: 'http://www.example.com',
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not pass validation when obfuscation target is `node` and value is not default', () => {
|
||||
assert.throws(testFunc, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { ObfuscationTarget } from '../../../../../src/enums/ObfuscationTarget';
|
||||
|
||||
describe('`sourceMapBaseUrl` IsAllowedForObfuscationTarget validator', () => {
|
||||
describe('Variant #1: positive validation', () => {
|
||||
describe('Variant #1: obfuscation target: `browser`', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapBaseUrl: 'http://www.example.com',
|
||||
target: ObfuscationTarget.Browser
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `browser`', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: obfuscation target: `node` and default value', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapBaseUrl: '',
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `node` and value is default', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: negative validation', () => {
|
||||
const expectedError: string = 'This option allowed only for obfuscation targets';
|
||||
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapBaseUrl: 'http://www.example.com',
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not pass validation when obfuscation target is `node` and value is not default', () => {
|
||||
assert.throws(testFunc, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';
|
||||
|
||||
describe('`sourceMapFileName` validation', () => {
|
||||
describe('IsAllowedForObfuscationTarget', () => {
|
||||
describe('Variant #1: positive validation', () => {
|
||||
describe('Variant #1: obfuscation target: `browser`', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapFileName: 'foo',
|
||||
target: ObfuscationTarget.Browser
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `browser`', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: obfuscation target: `node` and default value', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapFileName: '',
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `node` and value is default', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: negative validation', () => {
|
||||
const expectedError: string = 'This option allowed only for obfuscation targets';
|
||||
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapFileName: 'foo',
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not pass validation when obfuscation target is `node` and value is not default', () => {
|
||||
assert.throws(testFunc, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { ObfuscationTarget } from '../../../../../src/enums/ObfuscationTarget';
|
||||
|
||||
describe('`sourceMapFileName` IsAllowedForObfuscationTarget validator', () => {
|
||||
describe('Variant #1: positive validation', () => {
|
||||
describe('Variant #1: obfuscation target: `browser`', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapFileName: 'foo',
|
||||
target: ObfuscationTarget.Browser
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `browser`', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: obfuscation target: `node` and default value', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapFileName: '',
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `node` and value is default', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: negative validation', () => {
|
||||
const expectedError: string = 'This option allowed only for obfuscation targets';
|
||||
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapFileName: 'foo',
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not pass validation when obfuscation target is `node` and value is not default', () => {
|
||||
assert.throws(testFunc, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';
|
||||
import { SourceMapMode } from '../../../../src/enums/source-map/SourceMapMode';
|
||||
|
||||
describe('`sourceMapMode` validation', () => {
|
||||
describe('IsAllowedForObfuscationTarget', () => {
|
||||
describe('Variant #1: positive validation', () => {
|
||||
describe('Variant #1: obfuscation target: `browser`', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapMode: SourceMapMode.Inline,
|
||||
target: ObfuscationTarget.Browser
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `browser`', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: obfuscation target: `node` and default value', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapMode: SourceMapMode.Separate,
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `node` and value is default', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: negative validation', () => {
|
||||
const expectedError: string = 'This option allowed only for obfuscation targets';
|
||||
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapMode: SourceMapMode.Inline,
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not pass validation when obfuscation target is `node` and value is not default', () => {
|
||||
assert.throws(testFunc, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { ObfuscationTarget } from '../../../../../src/enums/ObfuscationTarget';
|
||||
import { SourceMapMode } from '../../../../../src/enums/source-map/SourceMapMode';
|
||||
|
||||
describe('`sourceMapMode` IsAllowedForObfuscationTarget validator', () => {
|
||||
describe('Variant #1: positive validation', () => {
|
||||
describe('Variant #1: obfuscation target: `browser`', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapMode: SourceMapMode.Inline,
|
||||
target: ObfuscationTarget.Browser
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `browser`', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: obfuscation target: `node` and default value', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapMode: SourceMapMode.Separate,
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `node` and value is default', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: negative validation', () => {
|
||||
const expectedError: string = 'This option allowed only for obfuscation targets';
|
||||
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMapMode: SourceMapMode.Inline,
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not pass validation when obfuscation target is `node` and value is not default', () => {
|
||||
assert.throws(testFunc, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { ObfuscationTarget } from '../../../../src/enums/ObfuscationTarget';
|
||||
|
||||
describe('`sourceMap` validation', () => {
|
||||
describe('IsAllowedForObfuscationTarget', () => {
|
||||
describe('Variant #1: positive validation', () => {
|
||||
describe('Variant #1: obfuscation target: `browser`', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMap: true,
|
||||
target: ObfuscationTarget.Browser
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `browser`', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: obfuscation target: `node` and default value', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMap: false,
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `node` and value is default', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: negative validation', () => {
|
||||
const expectedError: string = 'This option allowed only for obfuscation targets';
|
||||
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMap: true,
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not pass validation when obfuscation target is `node` and value is not default', () => {
|
||||
assert.throws(testFunc, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { ObfuscationTarget } from '../../../../../src/enums/ObfuscationTarget';
|
||||
|
||||
describe('`sourceMap` IsAllowedForObfuscationTarget validator', () => {
|
||||
describe('Variant #1: positive validation', () => {
|
||||
describe('Variant #1: obfuscation target: `browser`', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMap: true,
|
||||
target: ObfuscationTarget.Browser
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `browser`', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: obfuscation target: `node` and default value', () => {
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMap: false,
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should pass validation when obfuscation target is `node` and value is default', () => {
|
||||
assert.doesNotThrow(testFunc);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: negative validation', () => {
|
||||
const expectedError: string = 'This option allowed only for obfuscation targets';
|
||||
|
||||
let testFunc: () => string;
|
||||
|
||||
beforeEach(() => {
|
||||
testFunc = () => JavaScriptObfuscator.obfuscate(
|
||||
'',
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
sourceMap: true,
|
||||
target: ObfuscationTarget.Node
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should not pass validation when obfuscation target is `node` and value is not default', () => {
|
||||
assert.throws(testFunc, expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
+5
-5
@@ -89,11 +89,11 @@ import './functional-tests/node-transformers/preparing-transformers/obfuscating-
|
||||
import './functional-tests/node-transformers/preparing-transformers/obfuscating-guards/conditional-comment-obfuscating-guard/ConditionalCommentObfuscatingGuard.spec';
|
||||
import './functional-tests/node-transformers/preparing-transformers/obfuscating-guards/reserved-string-obfuscating-guard/ReservedStringObfuscatingGuard.spec';
|
||||
import './functional-tests/options/OptionsNormalizer.spec';
|
||||
import './functional-tests/options/domain-lock/validators/IsAllowedForObfuscationTarget.spec';
|
||||
import './functional-tests/options/source-map/validators/IsAllowedForObfuscationTarget.spec';
|
||||
import './functional-tests/options/source-map-base-url/validators/IsAllowedForObfuscationTarget.spec';
|
||||
import './functional-tests/options/source-map-file-name/validators/IsAllowedForObfuscationTarget.spec';
|
||||
import './functional-tests/options/source-map-mode/validators/IsAllowedForObfuscationTarget.spec';
|
||||
import './functional-tests/options/domain-lock/Validation.spec';
|
||||
import './functional-tests/options/source-map/Validation.spec';
|
||||
import './functional-tests/options/source-map-base-url/Validation.spec';
|
||||
import './functional-tests/options/source-map-file-name/Validation.spec';
|
||||
import './functional-tests/options/source-map-mode/Validation.spec';
|
||||
import './functional-tests/storages/string-array-storage/StringArrayStorage.spec';
|
||||
import './functional-tests/templates/debug-protection-nodes/DebugProtectionFunctionCallTemplate.spec';
|
||||
import './functional-tests/templates/domain-lock-nodes/DomainLockNodeTemplate.spec';
|
||||
|
||||
Reference in New Issue
Block a user