ソースを参照

Removed random internal random generation of identifiers prefix

sanex3339 7 年 前
コミット
19ff4cfb1e

+ 1 - 1
README.md

@@ -575,7 +575,7 @@ Available values:
 ### `identifiersPrefix`
 Type: `string` Default: `''`
 
-Sets prefix for all generated identifiers. If prefix sets to `true` - random prefix with length of 6 characters will generated. If prefix sets to `false` or empty string - prefix won't generated.
+Sets prefix for all generated identifiers.
 
 Use this option when you want to obfuscate multiple files. This option helps to avoid conflicts between identifiers of these files. Prefix should be different for every file.
 

ファイルの差分が大きいため隠しています
+ 0 - 0
dist/index.js


+ 3 - 5
src/cli/JavaScriptObfuscatorCLI.ts

@@ -18,7 +18,6 @@ import { DEFAULT_PRESET } from '../options/presets/Default';
 import { ArraySanitizer } from './sanitizers/ArraySanitizer';
 import { BooleanSanitizer } from './sanitizers/BooleanSanitizer';
 import { IdentifierNamesGeneratorSanitizer } from './sanitizers/IdentifierNamesGeneratorSanitizer';
-import { IdentifiersPrefixSanitizer } from './sanitizers/IdentifiersPrefixSanitizer';
 import { ObfuscationTargetSanitizer } from './sanitizers/ObfuscatingTargetSanitizer';
 import { SourceMapModeSanitizer } from './sanitizers/SourceMapModeSanitizer';
 import { StringArrayEncodingSanitizer } from './sanitizers/StringArrayEncodingSanitizer';
