mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
This commit is contained in:
@@ -35,7 +35,6 @@ import { NO_CUSTOM_NODES_PRESET } from '../../src/options/presets/NoCustomNodes'
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET,
|
||||
compact: false,
|
||||
identifierNamesGenerator: 'mangled'
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
|
||||
|
||||
+3
-2
@@ -9,14 +9,13 @@ import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
describe('MethodDefinitionTransformer', () => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/input.js');
|
||||
|
||||
describe('variant #1: default behaviour', () => {
|
||||
const regExp: RegExp = /\['bar'\]\(\)\{\}/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
@@ -39,6 +38,7 @@ describe('MethodDefinitionTransformer', () => {
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
@@ -66,6 +66,7 @@ describe('MethodDefinitionTransformer', () => {
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/sample-input.js');
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
|
||||
+1
-1
@@ -280,7 +280,7 @@ describe('DeadCodeInjectionTransformer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('variant #7- chance of `IfStatement` variant', () => {
|
||||
describe('variant #7 - chance of `IfStatement` variant', () => {
|
||||
const samplesCount: number = 1000;
|
||||
const delta: number = 0.1;
|
||||
const expectedDistribution: number = 0.25;
|
||||
|
||||
+22
@@ -413,4 +413,26 @@ describe('VariableDeclarationTransformer', () => {
|
||||
assert.match(obfuscatedCode, computedObjectExpressionRegExp);
|
||||
});
|
||||
});
|
||||
|
||||
describe('variant #12: method definition key identifier', () => {
|
||||
const regExp: RegExp = /\['bar'] *\(\) *{}/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/method-definition-identifier.js');
|
||||
const obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_CUSTOM_NODES_PRESET
|
||||
}
|
||||
);
|
||||
|
||||
obfuscatedCode = obfuscationResult.getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('shouldn\'t transform method definition node key identifier', () => {
|
||||
assert.match(obfuscatedCode, regExp);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
(function () {
|
||||
var bar = 1;
|
||||
|
||||
class Foo {
|
||||
bar() {}
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user