mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
fixed tests
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { Chance } from 'chance';
|
||||
|
||||
import { IObfuscationResult } from '../../src/interfaces/IObfuscationResult';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../src/JavaScriptObfuscator';
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from '../../src/preset-options/NoCustomNodesPreset';
|
||||
import { readFileAsString } from '../helpers/readFileAsString';
|
||||
import { RandomGeneratorUtils } from '../../src/utils/RandomGeneratorUtils';
|
||||
|
||||
describe('JavaScriptObfuscator', () => {
|
||||
describe('obfuscate (sourceCode: string, customOptions?: IObfuscatorOptions): IObfuscationResult', () => {
|
||||
beforeEach(() => {
|
||||
RandomGeneratorUtils.setRandomGenerator(new Chance());
|
||||
});
|
||||
|
||||
describe('if `sourceMap` option is `false`', () => {
|
||||
it('should returns object with obfuscated code and empty source map', () => {
|
||||
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
|
||||
@@ -171,5 +178,9 @@ describe('JavaScriptObfuscator', () => {
|
||||
assert.notEqual(obfuscationResult1.getObfuscatedCode(), obfuscationResult2.getObfuscatedCode());
|
||||
assert.notEqual(obfuscationResult3.getObfuscatedCode(), obfuscationResult4.getObfuscatedCode());
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
RandomGeneratorUtils.setRandomGenerator(new Chance());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+4
-2
@@ -31,7 +31,9 @@ describe('BinaryExpressionControlFlowReplacer', () => {
|
||||
|
||||
describe('variant #2 - multiple binary expressions with threshold = 1', () => {
|
||||
it('should replace binary expression node by call to control flow storage node', () => {
|
||||
const samplesCount: number = 50;
|
||||
const samplesCount: number = 100;
|
||||
const expectedValue: number = 0.5;
|
||||
const delta: number = 0.08;
|
||||
|
||||
let equalsValue: number = 0;
|
||||
|
||||
@@ -66,7 +68,7 @@ describe('BinaryExpressionControlFlowReplacer', () => {
|
||||
}
|
||||
}
|
||||
|
||||
assert.closeTo(equalsValue / samplesCount, 0.5, 0.05);
|
||||
assert.closeTo(equalsValue / samplesCount, expectedValue, delta);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user