mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
added back babel-polyfill
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import { BabelPolyfill } from 'polyfills/BabelPolyfill';
|
||||
|
||||
import { JavaScriptObfuscator } from "../src/JavaScriptObfuscator";
|
||||
|
||||
import { NO_CUSTOM_NODES_PRESET } from "../src/preset-options/NoCustomNodesPreset";
|
||||
|
||||
const assert: Chai.AssertStatic = require('chai').assert;
|
||||
|
||||
BabelPolyfill.append();
|
||||
|
||||
describe('JavaScriptObfuscator', () => {
|
||||
describe('obfuscate (sourceCode: string, customOptions?: IOptionsPreset): string', () => {
|
||||
it('should obfuscate simple code with variable inside global scope', () => {
|
||||
|
||||
@@ -2,12 +2,16 @@ import * as fs from 'fs';
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import * as sinon from 'sinon';
|
||||
|
||||
import { BabelPolyfill } from 'polyfills/BabelPolyfill';
|
||||
|
||||
import { StdoutWriteMock } from "../test/mocks/StdoutWriteMock";
|
||||
|
||||
import { JavaScriptObfuscator } from "../src/JavaScriptObfuscator";
|
||||
|
||||
const assert: Chai.AssertStatic = require('chai').assert;
|
||||
|
||||
BabelPolyfill.append();
|
||||
|
||||
describe('JavaScriptObfuscatorCLI', function (): void {
|
||||
let fixturesDirName: string = 'test/fixtures',
|
||||
fixtureFileName: string = 'sample.js',
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { BabelPolyfill } from 'polyfills/BabelPolyfill';
|
||||
|
||||
import { IBlockStatementNode } from "../src/interfaces/nodes/IBlockStatementNode";
|
||||
import { IFunctionDeclarationNode } from "../src/interfaces/nodes/IFunctionDeclarationNode";
|
||||
import { IIdentifierNode } from "../src/interfaces/nodes/IIdentifierNode";
|
||||
@@ -12,6 +14,8 @@ import { NodeUtils } from '../src/NodeUtils';
|
||||
|
||||
const assert: any = require('chai').assert;
|
||||
|
||||
BabelPolyfill.append();
|
||||
|
||||
function getProgramNode (bodyNodes: INode[] = []): IProgramNode {
|
||||
return {
|
||||
type: NodeType.Program,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { BabelPolyfill } from 'polyfills/BabelPolyfill';
|
||||
|
||||
import { IOptionsPreset } from "../src/interfaces/IOptionsPreset";
|
||||
|
||||
import { OptionsNormalizer } from '../src/OptionsNormalizer';
|
||||
@@ -6,6 +8,8 @@ import { DEFAULT_PRESET } from '../src/preset-options/DefaultPreset';
|
||||
|
||||
const assert: Chai.AssertStatic = require('chai').assert;
|
||||
|
||||
BabelPolyfill.append();
|
||||
|
||||
describe('OptionsNormalizer', () => {
|
||||
describe('normalizeOptionsPreset (options: IOptionsPreset): IOptionsPreset', () => {
|
||||
let optionsPreset1: IOptionsPreset = Object.assign({}, DEFAULT_PRESET, {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { BabelPolyfill } from 'polyfills/BabelPolyfill';
|
||||
|
||||
import { Utils } from '../src/Utils';
|
||||
|
||||
import { JSFuck } from '../src/enums/JSFuck';
|
||||
|
||||
const assert: Chai.AssertStatic = require('chai').assert;
|
||||
|
||||
BabelPolyfill.append();
|
||||
|
||||
describe('Utils', () => {
|
||||
describe('arrayContains (array: any[], searchElement: any): boolean', () => {
|
||||
it('should return boolean depends on condition if array is contains given value or not', () => {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export class BabelPolyfill {
|
||||
public static append (): void {
|
||||
if (!(<any>global)._babelPolyfill) {
|
||||
require('babel-polyfill');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user