OptionsNormalizer.spec.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { IOptionsPreset } from "../../src/interfaces/IOptionsPreset";
  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('normalizeOptionsPreset (options: IOptionsPreset): IOptionsPreset', () => {
  7. let optionsPreset1: IOptionsPreset,
  8. optionsPreset2: IOptionsPreset;
  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. unicodeArrayThreshold: 2
  19. });
  20. });
  21. it('should normalize options preset', () => {
  22. assert.deepEqual(
  23. OptionsNormalizer.normalizeOptionsPreset(optionsPreset1), Object.assign({}, DEFAULT_PRESET, {
  24. compact: true,
  25. rotateUnicodeArray: false,
  26. unicodeArray: false,
  27. unicodeArrayThreshold: 0,
  28. wrapUnicodeArrayCalls: false
  29. })
  30. );
  31. assert.deepEqual(
  32. OptionsNormalizer.normalizeOptionsPreset(optionsPreset2), Object.assign({}, DEFAULT_PRESET, {
  33. unicodeArrayThreshold: 1
  34. })
  35. );
  36. });
  37. });
  38. });