Browse Source

utils tests

sanex3339 9 years ago
parent
commit
f77c02af8d
2 changed files with 42 additions and 0 deletions
  1. 42 0
      test/OptionsNormalizer.spec.ts
  2. 0 0
      test/Utils.spec.ts

+ 42 - 0
test/OptionsNormalizer.spec.ts

@@ -0,0 +1,42 @@
+import { IOptionsPreset } from "../src/interfaces/IOptionsPreset";
+
+import { OptionsNormalizer } from '../src/OptionsNormalizer';
+
+import { DEFAULT_PRESET } from '../src/preset-options/DefaultPreset';
+
+let assert: any = require('chai').assert;
+
+describe('OptionsNormalizer', () => {
+    describe('normalizeOptionsPreset (options: IOptionsPreset): IOptionsPreset', () => {
+        let optionsPreset1: IOptionsPreset = Object.assign({}, DEFAULT_PRESET, {
+                compact: false,
+                rotateUnicodeArray: true,
+                unicodeArray: false,
+                unicodeArrayThreshold: 0.5,
+                wrapUnicodeArrayCalls: true
+
+            }),
+            optionsPreset2: IOptionsPreset = Object.assign({}, DEFAULT_PRESET, {
+                unicodeArrayThreshold: 2
+
+            });
+
+        it('should normalize options preset', () => {
+            assert.deepEqual(
+                OptionsNormalizer.normalizeOptionsPreset(optionsPreset1), Object.assign({}, DEFAULT_PRESET, {
+                    compact: true,
+                    rotateUnicodeArray: false,
+                    unicodeArray: false,
+                    unicodeArrayThreshold: 0,
+                    wrapUnicodeArrayCalls: false
+                })
+            );
+
+            assert.deepEqual(
+                OptionsNormalizer.normalizeOptionsPreset(optionsPreset2), Object.assign({}, DEFAULT_PRESET, {
+                    unicodeArrayThreshold: 1
+                })
+            );
+        });
+    });
+});

+ 0 - 0
test/utils.spec.ts → test/Utils.spec.ts