OptionsNormalizer.spec.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { IObfuscatorOptions } from "../../src/interfaces/IObfuscatorOptions";
  2. import { OptionsNormalizer } from '../../src/OptionsNormalizer';
  3. import { DEFAULT_PRESET } from '../../src/preset-options/DefaultPreset';
  4. const assert: Chai.AssertStatic = require('chai').assert;
  5. describe('OptionsNormalizer', () => {
  6. describe('normalizeOptions (options: IObfuscatorOptions): IObfuscatorOptions', () => {
  7. let optionsPreset1: IObfuscatorOptions,
  8. optionsPreset2: IObfuscatorOptions;
  9. beforeEach(() => {
  10. optionsPreset1 = Object.assign({}, DEFAULT_PRESET, {
  11. compact: false,
  12. rotateUnicodeArray: true,
  13. unicodeArray: false,
  14. unicodeArrayThreshold: 0.5,
  15. wrapUnicodeArrayCalls: true
  16. });
  17. optionsPreset2 = Object.assign({}, DEFAULT_PRESET, {
  18. rotateUnicodeArray: true,
  19. unicodeArray: true,
  20. unicodeArrayThreshold: 0,
  21. wrapUnicodeArrayCalls: true
  22. });
  23. });
  24. it('should normalize options preset', () => {
  25. assert.deepEqual(
  26. OptionsNormalizer.normalizeOptions(optionsPreset1), Object.assign({}, DEFAULT_PRESET, {
  27. compact: true,
  28. rotateUnicodeArray: false,
  29. unicodeArray: false,
  30. unicodeArrayThreshold: 0,
  31. wrapUnicodeArrayCalls: false
  32. })
  33. );
  34. assert.deepEqual(
  35. OptionsNormalizer.normalizeOptions(optionsPreset2), Object.assign({}, DEFAULT_PRESET, {
  36. rotateUnicodeArray: false,
  37. unicodeArray: false,
  38. unicodeArrayThreshold: 0,
  39. wrapUnicodeArrayCalls: false
  40. })
  41. );
  42. });
  43. });
  44. });