@@ -246,9 +245,8 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
                 IdentifierNamesGeneratorSanitizer
             )
             .option(
-                '--identifiers-prefix <string|boolean>',
-                'Sets prefix for all generated identifiers.',
-                IdentifiersPrefixSanitizer
+                '--identifiers-prefix <string>',
+                'Sets prefix for all generated identifiers.'
             )
             .option(
                 '--log <boolean>', 'Enables logging of the information to the console',
@@ -351,7 +349,7 @@ export class JavaScriptObfuscatorCLI implements IInitializable {
 
             this.processSourceCode(sourceCodeData, outputCodePath);
         } else {
-            sourceCodeData.forEach(({ filePath, content }: IFileData) => {
+            sourceCodeData.forEach(({ filePath, content }: IFileData, index: number) => {
                 const outputCodePath: string = outputPath
                     ? path.join(outputPath, filePath)
                     : CLIUtils.getOutputCodePath(filePath);

+ 0 - 21
src/cli/sanitizers/IdentifiersPrefixSanitizer.ts

@@ -1,21 +0,0 @@
-import { TCLISanitizer } from '../../types/cli/TCLISanitizer';
-
-/**
- * @param {string} value
- * @returns {string | boolean}
- * @constructor
- */
-export const IdentifiersPrefixSanitizer: TCLISanitizer = (value: string): string | boolean => {
-    switch (value) {
-        case 'true':
-        case '1':
-            return true;
-
-        case 'false':
-        case '0':
-            return false;
-
-        default:
-            return value;
-    }
-};

+ 0 - 16
src/generators/identifier-names-generators/AbstractIdentifierNamesGenerator.ts

@@ -7,11 +7,6 @@ import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
 
 @injectable()
 export abstract class AbstractIdentifierNamesGenerator implements IIdentifierNamesGenerator {
-    /**
-     * @type {string}
-     */
-    protected readonly identifiersPrefix: string;
-
     /**
      * @type {IOptions}
      */
@@ -32,10 +27,6 @@ export abstract class AbstractIdentifierNamesGenerator implements IIdentifierNam
     ) {
         this.randomGenerator = randomGenerator;
         this.options = options;
-
-        this.identifiersPrefix = this.options.identifiersPrefix === true
-            ? this.randomGenerator.getRandomString(6)
-            : this.options.identifiersPrefix || '';
     }
 
     /**
@@ -47,11 +38,4 @@ export abstract class AbstractIdentifierNamesGenerator implements IIdentifierNam
      * @returns {string}
      */
     public abstract generateWithPrefix (): string;
-
-    /**
-     * @returns {string}
-     */
-    public getPrefix (): string {
-        return this.identifiersPrefix;
-    }
 }

+ 1 - 1
src/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.ts

@@ -56,6 +56,6 @@ export class HexadecimalIdentifierNamesGenerator extends AbstractIdentifierNames
     public generateWithPrefix (): string {
         const identifierName: string = this.generate();
 
-        return `${this.identifiersPrefix}${identifierName}`.replace('__', '_');
+        return `${this.options.identifiersPrefix}${identifierName}`.replace('__', '_');
     }
 }

+ 1 - 1
src/generators/identifier-names-generators/MangledIdentifierNamesGenerator.ts

@@ -113,7 +113,7 @@ export class MangledIdentifierNamesGenerator extends AbstractIdentifierNamesGene
      */
     public generateWithPrefix (): string {
         const prefix: string = this.options.identifiersPrefix ?
-            `${this.identifiersPrefix}_`
+            `${this.options.identifiersPrefix}_`
             : '';
         const identifierName: string = this.generate();
 

+ 0 - 5
src/interfaces/generators/identifier-names-generators/IIdentifierNamesGenerator.d.ts

@@ -8,9 +8,4 @@ export interface IIdentifierNamesGenerator {
      * @returns {string}
      */
     generateWithPrefix (): string;
-
-    /**
-     * @returns {string}
-     */
-    getPrefix (): string;
 }

+ 1 - 1
src/interfaces/options/IOptions.d.ts

@@ -15,7 +15,7 @@ export interface IOptions {
     readonly disableConsoleOutput: boolean;
     readonly domainLock: string[];
     readonly identifierNamesGenerator: IdentifierNamesGenerator;
-    readonly identifiersPrefix: string | boolean;
+    readonly identifiersPrefix: string;
     readonly log: boolean;
     readonly renameGlobals: boolean;
     readonly reservedNames: string[];

+ 2 - 4
src/options/Options.ts

@@ -113,12 +113,10 @@ export class Options implements IOptions {
     public readonly identifierNamesGenerator: IdentifierNamesGenerator;
 
     /**
-     * We won't validate this field, because of missing support of multiple types validation in `class-validator`.
-     * Value of this field will transformed to the string in `OptionsNormalizer`
-     *
      * @type {string}
      */
-    public readonly identifiersPrefix: string | boolean;
+    @IsString()
+    public readonly identifiersPrefix: string;
 
     /**
      * @type {boolean}

+ 0 - 2
src/options/OptionsNormalizer.ts

@@ -9,7 +9,6 @@ import { ControlFlowFlatteningThresholdRule } from './normalizer-rules/ControlFl
 import { DeadCodeInjectionRule } from './normalizer-rules/DeadCodeInjectionRule';
 import { DeadCodeInjectionThresholdRule } from './normalizer-rules/DeadCodeInjectionThresholdRule';
 import { DomainLockRule } from './normalizer-rules/DomainLockRule';
-import { IdentifiersPrefixRule } from './normalizer-rules/IdentifiersPrefixRule';
 import { SelfDefendingRule } from './normalizer-rules/SelfDefendingRule';
 import { SourceMapBaseUrlRule } from './normalizer-rules/SourceMapBaseUrlRule';
 import { SourceMapFileNameRule } from './normalizer-rules/SourceMapFileNameRule';
@@ -27,7 +26,6 @@ export class OptionsNormalizer implements IOptionsNormalizer {
         DeadCodeInjectionRule,
         DeadCodeInjectionThresholdRule,
         DomainLockRule,
-        IdentifiersPrefixRule,
         SelfDefendingRule,
         SourceMapBaseUrlRule,
         SourceMapFileNameRule,

+ 0 - 26
src/options/normalizer-rules/IdentifiersPrefixRule.ts

@@ -1,26 +0,0 @@
-import { TOptionsNormalizerRule } from '../../types/options/TOptionsNormalizerRule';
-
-import { IOptions } from '../../interfaces/options/IOptions';
-
-/**
- * @param {IOptions} options
- * @returns {IOptions}
- */
-export const IdentifiersPrefixRule: TOptionsNormalizerRule = (options: IOptions): IOptions => {
-    const { identifiersPrefix }: { identifiersPrefix: string | boolean } = options;
-    const isStringPrefix: boolean = !!identifiersPrefix && typeof identifiersPrefix === 'string';
-    const isRandomPrefix: boolean = identifiersPrefix === true;
-
-    if (isStringPrefix || isRandomPrefix) {
-        return options;
-    }
-
-    const normalizedIdentifiersPrefix: string | boolean = typeof identifiersPrefix === 'number'
-        ? String(identifiersPrefix)
-        : false;
-
-    return {
-        ...options,
-        identifiersPrefix: normalizedIdentifiersPrefix
-    };
-};

+ 1 - 1
src/options/presets/Default.ts

@@ -16,7 +16,7 @@ export const DEFAULT_PRESET: TInputOptions = Object.freeze({
     disableConsoleOutput: false,
     domainLock: [],
     identifierNamesGenerator: IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
-    identifiersPrefix: false,
+    identifiersPrefix: '',
     log: false,
     renameGlobals: false,
     reservedNames: [],

+ 1 - 1
src/options/presets/NoCustomNodes.ts

@@ -15,7 +15,7 @@ export const NO_ADDITIONAL_NODES_PRESET: TInputOptions = Object.freeze({
     disableConsoleOutput: false,
     domainLock: [],
     identifierNamesGenerator: IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator,
-    identifiersPrefix: false,
+    identifiersPrefix: '',
     log: false,
     renameGlobals: false,
     reservedNames: [],

+ 2 - 3
src/storages/string-array/StringArrayStorage.ts

@@ -50,15 +50,14 @@ export class StringArrayStorage extends ArrayStorage <string> {
     public initialize (): void {
         super.initialize();
 
-        const namePrefix: string = this.identifierNamesGenerator.getPrefix();
         const baseStringArrayName: string = this.identifierNamesGenerator
             .generate()
             .slice(0, StringArrayStorage.stringArrayNameLength);
         const baseStringArrayCallsWrapperName: string = this.identifierNamesGenerator
             .generate()
             .slice(0, StringArrayStorage.stringArrayNameLength);
-        const stringArrayName: string = `${namePrefix}${baseStringArrayName}`;
-        const stringArrayCallsWrapperName: string = `${namePrefix}${baseStringArrayCallsWrapperName}`;
+        const stringArrayName: string = `${this.options.identifiersPrefix}${baseStringArrayName}`;
+        const stringArrayCallsWrapperName: string = `${this.options.identifiersPrefix}${baseStringArrayCallsWrapperName}`;
 
         this.storageId = `${stringArrayName}|${stringArrayCallsWrapperName}`;
     }

+ 0 - 128
test/functional-tests/options/OptionsNormalizer.spec.ts

@@ -176,134 +176,6 @@ describe('OptionsNormalizer', () => {
             });
         });
 
-        describe('identifiersPrefixRule', () => {
-            describe('variant #1: string option value', () => {
-                before(() => {
-                    optionsPreset = getNormalizedOptions({
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: 'foo',
-                    });
-
-                    expectedOptionsPreset = {
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: 'foo',
-                    };
-                });
-
-                it('should normalize options preset', () => {
-                    assert.deepEqual(optionsPreset, expectedOptionsPreset);
-                });
-            });
-
-            describe('variant #2: empty string option value', () => {
-                before(() => {
-                    optionsPreset = getNormalizedOptions({
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: '',
-                    });
-
-                    expectedOptionsPreset = {
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: false,
-                    };
-                });
-
-                it('should normalize options preset', () => {
-                    assert.deepEqual(optionsPreset, expectedOptionsPreset);
-                });
-            });
-
-            describe('variant #3: option value is `true`', () => {
-                before(() => {
-                    optionsPreset = getNormalizedOptions({
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: true,
-                    });
-
-                    expectedOptionsPreset = {
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: true,
-                    };
-                });
-
-                it('should normalize options preset', () => {
-                    assert.deepEqual(optionsPreset, expectedOptionsPreset);
-                });
-            });
-
-            describe('variant #4: option value is `false`', () => {
-                before(() => {
-                    optionsPreset = getNormalizedOptions({
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: false,
-                    });
-
-                    expectedOptionsPreset = {
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: false,
-                    };
-                });
-
-                it('should normalize options preset', () => {
-                    assert.deepEqual(optionsPreset, expectedOptionsPreset);
-                });
-            });
-
-            describe('variant #5: option value is object', () => {
-                before(() => {
-                    optionsPreset = getNormalizedOptions({
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: <any>{},
-                    });
-
-                    expectedOptionsPreset = {
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: false,
-                    };
-                });
-
-                it('should normalize options preset', () => {
-                    assert.deepEqual(optionsPreset, expectedOptionsPreset);
-                });
-            });
-
-            describe('variant #6: option value is function', () => {
-                before(() => {
-                    optionsPreset = getNormalizedOptions({
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: <any>{},
-                    });
-
-                    expectedOptionsPreset = {
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: false,
-                    };
-                });
-
-                it('should normalize options preset', () => {
-                    assert.deepEqual(optionsPreset, expectedOptionsPreset);
-                });
-            });
-
-            describe('variant #7: option value is number', () => {
-                before(() => {
-                    optionsPreset = getNormalizedOptions({
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: <any>123,
-                    });
-
-                    expectedOptionsPreset = {
-                        ...DEFAULT_PRESET,
-                        identifiersPrefix: '123',
-                    };
-                });
-
-                it('should normalize options preset', () => {
-                    assert.deepEqual(optionsPreset, expectedOptionsPreset);
-                });
-            });
-        });
-
         describe('selfDefendingRule', () => {
             before(() => {
                 optionsPreset = getNormalizedOptions({

+ 0 - 1
test/index.spec.ts

@@ -9,7 +9,6 @@ import './unit-tests/analyzers/stack-trace-analyzer/StackTraceAnalyzer.spec';
 import './unit-tests/cli/sanitizers/ArraySanitizer.spec';
 import './unit-tests/cli/sanitizers/BooleanSanitizer.spec';
 import './unit-tests/cli/sanitizers/IdentifierNamesGeneratorSanitizer.spec';
-import './unit-tests/cli/sanitizers/IdentifiersPrefixSanitizer.spec';
 import './unit-tests/cli/sanitizers/ObfuscationTargetSanitizer.spec';
 import './unit-tests/cli/sanitizers/SourceMapModeSanitizer.spec';
 import './unit-tests/cli/sanitizers/StringArrayEncodingSanitizer.spec';

+ 0 - 82
test/unit-tests/cli/sanitizers/IdentifiersPrefixSanitizer.spec.ts

@@ -1,82 +0,0 @@
-import { assert } from 'chai';
-
-import { IdentifiersPrefixSanitizer } from '../../../../src/cli/sanitizers/IdentifiersPrefixSanitizer';
-
-describe('IdentifiersPrefixSanitizer', () => {
-    describe('IdentifiersPrefixSanitizer: TCLISanitizer = (value: string): string | boolean', () => {
-        describe('variant #1: identifiers prefix `true`', () => {
-            const inputValue: string = 'true';
-            const expectedValue: boolean = true;
-
-            let value: boolean | string;
-
-            before(() => {
-                value = IdentifiersPrefixSanitizer(inputValue);
-            });
-
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
-        });
-
-        describe('variant #2: identifiers prefix `1`', () => {
-            const inputValue: string = '1';
-            const expectedValue: boolean = true;
-
-            let value: boolean | string;
-
-            before(() => {
-                value = IdentifiersPrefixSanitizer(inputValue);
-            });
-
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
-        });
-
-        describe('variant #3: identifiers prefix `false`', () => {
-            const inputValue: string = 'false';
-            const expectedValue: boolean = false;
-
-            let value: boolean | string;
-
-            before(() => {
-                value = IdentifiersPrefixSanitizer(inputValue);
-            });
-
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
-        });
-
-        describe('variant #4: identifiers prefix `0`', () => {
-            const inputValue: string = '0';
-            const expectedValue: boolean = false;
-
-            let value: boolean | string;
-
-            before(() => {
-                value = IdentifiersPrefixSanitizer(inputValue);
-            });
-
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
-        });
-
-        describe('variant #5: string identifiers prefix', () => {
-            const inputValue: string = 'foo';
-            const expectedValue: string = 'foo';
-
-            let value: boolean | string;
-
-            before(() => {
-                value = IdentifiersPrefixSanitizer(inputValue);
-            });
-
-            it('should sanitize value', () => {
-                assert.equal(value, expectedValue);
-            });
-        });
-    });
-});

+ 5 - 57
test/unit-tests/generators/identifier-names-generators/HexadecimalIdentifierNamesGenerator.spec.ts

@@ -36,62 +36,10 @@ describe('HexadecimalIdentifierNamesGenerator', () => {
     });
 
     describe('generateWithPrefix (): string', () => {
-        describe('Hexadecimal name with prefix', () => {
-            const regExp: RegExp = /^foo_0x(\w){4,6}$/;
-
-            let identifierNamesGenerator: IIdentifierNamesGenerator,
-                hexadecimalIdentifierName: string;
-
-            before(() => {
-                const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
-
-                inversifyContainerFacade.load('', {
-                    identifiersPrefix: 'foo'
-                });
-                identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
-                    ServiceIdentifiers.IIdentifierNamesGenerator,
-                    IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator
-                );
-
-                hexadecimalIdentifierName = identifierNamesGenerator.generateWithPrefix();
-            });
-
-            it('should return hexadecimal name with prefix', () => {
-                assert.match(hexadecimalIdentifierName, regExp);
-            })
-        });
-
-        describe('Hexadecimal name with random prefix', () => {
-            const regExp: RegExp = /^(\w){6}_0x(\w){4,6}$/;
-
-            let identifierNamesGenerator: IIdentifierNamesGenerator,
-                hexadecimalIdentifierName: string;
-
-            before(() => {
-                const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
-
-                inversifyContainerFacade.load('', {
-                    identifiersPrefix: true
-                });
-                identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
-                    ServiceIdentifiers.IIdentifierNamesGenerator,
-                    IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator
-                );
-
-                hexadecimalIdentifierName = identifierNamesGenerator.generateWithPrefix();
-            });
-
-            it('should return hexadecimal name with prefix', () => {
-                assert.match(hexadecimalIdentifierName, regExp);
-            })
-        });
-    });
-
-    describe('getPrefix (): string', () => {
-        const expectedIdentifierPrefix: string = 'foo';
+        const regExp: RegExp = /^foo_0x(\w){4,6}$/;
 
         let identifierNamesGenerator: IIdentifierNamesGenerator,
-            identifierPrefix: string;
+            hexadecimalIdentifierName: string;
 
         before(() => {
             const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
@@ -104,11 +52,11 @@ describe('HexadecimalIdentifierNamesGenerator', () => {
                 IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator
             );
 
-            identifierPrefix = identifierNamesGenerator.getPrefix();
+            hexadecimalIdentifierName = identifierNamesGenerator.generateWithPrefix();
         });
 
-        it('should return prefix', () => {
-            assert.equal(identifierPrefix, expectedIdentifierPrefix);
+        it('should return hexadecimal name with prefix', () => {
+            assert.match(hexadecimalIdentifierName, regExp);
         })
     });
 });

+ 23 - 91
test/unit-tests/generators/identifier-names-generators/MangledlIdentifierNamesGenerator.spec.ts

@@ -130,94 +130,8 @@ describe('MangledIdentifierNamesGenerator', () => {
     });
 
     describe('generateWithPrefix (): string', () => {
-        describe('Mangled name with prefix', () => {
-            let identifierNamesGenerator: IIdentifierNamesGenerator,
-                mangledIdentifierName: string;
-
-            before(() => {
-                const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
-
-                inversifyContainerFacade.load('', {
-                    identifiersPrefix: 'foo'
-                });
-                identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
-                    ServiceIdentifiers.IIdentifierNamesGenerator,
-                    IdentifierNamesGenerator.MangledIdentifierNamesGenerator
-                );
-            });
-
-            describe('variant #1: initial mangled name', () => {
-                const expectedMangledIdentifierName: string = 'foo_a';
-
-                beforeEach(() => {
-                    mangledIdentifierName = identifierNamesGenerator.generateWithPrefix();
-                });
-
-                it('should return mangled name with prefix', () => {
-                    assert.equal(mangledIdentifierName, expectedMangledIdentifierName);
-                });
-            });
-
-            describe('variant #2: second mangled name', () => {
-                const expectedMangledIdentifierName: string = 'foo_b';
-
-                beforeEach(() => {
-                    mangledIdentifierName = identifierNamesGenerator.generateWithPrefix();
-                });
-
-                it('should return mangled name with prefix', () => {
-                    assert.equal(mangledIdentifierName, expectedMangledIdentifierName);
-                });
-            });
-        });
-
-        describe('Mangled name with random prefix', () => {
-            let identifierNamesGenerator: IIdentifierNamesGenerator,
-                mangledIdentifierName: string;
-
-            before(() => {
-                const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
-
-                inversifyContainerFacade.load('', {
-                    identifiersPrefix: true
-                });
-                identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
-                    ServiceIdentifiers.IIdentifierNamesGenerator,
-                    IdentifierNamesGenerator.MangledIdentifierNamesGenerator
-                );
-            });
-
-            describe('variant #1: initial mangled name', () => {
-                const expectedMangledIdentifierNameRegExp: RegExp = /(\w){6}_a/;
-
-                beforeEach(() => {
-                    mangledIdentifierName = identifierNamesGenerator.generateWithPrefix();
-                });
-
-                it('should return mangled name with prefix', () => {
-                    assert.match(mangledIdentifierName, expectedMangledIdentifierNameRegExp);
-                });
-            });
-
-            describe('variant #2: second mangled name', () => {
-                const expectedMangledIdentifierNameRegExp: RegExp = /(\w){6}_b/;
-
-                beforeEach(() => {
-                    mangledIdentifierName = identifierNamesGenerator.generateWithPrefix();
-                });
-
-                it('should return mangled name with prefix', () => {
-                    assert.match(mangledIdentifierName, expectedMangledIdentifierNameRegExp);
-                });
-            });
-        });
-    });
-
-    describe('getPrefix (): string', () => {
-        const expectedIdentifierPrefix: string = 'foo';
-
         let identifierNamesGenerator: IIdentifierNamesGenerator,
-            identifierPrefix: string;
+            mangledIdentifierName: string;
 
         before(() => {
             const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
@@ -229,12 +143,30 @@ describe('MangledIdentifierNamesGenerator', () => {
                 ServiceIdentifiers.IIdentifierNamesGenerator,
                 IdentifierNamesGenerator.MangledIdentifierNamesGenerator
             );
+        });
+
+        describe('variant #1: initial mangled name', () => {
+            const expectedMangledIdentifierName: string = 'foo_a';
+
+            beforeEach(() => {
+                mangledIdentifierName = identifierNamesGenerator.generateWithPrefix();
+            });
 
-            identifierPrefix = identifierNamesGenerator.getPrefix();
+            it('should return mangled name with prefix', () => {
+                assert.equal(mangledIdentifierName, expectedMangledIdentifierName);
+            });
         });
 
-        it('should return prefix', () => {
-            assert.equal(identifierPrefix, expectedIdentifierPrefix);
-        })
+        describe('variant #2: second mangled name', () => {
+            const expectedMangledIdentifierName: string = 'foo_b';
+
+            beforeEach(() => {
+                mangledIdentifierName = identifierNamesGenerator.generateWithPrefix();
+            });
+
+            it('should return mangled name with prefix', () => {
+                assert.equal(mangledIdentifierName, expectedMangledIdentifierName);
+            });
+        });
     });
 });

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません