StringsArrayCallsWrapper.spec.ts 967 B

12345678910111213141516171819202122232425
  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('StringsArrayCallsWrapper', () => {
  6. it('should correctly append `StringsArrayCallsWrapper` custom node into the obfuscated code', () => {
  7. let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
  8. `var test = 'test';`,
  9. Object.assign({}, NO_CUSTOM_NODES_PRESET, {
  10. stringsArray: true,
  11. stringsArrayThreshold: 1,
  12. wrapStringsArrayCalls: true
  13. })
  14. );
  15. assert.match(
  16. obfuscationResult.getObfuscatedCode(),
  17. /var *_0x([a-z0-9]){4,6} *= *parseInt\(_0x([a-z0-9]){4,6}, *0x10\);/
  18. );
  19. });
  20. });