StringArrayCodeHelperGroup.spec.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { assert } from 'chai';
  2. import { StringArrayEncoding } from '../../../../../src/enums/StringArrayEncoding';
  3. import { IdentifierNamesGenerator } from '../../../../../src/enums/generators/identifier-names-generators/IdentifierNamesGenerator';
  4. import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../src/options/presets/NoCustomNodes';
  5. import { readFileAsString } from '../../../../helpers/readFileAsString';
  6. import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
  7. describe('StringArrayCodeHelperGroup', () => {
  8. const regExp: RegExp = new RegExp(
  9. 'var b *= *function\\(\\w, *\\w\\) *{.*return \\w;}; *' +
  10. 'var c *= *function\\(\\w, *\\w\\) *{.*return \\w;}; *' +
  11. 'var d *= *function\\(\\w, *\\w\\) *{.*return \\w;};'
  12. );
  13. describe('StringArrayCallsWrapper code helper names', () => {
  14. let obfuscatedCode: string;
  15. before(() => {
  16. const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
  17. obfuscatedCode = JavaScriptObfuscator.obfuscate(
  18. code,
  19. {
  20. ...NO_ADDITIONAL_NODES_PRESET,
  21. identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
  22. stringArray: true,
  23. stringArrayThreshold: 1,
  24. stringArrayEncoding: [
  25. StringArrayEncoding.None,
  26. StringArrayEncoding.Base64,
  27. StringArrayEncoding.Rc4
  28. ]
  29. }
  30. ).getObfuscatedCode();
  31. });
  32. it('should place multiple StringArrayCallsWrapper code helper names in the correct order', () => {
  33. assert.match(obfuscatedCode, regExp);
  34. });
  35. });
  36. });