mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
refactoring
This commit is contained in:
@@ -1,18 +1,21 @@
|
||||
import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
|
||||
|
||||
import * as chai from 'chai';
|
||||
import * as estraverse from 'estraverse';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TNodeWithBlockStatement } from '../../../src/types/TNodeWithBlockStatement';
|
||||
|
||||
import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade';
|
||||
import { IStackTraceAnalyzer } from '../../../src/interfaces/stack-trace-analyzer/IStackTraceAnalyzer';
|
||||
import { IStackTraceData } from '../../../src/interfaces/stack-trace-analyzer/IStackTraceData';
|
||||
|
||||
import { readFileAsString } from '../../helpers/readFileAsString';
|
||||
|
||||
import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade';
|
||||
import { Node } from '../../../src/node/Node';
|
||||
import { NodeMocks } from '../../mocks/NodeMocks';
|
||||
import { NodeUtils } from '../../../src/node/NodeUtils';
|
||||
import { StackTraceAnalyzer } from '../../../src/stack-trace-analyzer/StackTraceAnalyzer';
|
||||
|
||||
const assert: any = chai.assert;
|
||||
|
||||
@@ -146,7 +149,9 @@ function getObjectFunctionExpressionByName (astTree: ESTree.Node, objectName: st
|
||||
|
||||
describe('StackTraceAnalyzer', () => {
|
||||
describe('extract (): IStackTraceData[]', () => {
|
||||
const stackTraceAnalyzer: IStackTraceAnalyzer = new StackTraceAnalyzer();
|
||||
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade({});
|
||||
const stackTraceAnalyzer: IStackTraceAnalyzer = inversifyContainerFacade
|
||||
.get<IStackTraceAnalyzer>(ServiceIdentifiers.IStackTraceAnalyzer);
|
||||
|
||||
let astTree: TNodeWithBlockStatement,
|
||||
stackTraceData: IStackTraceData[],
|
||||
@@ -199,7 +204,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
assert.deepEqual(stackTraceData, expectedStackTraceData);
|
||||
});
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #2: basic-2', () => {
|
||||
it('should returns correct IStackTraceData - variant #2: basic-2', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/basic-2.js')
|
||||
@@ -235,7 +240,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
assert.deepEqual(stackTraceData, expectedStackTraceData);
|
||||
});
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #3: deep conditions nesting', () => {
|
||||
it('should returns correct IStackTraceData - variant #3: deep conditions nesting', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/deep-conditions-nesting.js')
|
||||
@@ -271,7 +276,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
assert.deepEqual(stackTraceData, expectedStackTraceData);
|
||||
});
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #4: call before declaration', () => {
|
||||
it('should returns correct IStackTraceData - variant #4: call before declaration', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/call-before-declaration.js')
|
||||
@@ -291,7 +296,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
assert.deepEqual(stackTraceData, expectedStackTraceData);
|
||||
});
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #5: call expression of object member #1', () => {
|
||||
it('should returns correct IStackTraceData - variant #5: call expression of object member #1', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/call-expression-of-object-member-1.js')
|
||||
@@ -347,7 +352,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
assert.deepEqual(stackTraceData, expectedStackTraceData);
|
||||
});
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #5: call expression of object member #2', () => {
|
||||
it('should returns correct IStackTraceData - variant #5: call expression of object member #2', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/call-expression-of-object-member-2.js')
|
||||
@@ -372,7 +377,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
assert.deepEqual(stackTraceData, expectedStackTraceData);
|
||||
});
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #6: no call expressions', () => {
|
||||
it('should returns correct IStackTraceData - variant #6: no call expressions', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/no-call-expressions.js')
|
||||
@@ -386,7 +391,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
assert.deepEqual(stackTraceData, expectedStackTraceData);
|
||||
});
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #7: only call expression', () => {
|
||||
it('should returns correct IStackTraceData - variant #7: only call expression', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/only-call-expression.js')
|
||||
@@ -400,7 +405,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
assert.deepEqual(stackTraceData, expectedStackTraceData);
|
||||
});
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #8: self-invoking functions', () => {
|
||||
it('should returns correct IStackTraceData - variant #8: self-invoking functions', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/self-invoking-functions.js')
|
||||
@@ -432,7 +437,7 @@ describe('StackTraceAnalyzer', () => {
|
||||
assert.deepEqual(stackTraceData, expectedStackTraceData);
|
||||
});
|
||||
|
||||
it('should returns correct BlockScopeTraceData - variant #9: no recursion', () => {
|
||||
it('should returns correct IStackTraceData - variant #9: no recursion', () => {
|
||||
astTree = NodeMocks.getProgramNode(
|
||||
NodeUtils.convertCodeToStructure(
|
||||
readFileAsString('./test/fixtures/stack-trace-analyzer/no-recursion.js')
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
|
||||
|
||||
import * as chai from 'chai';
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
import { TStatement } from '../../../src/types/TStatement';
|
||||
|
||||
import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade';
|
||||
import { IStackTraceAnalyzer } from '../../../src/interfaces/stack-trace-analyzer/IStackTraceAnalyzer';
|
||||
import { IStackTraceData } from '../../../src/interfaces/stack-trace-analyzer/IStackTraceData';
|
||||
|
||||
import { readFileAsString } from '../../helpers/readFileAsString';
|
||||
|
||||
import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade';
|
||||
import { NodeAppender } from '../../../src/node/NodeAppender';
|
||||
import { NodeMocks } from '../../mocks/NodeMocks';
|
||||
import { NodeUtils } from '../../../src/node/NodeUtils';
|
||||
import { StackTraceAnalyzer } from '../../../src/stack-trace-analyzer/StackTraceAnalyzer';
|
||||
|
||||
const assert: any = chai.assert;
|
||||
|
||||
@@ -50,7 +53,9 @@ describe('NodeAppender', () => {
|
||||
});
|
||||
|
||||
describe('appendNodeToOptimalBlockScope (blockScopeStackTraceData: IStackTraceData[], blockScopeNode: TNodeWithBlockStatement, nodeBodyStatements: TStatement[], index: number = 0): void', () => {
|
||||
const stackTraceAnalyzer: IStackTraceAnalyzer = new StackTraceAnalyzer();
|
||||
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade({});
|
||||
const stackTraceAnalyzer: IStackTraceAnalyzer = inversifyContainerFacade
|
||||
.get<IStackTraceAnalyzer>(ServiceIdentifiers.IStackTraceAnalyzer);
|
||||
|
||||
let astTree: ESTree.Program,
|
||||
expectedAstTree: ESTree.Program,
|
||||
|
||||
Reference in New Issue
Block a user