Added tests for StringArrayRotateFunction transformer, code helper, and template

This commit is contained in:
sanex
2020-12-29 17:17:26 +03:00
parent 6ed3d4e3ed
commit 3f5b2c6811
7 changed files with 216 additions and 1 deletions
@@ -57,6 +57,32 @@ describe('StringArrayRotateFunctionCodeHelper', () => {
});
});
describe('Comparison expression', () => {
describe('Should add comparison expression to the code helper', () => {
const comparisonExpressionRegExp: RegExp = /var _0x([a-f0-9]){4,6} *= *-?parseInt\(_0x([a-f0-9]){4,6}\(0x.\)\)/;
let obfuscatedCode: string;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
rotateStringArray: true,
stringArray: true,
stringArrayThreshold: 1
}
).getObfuscatedCode();
});
it('should add comparison expression to the code', () => {
assert.match(obfuscatedCode, comparisonExpressionRegExp);
});
});
});
describe('Preserve string array name', () => {
const arrayRotateRegExp: RegExp = /c\['push']\(c\['shift']\(\)\);/;
const comparisonRegExp: RegExp = /if *\(e *=== *d\) *{/;