Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

issue-61.spec.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. const { default: getParser } = require('../../lib/parser/index.cjs');
  2. test('fenced description', () => {
  3. const parsed = getParser({ spacing: 'preserve' })(`
  4. /**
  5. * @example "" \`\`\`ts
  6. @transient()
  7. class Foo { }
  8. \`\`\`
  9. */`);
  10. const source = [
  11. {
  12. number: 1,
  13. source: ' /**',
  14. tokens: {
  15. start: ' ',
  16. delimiter: '/**',
  17. postDelimiter: '',
  18. tag: '',
  19. postTag: '',
  20. name: '',
  21. postName: '',
  22. type: '',
  23. postType: '',
  24. description: '',
  25. end: '',
  26. lineEnd: '',
  27. },
  28. },
  29. {
  30. number: 2,
  31. source: ' * @example "" ```ts',
  32. tokens: {
  33. start: ' ',
  34. delimiter: '*',
  35. postDelimiter: ' ',
  36. tag: '@example',
  37. postTag: ' ',
  38. name: '""',
  39. postName: ' ',
  40. type: '',
  41. postType: '',
  42. description: '```ts',
  43. end: '',
  44. lineEnd: '',
  45. },
  46. },
  47. {
  48. number: 3,
  49. source: '@transient()',
  50. tokens: {
  51. start: '',
  52. delimiter: '',
  53. postDelimiter: '',
  54. tag: '',
  55. postTag: '',
  56. name: '',
  57. postName: '',
  58. type: '',
  59. postType: '',
  60. description: '@transient()',
  61. end: '',
  62. lineEnd: '',
  63. },
  64. },
  65. {
  66. number: 4,
  67. source: 'class Foo { }',
  68. tokens: {
  69. start: '',
  70. delimiter: '',
  71. postDelimiter: '',
  72. tag: '',
  73. postTag: '',
  74. name: '',
  75. postName: '',
  76. type: '',
  77. postType: '',
  78. description: 'class Foo { }',
  79. end: '',
  80. lineEnd: '',
  81. },
  82. },
  83. {
  84. number: 5,
  85. source: '```',
  86. tokens: {
  87. start: '',
  88. delimiter: '',
  89. postDelimiter: '',
  90. tag: '',
  91. postTag: '',
  92. name: '',
  93. postName: '',
  94. type: '',
  95. postType: '',
  96. description: '```',
  97. end: '',
  98. lineEnd: '',
  99. },
  100. },
  101. {
  102. number: 6,
  103. source: ' */',
  104. tokens: {
  105. start: ' ',
  106. delimiter: '',
  107. postDelimiter: '',
  108. tag: '',
  109. postTag: '',
  110. name: '',
  111. postName: '',
  112. type: '',
  113. postType: '',
  114. description: '',
  115. end: '*/',
  116. lineEnd: '',
  117. },
  118. },
  119. ];
  120. expect(parsed).toEqual([
  121. {
  122. description: '',
  123. tags: [
  124. {
  125. tag: 'example',
  126. name: '',
  127. type: '',
  128. optional: false,
  129. description: '```ts\n@transient()\nclass Foo { }\n```',
  130. problems: [],
  131. source: source.slice(1),
  132. },
  133. ],
  134. source,
  135. problems: [],
  136. },
  137. ]);
  138. });
  139. test('fenced one-liner', () => {
  140. const parsed = getParser({ spacing: 'preserve' })(
  141. '/** @example "" ```ts @transient() class Foo { } ```*/'
  142. );
  143. const source = [
  144. {
  145. number: 0,
  146. source: '/** @example "" ```ts @transient() class Foo { } ```*/',
  147. tokens: {
  148. start: '',
  149. delimiter: '/**',
  150. postDelimiter: ' ',
  151. tag: '@example',
  152. postTag: ' ',
  153. name: '""',
  154. postName: ' ',
  155. type: '',
  156. postType: '',
  157. description: '```ts @transient() class Foo { } ```',
  158. end: '*/',
  159. lineEnd: '',
  160. },
  161. },
  162. ];
  163. expect(parsed).toEqual([
  164. {
  165. description: '',
  166. tags: [
  167. {
  168. tag: 'example',
  169. name: '',
  170. type: '',
  171. optional: false,
  172. description: '```ts @transient() class Foo { } ```',
  173. problems: [],
  174. source,
  175. },
  176. ],
  177. source,
  178. problems: [],
  179. },
  180. ]);
  181. });
  182. test('multiple fences', () => {
  183. const parsed = getParser({ spacing: 'preserve' })(`
  184. /**
  185. * @example "" \`\`\`ts
  186. @one
  187. \`\`\`
  188. text
  189. \`\`\`
  190. @two
  191. \`\`\`
  192. */`);
  193. const source = [
  194. {
  195. number: 1,
  196. source: ' /**',
  197. tokens: {
  198. start: ' ',
  199. delimiter: '/**',
  200. postDelimiter: '',
  201. tag: '',
  202. postTag: '',
  203. name: '',
  204. postName: '',
  205. type: '',
  206. postType: '',
  207. description: '',
  208. end: '',
  209. lineEnd: '',
  210. },
  211. },
  212. {
  213. number: 2,
  214. source: ' * @example "" ```ts',
  215. tokens: {
  216. start: ' ',
  217. delimiter: '*',
  218. postDelimiter: ' ',
  219. tag: '@example',
  220. postTag: ' ',
  221. name: '""',
  222. postName: ' ',
  223. type: '',
  224. postType: '',
  225. description: '```ts',
  226. end: '',
  227. lineEnd: '',
  228. },
  229. },
  230. {
  231. number: 3,
  232. source: '@one',
  233. tokens: {
  234. start: '',
  235. delimiter: '',
  236. postDelimiter: '',
  237. tag: '',
  238. postTag: '',
  239. name: '',
  240. postName: '',
  241. type: '',
  242. postType: '',
  243. description: '@one',
  244. end: '',
  245. lineEnd: '',
  246. },
  247. },
  248. {
  249. number: 4,
  250. source: '```',
  251. tokens: {
  252. start: '',
  253. delimiter: '',
  254. postDelimiter: '',
  255. tag: '',
  256. postTag: '',
  257. name: '',
  258. postName: '',
  259. type: '',
  260. postType: '',
  261. description: '```',
  262. end: '',
  263. lineEnd: '',
  264. },
  265. },
  266. {
  267. number: 5,
  268. source: 'text',
  269. tokens: {
  270. start: '',
  271. delimiter: '',
  272. postDelimiter: '',
  273. tag: '',
  274. postTag: '',
  275. name: '',
  276. postName: '',
  277. type: '',
  278. postType: '',
  279. description: 'text',
  280. end: '',
  281. lineEnd: '',
  282. },
  283. },
  284. {
  285. number: 6,
  286. source: '```',
  287. tokens: {
  288. start: '',
  289. delimiter: '',
  290. postDelimiter: '',
  291. tag: '',
  292. postTag: '',
  293. name: '',
  294. postName: '',
  295. type: '',
  296. postType: '',
  297. description: '```',
  298. end: '',
  299. lineEnd: '',
  300. },
  301. },
  302. {
  303. number: 7,
  304. source: '@two',
  305. tokens: {
  306. start: '',
  307. delimiter: '',
  308. postDelimiter: '',
  309. tag: '',
  310. postTag: '',
  311. name: '',
  312. postName: '',
  313. type: '',
  314. postType: '',
  315. description: '@two',
  316. end: '',
  317. lineEnd: '',
  318. },
  319. },
  320. {
  321. number: 8,
  322. source: '```',
  323. tokens: {
  324. start: '',
  325. delimiter: '',
  326. postDelimiter: '',
  327. tag: '',
  328. postTag: '',
  329. name: '',
  330. postName: '',
  331. type: '',
  332. postType: '',
  333. description: '```',
  334. end: '',
  335. lineEnd: '',
  336. },
  337. },
  338. {
  339. number: 9,
  340. source: ' */',
  341. tokens: {
  342. start: ' ',
  343. delimiter: '',
  344. postDelimiter: '',
  345. tag: '',
  346. postTag: '',
  347. name: '',
  348. postName: '',
  349. type: '',
  350. postType: '',
  351. description: '',
  352. end: '*/',
  353. lineEnd: '',
  354. },
  355. },
  356. ];
  357. expect(parsed).toEqual([
  358. {
  359. description: '',
  360. tags: [
  361. {
  362. tag: 'example',
  363. name: '',
  364. type: '',
  365. optional: false,
  366. description: '```ts\n@one\n```\ntext\n```\n@two\n```',
  367. source: source.slice(1),
  368. problems: [],
  369. },
  370. ],
  371. source,
  372. problems: [],
  373. },
  374. ]);
  375. });
  376. test('custom fences', () => {
  377. const parsed = getParser({ spacing: 'preserve', fence: '###' })(`
  378. /**
  379. * @example "" ###ts
  380. @one
  381. ###
  382. text
  383. ###
  384. @two
  385. ###
  386. */`);
  387. const source = [
  388. {
  389. number: 1,
  390. source: ' /**',
  391. tokens: {
  392. start: ' ',
  393. delimiter: '/**',
  394. postDelimiter: '',
  395. tag: '',
  396. postTag: '',
  397. name: '',
  398. postName: '',
  399. type: '',
  400. postType: '',
  401. description: '',
  402. end: '',
  403. lineEnd: '',
  404. },
  405. },
  406. {
  407. number: 2,
  408. source: ' * @example "" ###ts',
  409. tokens: {
  410. start: ' ',
  411. delimiter: '*',
  412. postDelimiter: ' ',
  413. tag: '@example',
  414. postTag: ' ',
  415. name: '""',
  416. postName: ' ',
  417. type: '',
  418. postType: '',
  419. description: '###ts',
  420. end: '',
  421. lineEnd: '',
  422. },
  423. },
  424. {
  425. number: 3,
  426. source: '@one',
  427. tokens: {
  428. start: '',
  429. delimiter: '',
  430. postDelimiter: '',
  431. tag: '',
  432. postTag: '',
  433. name: '',
  434. postName: '',
  435. type: '',
  436. postType: '',
  437. description: '@one',
  438. end: '',
  439. lineEnd: '',
  440. },
  441. },
  442. {
  443. number: 4,
  444. source: '###',
  445. tokens: {
  446. start: '',
  447. delimiter: '',
  448. postDelimiter: '',
  449. tag: '',
  450. postTag: '',
  451. name: '',
  452. postName: '',
  453. type: '',
  454. postType: '',
  455. description: '###',
  456. end: '',
  457. lineEnd: '',
  458. },
  459. },
  460. {
  461. number: 5,
  462. source: 'text',
  463. tokens: {
  464. start: '',
  465. delimiter: '',
  466. postDelimiter: '',
  467. tag: '',
  468. postTag: '',
  469. name: '',
  470. postName: '',
  471. type: '',
  472. postType: '',
  473. description: 'text',
  474. end: '',
  475. lineEnd: '',
  476. },
  477. },
  478. {
  479. number: 6,
  480. source: '###',
  481. tokens: {
  482. start: '',
  483. delimiter: '',
  484. postDelimiter: '',
  485. tag: '',
  486. postTag: '',
  487. name: '',
  488. postName: '',
  489. type: '',
  490. postType: '',
  491. description: '###',
  492. end: '',
  493. lineEnd: '',
  494. },
  495. },
  496. {
  497. number: 7,
  498. source: '@two',
  499. tokens: {
  500. start: '',
  501. delimiter: '',
  502. postDelimiter: '',
  503. tag: '',
  504. postTag: '',
  505. name: '',
  506. postName: '',
  507. type: '',
  508. postType: '',
  509. description: '@two',
  510. end: '',
  511. lineEnd: '',
  512. },
  513. },
  514. {
  515. number: 8,
  516. source: '###',
  517. tokens: {
  518. start: '',
  519. delimiter: '',
  520. postDelimiter: '',
  521. tag: '',
  522. postTag: '',
  523. name: '',
  524. postName: '',
  525. type: '',
  526. postType: '',
  527. description: '###',
  528. end: '',
  529. lineEnd: '',
  530. },
  531. },
  532. {
  533. number: 9,
  534. source: ' */',
  535. tokens: {
  536. start: ' ',
  537. delimiter: '',
  538. postDelimiter: '',
  539. tag: '',
  540. postTag: '',
  541. name: '',
  542. postName: '',
  543. type: '',
  544. postType: '',
  545. description: '',
  546. end: '*/',
  547. lineEnd: '',
  548. },
  549. },
  550. ];
  551. expect(parsed).toEqual([
  552. {
  553. description: '',
  554. tags: [
  555. {
  556. tag: 'example',
  557. name: '',
  558. type: '',
  559. optional: false,
  560. description: '###ts\n@one\n###\ntext\n###\n@two\n###',
  561. source: source.slice(1),
  562. problems: [],
  563. },
  564. ],
  565. source,
  566. problems: [],
  567. },
  568. ]);
  569. });