From 821b7d06bbe20e19b8eaa5cb12d9906477a07207 Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Wed, 13 Jul 2016 13:58:11 +0300 Subject: [PATCH] options validation with Joi tests update --- test/dev/test.ts | 3 +-- test/unit-tests/OptionsNormalizer.spec.ts | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/test/dev/test.ts b/test/dev/test.ts index df482887..0c85a081 100644 --- a/test/dev/test.ts +++ b/test/dev/test.ts @@ -60,8 +60,7 @@ let obfuscatedCode: string = JavaScriptObfuscator.obfuscate( `, { disableConsoleOutput: false, - encodeUnicodeLiterals: true, - unicodeArrayThreshold: 2 + encodeUnicodeLiterals: true } ).getObfuscatedCode(); diff --git a/test/unit-tests/OptionsNormalizer.spec.ts b/test/unit-tests/OptionsNormalizer.spec.ts index 765d0052..c987296b 100644 --- a/test/unit-tests/OptionsNormalizer.spec.ts +++ b/test/unit-tests/OptionsNormalizer.spec.ts @@ -8,7 +8,8 @@ const assert: Chai.AssertStatic = require('chai').assert; describe('OptionsNormalizer', () => { describe('normalizeOptions (options: IObfuscatorOptions): IObfuscatorOptions', () => { - let optionsPreset1: IObfuscatorOptions; + let optionsPreset1: IObfuscatorOptions, + optionsPreset2: IObfuscatorOptions; beforeEach(() => { optionsPreset1 = Object.assign({}, DEFAULT_PRESET, { @@ -18,6 +19,12 @@ describe('OptionsNormalizer', () => { unicodeArrayThreshold: 0.5, wrapUnicodeArrayCalls: true }); + optionsPreset2 = Object.assign({}, DEFAULT_PRESET, { + rotateUnicodeArray: true, + unicodeArray: true, + unicodeArrayThreshold: 0, + wrapUnicodeArrayCalls: true + }); }); it('should normalize options preset', () => { @@ -30,6 +37,15 @@ describe('OptionsNormalizer', () => { wrapUnicodeArrayCalls: false }) ); + + assert.deepEqual( + OptionsNormalizer.normalizeOptions(optionsPreset2), Object.assign({}, DEFAULT_PRESET, { + rotateUnicodeArray: false, + unicodeArray: false, + unicodeArrayThreshold: 0, + wrapUnicodeArrayCalls: false + }) + ); }); }); });