mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Removed unnecessary CLI sanitizers
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { IdentifierNamesGeneratorSanitizer } from '../../../../src/cli/sanitizers/IdentifierNamesGeneratorSanitizer';
|
||||
|
||||
describe('IdentifierNamesGeneratorSanitizer', () => {
|
||||
describe('Variant #1: valid identifier names generator', () => {
|
||||
const inputValue: string = 'mangled';
|
||||
const expectedValue: string = inputValue;
|
||||
|
||||
let value: string;
|
||||
|
||||
before(() => {
|
||||
value = IdentifierNamesGeneratorSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should sanitize value', () => {
|
||||
assert.equal(value, expectedValue);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: invalid identifier names generator', () => {
|
||||
const inputValue: string = 'foo';
|
||||
|
||||
let testFunc: () => void;
|
||||
|
||||
before(() => {
|
||||
testFunc = () => IdentifierNamesGeneratorSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should throw error', () => {
|
||||
assert.throw(testFunc, ReferenceError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,34 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { ObfuscationTargetSanitizer } from '../../../../src/cli/sanitizers/ObfuscatingTargetSanitizer';
|
||||
|
||||
describe('ObfuscationTargetSanitizer', () => {
|
||||
describe('Variant #1: valid obfuscation target', () => {
|
||||
const inputValue: string = 'browser';
|
||||
const expectedValue: string = inputValue;
|
||||
|
||||
let value: string;
|
||||
|
||||
before(() => {
|
||||
value = ObfuscationTargetSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should sanitize value', () => {
|
||||
assert.equal(value, expectedValue);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: invalid obfuscation target', () => {
|
||||
const inputValue: string = 'foo';
|
||||
|
||||
let testFunc: () => void;
|
||||
|
||||
before(() => {
|
||||
testFunc = () => ObfuscationTargetSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should throw error', () => {
|
||||
assert.throw(testFunc, ReferenceError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,34 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { OptionsPresetSanitizer } from '../../../../src/cli/sanitizers/OptionsPresetSanitizer';
|
||||
|
||||
describe('OptionsPresetSanitizer', () => {
|
||||
describe('Variant #1: valid options preset', () => {
|
||||
const inputValue: string = 'low-obfuscation';
|
||||
const expectedValue: string = inputValue;
|
||||
|
||||
let value: string;
|
||||
|
||||
before(() => {
|
||||
value = OptionsPresetSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should sanitize value', () => {
|
||||
assert.equal(value, expectedValue);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: invalid options preset', () => {
|
||||
const inputValue: string = 'foo';
|
||||
|
||||
let testFunc: () => void;
|
||||
|
||||
before(() => {
|
||||
testFunc = () => OptionsPresetSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should throw error', () => {
|
||||
assert.throw(testFunc, ReferenceError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,34 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { SourceMapModeSanitizer } from '../../../../src/cli/sanitizers/SourceMapModeSanitizer';
|
||||
|
||||
describe('SourceMapModeSanitizer', () => {
|
||||
describe('Variant #1: valid source map mode', () => {
|
||||
const inputValue: string = 'inline';
|
||||
const expectedValue: string = inputValue;
|
||||
|
||||
let value: string;
|
||||
|
||||
before(() => {
|
||||
value = SourceMapModeSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should sanitize value', () => {
|
||||
assert.equal(value, expectedValue);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: invalid source map mode', () => {
|
||||
const inputValue: string = 'foo';
|
||||
|
||||
let testFunc: () => void;
|
||||
|
||||
before(() => {
|
||||
testFunc = () => SourceMapModeSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should throw error', () => {
|
||||
assert.throw(testFunc, ReferenceError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,70 +0,0 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { TStringArrayEncoding } from '../../../../src/types/options/TStringArrayEncoding';
|
||||
|
||||
import { StringArrayEncoding } from '../../../../src/enums/StringArrayEncoding';
|
||||
|
||||
import { StringArrayEncodingSanitizer } from '../../../../src/cli/sanitizers/StringArrayEncodingSanitizer';
|
||||
|
||||
describe('StringArrayEncodingSanitizer', () => {
|
||||
describe('Variant #1: string array encoding `base64`', () => {
|
||||
const inputValue: string = 'base64';
|
||||
const expectedValue: TStringArrayEncoding[] = [StringArrayEncoding.Base64];
|
||||
|
||||
let value: TStringArrayEncoding[];
|
||||
|
||||
before(() => {
|
||||
value = StringArrayEncodingSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should sanitize value', () => {
|
||||
assert.deepEqual(value, expectedValue);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #2: string array encoding `base64, rc4`', () => {
|
||||
const inputValue: string = 'base64,rc4';
|
||||
const expectedValue: TStringArrayEncoding[] = [
|
||||
StringArrayEncoding.Base64,
|
||||
StringArrayEncoding.Rc4
|
||||
];
|
||||
|
||||
let value: TStringArrayEncoding[];
|
||||
|
||||
before(() => {
|
||||
value = StringArrayEncodingSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should sanitize value', () => {
|
||||
assert.deepEqual(value, expectedValue);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #3: string array encoding `foo`', () => {
|
||||
const inputValue: string = 'foo';
|
||||
|
||||
let testFunc: () => TStringArrayEncoding[];
|
||||
|
||||
before(() => {
|
||||
testFunc = () => StringArrayEncodingSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should throw an error for invalid encoding', () => {
|
||||
assert.throws(testFunc, 'Invalid value');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #4: string array encoding `base64,foo`', () => {
|
||||
const inputValue: string = 'base64,foo';
|
||||
|
||||
let testFunc: () => TStringArrayEncoding[];
|
||||
|
||||
before(() => {
|
||||
testFunc = () => StringArrayEncodingSanitizer(inputValue);
|
||||
});
|
||||
|
||||
it('should throw an error for invalid encoding', () => {
|
||||
assert.throws(testFunc, 'Invalid value');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -2,6 +2,8 @@ import { assert } from 'chai';
|
||||
|
||||
import { TInputOptions } from '../../../../src/types/options/TInputOptions';
|
||||
|
||||
import { StringArrayEncoding } from '../../../../src/enums/StringArrayEncoding';
|
||||
|
||||
import { CLIUtils } from '../../../../src/cli/utils/CLIUtils';
|
||||
|
||||
describe('CLIUtils', () => {
|
||||
@@ -83,4 +85,20 @@ describe('CLIUtils', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('stringifyOptionAvailableValues', () => {
|
||||
describe('Variant #1: should stringify option available values', () => {
|
||||
const expectedResult: string = 'none, base64, rc4';
|
||||
|
||||
let result: Object;
|
||||
|
||||
before(() => {
|
||||
result = CLIUtils.stringifyOptionAvailableValues(StringArrayEncoding);
|
||||
});
|
||||
|
||||
it('should return option available values as string', () => {
|
||||
assert.deepEqual(result, expectedResult);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user