UnicodeArrayNode.spec.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. import { IObfuscationResult } from '../../../../src/interfaces/IObfuscationResult';
  2. import { NO_CUSTOM_NODES_PRESET } from '../../../../src/preset-options/NoCustomNodesPreset';
  3. import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscator';
  4. const assert: Chai.AssertStatic = require('chai').assert;
  5. describe('UnicodeArrayNode', () => {
  6. it('should correctly appendNode `UnicodeArrayNode` custom node into the obfuscated code if `unicodeArray` option is set', () => {
  7. let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
  8. `var test = 'test';`,
  9. Object.assign({}, NO_CUSTOM_NODES_PRESET, {
  10. unicodeArray: true,
  11. unicodeArrayThreshold: 1
  12. })
  13. );
  14. assert.match(obfuscationResult.getObfuscatedCode(), /^var _0x([a-z0-9]){4} *= *\[/);
  15. });
  16. it('should\'t appendNode `UnicodeArrayNode` custom node into the obfuscated code if `unicodeArray` option is not set', () => {
  17. let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
  18. `var test = 'test';`,
  19. Object.assign({}, NO_CUSTOM_NODES_PRESET, {
  20. unicodeArray: false
  21. })
  22. );
  23. assert.notMatch(obfuscationResult.getObfuscatedCode(), /^var _0x([a-z0-9]){4} *= *\[/);
  24. });
  25. });