DomainLockNode.spec.ts 1.1 KB

1234567891011121314151617181920212223242526272829
  1. import { IObfuscationResult } from "../../../../src/interfaces/IObfuscationResult";
  2. import { JavaScriptObfuscator } from "../../../../src/JavaScriptObfuscator";
  3. const assert: Chai.AssertStatic = require('chai').assert;
  4. describe('DomainLockNode', () => {
  5. it('should correctly append `DomainLockNode` custom node into the obfuscated code if `domainLock` option is set', () => {
  6. let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
  7. `var test = 'test';`,
  8. {
  9. domainLock: ['.example.com']
  10. }
  11. );
  12. assert.match(obfuscationResult.getObfuscatedCode(), /var _0x([a-z0-9]){5,6} *= *new RegExp/);
  13. });
  14. it('should\'t append `DomainLockNode` custom node into the obfuscated code if `domainLock` option is not set', () => {
  15. let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
  16. `var test = 'test';`,
  17. {
  18. domainLock: []
  19. }
  20. );
  21. assert.notMatch(obfuscationResult.getObfuscatedCode(), /var _0x([a-z0-9]){5,6} *= *new RegExp/);
  22. });
  23. });