FunctionObfuscator.spec.ts 859 B

1234567891011121314151617181920
  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('FunctionObfuscator', () => {
  6. describe('obfuscation of identifiers of FunctionDeclaration and FunctionExpression node body', () => {
  7. it('should replace identifier name with obfuscated one', () => {
  8. let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
  9. `var test = 'test';`,
  10. Object.assign({}, NO_CUSTOM_NODES_PRESET)
  11. );
  12. assert.match(obfuscationResult.getObfuscatedCode(), /^var *test *= *'\\x74\\x65\\x73\\x74';$/);
  13. });
  14. });
  15. });