diff --git a/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts b/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts index da6b796d..747257d3 100644 --- a/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts +++ b/test/functional-tests/javascript-obfuscator/JavaScriptObfuscator.spec.ts @@ -569,6 +569,29 @@ describe('JavaScriptObfuscator', () => { }); }); + describe('dictionary identifier names generator', () => { + const regExp: RegExp = /var *[ab] *= *0x1; *var *[ab] *= *0x2; *var *A *= *0x3;/; + + let obfuscatedCode: string; + + beforeEach(() => { + const code: string = readFileAsString(__dirname + '/fixtures/dictionary-identifiers.js'); + + obfuscatedCode = JavaScriptObfuscator.obfuscate( + code, + { + ...NO_ADDITIONAL_NODES_PRESET, + identifierNamesGenerator: IdentifierNamesGenerator.DictionaryIdentifierNamesGenerator, + identifiersDictionary: ['a', 'b'] + } + ).getObfuscatedCode(); + }); + + it('should generate identifier based on the dictionary', () => { + assert.match(obfuscatedCode, regExp); + }); + }); + describe('parse module', () => { describe('Variant #1: import', () => { const importRegExp: RegExp = /import *{foo} *from *'.\/foo';/; diff --git a/test/functional-tests/javascript-obfuscator/fixtures/dictionary-identifiers.js b/test/functional-tests/javascript-obfuscator/fixtures/dictionary-identifiers.js new file mode 100644 index 00000000..7d32f275 --- /dev/null +++ b/test/functional-tests/javascript-obfuscator/fixtures/dictionary-identifiers.js @@ -0,0 +1,5 @@ +(function () { + var test1 = 1; + var test2 = 2; + var test3 = 3; +})(); \ No newline at end of file