fixed tests

This commit is contained in:
sanex3339
2016-12-18 01:08:20 +03:00
parent b0a18660bb
commit 421ee62af6
6 changed files with 39 additions and 23 deletions
@@ -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());
});
});
});
@@ -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);
});
});
});