OptionsNormalizer.spec.ts 1.6 KB

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