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.

util.spec.ts 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import {
  2. isSpace,
  3. seedTokens,
  4. seedBlock,
  5. splitLines,
  6. splitSpace,
  7. seedSpec,
  8. } from '../../src/util';
  9. test.each([
  10. ['win', 'a\r\nb\r\nc', ['a\r', 'b\r', 'c']],
  11. ['unix', 'a\nb\nc', ['a', 'b', 'c']],
  12. ['mixed', 'a\nb\r\nc', ['a', 'b\r', 'c']],
  13. ['none', 'abc', ['abc']],
  14. ])('spliLines - %s', (name, source, parsed) =>
  15. expect(splitLines(source)).toEqual(parsed)
  16. );
  17. test.each([
  18. ['pre', ' abc', [' ', 'abc']],
  19. ['pre', 'abc ', ['', 'abc ']],
  20. ['pre+post', ' abc ', [' ', 'abc ']],
  21. ['none', 'abc', ['', 'abc']],
  22. ])('spliSpace - %s', (name, source, parsed) =>
  23. expect(splitSpace(source)).toEqual(parsed)
  24. );
  25. test.each([
  26. ['space', ' ', true],
  27. ['spaces', ' ', true],
  28. ['tab', '\t', true],
  29. ['tabs', '\t\t', true],
  30. ['line end', '\n', true],
  31. ['line ends', '\n\n', true],
  32. ['line return', '\r', true],
  33. ['line returns', '\r\r', true],
  34. ['mixed space', '\n\r\t', true],
  35. ['mixed', '\naba', false],
  36. ['alpahnumeric', '1abcd34', false],
  37. ['symbols', '*', false],
  38. ['empty', '', false],
  39. ])('isSpace - %s', (name, source, result) =>
  40. expect(isSpace(source)).toBe(result)
  41. );
  42. test('seedTokens defaults', () => {
  43. expect(seedTokens()).toEqual({
  44. start: '',
  45. delimiter: '',
  46. postDelimiter: '',
  47. tag: '',
  48. postTag: '',
  49. name: '',
  50. postName: '',
  51. type: '',
  52. postType: '',
  53. description: '',
  54. end: '',
  55. lineEnd: '',
  56. });
  57. });
  58. test('seedTokens overrides', () => {
  59. expect(seedTokens({ description: 'abc' })).toEqual({
  60. start: '',
  61. delimiter: '',
  62. postDelimiter: '',
  63. tag: '',
  64. postTag: '',
  65. name: '',
  66. postName: '',
  67. type: '',
  68. postType: '',
  69. description: 'abc',
  70. end: '',
  71. lineEnd: '',
  72. });
  73. });
  74. test('seedBlock defaults', () => {
  75. expect(seedBlock()).toEqual({
  76. description: '',
  77. tags: [],
  78. source: [],
  79. problems: [],
  80. });
  81. });
  82. test('seedBlock overrides', () => {
  83. expect(seedBlock({ description: 'abc' })).toEqual({
  84. description: 'abc',
  85. tags: [],
  86. source: [],
  87. problems: [],
  88. });
  89. });
  90. test('seedSpec defaults', () => {
  91. expect(seedSpec()).toEqual({
  92. tag: '',
  93. name: '',
  94. type: '',
  95. optional: false,
  96. description: '',
  97. problems: [],
  98. source: [],
  99. });
  100. });
  101. test('seedSpec overrides', () => {
  102. expect(seedSpec({ description: 'abc' })).toEqual({
  103. tag: '',
  104. name: '',
  105. type: '',
  106. optional: false,
  107. description: 'abc',
  108. problems: [],
  109. source: [],
  110. });
  111. });