rtlcss-directives.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. module.exports = [
  2. {
  3. 'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (autoRename:true)',
  4. 'expected': '.right .rtl .bright .ultra { display:block; }',
  5. 'input': '/*rtl:ignore*/ .right .rtl .bright .ultra { display:block; }',
  6. 'reversable': false,
  7. 'options': { 'autoRename': true }
  8. },
  9. {
  10. 'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (autoRename:true, clean: false)',
  11. 'expected': '/*rtl:ignore*/ .right .rtl .bright .ultra { display:block; }',
  12. 'input': '/*rtl:ignore*/ .right .rtl .bright .ultra { display:block; }',
  13. 'reversable': false,
  14. 'options': { 'autoRename': true, 'clean': false }
  15. },
  16. {
  17. 'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (autoRename:true, !important comment)',
  18. 'expected': '.right .rtl .bright .ultra { display:block; }',
  19. 'input': '/*!rtl:ignore*/ .right .rtl .bright .ultra { display:block; }',
  20. 'reversable': false,
  21. 'options': { 'autoRename': true }
  22. },
  23. {
  24. 'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (autoRename:true, clean:false, !important comment)',
  25. 'expected': '/*!rtl:ignore*/ .right .rtl .bright .ultra { display:block; }',
  26. 'input': '/*!rtl:ignore*/ .right .rtl .bright .ultra { display:block; }',
  27. 'reversable': false,
  28. 'options': { 'autoRename': true, 'clean': false }
  29. },
  30. {
  31. 'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (autoRename:true,greedy)',
  32. 'expected': '.right .rtl .bright .ultra { display:block; }',
  33. 'input': '/*rtl:ignore*/ .right .rtl .bright .ultra { display:block; }',
  34. 'reversable': false,
  35. 'options': { 'autoRename': true, 'greedy': true }
  36. },
  37. {
  38. 'should': 'Should auto rename selectors having no directional decl. unless forced to ignore. (autoRename:true, greedy, !important comment)',
  39. 'expected': '.right .rtl .bright .ultra { display:block; }',
  40. 'input': '/*!rtl:ignore*/ .right .rtl .bright .ultra { display:block; }',
  41. 'reversable': false,
  42. 'options': { 'autoRename': true, 'greedy': true }
  43. },
  44. {
  45. 'should': 'Should rename selectors when forced. (default)',
  46. 'expected': '.left .ltr .bright .ultra { display:block; }',
  47. 'input': '/*rtl:rename*/.right .rtl .bright .ultra { display:block; }',
  48. 'reversable': false
  49. },
  50. {
  51. 'should': 'Should rename selectors when forced. (clean:false)',
  52. 'expected': '/*rtl:rename*/.left .ltr .bright .ultra { display:block; left:0;}',
  53. 'input': '/*rtl:rename*/.right .rtl .bright .ultra { display:block; right:0;}',
  54. 'reversable': false,
  55. 'options': { 'clean': false }
  56. },
  57. {
  58. 'should': 'Should rename selectors when forced. (!important comment)',
  59. 'expected': '.left .ltr .bright .ultra { display:block; left:0; }',
  60. 'input': '/*!rtl:rename*/.right .rtl .bright .ultra { display:block; right:0; }',
  61. 'reversable': false
  62. },
  63. {
  64. 'should': 'Should rename selectors when forced. (clean:false, !important comment)',
  65. 'expected': '/*!rtl:rename*/.left .ltr .bright .ultra { display:block; left:0; }',
  66. 'input': '/*!rtl:rename*/.right .rtl .bright .ultra { display:block; right:0; }',
  67. 'reversable': false,
  68. 'options': { 'clean': false }
  69. },
  70. {
  71. 'should': 'Should rename selectors when forced. (greedy)',
  72. 'expected': '.left .ltr .bleft .urtla { display:block; left:0; }',
  73. 'input': '/*rtl:rename*/.right .rtl .bright .ultra { display:block; right:0; }',
  74. 'reversable': false,
  75. 'options': { 'greedy': true }
  76. },
  77. {
  78. 'should': 'Should rename selectors when forced. (greedy, !important comment)',
  79. 'expected': '.left .ltr .bleft .urtla { display:block; left:0; }',
  80. 'input': '/*!rtl:rename*/.right .rtl .bright .ultra { display:block; right:0; }',
  81. 'reversable': false,
  82. 'options': { 'greedy': true }
  83. },
  84. {
  85. 'should': 'Should prepend value. (default)',
  86. 'expected': 'div { font-family: "Droid Arabic Kufi", "Droid Sans", Tahoma; }',
  87. 'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:prepend:"Droid Arabic Kufi", */; }',
  88. 'reversable': false
  89. },
  90. {
  91. 'should': 'Should prepend value. (clean:false)',
  92. 'expected': 'div { font-family: "Droid Arabic Kufi", "Droid Sans", Tahoma/*rtl:prepend:"Droid Arabic Kufi", */; }',
  93. 'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:prepend:"Droid Arabic Kufi", */; }',
  94. 'reversable': false,
  95. 'options': { 'clean': false }
  96. },
  97. {
  98. 'should': 'Should prepend value (!important comment)',
  99. 'expected': 'div { font-family: "Droid Arabic Kufi", "Droid Sans", Tahoma; }',
  100. 'input': 'div { font-family: "Droid Sans", Tahoma/*!rtl:prepend:"Droid Arabic Kufi", */; }',
  101. 'reversable': false
  102. },
  103. {
  104. 'should': 'Should prepend value (clean:false, !important comment)',
  105. 'expected': 'div { font-family: "Droid Arabic Kufi", "Droid Sans", Tahoma/*!rtl:prepend:"Droid Arabic Kufi", */; }',
  106. 'input': 'div { font-family: "Droid Sans", Tahoma/*!rtl:prepend:"Droid Arabic Kufi", */; }',
  107. 'reversable': false,
  108. 'options': { 'clean': false }
  109. },
  110. {
  111. 'should': 'Should replace value.',
  112. 'expected': 'div { font-family: "Droid Arabic Kufi"; }',
  113. 'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:"Droid Arabic Kufi"*/; }',
  114. 'reversable': false
  115. },
  116. {
  117. 'should': 'Should replace value.(clean:false)',
  118. 'expected': 'div { font-family: "Droid Arabic Kufi"/*rtl:"Droid Arabic Kufi"*/; }',
  119. 'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:"Droid Arabic Kufi"*/; }',
  120. 'reversable': false,
  121. 'options': { 'clean': false }
  122. },
  123. {
  124. 'should': 'Should replace value. (!important comment)',
  125. 'expected': 'div { font-family: "Droid Arabic Kufi"; }',
  126. 'input': 'div { font-family: "Droid Sans", Tahoma/*!rtl:"Droid Arabic Kufi"*/; }',
  127. 'reversable': false
  128. },
  129. {
  130. 'should': 'Should replace value. (clean:false, !important comment)',
  131. 'expected': 'div { font-family: "Droid Arabic Kufi"/*!rtl:"Droid Arabic Kufi"*/; }',
  132. 'input': 'div { font-family: "Droid Sans", Tahoma/*!rtl:"Droid Arabic Kufi"*/; }',
  133. 'reversable': false,
  134. 'options': { 'clean': false }
  135. },
  136. {
  137. 'should': 'Should append value. (default)',
  138. 'expected': 'div { font-family: "Droid Sans", Tahoma, "Droid Arabic Kufi"; }',
  139. 'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:append:, "Droid Arabic Kufi"*/; }',
  140. 'reversable': false
  141. },
  142. {
  143. 'should': 'Should append value. (clean:false)',
  144. 'expected': 'div { font-family: "Droid Sans", Tahoma/*rtl:append:, "Droid Arabic Kufi"*/, "Droid Arabic Kufi"; }',
  145. 'input': 'div { font-family: "Droid Sans", Tahoma/*rtl:append:, "Droid Arabic Kufi"*/; }',
  146. 'reversable': false,
  147. 'options': { 'clean': false }
  148. },
  149. {
  150. 'should': 'Should append value. (!important comment)',
  151. 'expected': 'div { font-family: "Droid Sans", Tahoma, "Droid Arabic Kufi"; }',
  152. 'input': 'div { font-family: "Droid Sans", Tahoma/*!rtl:append:, "Droid Arabic Kufi"*/; }',
  153. 'reversable': false
  154. },
  155. {
  156. 'should': 'Should append value. (clean:false, !important comment)',
  157. 'expected': 'div { font-family: "Droid Sans", Tahoma/*!rtl:append:, "Droid Arabic Kufi"*/, "Droid Arabic Kufi"; }',
  158. 'input': 'div { font-family: "Droid Sans", Tahoma/*!rtl:append:, "Droid Arabic Kufi"*/; }',
  159. 'reversable': false,
  160. 'options': { 'clean': false }
  161. },
  162. {
  163. 'should': 'Should insert value. (default)',
  164. 'expected': 'div { font-family: "Droid Sans", "Droid Arabic Kufi", Tahoma; }',
  165. 'input': 'div { font-family: "Droid Sans"/*rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
  166. 'reversable': false
  167. },
  168. {
  169. 'should': 'Should insert value. (clean:false)',
  170. 'expected': 'div { font-family: "Droid Sans", "Droid Arabic Kufi"/*rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
  171. 'input': 'div { font-family: "Droid Sans"/*rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
  172. 'reversable': false,
  173. 'options': { 'clean': false }
  174. },
  175. {
  176. 'should': 'Should insert value. (!important comment)',
  177. 'expected': 'div { font-family: "Droid Sans", "Droid Arabic Kufi", Tahoma; }',
  178. 'input': 'div { font-family: "Droid Sans"/*!rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
  179. 'reversable': false
  180. },
  181. {
  182. 'should': 'Should insert value. (clean:false, !important comment)',
  183. 'expected': 'div { font-family: "Droid Sans", "Droid Arabic Kufi"/*!rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
  184. 'input': 'div { font-family: "Droid Sans"/*!rtl:insert:, "Droid Arabic Kufi"*/, Tahoma; }',
  185. 'reversable': false,
  186. 'options': { 'clean': false }
  187. },
  188. {
  189. 'should': 'Should ignore flipping - rule level (default)',
  190. 'expected': 'div { left:10px; text-align:right;}',
  191. 'input': '/*rtl:ignore*/div { left:10px; text-align:right;}',
  192. 'reversable': false
  193. },
  194. {
  195. 'should': 'Should ignore flipping - rule level (clean:false)',
  196. 'expected': '/*rtl:ignore*/div { left:10px; text-align:right;}',
  197. 'input': '/*rtl:ignore*/div { left:10px; text-align:right;}',
  198. 'reversable': false,
  199. 'options': { 'clean': false }
  200. },
  201. {
  202. 'should': 'Should ignore flipping - rule level (default, !important comment)',
  203. 'expected': 'div { left:10px; text-align:right;}',
  204. 'input': '/*!rtl:ignore*/div { left:10px; text-align:right;}',
  205. 'reversable': false
  206. },
  207. {
  208. 'should': 'Should ignore flipping - rule level (clean:false , !important comment)',
  209. 'expected': '/*!rtl:ignore*/div { left:10px; text-align:right;}',
  210. 'input': '/*!rtl:ignore*/div { left:10px; text-align:right;}',
  211. 'reversable': false,
  212. 'options': { 'clean': false }
  213. },
  214. {
  215. 'should': 'Should ignore flipping - decl. level (default)',
  216. 'expected': 'div { left:10px;text-align:left;}',
  217. 'input': 'div { left:10px/*rtl:ignore*/;text-align:right;}',
  218. 'reversable': false
  219. },
  220. {
  221. 'should': 'Should ignore flipping - decl. level (clean:false)',
  222. 'expected': 'div { left:10px/*rtl:ignore*/;text-align:left;}',
  223. 'input': 'div { left:10px/*rtl:ignore*/;text-align:right;}',
  224. 'reversable': false,
  225. 'options': { 'clean': false }
  226. },
  227. {
  228. 'should': 'Should ignore flipping - decl. level (default, !important comment)',
  229. 'expected': 'div { left:10px;text-align:left;}',
  230. 'input': 'div { left:10px/*!rtl:ignore*/;text-align:right;}',
  231. 'reversable': false
  232. },
  233. {
  234. 'should': 'Should ignore flipping - decl. level (clean:false, !important comment)',
  235. 'expected': 'div { left:10px/*!rtl:ignore*/;text-align:left;}',
  236. 'input': 'div { left:10px/*!rtl:ignore*/;text-align:right;}',
  237. 'options': { 'clean': false }
  238. },
  239. {
  240. 'should': 'Should add raw css rules',
  241. 'expected': 'div { left:10px;text-align:right;} a {display:block;}',
  242. 'input': '/*rtl:raw:div { left:10px;text-align:right;}*/ a {display:block;}',
  243. 'reversable': false
  244. },
  245. {
  246. 'should': 'Should add raw css declarations',
  247. 'expected': 'div { font-family: "Droid Kufi Arabic"; right:10px;text-align:left;}',
  248. 'input': 'div { /*rtl:raw: font-family: "Droid Kufi Arabic";*/ left:10px;text-align:right;}',
  249. 'reversable': false
  250. },
  251. {
  252. 'should': 'Should add raw css (clean:false)',
  253. 'expected': 'div { left:10px;text-align:right;} /*rtl:raw:div { left:10px;text-align:right;}*/ a {display:block;}',
  254. 'input': '/*rtl:raw:div { left:10px;text-align:right;}*/ a {display:block;}',
  255. 'reversable': false,
  256. 'options': { 'clean': false }
  257. },
  258. {
  259. 'should': 'Should add raw css declarations (clean:false)',
  260. 'expected': 'div { font-family: "Droid Kufi Arabic"; /*rtl:raw: font-family: "Droid Kufi Arabic";*/ right:10px;text-align:left;}',
  261. 'input': 'div { /*rtl:raw: font-family: "Droid Kufi Arabic";*/ left:10px;text-align:right;}',
  262. 'reversable': false,
  263. 'options': { 'clean': false }
  264. },
  265. {
  266. 'should': 'Should support block-style',
  267. 'expected': ' div {left:10px; text-align:right;}',
  268. 'input': ' div {/*rtl:begin:ignore*/left:10px;/*rtl:end:ignore*/ text-align:left;}',
  269. 'reversable': false
  270. },
  271. {
  272. 'should': 'Should support none block-style',
  273. 'expected': ' div {left:10px; text-align:left;}',
  274. 'input': ' /*rtl:ignore*/div {left:10px; text-align:left;}',
  275. 'reversable': false
  276. },
  277. {
  278. 'should': 'Should remove rules (block-style)',
  279. 'expected': ' b{float:right;}',
  280. 'input': ' /*rtl:begin:remove*/div {left:10px; text-align:left;} a { display:block;} /*rtl:end:remove*/ b{float:left;}',
  281. 'reversable': false
  282. },
  283. {
  284. 'should': 'Should remove rules',
  285. 'expected': ' a { display:block;} b{float:right;}',
  286. 'input': ' /*rtl:remove*/div {left:10px; text-align:left;} a { display:block;} b{float:left;}',
  287. 'reversable': false
  288. },
  289. {
  290. 'should': 'Should remove declarations',
  291. 'expected': ' div { text-align:right;}',
  292. 'input': ' div {/*rtl:remove*/left:10px; text-align:left;}',
  293. 'reversable': false
  294. },
  295. {
  296. 'should': 'Should remove declarations (block-style)',
  297. 'expected': ' div { display:inline;}',
  298. 'input': ' div {/*rtl:begin:remove*/left:10px; text-align:left;/*rtl:end:remove*/ display:inline;}',
  299. 'reversable': false
  300. },
  301. {
  302. 'should': 'Should override options',
  303. 'expected': '.right { display:inline;}',
  304. 'input': '/*rtl:options:{"autoRename":false}*/ .right { display:inline;}',
  305. 'reversable': false,
  306. 'options': { 'autoRename': true }
  307. },
  308. {
  309. 'should': 'Should support nested options override',
  310. 'expected': '.right { display:inline;}.bleft { display:inline;}',
  311. 'input': '/*rtl:begin:options:{"autoRename":false}*/ .right { display:inline;} /*rtl:begin:options:{"autoRename":true, "greedy": true}*/.bright { display:inline;}/*rtl:end:options*//*rtl:end:options*/',
  312. 'reversable': false,
  313. 'options': { 'autoRename': true }
  314. },
  315. {
  316. 'should': 'Should ignore the target node (decl)',
  317. 'expected': `
  318. .code {
  319. direction:ltr;
  320. text-align:left;
  321. float: right;
  322. text-align: left;
  323. }
  324. `,
  325. 'input': `
  326. .code {
  327. /*rtl:ignore*/
  328. direction:ltr;
  329. /*rtl:ignore*/
  330. text-align:left;
  331. /*rtl:ignore*/
  332. float: right;
  333. /*rtl:ignore*/
  334. text-align: left;
  335. }
  336. `,
  337. 'reversable': false
  338. },
  339. {
  340. 'should': 'Should ignore the target node (rule)',
  341. 'expected': `
  342. .example-1 {
  343. text-align:right;
  344. left:10px;
  345. }
  346. .example-2 {
  347. left:10px;
  348. text-align:right;
  349. }
  350. .example-3 {
  351. right:10px;
  352. text-align:left;
  353. }
  354. `,
  355. 'input': `
  356. /*rtl:ignore*/
  357. .example-1 {
  358. text-align:right;
  359. left:10px;
  360. }
  361. /*rtl:ignore*/
  362. .example-2 {
  363. left:10px;
  364. text-align:right;
  365. }
  366. .example-3 {
  367. left:10px;
  368. text-align:right;
  369. }
  370. `,
  371. 'reversable': false
  372. },
  373. {
  374. 'should': 'Should ignore the target node (atrule)',
  375. 'expected': `
  376. @media screen and (max-width: 568px) {
  377. .example {
  378. left:10px;
  379. text-align:right;
  380. }
  381. }
  382. @media screen and (max-width: 568px) {
  383. .example {
  384. right:10px;
  385. text-align:left;
  386. }
  387. }
  388. `,
  389. 'input': `
  390. /*rtl:ignore*/
  391. @media screen and (max-width: 568px) {
  392. .example {
  393. left:10px;
  394. text-align:right;
  395. }
  396. }
  397. @media screen and (max-width: 568px) {
  398. .example {
  399. left:10px;
  400. text-align:right;
  401. }
  402. }
  403. `,
  404. 'reversable': false
  405. },
  406. {
  407. 'should': 'Should ignore white spaces before value directive prefix',
  408. 'expected': ' div { direction:ltr; text-align:right;}',
  409. 'input': ' div { direction:ltr/* rtl:ignore*/; text-align:left;}',
  410. 'reversable': false
  411. },
  412. {
  413. 'should': 'Should ignore white spaces before value directive perfix (!important comment)',
  414. 'expected': ' div { direction:ltr; text-align:right;}',
  415. 'input': ' div { direction:ltr/* !rtl:ignore*/; text-align:left;}',
  416. 'reversable': false
  417. },
  418. {
  419. 'should': 'Should ignore white spaces before directive prefix (block-style) ',
  420. 'expected': ' div { direction:ltr; text-align:right;}',
  421. 'input': ' div {/* rtl:begin:ignore*/ direction:ltr;/* rtl:end:ignore*/ text-align:left;}',
  422. 'reversable': false
  423. },
  424. {
  425. 'should': 'Should ignore white spaces before directive prefix (block-style, !important comment) ',
  426. 'expected': ' div { direction:ltr; text-align:right;}',
  427. 'input': ' div {/* !rtl:begin:ignore*/ direction:ltr;/* ! rtl:end:ignore*/ text-align:left;}',
  428. 'reversable': false
  429. }
  430. ]