mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Fixed order of StringArrayCallsWrapper code helpers, added tests
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { StringArrayEncoding } from '../../../../../src/enums/StringArrayEncoding';
|
||||
import { IdentifierNamesGenerator } from '../../../../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
describe('StringArrayCodeHelperGroup', () => {
|
||||
const regExp: RegExp = new RegExp(
|
||||
'var b *= *function\\(\\w, *\\w\\) *{.*return \\w;}; *' +
|
||||
'var c *= *function\\(\\w, *\\w\\) *{.*return \\w;}; *' +
|
||||
'var d *= *function\\(\\w, *\\w\\) *{.*return \\w;};'
|
||||
);
|
||||
|
||||
describe('StringArrayCallsWrapper code helper names', () => {
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
|
||||
stringArray: true,
|
||||
stringArrayThreshold: 1,
|
||||
stringArrayEncoding: [
|
||||
StringArrayEncoding.None,
|
||||
StringArrayEncoding.Base64,
|
||||
StringArrayEncoding.Rc4
|
||||
]
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('should place multiple StringArrayCallsWrapper code helper names in the correct order', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
var foo = 'foo';
|
||||
var bar = 'bar';
|
||||
var baz = 'baz';
|
||||
Reference in New Issue
Block a user