Skip to content

Commit f1806fc

Browse files
committed
tests refactoring: custom nodes
1 parent d237d48 commit f1806fc

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

test/functional-tests/custom-nodes/string-array-nodes/StringArrayNode.spec.ts

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,23 @@ describe('StringArrayNode', () => {
3232
});
3333
});
3434

35-
it('should correctly append `StringArrayNode` custom node into the obfuscated code if `stringArray` option is set', () => {
36-
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
37-
readFileAsString(__dirname + '/fixtures/simple-input.js'),
38-
{
39-
...NO_CUSTOM_NODES_PRESET,
40-
stringArray: true,
41-
stringArrayThreshold: 1
42-
}
43-
);
44-
45-
assert.match(obfuscationResult.getObfuscatedCode(), /^var _0x([a-f0-9]){4} *= *\[/);
46-
});
35+
describe('`stringArray` option isn\'t set', () => {
36+
let obfuscatedCode: string;
4737

48-
it('should\'t append `StringArrayNode` custom node into the obfuscated code if `stringArray` option is not set', () => {
49-
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
50-
readFileAsString(__dirname + '/fixtures/simple-input.js'),
51-
{
52-
...NO_CUSTOM_NODES_PRESET,
53-
stringArray: false
54-
}
55-
);
38+
before(() => {
39+
let obfuscationResult: IObfuscationResult = JavaScriptObfuscator.obfuscate(
40+
readFileAsString(__dirname + '/fixtures/simple-input.js'),
41+
{
42+
...NO_CUSTOM_NODES_PRESET,
43+
stringArray: false
44+
}
45+
);
46+
47+
obfuscatedCode = obfuscationResult.getObfuscatedCode();
48+
});
5649

57-
assert.notMatch(obfuscationResult.getObfuscatedCode(), /^var _0x([a-f0-9]){4} *= *\[/);
50+
it('shouldn\'t append custom node into the obfuscated code', () => {
51+
assert.notMatch(obfuscatedCode, regExp);
52+
});
5853
});
5954
});

0 commit comments

Comments
 (0)