1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import { IObfuscatorOptions } from '../../src/interfaces/IObfuscatorOptions';
- import { IOptions } from '../../src/interfaces/IOptions';
- import { DEFAULT_PRESET } from '../../src/preset-options/DefaultPreset';
- import { Options } from '../../src/options/Options';
- import { OptionsNormalizer } from '../../src/options/OptionsNormalizer';
- const assert: Chai.AssertStatic = require('chai').assert;
- describe('OptionsNormalizer', () => {
- describe('normalizeOptions (options: IObfuscatorOptions): IObfuscatorOptions', () => {
- let options1: IOptions,
- options2: IOptions,
- options3: IOptions,
- optionsPreset1: IObfuscatorOptions,
- optionsPreset2: IObfuscatorOptions,
- optionsPreset3: IObfuscatorOptions,
- expectedOptionsPreset1: IObfuscatorOptions,
- expectedOptionsPreset2: IObfuscatorOptions,
- expectedOptionsPreset3: IObfuscatorOptions;
- beforeEach(() => {
- optionsPreset1 = Object.assign({}, DEFAULT_PRESET, {
- compact: false,
- rotateUnicodeArray: true,
- sourceMapBaseUrl: 'http://localhost:9000',
- unicodeArray: false,
- unicodeArrayThreshold: 0.5,
- wrapUnicodeArrayCalls: true
- });
- optionsPreset2 = Object.assign({}, DEFAULT_PRESET, {
- rotateUnicodeArray: true,
- sourceMapBaseUrl: 'http://localhost:9000',
- sourceMapFileName: '//outputSourceMapName',
- unicodeArray: true,
- unicodeArrayThreshold: 0,
- wrapUnicodeArrayCalls: true
- });
- optionsPreset3 = Object.assign({}, DEFAULT_PRESET, {
- domainLock: ['//localhost:9000', 'https://google.ru/abc?cde=fgh'],
- sourceMapFileName: '/outputSourceMapName.map',
- unicodeArray: true,
- encodeUnicodeLiterals: true,
- wrapUnicodeArrayCalls: false
- });
- expectedOptionsPreset1 = Object.assign({}, DEFAULT_PRESET, {
- compact: true,
- rotateUnicodeArray: false,
- sourceMapBaseUrl: '',
- unicodeArray: false,
- unicodeArrayThreshold: 0,
- wrapUnicodeArrayCalls: false
- });
- expectedOptionsPreset2 = Object.assign({}, DEFAULT_PRESET, {
- rotateUnicodeArray: false,
- sourceMapBaseUrl: 'http://localhost:9000/',
- sourceMapFileName: 'outputSourceMapName.js.map',
- unicodeArray: false,
- unicodeArrayThreshold: 0,
- wrapUnicodeArrayCalls: false
- });
- expectedOptionsPreset3 = Object.assign({}, DEFAULT_PRESET, {
- domainLock: ['localhost', 'google.ru'],
- sourceMapFileName: 'outputSourceMapName.js.map',
- unicodeArray: true,
- encodeUnicodeLiterals: true,
- wrapUnicodeArrayCalls: true
- });
- options1 = new Options(optionsPreset1);
- options2 = new Options(optionsPreset2);
- options3 = new Options(optionsPreset3);
- });
- it('should normalize options preset', () => {
- assert.deepEqual(OptionsNormalizer.normalizeOptions(options1), expectedOptionsPreset1);
- assert.deepEqual(OptionsNormalizer.normalizeOptions(options2), expectedOptionsPreset2);
- assert.deepEqual(OptionsNormalizer.normalizeOptions(options3), expectedOptionsPreset3);
- });
- });
- });
|