Browse Source

Added tests for `renameProperties` option integration with `splitStrings` option

sanex3339 5 years ago
parent
commit
a89e614ceb

+ 25 - 0
test/functional-tests/node-transformers/rename-properties-transformers/rename-properties-transformer/RenamePropertiesTransformer.spec.ts

@@ -292,6 +292,31 @@ describe('RenamePropertiesTransformer', () => {
                     assert.match(obfuscatedCode, regExp);
                 });
             });
+
+            describe('Variant #8: integration with `splitStrings` option', () => {
+                const propertyRegExp: RegExp = /'a': *'long' *\+ *'Prop' *\+ *'erty' *\+ *'Valu' *\+ *'e'/;
+
+                let obfuscatedCode: string;
+
+                before(() => {
+                    const code: string = readFileAsString(__dirname + '/fixtures/split-strings-integration.js');
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
+                        code,
+                        {
+                            ...NO_ADDITIONAL_NODES_PRESET,
+                            renameProperties: true,
+                            identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
+                            splitStrings: true,
+                            splitStringsChunkLength: 4
+                        }
+                    ).getObfuscatedCode();
+                });
+
+                it('Should rename property before `splitStrings` option will applied', () => {
+                    assert.match(obfuscatedCode, propertyRegExp);
+                });
+            });
         });
     });
 });

+ 3 - 0
test/functional-tests/node-transformers/rename-properties-transformers/rename-properties-transformer/fixtures/split-strings-integration.js

@@ -0,0 +1,3 @@
+const foo = {
+    longPropertyName: 'longPropertyValue'
+};