OptionsNormalizer.spec.ts 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. import 'reflect-metadata';
  2. import { ServiceIdentifiers } from '../../../src/container/ServiceIdentifiers';
  3. import { assert } from 'chai';
  4. import { TInputOptions } from '../../../src/types/options/TInputOptions';
  5. import { IInversifyContainerFacade } from '../../../src/interfaces/container/IInversifyContainerFacade';
  6. import { IOptions } from '../../../src/interfaces/options/IOptions';
  7. import { IOptionsNormalizer } from '../../../src/interfaces/options/IOptionsNormalizer';
  8. import { StringArrayEncoding } from '../../../src/enums/node-transformers/string-array-transformers/StringArrayEncoding';
  9. import { DEFAULT_PRESET } from '../../../src/options/presets/Default';
  10. import { InversifyContainerFacade } from '../../../src/container/InversifyContainerFacade';
  11. /**
  12. * @param optionsPreset
  13. * @returns {IOptions}
  14. */
  15. function getNormalizedOptions (optionsPreset: TInputOptions): TInputOptions {
  16. const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
  17. inversifyContainerFacade.load('', '', optionsPreset);
  18. const options: IOptions = inversifyContainerFacade
  19. .get<IOptions>(ServiceIdentifiers.IOptions);
  20. const optionsNormalizer: IOptionsNormalizer = inversifyContainerFacade
  21. .get<IOptionsNormalizer>(ServiceIdentifiers.IOptionsNormalizer);
  22. return <TInputOptions>optionsNormalizer.normalize(options);
  23. }
  24. function getDefaultOptions(): TInputOptions {
  25. return {
  26. ...DEFAULT_PRESET,
  27. seed: 1 // set `seed` to the fixed value, to prevent a new seed for the each case
  28. };
  29. }
  30. describe('OptionsNormalizer', () => {
  31. describe('normalize', () => {
  32. let optionsPreset: TInputOptions,
  33. expectedOptionsPreset: TInputOptions;
  34. describe('controlFlowFlatteningThresholdRule', () => {
  35. before(() => {
  36. optionsPreset = getNormalizedOptions({
  37. ...getDefaultOptions(),
  38. controlFlowFlattening: true,
  39. controlFlowFlatteningThreshold: 0
  40. });
  41. expectedOptionsPreset = {
  42. ...getDefaultOptions(),
  43. controlFlowFlattening: false,
  44. controlFlowFlatteningThreshold: 0
  45. };
  46. });
  47. it('should normalize options preset', () => {
  48. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  49. });
  50. });
  51. describe('deadCodeInjectionRule', () => {
  52. before(() => {
  53. optionsPreset = getNormalizedOptions({
  54. ...getDefaultOptions(),
  55. deadCodeInjection: true,
  56. deadCodeInjectionThreshold: 0.4,
  57. stringArray: false,
  58. stringArrayThreshold: 0
  59. });
  60. expectedOptionsPreset = {
  61. ...getDefaultOptions(),
  62. deadCodeInjection: true,
  63. deadCodeInjectionThreshold: 0.4,
  64. stringArray: true,
  65. stringArrayThreshold: 0.75
  66. };
  67. });
  68. it('should normalize options preset', () => {
  69. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  70. });
  71. });
  72. describe('deadCodeInjectionRule', () => {
  73. describe('`stringArrayThreshold` option is empty', () => {
  74. before(() => {
  75. optionsPreset = getNormalizedOptions({
  76. ...getDefaultOptions(),
  77. deadCodeInjection: true,
  78. deadCodeInjectionThreshold: 0.4,
  79. stringArray: false,
  80. stringArrayThreshold: 0
  81. });
  82. expectedOptionsPreset = {
  83. ...getDefaultOptions(),
  84. deadCodeInjection: true,
  85. deadCodeInjectionThreshold: 0.4,
  86. stringArray: true,
  87. stringArrayThreshold: 0.75
  88. };
  89. });
  90. it('should normalize options preset', () => {
  91. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  92. });
  93. });
  94. describe('`stringArrayThreshold` option is not empty', () => {
  95. before(() => {
  96. optionsPreset = getNormalizedOptions({
  97. ...getDefaultOptions(),
  98. deadCodeInjection: true,
  99. deadCodeInjectionThreshold: 0.4,
  100. stringArray: false,
  101. stringArrayThreshold: 0.5
  102. });
  103. expectedOptionsPreset = {
  104. ...getDefaultOptions(),
  105. deadCodeInjection: true,
  106. deadCodeInjectionThreshold: 0.4,
  107. stringArray: true,
  108. stringArrayThreshold: 0.5
  109. };
  110. });
  111. it('should normalize options preset', () => {
  112. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  113. });
  114. });
  115. });
  116. describe('deadCodeInjectionThresholdRule', () => {
  117. before(() => {
  118. optionsPreset = getNormalizedOptions({
  119. ...getDefaultOptions(),
  120. deadCodeInjection: true,
  121. deadCodeInjectionThreshold: 0
  122. });
  123. expectedOptionsPreset = {
  124. ...getDefaultOptions(),
  125. deadCodeInjection: false,
  126. deadCodeInjectionThreshold: 0
  127. };
  128. });
  129. it('should normalize options preset', () => {
  130. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  131. });
  132. });
  133. describe('domainLockRedirectUrlRule', () => {
  134. describe('Variant #1: `domainLock` option is set', () => {
  135. before(() => {
  136. optionsPreset = getNormalizedOptions({
  137. ...getDefaultOptions(),
  138. domainLock: [
  139. 'localhost'
  140. ],
  141. domainLockRedirectUrl: 'https://example.com'
  142. });
  143. expectedOptionsPreset = {
  144. ...getDefaultOptions(),
  145. domainLock: [
  146. 'localhost'
  147. ],
  148. domainLockRedirectUrl: 'https://example.com'
  149. };
  150. });
  151. it('should not normalize options preset', () => {
  152. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  153. });
  154. });
  155. describe('Variant #2 `domainLock` option is not set', () => {
  156. before(() => {
  157. optionsPreset = getNormalizedOptions({
  158. ...getDefaultOptions(),
  159. domainLock: [],
  160. domainLockRedirectUrl: 'https://example.com'
  161. });
  162. expectedOptionsPreset = {
  163. ...getDefaultOptions(),
  164. domainLock: [],
  165. domainLockRedirectUrl: 'about:blank'
  166. };
  167. });
  168. it('should normalize options preset', () => {
  169. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  170. });
  171. });
  172. });
  173. describe('domainLockRule', () => {
  174. before(() => {
  175. optionsPreset = getNormalizedOptions({
  176. ...getDefaultOptions(),
  177. domainLock: [
  178. '//localhost:9000',
  179. 'https://google.ru/abc?cde=fgh'
  180. ]
  181. });
  182. expectedOptionsPreset = {
  183. ...getDefaultOptions(),
  184. domainLock: [
  185. 'localhost',
  186. 'google.ru'
  187. ]
  188. };
  189. });
  190. it('should normalize options preset', () => {
  191. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  192. });
  193. });
  194. describe('inputFileNameRule', () => {
  195. describe('Variant #1: extension isn\'t set', () => {
  196. before(() => {
  197. optionsPreset = getNormalizedOptions({
  198. ...getDefaultOptions(),
  199. inputFileName: 'foo'
  200. });
  201. expectedOptionsPreset = {
  202. ...getDefaultOptions(),
  203. inputFileName: 'foo.js'
  204. };
  205. });
  206. it('should normalize options preset', () => {
  207. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  208. });
  209. });
  210. describe('Variant #2: extension is set', () => {
  211. before(() => {
  212. optionsPreset = getNormalizedOptions({
  213. ...getDefaultOptions(),
  214. inputFileName: 'foo.js'
  215. });
  216. expectedOptionsPreset = {
  217. ...getDefaultOptions(),
  218. inputFileName: 'foo.js'
  219. };
  220. });
  221. it('should normalize options preset', () => {
  222. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  223. });
  224. });
  225. describe('Variant #3: extension in set with `.map` postfix', () => {
  226. before(() => {
  227. optionsPreset = getNormalizedOptions({
  228. ...getDefaultOptions(),
  229. inputFileName: 'foo.map.js'
  230. });
  231. expectedOptionsPreset = {
  232. ...getDefaultOptions(),
  233. inputFileName: 'foo.map.js'
  234. };
  235. });
  236. it('should normalize options preset', () => {
  237. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  238. });
  239. });
  240. describe('Variant #4: no file name', () => {
  241. before(() => {
  242. optionsPreset = getNormalizedOptions({
  243. ...getDefaultOptions(),
  244. inputFileName: ''
  245. });
  246. expectedOptionsPreset = {
  247. ...getDefaultOptions(),
  248. inputFileName: ''
  249. };
  250. });
  251. it('should normalize options preset', () => {
  252. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  253. });
  254. });
  255. });
  256. describe('identifierNamesCacheRule', () => {
  257. describe('Variant #1: all fields are exist with values', () => {
  258. before(() => {
  259. optionsPreset = getNormalizedOptions({
  260. ...getDefaultOptions(),
  261. identifierNamesCache: {
  262. globalIdentifiers: {
  263. foo: '_0x123456'
  264. },
  265. propertyIdentifiers: {
  266. bar: '_0x654321'
  267. }
  268. }
  269. });
  270. expectedOptionsPreset = {
  271. ...getDefaultOptions(),
  272. identifierNamesCache: {
  273. globalIdentifiers: {
  274. foo: '_0x123456'
  275. },
  276. propertyIdentifiers: {
  277. bar: '_0x654321'
  278. }
  279. }
  280. };
  281. });
  282. it('should not normalize options preset', () => {
  283. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  284. });
  285. });
  286. describe('Variant #2: some fields are exist with values', () => {
  287. before(() => {
  288. optionsPreset = getNormalizedOptions({
  289. ...getDefaultOptions(),
  290. identifierNamesCache: {
  291. globalIdentifiers: {
  292. foo: '_0x123456'
  293. },
  294. propertyIdentifiers: {}
  295. }
  296. });
  297. expectedOptionsPreset = {
  298. ...getDefaultOptions(),
  299. identifierNamesCache: {
  300. globalIdentifiers: {
  301. foo: '_0x123456'
  302. },
  303. propertyIdentifiers: {}
  304. }
  305. };
  306. });
  307. it('should not normalize options preset', () => {
  308. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  309. });
  310. });
  311. describe('Variant #3: all fields are exist with empty objects', () => {
  312. before(() => {
  313. optionsPreset = getNormalizedOptions({
  314. ...getDefaultOptions(),
  315. identifierNamesCache: {
  316. globalIdentifiers: {},
  317. propertyIdentifiers: {}
  318. }
  319. });
  320. expectedOptionsPreset = {
  321. ...getDefaultOptions(),
  322. identifierNamesCache: {
  323. globalIdentifiers: {},
  324. propertyIdentifiers: {}
  325. }
  326. };
  327. });
  328. it('should not normalize options preset', () => {
  329. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  330. });
  331. });
  332. describe('Variant #4: some fields are missing', () => {
  333. before(() => {
  334. optionsPreset = getNormalizedOptions({
  335. ...getDefaultOptions(),
  336. identifierNamesCache: {
  337. globalIdentifiers: {
  338. foo: '_0x123456'
  339. }
  340. }
  341. });
  342. expectedOptionsPreset = {
  343. ...getDefaultOptions(),
  344. identifierNamesCache: {
  345. globalIdentifiers: {
  346. foo: '_0x123456'
  347. },
  348. propertyIdentifiers: {}
  349. }
  350. };
  351. });
  352. it('should normalize options preset', () => {
  353. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  354. });
  355. });
  356. describe('Variant #5: all fields are missing', () => {
  357. before(() => {
  358. optionsPreset = getNormalizedOptions({
  359. ...getDefaultOptions(),
  360. identifierNamesCache: {}
  361. });
  362. expectedOptionsPreset = {
  363. ...getDefaultOptions(),
  364. identifierNamesCache: {
  365. globalIdentifiers: {},
  366. propertyIdentifiers: {}
  367. }
  368. };
  369. });
  370. it('should normalize options preset', () => {
  371. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  372. });
  373. });
  374. });
  375. describe('seedRule', () => {
  376. describe('Variant #1: seed value is string', () => {
  377. before(() => {
  378. optionsPreset = getNormalizedOptions({
  379. ...getDefaultOptions(),
  380. seed: 'abc'
  381. });
  382. expectedOptionsPreset = {
  383. ...getDefaultOptions(),
  384. seed: 'abc'
  385. };
  386. });
  387. it('should not normalize options preset', () => {
  388. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  389. });
  390. });
  391. describe('Variant #2: seed value is number', () => {
  392. before(() => {
  393. optionsPreset = getNormalizedOptions({
  394. ...getDefaultOptions(),
  395. seed: 123
  396. });
  397. expectedOptionsPreset = {
  398. ...getDefaultOptions(),
  399. seed: 123
  400. };
  401. });
  402. it('should normalize options preset', () => {
  403. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  404. });
  405. });
  406. describe('Variant #3: seed value is `0``', () => {
  407. let seedValue: number;
  408. before(() => {
  409. optionsPreset = getNormalizedOptions({
  410. ...getDefaultOptions(),
  411. seed: 0
  412. });
  413. seedValue = Number(optionsPreset.seed);
  414. });
  415. it('should normalize seed value', () => {
  416. assert.isAtLeast(seedValue, 0);
  417. assert.isBelow(seedValue, 999_999_999);
  418. });
  419. });
  420. });
  421. describe('selfDefendingRule', () => {
  422. before(() => {
  423. optionsPreset = getNormalizedOptions({
  424. ...getDefaultOptions(),
  425. selfDefending: true,
  426. compact: false
  427. });
  428. expectedOptionsPreset = {
  429. ...getDefaultOptions(),
  430. selfDefending: true,
  431. compact: true
  432. };
  433. });
  434. it('should normalize options preset', () => {
  435. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  436. });
  437. });
  438. describe('sourceMapBaseUrlRule', () => {
  439. describe('Variant #1: only source map base url', () => {
  440. before(() => {
  441. optionsPreset = getNormalizedOptions({
  442. ...getDefaultOptions(),
  443. sourceMapBaseUrl: 'http://localhost:9000',
  444. });
  445. expectedOptionsPreset = {
  446. ...getDefaultOptions(),
  447. sourceMapBaseUrl: ''
  448. };
  449. });
  450. it('should normalize options preset', () => {
  451. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  452. });
  453. });
  454. describe('Variant #2: source map base url with source map file name', () => {
  455. before(() => {
  456. optionsPreset = getNormalizedOptions({
  457. ...getDefaultOptions(),
  458. sourceMapBaseUrl: 'http://localhost:9000',
  459. sourceMapFileName: '/outputSourceMapName.map'
  460. });
  461. expectedOptionsPreset = {
  462. ...getDefaultOptions(),
  463. sourceMapBaseUrl: 'http://localhost:9000/',
  464. sourceMapFileName: 'outputSourceMapName.js.map'
  465. };
  466. });
  467. it('should normalize options preset', () => {
  468. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  469. });
  470. });
  471. });
  472. describe('sourceMapFileNameRule', () => {
  473. describe('Base filename without extension', () => {
  474. before(() => {
  475. optionsPreset = getNormalizedOptions({
  476. ...getDefaultOptions(),
  477. sourceMapBaseUrl: 'http://localhost:9000',
  478. sourceMapFileName: 'outputSourceMapName'
  479. });
  480. expectedOptionsPreset = {
  481. ...getDefaultOptions(),
  482. sourceMapBaseUrl: 'http://localhost:9000/',
  483. sourceMapFileName: 'outputSourceMapName.js.map'
  484. };
  485. });
  486. it('should normalize options preset', () => {
  487. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  488. });
  489. });
  490. describe('Slashes in file name', () => {
  491. before(() => {
  492. optionsPreset = getNormalizedOptions({
  493. ...getDefaultOptions(),
  494. sourceMapBaseUrl: 'http://localhost:9000',
  495. sourceMapFileName: '//outputSourceMapName'
  496. });
  497. expectedOptionsPreset = {
  498. ...getDefaultOptions(),
  499. sourceMapBaseUrl: 'http://localhost:9000/',
  500. sourceMapFileName: 'outputSourceMapName.js.map'
  501. };
  502. });
  503. it('should normalize options preset', () => {
  504. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  505. });
  506. });
  507. describe('`js` file extension in file name', () => {
  508. before(() => {
  509. optionsPreset = getNormalizedOptions({
  510. ...getDefaultOptions(),
  511. sourceMapBaseUrl: 'http://localhost:9000',
  512. sourceMapFileName: 'outputSourceMapName.js'
  513. });
  514. expectedOptionsPreset = {
  515. ...getDefaultOptions(),
  516. sourceMapBaseUrl: 'http://localhost:9000/',
  517. sourceMapFileName: 'outputSourceMapName.js.map'
  518. };
  519. });
  520. it('should normalize options preset', () => {
  521. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  522. });
  523. });
  524. describe('Non `js` file extension in file name', () => {
  525. before(() => {
  526. optionsPreset = getNormalizedOptions({
  527. ...getDefaultOptions(),
  528. sourceMapBaseUrl: 'http://localhost:9000',
  529. sourceMapFileName: 'outputSourceMapName.exe'
  530. });
  531. expectedOptionsPreset = {
  532. ...getDefaultOptions(),
  533. sourceMapBaseUrl: 'http://localhost:9000/',
  534. sourceMapFileName: 'outputSourceMapName.js.map'
  535. };
  536. });
  537. it('should normalize options preset', () => {
  538. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  539. });
  540. });
  541. describe('File hash in file name', () => {
  542. before(() => {
  543. optionsPreset = getNormalizedOptions({
  544. ...getDefaultOptions(),
  545. sourceMapBaseUrl: 'http://localhost:9000',
  546. sourceMapFileName: 'outputSourceMapName.7e2c49a622975ebd9b7e'
  547. });
  548. expectedOptionsPreset = {
  549. ...getDefaultOptions(),
  550. sourceMapBaseUrl: 'http://localhost:9000/',
  551. sourceMapFileName: 'outputSourceMapName.7e2c49a622975ebd9b7e.js.map'
  552. };
  553. });
  554. it('should normalize options preset', () => {
  555. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  556. });
  557. });
  558. describe('File hash and `js` file extension in file name #1', () => {
  559. before(() => {
  560. optionsPreset = getNormalizedOptions({
  561. ...getDefaultOptions(),
  562. sourceMapBaseUrl: 'http://localhost:9000',
  563. sourceMapFileName: 'outputSourceMapName.7e2c49a622975ebd9b7e.js'
  564. });
  565. expectedOptionsPreset = {
  566. ...getDefaultOptions(),
  567. sourceMapBaseUrl: 'http://localhost:9000/',
  568. sourceMapFileName: 'outputSourceMapName.7e2c49a622975ebd9b7e.js.map'
  569. };
  570. });
  571. it('should normalize options preset', () => {
  572. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  573. });
  574. });
  575. describe('File hash and non `js` file extension in file name', () => {
  576. before(() => {
  577. optionsPreset = getNormalizedOptions({
  578. ...getDefaultOptions(),
  579. sourceMapBaseUrl: 'http://localhost:9000',
  580. sourceMapFileName: 'outputSourceMapName.7e2c49a622975ebd9b7e.exe'
  581. });
  582. expectedOptionsPreset = {
  583. ...getDefaultOptions(),
  584. sourceMapBaseUrl: 'http://localhost:9000/',
  585. sourceMapFileName: 'outputSourceMapName.7e2c49a622975ebd9b7e.js.map'
  586. };
  587. });
  588. it('should normalize options preset', () => {
  589. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  590. });
  591. });
  592. });
  593. describe('splitStringsChunkLengthRule', () => {
  594. describe('`splitStringsChunkLengthRule` value is float number', () => {
  595. before(() => {
  596. optionsPreset = getNormalizedOptions({
  597. ...getDefaultOptions(),
  598. splitStrings: true,
  599. splitStringsChunkLength: 5.6
  600. });
  601. expectedOptionsPreset = {
  602. ...getDefaultOptions(),
  603. splitStrings: true,
  604. splitStringsChunkLength: 5
  605. };
  606. });
  607. it('should normalize options preset', () => {
  608. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  609. });
  610. });
  611. });
  612. describe('stringArrayRule', () => {
  613. before(() => {
  614. optionsPreset = getNormalizedOptions({
  615. ...getDefaultOptions(),
  616. shuffleStringArray: true,
  617. stringArray: false,
  618. stringArrayEncoding: [StringArrayEncoding.Rc4],
  619. stringArrayIndexShift: true,
  620. stringArrayWrappersChainedCalls: true,
  621. stringArrayWrappersCount: 5,
  622. stringArrayThreshold: 0.5,
  623. rotateStringArray: true
  624. });
  625. expectedOptionsPreset = {
  626. ...getDefaultOptions(),
  627. shuffleStringArray: false,
  628. stringArray: false,
  629. stringArrayEncoding: [StringArrayEncoding.None],
  630. stringArrayIndexShift: false,
  631. stringArrayWrappersChainedCalls: false,
  632. stringArrayWrappersCount: 0,
  633. stringArrayThreshold: 0,
  634. rotateStringArray: false
  635. };
  636. });
  637. it('should normalize options preset', () => {
  638. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  639. });
  640. });
  641. describe('stringArrayEncodingRule', () => {
  642. before(() => {
  643. optionsPreset = getNormalizedOptions({
  644. ...getDefaultOptions(),
  645. stringArrayEncoding: []
  646. });
  647. expectedOptionsPreset = {
  648. ...getDefaultOptions(),
  649. stringArrayEncoding: [
  650. StringArrayEncoding.None
  651. ]
  652. };
  653. });
  654. it('should normalize options preset', () => {
  655. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  656. });
  657. });
  658. describe('stringArrayWrappersChainedCallsRule', () => {
  659. before(() => {
  660. optionsPreset = getNormalizedOptions({
  661. ...getDefaultOptions(),
  662. stringArrayWrappersChainedCalls: true,
  663. stringArrayWrappersCount: 0
  664. });
  665. expectedOptionsPreset = {
  666. ...getDefaultOptions(),
  667. stringArrayWrappersChainedCalls: false,
  668. stringArrayWrappersCount: 0
  669. };
  670. });
  671. it('should normalize options preset', () => {
  672. assert.deepEqual(optionsPreset, expectedOptionsPreset);
  673. });
  674. });
  675. });
  676. });