OptionsNormalizer.spec.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 = Object.assign({}, DEFAULT_PRESET, {
  8. compact: false,
  9. rotateUnicodeArray: true,
  10. unicodeArray: false,
  11. unicodeArrayThreshold: 0.5,
  12. wrapUnicodeArrayCalls: true
  13. }),
  14. optionsPreset2: IOptionsPreset = Object.assign({}, DEFAULT_PRESET, {
  15. unicodeArrayThreshold: 2
  16. });
  17. it('should normalize options preset', () => {
  18. assert.deepEqual(
  19. OptionsNormalizer.normalizeOptionsPreset(optionsPreset1), Object.assign({}, DEFAULT_PRESET, {
  20. compact: true,
  21. rotateUnicodeArray: false,
  22. unicodeArray: false,
  23. unicodeArrayThreshold: 0,
  24. wrapUnicodeArrayCalls: false
  25. })
  26. );
  27. assert.deepEqual(
  28. OptionsNormalizer.normalizeOptionsPreset(optionsPreset2), Object.assign({}, DEFAULT_PRESET, {
  29. unicodeArrayThreshold: 1
  30. })
  31. );
  32. });
  33. });
  34. });