Explorar o código

JavaScriptObfuscator tests

sanex3339 %!s(int64=9) %!d(string=hai) anos
pai
achega
7ddf2a0fd1
Modificáronse 1 ficheiros con 26 adicións e 0 borrados
  1. 26 0
      test/JavaScriptObfuscator.spec.ts

+ 26 - 0
test/JavaScriptObfuscator.spec.ts

@@ -26,5 +26,31 @@ describe('JavaScriptObfuscator', () => {
                 /^\(function *\(\) *\{ *var *_0x[\w]+ *= *0x\d+; *\}(\(\)\)|\)\(\));?$/
                 /^\(function *\(\) *\{ *var *_0x[\w]+ *= *0x\d+; *\}(\(\)\)|\)\(\));?$/
             );
             );
         });
         });
+
+        it('should obfuscate simple code with literal variable value', () => {
+            let pattern = /^var _0x(\w){4} *= *\['(\\[x|u]\d+)+'\]; *var *test *= *_0x(\w){4}\[0x0\];$/;
+
+            assert.match(
+                JavaScriptObfuscator.obfuscate(
+                    `var test = 'abc';`,
+                    Object.assign({}, DEFAULT_PRESET, NO_CUSTOM_NODES_PRESET, {
+                        unicodeArray: true,
+                        unicodeArrayThreshold: 1
+                    })
+                ),
+                pattern
+            );
+
+            assert.match(
+                JavaScriptObfuscator.obfuscate(
+                    `var test = 'абц';`,
+                    Object.assign({}, DEFAULT_PRESET, NO_CUSTOM_NODES_PRESET, {
+                        unicodeArray: true,
+                        unicodeArrayThreshold: 1
+                    })
+                ),
+                pattern
+            );
+        });
     });
     });
 });
 });