Switched esprima on espree. Obfuscation of export declarations

This commit is contained in:
sanex3339
2018-03-25 20:32:08 +03:00
parent 6f480a6f6f
commit 3ea05aa0e1
50 changed files with 1054 additions and 712 deletions
@@ -594,19 +594,43 @@ describe('JavaScriptObfuscator', () => {
});
describe('parse module', () => {
const regExp: RegExp = /var *test *= *0x1/;
describe('Variant #1: import', () => {
const importRegExp: RegExp = /import *{foo} *from *'.\/foo';/;
const variableDeclarationRegExp: RegExp = /var *test *= *0x1/;
let obfuscatedCode: string;
let obfuscatedCode: string;
beforeEach(() => {
const code: string = readFileAsString(__dirname + '/fixtures/parse-module.js');
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(code);
beforeEach(() => {
const code: string = readFileAsString(__dirname + '/fixtures/parse-module-1.js');
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(code);
obfuscatedCode = obfuscationResult.getObfuscatedCode();
obfuscatedCode = obfuscationResult.getObfuscatedCode();
});
it('Match #!: should correctly obfuscate a import', () => {
assert.match(obfuscatedCode, importRegExp);
});
it('Match #2: should correctly obfuscate a module', () => {
assert.match(obfuscatedCode, variableDeclarationRegExp);
});
});
it('should correctly obfuscate a module', () => {
assert.match(obfuscatedCode, regExp);
describe('Variant #2: export', () => {
const regExp: RegExp = /export *const *foo *= *0x1;/;
let obfuscatedCode: string;
beforeEach(() => {
const code: string = readFileAsString(__dirname + '/fixtures/parse-module-2.js');
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(code);
obfuscatedCode = obfuscationResult.getObfuscatedCode();
});
it('should correctly obfuscate a module', () => {
assert.match(obfuscatedCode, regExp);
});
});
});