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.

transforms-indent.spec.ts 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import indent from '../../src/transforms/indent';
  2. import getParser from '../../src/parser/index';
  3. import getStringifier from '../../src/stringifier/index';
  4. test('push', () => {
  5. const source = `
  6. /**
  7. * Description may go
  8. * over multiple lines followed by @tags
  9. *
  10. * @my-tag {my.type} my-name description line 1
  11. description line 2
  12. * description line 3
  13. */`;
  14. const expected = `
  15. /**
  16. * Description may go
  17. * over multiple lines followed by @tags
  18. *
  19. * @my-tag {my.type} my-name description line 1
  20. description line 2
  21. * description line 3
  22. */`;
  23. const parsed = getParser()(source);
  24. const out = getStringifier()(indent(4)(parsed[0]));
  25. expect(out).toBe(expected.slice(1));
  26. });
  27. test('pull', () => {
  28. const source = `
  29. /**
  30. * Description may go
  31. * over multiple lines followed by @tags
  32. *
  33. * @my-tag {my.type} my-name description line 1
  34. description line 2
  35. * description line 3
  36. */`;
  37. const expected = `
  38. /**
  39. * Description may go
  40. * over multiple lines followed by @tags
  41. *
  42. * @my-tag {my.type} my-name description line 1
  43. description line 2
  44. * description line 3
  45. */`;
  46. const parsed = getParser()(source);
  47. const out = getStringifier()(indent(2)(parsed[0]));
  48. expect(out).toBe(expected.slice(1));
  49. });
  50. test('force pull', () => {
  51. const source = `
  52. /**
  53. * Description may go
  54. * over multiple lines followed by @tags
  55. *
  56. * @my-tag {my.type} my-name description line 1
  57. description line 2
  58. * description line 3
  59. */`;
  60. const expected = `
  61. /**
  62. * Description may go
  63. * over multiple lines followed by @tags
  64. *
  65. * @my-tag {my.type} my-name description line 1
  66. description line 2
  67. * description line 3
  68. */`;
  69. const parsed = getParser()(source);
  70. const indented = indent(0)(parsed[0]);
  71. const out = getStringifier()(indented);
  72. expect(out).toBe(expected.slice(1));
  73. });
  74. test('spec source referencing', () => {
  75. const parsed = getParser()(`/** @tag {type} name Description */`);
  76. const block = indent(0)(parsed[0]);
  77. expect(block.tags[0].source[0] === block.source[0]).toBe(true);
  78. });
  79. test('block source clonning', () => {
  80. const parsed = getParser()(`/** @tag {type} name Description */`);
  81. const block = indent(0)(parsed[0]);
  82. parsed[0].source[0].tokens.description = 'test';
  83. expect(block.source[0].tokens.description).toBe('Description ');
  84. });