Ver código fonte

options validation with Joi tests update

sanex3339 8 anos atrás
pai
commit
821b7d06bb
2 arquivos alterados com 18 adições e 3 exclusões
  1. 1 2
      test/dev/test.ts
  2. 17 1
      test/unit-tests/OptionsNormalizer.spec.ts

+ 1 - 2
test/dev/test.ts

@@ -60,8 +60,7 @@ let obfuscatedCode: string = JavaScriptObfuscator.obfuscate(
     `,
     `,
     {
     {
         disableConsoleOutput: false,
         disableConsoleOutput: false,
-        encodeUnicodeLiterals: true,
-        unicodeArrayThreshold: 2
+        encodeUnicodeLiterals: true
     }
     }
 ).getObfuscatedCode();
 ).getObfuscatedCode();
 
 

+ 17 - 1
test/unit-tests/OptionsNormalizer.spec.ts

@@ -8,7 +8,8 @@ const assert: Chai.AssertStatic = require('chai').assert;
 
 
 describe('OptionsNormalizer', () => {
 describe('OptionsNormalizer', () => {
     describe('normalizeOptions (options: IObfuscatorOptions): IObfuscatorOptions', () => {
     describe('normalizeOptions (options: IObfuscatorOptions): IObfuscatorOptions', () => {
-        let optionsPreset1: IObfuscatorOptions;
+        let optionsPreset1: IObfuscatorOptions,
+            optionsPreset2: IObfuscatorOptions;
 
 
         beforeEach(() => {
         beforeEach(() => {
             optionsPreset1 = Object.assign({}, DEFAULT_PRESET, {
             optionsPreset1 = Object.assign({}, DEFAULT_PRESET, {
@@ -18,6 +19,12 @@ describe('OptionsNormalizer', () => {
                 unicodeArrayThreshold: 0.5,
                 unicodeArrayThreshold: 0.5,
                 wrapUnicodeArrayCalls: true
                 wrapUnicodeArrayCalls: true
             });
             });
+            optionsPreset2 = Object.assign({}, DEFAULT_PRESET, {
+                rotateUnicodeArray: true,
+                unicodeArray: true,
+                unicodeArrayThreshold: 0,
+                wrapUnicodeArrayCalls: true
+            });
         });
         });
 
 
         it('should normalize options preset', () => {
         it('should normalize options preset', () => {
@@ -30,6 +37,15 @@ describe('OptionsNormalizer', () => {
                     wrapUnicodeArrayCalls: false
                     wrapUnicodeArrayCalls: false
                 })
                 })
             );
             );
+
+            assert.deepEqual(
+                OptionsNormalizer.normalizeOptions(optionsPreset2), Object.assign({}, DEFAULT_PRESET, {
+                    rotateUnicodeArray: false,
+                    unicodeArray: false,
+                    unicodeArrayThreshold: 0,
+                    wrapUnicodeArrayCalls: false
+                })
+            );
         });
         });
     });
     });
 });
 });