forked from javascript-obfuscator/javascript-obfuscator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringArrayCodeHelper.spec.ts
More file actions
52 lines (40 loc) · 1.62 KB
/
Copy pathStringArrayCodeHelper.spec.ts
File metadata and controls
52 lines (40 loc) · 1.62 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
46
47
48
49
50
51
52
import { assert } from 'chai';
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../src/options/presets/NoCustomNodes';
import { readFileAsString } from '../../../helpers/readFileAsString';
import { JavaScriptObfuscator } from '../../../../src/JavaScriptObfuscatorFacade';
describe('StringArrayCodeHelper', () => {
const regExp: RegExp = /^var _0x([a-f0-9]){4} *= *\[/;
describe('`stringArray` option is set', () => {
let obfuscatedCode: string;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
stringArray: true,
stringArrayThreshold: 1
}
).getObfuscatedCode();
});
it('should correctly append code helper into the obfuscated code', () => {
assert.match(obfuscatedCode, regExp);
});
});
describe('`stringArray` option isn\'t set', () => {
let obfuscatedCode: string;
before(() => {
const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
obfuscatedCode = JavaScriptObfuscator.obfuscate(
code,
{
...NO_ADDITIONAL_NODES_PRESET,
stringArray: false
}
).getObfuscatedCode();
});
it('shouldn\'t append code helper into the obfuscated code', () => {
assert.notMatch(obfuscatedCode, regExp);
});
});
});