Fixed order of StringArrayCallsWrapper code helpers, added tests

This commit is contained in:
sanex
2020-08-31 09:41:15 +03:00
parent 42ff66849e
commit 017ade47db
8 changed files with 57 additions and 6 deletions
@@ -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';