mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added tests for StringArrayRotateFunction transformer, code helper, and template
This commit is contained in:
+26
@@ -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\) *{/;
|
||||
|
||||
Reference in New Issue
Block a user