forked from javascript-obfuscator/javascript-obfuscator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomGeneratorUtils.spec.ts
More file actions
45 lines (35 loc) · 1.69 KB
/
Copy pathRandomGeneratorUtils.spec.ts
File metadata and controls
45 lines (35 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { assert } from 'chai';
import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade';
import { IRandomGenerator } from '../../../src/interfaces/utils/IRandomGenerator';
import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade';
describe('RandomGeneratorUtils', () => {
describe('getRandomVariableName (length: number = 6): string', () => {
let randomGenerator: IRandomGenerator,
randomVariableName: string,
regExp: RegExp;
before(() => {
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
inversifyContainerFacade.load('', {});
randomGenerator = inversifyContainerFacade.get<IRandomGenerator>(ServiceIdentifiers.IRandomGenerator)
});
describe('variant #1: string with random variable of length `4`', () => {
before(() => {
randomVariableName = randomGenerator.getRandomVariableName(4);
regExp = /^_0x(\w){4}$/;
});
it('should return random variable name', () => {
assert.match(randomVariableName, regExp);
})
});
describe('variant #2: string with random variable of length `6`', () => {
before(() => {
randomVariableName = randomGenerator.getRandomVariableName(6);
regExp = /^_0x(\w){4,6}$/;
});
it('should return random variable name', () => {
assert.match(randomVariableName, regExp);
})
});
});
});