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-129.spec.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. const {
  2. parse,
  3. inspect,
  4. stringify,
  5. transforms: { align },
  6. } = require('../../lib/index.cjs');
  7. const tokens = {
  8. start: '',
  9. delimiter: '',
  10. postDelimiter: '',
  11. tag: '',
  12. postTag: '',
  13. type: '',
  14. postType: '',
  15. name: '',
  16. postName: '',
  17. description: '',
  18. end: '',
  19. lineEnd: '',
  20. };
  21. test('carriage returns', () => {
  22. const parsed = parse(`
  23. /**
  24. * description\r
  25. * @param0 {param-type}\r
  26. * @param1 {param-type} paramName param description\r
  27. */`);
  28. const source = [
  29. {
  30. number: 1,
  31. source: ' /**',
  32. tokens: {
  33. ...tokens,
  34. start: ' ',
  35. delimiter: '/**',
  36. },
  37. },
  38. {
  39. number: 2,
  40. source: ' * description\r',
  41. tokens: {
  42. ...tokens,
  43. start: ' ',
  44. delimiter: '*',
  45. postDelimiter: ' ',
  46. description: 'description',
  47. lineEnd: '\r',
  48. },
  49. },
  50. {
  51. number: 3,
  52. source: ' * @param0 {param-type}\r',
  53. tokens: {
  54. ...tokens,
  55. start: ' ',
  56. delimiter: '*',
  57. postDelimiter: ' ',
  58. tag: '@param0',
  59. postTag: ' ',
  60. type: '{param-type}',
  61. lineEnd: '\r',
  62. },
  63. },
  64. {
  65. number: 4,
  66. source: ' * @param1 {param-type} paramName param description\r',
  67. tokens: {
  68. ...tokens,
  69. start: ' ',
  70. delimiter: '*',
  71. postDelimiter: ' ',
  72. tag: '@param1',
  73. postTag: ' ',
  74. type: '{param-type}',
  75. postType: ' ',
  76. name: 'paramName',
  77. postName: ' ',
  78. description: 'param description',
  79. lineEnd: '\r',
  80. },
  81. },
  82. {
  83. number: 5,
  84. source: ' */',
  85. tokens: {
  86. ...tokens,
  87. start: ' ',
  88. end: '*/',
  89. },
  90. },
  91. ];
  92. expect(parsed[0]).toMatchObject({
  93. description: 'description',
  94. problems: [],
  95. source,
  96. tags: [
  97. {
  98. tag: 'param0',
  99. type: 'param-type',
  100. name: '',
  101. optional: false,
  102. description: '',
  103. source: [source[2]],
  104. },
  105. {
  106. tag: 'param1',
  107. type: 'param-type',
  108. name: 'paramName',
  109. optional: false,
  110. description: 'param description',
  111. source: [source[3], source[4]],
  112. },
  113. ],
  114. });
  115. });
  116. test('carriage returns with alignment', () => {
  117. const source = `
  118. /**\r
  119. * Description may go\r
  120. * over multiple lines followed by @tags\r
  121. * @param {string} name the name parameter\r
  122. * @param {any} value\r
  123. */\r`.slice(1);
  124. const expected = `
  125. /**\r
  126. * Description may go\r
  127. * over multiple lines followed by @tags\r
  128. * @param {string} name the name parameter\r
  129. * @param {any} value\r
  130. */\r`.slice(1);
  131. const parsed = parse(source);
  132. const aligned = align()(parsed[0]);
  133. const stringified = stringify(aligned);
  134. expect(stringified).toEqual(expected);
  135. });