|
@@ -577,6 +577,75 @@ describe('LiteralTransformer', () => {
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ describe('Variant #14: import declaration source literal', () => {
|
|
|
+ const importDeclarationRegExp: RegExp = /import *{ *bar *} *from *'foo';/;
|
|
|
+
|
|
|
+ let obfuscatedCode: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const code: string = readFileAsString(__dirname + '/fixtures/import-declaration-source.js');
|
|
|
+
|
|
|
+ obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
|
|
+ code,
|
|
|
+ {
|
|
|
+ ...NO_ADDITIONAL_NODES_PRESET,
|
|
|
+ stringArray: true,
|
|
|
+ stringArrayThreshold: 1
|
|
|
+ }
|
|
|
+ ).getObfuscatedCode();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('Should not add `ImportDeclaration` source literal to the string array', () => {
|
|
|
+ assert.match(obfuscatedCode, importDeclarationRegExp);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('Variant #15: export all declaration source literal', () => {
|
|
|
+ const exportAllDeclarationRegExp: RegExp = /export *\* *from *'foo';/;
|
|
|
+
|
|
|
+ let obfuscatedCode: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const code: string = readFileAsString(__dirname + '/fixtures/export-all-declaration-source.js');
|
|
|
+
|
|
|
+ obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
|
|
+ code,
|
|
|
+ {
|
|
|
+ ...NO_ADDITIONAL_NODES_PRESET,
|
|
|
+ stringArray: true,
|
|
|
+ stringArrayThreshold: 1
|
|
|
+ }
|
|
|
+ ).getObfuscatedCode();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('Should not add `ExportAllDeclaration` source literal to the string array', () => {
|
|
|
+ assert.match(obfuscatedCode, exportAllDeclarationRegExp);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('Variant #16: export named declaration source literal', () => {
|
|
|
+ const exportNamedDeclarationRegExp: RegExp = /export *{ *bar *} *from *'foo';/;
|
|
|
+
|
|
|
+ let obfuscatedCode: string;
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ const code: string = readFileAsString(__dirname + '/fixtures/export-named-declaration-source.js');
|
|
|
+
|
|
|
+ obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
|
|
+ code,
|
|
|
+ {
|
|
|
+ ...NO_ADDITIONAL_NODES_PRESET,
|
|
|
+ stringArray: true,
|
|
|
+ stringArrayThreshold: 1
|
|
|
+ }
|
|
|
+ ).getObfuscatedCode();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('Should not add `ExportNamedDeclaration` source literal to the string array', () => {
|
|
|
+ assert.match(obfuscatedCode, exportNamedDeclarationRegExp);
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
describe('transformation of literal node with boolean value', () => {
|