mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Fixed line separators in tests of CommentsTransformer and HashbangOperatorTransformer
This commit is contained in:
+5
-3
@@ -7,9 +7,11 @@ import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
describe('HashbangOperatorTransformer', () => {
|
||||
const lineSeparator: string = '\r?\n';
|
||||
|
||||
describe('Variant #1: simple', () => {
|
||||
const regExp: RegExp = new RegExp(
|
||||
`^#!\/usr\/bin\/env node\n` +
|
||||
`^#!\/usr\/bin\/env node${lineSeparator}` +
|
||||
`var foo *= *'abc';`
|
||||
);
|
||||
|
||||
@@ -33,7 +35,7 @@ describe('HashbangOperatorTransformer', () => {
|
||||
|
||||
describe('Variant #2: multiple new lines', () => {
|
||||
const regExp: RegExp = new RegExp(
|
||||
`^#!\/usr\/bin\/env node\n\n\n\n` +
|
||||
`^#!\/usr\/bin\/env node${lineSeparator.repeat(4)}` +
|
||||
`var foo *= *'abc';`
|
||||
);
|
||||
|
||||
@@ -57,7 +59,7 @@ describe('HashbangOperatorTransformer', () => {
|
||||
|
||||
describe('Variant #3: `stringArray` option enabled', () => {
|
||||
const regExp: RegExp = new RegExp(
|
||||
`^#!\/usr\/bin\/env node\n` +
|
||||
`^#!\/usr\/bin\/env node${lineSeparator}` +
|
||||
`var _0x(\\w){4} *= *\\['abc'];`
|
||||
);
|
||||
|
||||
|
||||
+8
-6
@@ -7,6 +7,8 @@ import { readFileAsString } from '../../../../helpers/readFileAsString';
|
||||
import { JavaScriptObfuscator } from '../../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
describe('CommentsTransformer', () => {
|
||||
const lineSeparatorEscaped: string = '\\r?\\n';
|
||||
|
||||
describe('Variant #1: simple comment without preserved words', () => {
|
||||
const regExp: RegExp = /^var test *= *0x1;$/;
|
||||
|
||||
@@ -72,10 +74,10 @@ describe('CommentsTransformer', () => {
|
||||
|
||||
describe('Variant #4: comment with preserved and non-preserved words', () => {
|
||||
const regExp: RegExp = new RegExp(``+
|
||||
`^\\/\\*\\* *\\n` +
|
||||
` *\\* *@license *\\n` +
|
||||
` *\\* *test\\n` +
|
||||
` *\\*\\/\\n` +
|
||||
`^\\/\\*\\* *${lineSeparatorEscaped}` +
|
||||
` *\\* *@license *${lineSeparatorEscaped}` +
|
||||
` *\\* *test${lineSeparatorEscaped}` +
|
||||
` *\\*\\/${lineSeparatorEscaped}` +
|
||||
`var test *= *0x1;` +
|
||||
` *\\/\\*\\* *@preserved *\\*\\/$` +
|
||||
``);
|
||||
@@ -117,7 +119,7 @@ describe('CommentsTransformer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #5: only comment with preserved words', () => {
|
||||
describe('Variant #6: only comment with preserved words', () => {
|
||||
const regExp: RegExp = /^\/\/ *@license$/;
|
||||
|
||||
let obfuscatedCode: string;
|
||||
@@ -138,7 +140,7 @@ describe('CommentsTransformer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #6: simple comment with preserved words and additional code helper is inserted', () => {
|
||||
describe('Variant #7: simple comment with preserved words and additional code helper is inserted', () => {
|
||||
describe('Variant #1: `stringArray` code helper', () => {
|
||||
const regExp: RegExp = /^\/\/ *@license *test *comment *\n*var _0x([a-f0-9]){4} *= *\['abc'];/;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user