Added functional tests for dictionary names generator

This commit is contained in:
sanex3339
2019-12-31 14:13:30 +03:00
parent fa67ddee16
commit 9c186a4e34
2 changed files with 28 additions and 0 deletions
@@ -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';/;
@@ -0,0 +1,5 @@
(function () {
var test1 = 1;
var test2 = 2;
var test3 = 3;
})();