ControlFlowStorage.spec.ts 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. /*
  2. import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
  3. import { assert } from 'chai';
  4. import { ICustomNode } from '../../../src/interfaces/custom-nodes/ICustomNode';
  5. import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade';
  6. import { IStorage } from '../../../src/interfaces/storages/IStorage';
  7. import { CustomNodes } from '../../../src/enums/container/CustomNodes';
  8. import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade';
  9. describe('ControlFlowStorage', () => {
  10. describe('toString (): string', () => {
  11. it('should returns obfuscated code if `.toString()` was called on `ObfuscationResult` object', () => {
  12. const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade({
  13. controlFlowFlattening: true
  14. });
  15. const controlFlowStorage: IStorage <ICustomNode> = inversifyContainerFacade
  16. .get<IStorage<ICustomNode>>(ServiceIdentifiers['IStorage<ICustomNode>']);
  17. const controlFlowStorageCallNode: ICustomNode = inversifyContainerFacade
  18. .getNamed<ICustomNode>(ServiceIdentifiers.ICustomNode, CustomNodes.ControlFlowStorageCallNode);
  19. controlFlowStorage.set('key1', controlFlowStorageCallNode);
  20. assert.equal(controlFlowStorage.toString(), [`key1: ${controlFlowStorageCallNode.getCode()}`]);
  21. });
  22. });
  23. });
  24. */