mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Added functional tests for dictionary names generator
This commit is contained in:
@@ -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;
|
||||
})();
|
||||
Reference in New Issue
Block a user