eslint-plugin-traceability 1.23.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/lib/{src/rules → rules}/require-traceability.js +49 -4
  3. package/package.json +8 -8
  4. package/user-docs/api-reference.md +25 -0
  5. package/lib/tests/cli-error-handling.test.d.ts +0 -1
  6. package/lib/tests/cli-error-handling.test.js +0 -54
  7. package/lib/tests/config/eslint-config-validation.test.d.ts +0 -9
  8. package/lib/tests/config/eslint-config-validation.test.js +0 -101
  9. package/lib/tests/config/flat-config-presets-integration.test.d.ts +0 -1
  10. package/lib/tests/config/flat-config-presets-integration.test.js +0 -76
  11. package/lib/tests/config/require-story-annotation-config.test.d.ts +0 -10
  12. package/lib/tests/config/require-story-annotation-config.test.js +0 -26
  13. package/lib/tests/fixtures/stale/example.d.ts +0 -0
  14. package/lib/tests/fixtures/stale/example.js +0 -4
  15. package/lib/tests/fixtures/update/example.d.ts +0 -0
  16. package/lib/tests/fixtures/update/example.js +0 -4
  17. package/lib/tests/fixtures/valid-annotations/example.d.ts +0 -0
  18. package/lib/tests/fixtures/valid-annotations/example.js +0 -3
  19. package/lib/tests/integration/annotation-placement-inside-prettier.integration.test.d.ts +0 -1
  20. package/lib/tests/integration/annotation-placement-inside-prettier.integration.test.js +0 -133
  21. package/lib/tests/integration/catch-annotation-prettier.integration.test.d.ts +0 -1
  22. package/lib/tests/integration/catch-annotation-prettier.integration.test.js +0 -121
  23. package/lib/tests/integration/cli-integration.test.d.ts +0 -1
  24. package/lib/tests/integration/cli-integration.test.js +0 -96
  25. package/lib/tests/integration/else-if-annotation-prettier.integration.test.d.ts +0 -1
  26. package/lib/tests/integration/else-if-annotation-prettier.integration.test.js +0 -100
  27. package/lib/tests/integration/no-redundant-annotation.integration.test.d.ts +0 -1
  28. package/lib/tests/integration/no-redundant-annotation.integration.test.js +0 -129
  29. package/lib/tests/integration/prettier-test-helpers.d.ts +0 -9
  30. package/lib/tests/integration/prettier-test-helpers.js +0 -35
  31. package/lib/tests/integration/require-traceability-aliases.integration.test.d.ts +0 -1
  32. package/lib/tests/integration/require-traceability-aliases.integration.test.js +0 -152
  33. package/lib/tests/integration/require-traceability-test-callbacks.integration.test.d.ts +0 -1
  34. package/lib/tests/integration/require-traceability-test-callbacks.integration.test.js +0 -149
  35. package/lib/tests/maintenance/batch.test.d.ts +0 -1
  36. package/lib/tests/maintenance/batch.test.js +0 -80
  37. package/lib/tests/maintenance/cli.test.d.ts +0 -1
  38. package/lib/tests/maintenance/cli.test.js +0 -306
  39. package/lib/tests/maintenance/detect-isolated.test.d.ts +0 -1
  40. package/lib/tests/maintenance/detect-isolated.test.js +0 -187
  41. package/lib/tests/maintenance/detect.test.d.ts +0 -1
  42. package/lib/tests/maintenance/detect.test.js +0 -46
  43. package/lib/tests/maintenance/index.test.d.ts +0 -1
  44. package/lib/tests/maintenance/index.test.js +0 -26
  45. package/lib/tests/maintenance/report.test.d.ts +0 -1
  46. package/lib/tests/maintenance/report.test.js +0 -68
  47. package/lib/tests/maintenance/storyParser.test.d.ts +0 -8
  48. package/lib/tests/maintenance/storyParser.test.js +0 -505
  49. package/lib/tests/maintenance/update-isolated.test.d.ts +0 -1
  50. package/lib/tests/maintenance/update-isolated.test.js +0 -71
  51. package/lib/tests/maintenance/update.test.d.ts +0 -1
  52. package/lib/tests/maintenance/update.test.js +0 -27
  53. package/lib/tests/perf/maintenance-cli-large-workspace.test.d.ts +0 -1
  54. package/lib/tests/perf/maintenance-cli-large-workspace.test.js +0 -229
  55. package/lib/tests/perf/maintenance-large-workspace.test.d.ts +0 -1
  56. package/lib/tests/perf/maintenance-large-workspace.test.js +0 -169
  57. package/lib/tests/perf/require-branch-annotation-large-file.test.d.ts +0 -1
  58. package/lib/tests/perf/require-branch-annotation-large-file.test.js +0 -67
  59. package/lib/tests/perf/valid-annotation-format-large-file.test.d.ts +0 -1
  60. package/lib/tests/perf/valid-annotation-format-large-file.test.js +0 -75
  61. package/lib/tests/plugin-default-export-and-configs.test.d.ts +0 -1
  62. package/lib/tests/plugin-default-export-and-configs.test.js +0 -121
  63. package/lib/tests/plugin-setup-error.test.d.ts +0 -6
  64. package/lib/tests/plugin-setup-error.test.js +0 -38
  65. package/lib/tests/plugin-setup.test.d.ts +0 -1
  66. package/lib/tests/plugin-setup.test.js +0 -63
  67. package/lib/tests/rules/auto-fix-behavior-008.test.d.ts +0 -1
  68. package/lib/tests/rules/auto-fix-behavior-008.test.js +0 -285
  69. package/lib/tests/rules/error-reporting.test.d.ts +0 -1
  70. package/lib/tests/rules/error-reporting.test.js +0 -99
  71. package/lib/tests/rules/no-redundant-annotation.test.d.ts +0 -1
  72. package/lib/tests/rules/no-redundant-annotation.test.js +0 -163
  73. package/lib/tests/rules/prefer-implements-annotation.test.d.ts +0 -1
  74. package/lib/tests/rules/prefer-implements-annotation.test.js +0 -162
  75. package/lib/tests/rules/require-branch-annotation.test.d.ts +0 -1
  76. package/lib/tests/rules/require-branch-annotation.test.js +0 -593
  77. package/lib/tests/rules/require-req-annotation.test.d.ts +0 -1
  78. package/lib/tests/rules/require-req-annotation.test.js +0 -264
  79. package/lib/tests/rules/require-story-annotation.test.d.ts +0 -1
  80. package/lib/tests/rules/require-story-annotation.test.js +0 -376
  81. package/lib/tests/rules/require-story-core-edgecases.test.d.ts +0 -1
  82. package/lib/tests/rules/require-story-core-edgecases.test.js +0 -15
  83. package/lib/tests/rules/require-story-core.autofix.test.d.ts +0 -1
  84. package/lib/tests/rules/require-story-core.autofix.test.js +0 -66
  85. package/lib/tests/rules/require-story-core.test.d.ts +0 -1
  86. package/lib/tests/rules/require-story-core.test.js +0 -65
  87. package/lib/tests/rules/require-story-helpers-edgecases.test.d.ts +0 -7
  88. package/lib/tests/rules/require-story-helpers-edgecases.test.js +0 -80
  89. package/lib/tests/rules/require-story-helpers.test.d.ts +0 -1
  90. package/lib/tests/rules/require-story-helpers.test.js +0 -474
  91. package/lib/tests/rules/require-story-io-behavior.test.d.ts +0 -7
  92. package/lib/tests/rules/require-story-io-behavior.test.js +0 -46
  93. package/lib/tests/rules/require-story-io.edgecases.test.d.ts +0 -7
  94. package/lib/tests/rules/require-story-io.edgecases.test.js +0 -46
  95. package/lib/tests/rules/require-story-utils.test.d.ts +0 -7
  96. package/lib/tests/rules/require-story-utils.test.js +0 -158
  97. package/lib/tests/rules/require-story-visitors-edgecases.test.d.ts +0 -7
  98. package/lib/tests/rules/require-story-visitors-edgecases.test.js +0 -27
  99. package/lib/tests/rules/require-test-traceability.test.d.ts +0 -1
  100. package/lib/tests/rules/require-test-traceability.test.js +0 -95
  101. package/lib/tests/rules/valid-annotation-format-internal.test.d.ts +0 -8
  102. package/lib/tests/rules/valid-annotation-format-internal.test.js +0 -47
  103. package/lib/tests/rules/valid-annotation-format.test.d.ts +0 -1
  104. package/lib/tests/rules/valid-annotation-format.test.js +0 -634
  105. package/lib/tests/rules/valid-req-reference.test.d.ts +0 -1
  106. package/lib/tests/rules/valid-req-reference.test.js +0 -129
  107. package/lib/tests/rules/valid-story-reference.test.d.ts +0 -1
  108. package/lib/tests/rules/valid-story-reference.test.js +0 -413
  109. package/lib/tests/utils/annotation-checker-autofix-behavior.test.d.ts +0 -5
  110. package/lib/tests/utils/annotation-checker-autofix-behavior.test.js +0 -103
  111. package/lib/tests/utils/annotation-checker.test.d.ts +0 -24
  112. package/lib/tests/utils/annotation-checker.test.js +0 -84
  113. package/lib/tests/utils/annotation-scope-analyzer.test.d.ts +0 -1
  114. package/lib/tests/utils/annotation-scope-analyzer.test.js +0 -211
  115. package/lib/tests/utils/branch-annotation-catch-insert-position.test.d.ts +0 -1
  116. package/lib/tests/utils/branch-annotation-catch-insert-position.test.js +0 -69
  117. package/lib/tests/utils/branch-annotation-catch-position.test.d.ts +0 -1
  118. package/lib/tests/utils/branch-annotation-catch-position.test.js +0 -115
  119. package/lib/tests/utils/branch-annotation-else-if-insert-position.test.d.ts +0 -1
  120. package/lib/tests/utils/branch-annotation-else-if-insert-position.test.js +0 -82
  121. package/lib/tests/utils/branch-annotation-else-if-position.test.d.ts +0 -1
  122. package/lib/tests/utils/branch-annotation-else-if-position.test.js +0 -145
  123. package/lib/tests/utils/branch-annotation-helpers.test.d.ts +0 -1
  124. package/lib/tests/utils/branch-annotation-helpers.test.js +0 -462
  125. package/lib/tests/utils/fsTestHelpers.d.ts +0 -7
  126. package/lib/tests/utils/fsTestHelpers.js +0 -26
  127. package/lib/tests/utils/ioTestHelpers.d.ts +0 -7
  128. package/lib/tests/utils/ioTestHelpers.js +0 -24
  129. package/lib/tests/utils/req-annotation-detection.test.d.ts +0 -1
  130. package/lib/tests/utils/req-annotation-detection.test.js +0 -358
  131. package/lib/tests/utils/require-story-core-test-helpers.d.ts +0 -10
  132. package/lib/tests/utils/require-story-core-test-helpers.js +0 -75
  133. package/lib/tests/utils/temp-dir-helpers.d.ts +0 -19
  134. package/lib/tests/utils/temp-dir-helpers.js +0 -62
  135. package/lib/tests/utils/ts-language-options.d.ts +0 -16
  136. package/lib/tests/utils/ts-language-options.js +0 -30
  137. /package/lib/{src/index.d.ts → index.d.ts} +0 -0
  138. /package/lib/{src/index.js → index.js} +0 -0
  139. /package/lib/{src/maintenance → maintenance}/batch.d.ts +0 -0
  140. /package/lib/{src/maintenance → maintenance}/batch.js +0 -0
  141. /package/lib/{src/maintenance → maintenance}/cli.d.ts +0 -0
  142. /package/lib/{src/maintenance → maintenance}/cli.js +0 -0
  143. /package/lib/{src/maintenance → maintenance}/commands.d.ts +0 -0
  144. /package/lib/{src/maintenance → maintenance}/commands.js +0 -0
  145. /package/lib/{src/maintenance → maintenance}/detect.d.ts +0 -0
  146. /package/lib/{src/maintenance → maintenance}/detect.js +0 -0
  147. /package/lib/{src/maintenance → maintenance}/flags.d.ts +0 -0
  148. /package/lib/{src/maintenance → maintenance}/flags.js +0 -0
  149. /package/lib/{src/maintenance → maintenance}/index.d.ts +0 -0
  150. /package/lib/{src/maintenance → maintenance}/index.js +0 -0
  151. /package/lib/{src/maintenance → maintenance}/report.d.ts +0 -0
  152. /package/lib/{src/maintenance → maintenance}/report.js +0 -0
  153. /package/lib/{src/maintenance → maintenance}/storyParser.d.ts +0 -0
  154. /package/lib/{src/maintenance → maintenance}/storyParser.js +0 -0
  155. /package/lib/{src/maintenance → maintenance}/update.d.ts +0 -0
  156. /package/lib/{src/maintenance → maintenance}/update.js +0 -0
  157. /package/lib/{src/maintenance → maintenance}/utils.d.ts +0 -0
  158. /package/lib/{src/maintenance → maintenance}/utils.js +0 -0
  159. /package/lib/{src/rules → rules}/helpers/pattern-validators.d.ts +0 -0
  160. /package/lib/{src/rules → rules}/helpers/pattern-validators.js +0 -0
  161. /package/lib/{src/rules → rules}/helpers/prefer-implements-inline.d.ts +0 -0
  162. /package/lib/{src/rules → rules}/helpers/prefer-implements-inline.js +0 -0
  163. /package/lib/{src/rules → rules}/helpers/require-story-comment-detection.d.ts +0 -0
  164. /package/lib/{src/rules → rules}/helpers/require-story-comment-detection.js +0 -0
  165. /package/lib/{src/rules → rules}/helpers/require-story-core.d.ts +0 -0
  166. /package/lib/{src/rules → rules}/helpers/require-story-core.js +0 -0
  167. /package/lib/{src/rules → rules}/helpers/require-story-helpers.d.ts +0 -0
  168. /package/lib/{src/rules → rules}/helpers/require-story-helpers.js +0 -0
  169. /package/lib/{src/rules → rules}/helpers/require-story-io.d.ts +0 -0
  170. /package/lib/{src/rules → rules}/helpers/require-story-io.js +0 -0
  171. /package/lib/{src/rules → rules}/helpers/require-story-name-extraction.d.ts +0 -0
  172. /package/lib/{src/rules → rules}/helpers/require-story-name-extraction.js +0 -0
  173. /package/lib/{src/rules → rules}/helpers/require-story-node-utils.d.ts +0 -0
  174. /package/lib/{src/rules → rules}/helpers/require-story-node-utils.js +0 -0
  175. /package/lib/{src/rules → rules}/helpers/require-story-utils.d.ts +0 -0
  176. /package/lib/{src/rules → rules}/helpers/require-story-utils.js +0 -0
  177. /package/lib/{src/rules → rules}/helpers/require-story-visitors.d.ts +0 -0
  178. /package/lib/{src/rules → rules}/helpers/require-story-visitors.js +0 -0
  179. /package/lib/{src/rules → rules}/helpers/require-test-traceability-helpers.d.ts +0 -0
  180. /package/lib/{src/rules → rules}/helpers/require-test-traceability-helpers.js +0 -0
  181. /package/lib/{src/rules → rules}/helpers/test-callback-exclusion.d.ts +0 -0
  182. /package/lib/{src/rules → rules}/helpers/test-callback-exclusion.js +0 -0
  183. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-internal.d.ts +0 -0
  184. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-internal.js +0 -0
  185. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-validators.d.ts +0 -0
  186. /package/lib/{src/rules → rules}/helpers/valid-annotation-format-validators.js +0 -0
  187. /package/lib/{src/rules → rules}/helpers/valid-annotation-options.d.ts +0 -0
  188. /package/lib/{src/rules → rules}/helpers/valid-annotation-options.js +0 -0
  189. /package/lib/{src/rules → rules}/helpers/valid-annotation-utils.d.ts +0 -0
  190. /package/lib/{src/rules → rules}/helpers/valid-annotation-utils.js +0 -0
  191. /package/lib/{src/rules → rules}/helpers/valid-implements-utils.d.ts +0 -0
  192. /package/lib/{src/rules → rules}/helpers/valid-implements-utils.js +0 -0
  193. /package/lib/{src/rules → rules}/helpers/valid-req-reference-helpers.d.ts +0 -0
  194. /package/lib/{src/rules → rules}/helpers/valid-req-reference-helpers.js +0 -0
  195. /package/lib/{src/rules → rules}/helpers/valid-story-reference-helpers.d.ts +0 -0
  196. /package/lib/{src/rules → rules}/helpers/valid-story-reference-helpers.js +0 -0
  197. /package/lib/{src/rules → rules}/no-redundant-annotation.d.ts +0 -0
  198. /package/lib/{src/rules → rules}/no-redundant-annotation.js +0 -0
  199. /package/lib/{src/rules → rules}/prefer-implements-annotation.d.ts +0 -0
  200. /package/lib/{src/rules → rules}/prefer-implements-annotation.js +0 -0
  201. /package/lib/{src/rules → rules}/require-branch-annotation.d.ts +0 -0
  202. /package/lib/{src/rules → rules}/require-branch-annotation.js +0 -0
  203. /package/lib/{src/rules → rules}/require-req-annotation.d.ts +0 -0
  204. /package/lib/{src/rules → rules}/require-req-annotation.js +0 -0
  205. /package/lib/{src/rules → rules}/require-story-annotation.d.ts +0 -0
  206. /package/lib/{src/rules → rules}/require-story-annotation.js +0 -0
  207. /package/lib/{src/rules → rules}/require-test-traceability.d.ts +0 -0
  208. /package/lib/{src/rules → rules}/require-test-traceability.js +0 -0
  209. /package/lib/{src/rules → rules}/require-traceability.d.ts +0 -0
  210. /package/lib/{src/rules → rules}/valid-annotation-format.d.ts +0 -0
  211. /package/lib/{src/rules → rules}/valid-annotation-format.js +0 -0
  212. /package/lib/{src/rules → rules}/valid-req-reference.d.ts +0 -0
  213. /package/lib/{src/rules → rules}/valid-req-reference.js +0 -0
  214. /package/lib/{src/rules → rules}/valid-story-reference.d.ts +0 -0
  215. /package/lib/{src/rules → rules}/valid-story-reference.js +0 -0
  216. /package/lib/{src/utils → utils}/annotation-checker.d.ts +0 -0
  217. /package/lib/{src/utils → utils}/annotation-checker.js +0 -0
  218. /package/lib/{src/utils → utils}/annotation-scope-analyzer.d.ts +0 -0
  219. /package/lib/{src/utils → utils}/annotation-scope-analyzer.js +0 -0
  220. /package/lib/{src/utils → utils}/branch-annotation-catch-helpers.d.ts +0 -0
  221. /package/lib/{src/utils → utils}/branch-annotation-catch-helpers.js +0 -0
  222. /package/lib/{src/utils → utils}/branch-annotation-helpers.d.ts +0 -0
  223. /package/lib/{src/utils → utils}/branch-annotation-helpers.js +0 -0
  224. /package/lib/{src/utils → utils}/branch-annotation-if-helpers.d.ts +0 -0
  225. /package/lib/{src/utils → utils}/branch-annotation-if-helpers.js +0 -0
  226. /package/lib/{src/utils → utils}/branch-annotation-indent-helpers.d.ts +0 -0
  227. /package/lib/{src/utils → utils}/branch-annotation-indent-helpers.js +0 -0
  228. /package/lib/{src/utils → utils}/branch-annotation-loop-helpers.d.ts +0 -0
  229. /package/lib/{src/utils → utils}/branch-annotation-loop-helpers.js +0 -0
  230. /package/lib/{src/utils → utils}/branch-annotation-report-helpers.d.ts +0 -0
  231. /package/lib/{src/utils → utils}/branch-annotation-report-helpers.js +0 -0
  232. /package/lib/{src/utils → utils}/branch-annotation-story-fix-helpers.d.ts +0 -0
  233. /package/lib/{src/utils → utils}/branch-annotation-story-fix-helpers.js +0 -0
  234. /package/lib/{src/utils → utils}/branch-annotation-switch-helpers.d.ts +0 -0
  235. /package/lib/{src/utils → utils}/branch-annotation-switch-helpers.js +0 -0
  236. /package/lib/{src/utils → utils}/branch-validation.d.ts +0 -0
  237. /package/lib/{src/utils → utils}/branch-validation.js +0 -0
  238. /package/lib/{src/utils → utils}/comment-text-helpers.d.ts +0 -0
  239. /package/lib/{src/utils → utils}/comment-text-helpers.js +0 -0
  240. /package/lib/{src/utils → utils}/function-annotation-helpers.d.ts +0 -0
  241. /package/lib/{src/utils → utils}/function-annotation-helpers.js +0 -0
  242. /package/lib/{src/utils → utils}/redundancy-detector.d.ts +0 -0
  243. /package/lib/{src/utils → utils}/redundancy-detector.js +0 -0
  244. /package/lib/{src/utils → utils}/reqAnnotationDetection.d.ts +0 -0
  245. /package/lib/{src/utils → utils}/reqAnnotationDetection.js +0 -0
  246. /package/lib/{src/utils → utils}/storyReferenceUtils.d.ts +0 -0
  247. /package/lib/{src/utils → utils}/storyReferenceUtils.js +0 -0
@@ -1,474 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
5
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
6
- * @req REQ-ANNOTATION-REQUIRED - Verify helper functions in require-story helpers produce correct fixes and reporting behavior
7
- * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED
8
- */
9
- const require_story_core_1 = require("../../src/rules/helpers/require-story-core");
10
- const require_story_helpers_1 = require("../../src/rules/helpers/require-story-helpers");
11
- const require_story_utils_1 = require("../../src/rules/helpers/require-story-utils");
12
- describe("Require Story Helpers (Story 003.0)", () => {
13
- test("createAddStoryFix uses parent range start when available", () => {
14
- const target = {
15
- type: "FunctionDeclaration",
16
- range: [20, 40],
17
- parent: { type: "ExportNamedDeclaration", range: [10, 50] },
18
- };
19
- const fixer = {
20
- insertTextBeforeRange: jest.fn((r, t) => ({ r, t })),
21
- };
22
- const defaultTemplate = (0, require_story_helpers_1.getAnnotationTemplate)();
23
- const fixFn = (0, require_story_core_1.createAddStoryFix)(target, defaultTemplate);
24
- const result = fixFn(fixer);
25
- expect(fixer.insertTextBeforeRange).toHaveBeenCalledTimes(1);
26
- const calledArgs = fixer.insertTextBeforeRange.mock.calls[0];
27
- expect(calledArgs[0]).toEqual([10, 10]);
28
- expect(typeof calledArgs[1]).toBe("string");
29
- expect(calledArgs[1].length).toBeGreaterThan(0);
30
- expect(result).toEqual({ r: [10, 10], t: calledArgs[1] });
31
- });
32
- test("createMethodFix falls back to node.range when parent not export", () => {
33
- const node = {
34
- type: "MethodDefinition",
35
- range: [30, 60],
36
- parent: { type: "ClassBody" },
37
- };
38
- const fixer = {
39
- insertTextBeforeRange: jest.fn((r, t) => ({ r, t })),
40
- };
41
- const defaultTemplate = (0, require_story_helpers_1.getAnnotationTemplate)();
42
- const fixFn = (0, require_story_core_1.createMethodFix)(node, defaultTemplate);
43
- const res = fixFn(fixer);
44
- expect(fixer.insertTextBeforeRange.mock.calls[0][0]).toEqual([30, 30]);
45
- const insertedText = fixer.insertTextBeforeRange.mock
46
- .calls[0][1];
47
- expect(typeof insertedText).toBe("string");
48
- expect(insertedText.length).toBeGreaterThan(0);
49
- expect(res).toEqual({ r: [30, 30], t: insertedText });
50
- });
51
- test("reportMissing does not call context.report if JSDoc contains @story", () => {
52
- const node = {
53
- type: "FunctionDeclaration",
54
- id: { type: "Identifier", name: "fn" },
55
- range: [0, 10],
56
- };
57
- const fakeSource = {
58
- getJSDocComment: () => ({
59
- value: "@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md",
60
- }),
61
- getText: () => "",
62
- };
63
- const context = {
64
- getSourceCode: () => fakeSource,
65
- report: jest.fn(),
66
- };
67
- (0, require_story_helpers_1.reportMissing)(context, fakeSource, { node, target: node });
68
- expect(context.report).not.toHaveBeenCalled();
69
- });
70
- test("reportMissing calls context.report when no JSDoc story present", () => {
71
- const node = {
72
- type: "FunctionDeclaration",
73
- id: { type: "Identifier", name: "fn2" },
74
- range: [0, 10],
75
- };
76
- const fakeSource = {
77
- getJSDocComment: () => null,
78
- getText: () => "",
79
- };
80
- const context = {
81
- getSourceCode: () => fakeSource,
82
- report: jest.fn(),
83
- };
84
- (0, require_story_helpers_1.reportMissing)(context, fakeSource, { node, target: node });
85
- expect(context.report).toHaveBeenCalledTimes(1);
86
- const call = context.report.mock.calls[0][0];
87
- expect(call.node).toBe(node.id);
88
- expect(call.messageId).toBe("missingStory");
89
- });
90
- /**
91
- * Additional helper tests for story annotations and IO helpers
92
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
93
- * @req REQ-ANNOTATION-REQUIRED - Verify resolveTargetNode/getNodeName/shouldProcessNode and IO helpers
94
- */
95
- test("resolveTargetNode prefers parent when parent is ExportNamedDeclaration", () => {
96
- const fakeSource = { getText: () => "" };
97
- const node = {
98
- type: "FunctionExpression",
99
- range: [5, 10],
100
- parent: { type: "ExportNamedDeclaration", range: [1, 20] },
101
- };
102
- const resolved = (0, require_story_helpers_1.resolveTargetNode)(fakeSource, node);
103
- expect(resolved).toBe(node.parent);
104
- });
105
- test("resolveTargetNode falls back to node when parent is not an export", () => {
106
- const fakeSource = { getText: () => "" };
107
- const node = {
108
- type: "FunctionDeclaration",
109
- range: [5, 10],
110
- parent: { type: "ClassBody", range: [1, 20] },
111
- };
112
- const resolved = (0, require_story_helpers_1.resolveTargetNode)(fakeSource, node);
113
- expect(resolved).toBe(node);
114
- });
115
- test("getNodeName extracts names from common node shapes", () => {
116
- const funcNode = {
117
- type: "FunctionDeclaration",
118
- id: { name: "myFunc" },
119
- };
120
- const propNode = { type: "MethodDefinition", key: { name: "myProp" } };
121
- expect((0, require_story_utils_1.getNodeName)(funcNode)).toBe("myFunc");
122
- expect((0, require_story_utils_1.getNodeName)(propNode)).toBe("myProp");
123
- });
124
- test("shouldProcessNode returns booleans for typical node types", () => {
125
- const funcDecl = { type: "FunctionDeclaration" };
126
- const varDecl = { type: "VariableDeclaration" };
127
- expect((0, require_story_helpers_1.shouldProcessNode)(funcDecl, require_story_helpers_1.DEFAULT_SCOPE)).toBeTruthy();
128
- expect((0, require_story_helpers_1.shouldProcessNode)(varDecl, require_story_helpers_1.DEFAULT_SCOPE)).toBeFalsy();
129
- });
130
- test("linesBeforeHasStory detects preceding JSDoc story text", () => {
131
- const jsdoc = "/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\n";
132
- const rest = "function fn() {}\n";
133
- const full = jsdoc + rest;
134
- const fakeSource = {
135
- getText: () => full,
136
- getJSDocComment: () => ({
137
- value: "@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md",
138
- }),
139
- lines: full.split(/\r?\n/),
140
- };
141
- const nodeLine = fakeSource.lines.findIndex((l) => l.includes("function fn() {}")) + 1;
142
- const node = {
143
- type: "FunctionDeclaration",
144
- range: [full.indexOf("function"), full.length],
145
- loc: { start: { line: nodeLine } },
146
- };
147
- const has = (0, require_story_helpers_1.linesBeforeHasStory)(fakeSource, node);
148
- expect(has).toBeTruthy();
149
- });
150
- test("fallbackTextBeforeHasStory returns boolean when called with source text and range", () => {
151
- const jsdoc = "/**\n * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md\n */\n";
152
- const rest = "function fnB() {}\n";
153
- const full = jsdoc + rest;
154
- const fakeSource = {
155
- getText: () => full,
156
- };
157
- const node = {
158
- type: "FunctionDeclaration",
159
- range: [full.indexOf("function"), full.length],
160
- };
161
- const res = (0, require_story_helpers_1.fallbackTextBeforeHasStory)(fakeSource, node);
162
- expect(typeof res).toBe("boolean");
163
- expect(res).toBeTruthy();
164
- });
165
- test("parentChainHasStory returns true when ancestors have JSDoc story", () => {
166
- const fakeSource = {
167
- getCommentsBefore: () => [
168
- {
169
- type: "Block",
170
- value: "@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md",
171
- },
172
- ],
173
- };
174
- const node = {
175
- type: "Identifier",
176
- parent: { parent: { type: "ExportNamedDeclaration" } },
177
- };
178
- const res = (0, require_story_helpers_1.parentChainHasStory)(fakeSource, node);
179
- expect(res).toBeTruthy();
180
- });
181
- /**
182
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
183
- * @req REQ-TEST-CALLBACK-EXCLUSION - Verify arrow function test callbacks can be excluded by default
184
- */
185
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow function used as test callback is excluded by default", () => {
186
- const node = {
187
- type: "ArrowFunctionExpression",
188
- parent: {
189
- type: "CallExpression",
190
- callee: { type: "Identifier", name: "it" },
191
- },
192
- };
193
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE);
194
- expect(result).toBeFalsy();
195
- });
196
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow function used as beforeEach callback is excluded by default", () => {
197
- const node = {
198
- type: "ArrowFunctionExpression",
199
- parent: {
200
- type: "CallExpression",
201
- callee: { type: "Identifier", name: "beforeEach" },
202
- },
203
- };
204
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE);
205
- expect(result).toBeFalsy();
206
- });
207
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow function used as afterEach callback is excluded by default", () => {
208
- const node = {
209
- type: "ArrowFunctionExpression",
210
- parent: {
211
- type: "CallExpression",
212
- callee: { type: "Identifier", name: "afterEach" },
213
- },
214
- };
215
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE);
216
- expect(result).toBeFalsy();
217
- });
218
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow function used as beforeAll callback is excluded by default", () => {
219
- const node = {
220
- type: "ArrowFunctionExpression",
221
- parent: {
222
- type: "CallExpression",
223
- callee: { type: "Identifier", name: "beforeAll" },
224
- },
225
- };
226
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE);
227
- expect(result).toBeFalsy();
228
- });
229
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow function used as afterAll callback is excluded by default", () => {
230
- const node = {
231
- type: "ArrowFunctionExpression",
232
- parent: {
233
- type: "CallExpression",
234
- callee: { type: "Identifier", name: "afterAll" },
235
- },
236
- };
237
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE);
238
- expect(result).toBeFalsy();
239
- });
240
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow function used as suite callback is excluded by default", () => {
241
- const node = {
242
- type: "ArrowFunctionExpression",
243
- parent: {
244
- type: "CallExpression",
245
- callee: { type: "Identifier", name: "suite" },
246
- },
247
- };
248
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE);
249
- expect(result).toBeFalsy();
250
- });
251
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow function used as context callback is excluded by default", () => {
252
- const node = {
253
- type: "ArrowFunctionExpression",
254
- parent: {
255
- type: "CallExpression",
256
- callee: { type: "Identifier", name: "context" },
257
- },
258
- };
259
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE);
260
- expect(result).toBeFalsy();
261
- });
262
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow function used as specify callback is excluded by default", () => {
263
- const node = {
264
- type: "ArrowFunctionExpression",
265
- parent: {
266
- type: "CallExpression",
267
- callee: { type: "Identifier", name: "specify" },
268
- },
269
- };
270
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE);
271
- expect(result).toBeFalsy();
272
- });
273
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow function used as bench callback is checked by default", () => {
274
- const node = {
275
- type: "ArrowFunctionExpression",
276
- parent: {
277
- type: "CallExpression",
278
- callee: { type: "Identifier", name: "bench" },
279
- },
280
- };
281
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE);
282
- expect(result).toBeTruthy();
283
- });
284
- /**
285
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
286
- * @req REQ-TEST-CALLBACK-EXCLUSION - Verify arrow function test callbacks are checked when exclusion is disabled
287
- */
288
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow function test callback is checked when excludeTestCallbacks is false", () => {
289
- const node = {
290
- type: "ArrowFunctionExpression",
291
- parent: {
292
- type: "CallExpression",
293
- callee: { type: "Identifier", name: "it" },
294
- },
295
- };
296
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
297
- excludeTestCallbacks: false,
298
- });
299
- expect(result).toBeTruthy();
300
- });
301
- test("[REQ-TEST-CALLBACK-EXCLUSION] beforeEach arrow function callback is checked when excludeTestCallbacks is false", () => {
302
- const node = {
303
- type: "ArrowFunctionExpression",
304
- parent: {
305
- type: "CallExpression",
306
- callee: { type: "Identifier", name: "beforeEach" },
307
- },
308
- };
309
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
310
- excludeTestCallbacks: false,
311
- });
312
- expect(result).toBeTruthy();
313
- });
314
- test("[REQ-TEST-CALLBACK-EXCLUSION] afterEach arrow function callback is checked when excludeTestCallbacks is false", () => {
315
- const node = {
316
- type: "ArrowFunctionExpression",
317
- parent: {
318
- type: "CallExpression",
319
- callee: { type: "Identifier", name: "afterEach" },
320
- },
321
- };
322
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
323
- excludeTestCallbacks: false,
324
- });
325
- expect(result).toBeTruthy();
326
- });
327
- test("[REQ-TEST-CALLBACK-EXCLUSION] beforeAll arrow function callback is checked when excludeTestCallbacks is false", () => {
328
- const node = {
329
- type: "ArrowFunctionExpression",
330
- parent: {
331
- type: "CallExpression",
332
- callee: { type: "Identifier", name: "beforeAll" },
333
- },
334
- };
335
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
336
- excludeTestCallbacks: false,
337
- });
338
- expect(result).toBeTruthy();
339
- });
340
- test("[REQ-TEST-CALLBACK-EXCLUSION] afterAll arrow function callback is checked when excludeTestCallbacks is false", () => {
341
- const node = {
342
- type: "ArrowFunctionExpression",
343
- parent: {
344
- type: "CallExpression",
345
- callee: { type: "Identifier", name: "afterAll" },
346
- },
347
- };
348
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
349
- excludeTestCallbacks: false,
350
- });
351
- expect(result).toBeTruthy();
352
- });
353
- test("[REQ-TEST-CALLBACK-EXCLUSION] suite arrow function callback is checked when excludeTestCallbacks is false", () => {
354
- const node = {
355
- type: "ArrowFunctionExpression",
356
- parent: {
357
- type: "CallExpression",
358
- callee: { type: "Identifier", name: "suite" },
359
- },
360
- };
361
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
362
- excludeTestCallbacks: false,
363
- });
364
- expect(result).toBeTruthy();
365
- });
366
- test("[REQ-TEST-CALLBACK-EXCLUSION] context arrow function callback is checked when excludeTestCallbacks is false", () => {
367
- const node = {
368
- type: "ArrowFunctionExpression",
369
- parent: {
370
- type: "CallExpression",
371
- callee: { type: "Identifier", name: "context" },
372
- },
373
- };
374
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
375
- excludeTestCallbacks: false,
376
- });
377
- expect(result).toBeTruthy();
378
- });
379
- test("[REQ-TEST-CALLBACK-EXCLUSION] specify arrow function callback is checked when excludeTestCallbacks is false", () => {
380
- const node = {
381
- type: "ArrowFunctionExpression",
382
- parent: {
383
- type: "CallExpression",
384
- callee: { type: "Identifier", name: "specify" },
385
- },
386
- };
387
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
388
- excludeTestCallbacks: false,
389
- });
390
- expect(result).toBeTruthy();
391
- });
392
- test("[REQ-TEST-CALLBACK-EXCLUSION] bench arrow function callback is always checked (also when excludeTestCallbacks is false)", () => {
393
- const node = {
394
- type: "ArrowFunctionExpression",
395
- parent: {
396
- type: "CallExpression",
397
- callee: { type: "Identifier", name: "bench" },
398
- },
399
- };
400
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
401
- excludeTestCallbacks: false,
402
- });
403
- expect(result).toBeTruthy();
404
- });
405
- /**
406
- * Additional coverage for nested and helper-wrapped test callbacks.
407
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
408
- * @req REQ-TEST-CALLBACK-EXCLUSION - Document how nested and wrapper-based callbacks interact with exclusion logic
409
- */
410
- test("[REQ-TEST-CALLBACK-EXCLUSION] Nested anonymous arrow inside it() callback is excluded via nested-function inheritance", () => {
411
- const outerCallback = {
412
- type: "ArrowFunctionExpression",
413
- parent: {
414
- type: "CallExpression",
415
- callee: { type: "Identifier", name: "it" },
416
- },
417
- };
418
- const innerCallback = {
419
- type: "ArrowFunctionExpression",
420
- parent: {
421
- type: "BlockStatement",
422
- parent: outerCallback,
423
- },
424
- };
425
- // Outer callback is treated as a test framework callback and excluded.
426
- const outerResult = (0, require_story_helpers_1.shouldProcessNode)(outerCallback, require_story_helpers_1.DEFAULT_SCOPE);
427
- // Inner anonymous arrow inherits from its nested parent and is also excluded.
428
- const innerResult = (0, require_story_helpers_1.shouldProcessNode)(innerCallback, require_story_helpers_1.DEFAULT_SCOPE);
429
- expect(outerResult).toBeFalsy();
430
- expect(innerResult).toBeFalsy();
431
- });
432
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow callback passed to local wrapper around describe() is not treated as a test callback", () => {
433
- const node = {
434
- type: "ArrowFunctionExpression",
435
- parent: {
436
- type: "CallExpression",
437
- callee: { type: "Identifier", name: "withDescribe" },
438
- },
439
- };
440
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE);
441
- expect(result).toBeTruthy();
442
- });
443
- /**
444
- * Additional coverage for configurable test helper names.
445
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
446
- * @req REQ-TEST-CALLBACK-EXCLUSION - Verify additionalTestHelperNames interacts correctly with exclusion logic
447
- */
448
- test("[REQ-TEST-CALLBACK-EXCLUSION] Arrow callback passed to configured additionalTestHelperNames helper is excluded by default", () => {
449
- const node = {
450
- type: "ArrowFunctionExpression",
451
- parent: {
452
- type: "CallExpression",
453
- callee: { type: "Identifier", name: "withTest" },
454
- },
455
- };
456
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
457
- additionalTestHelperNames: ["withTest"],
458
- });
459
- expect(result).toBeFalsy();
460
- });
461
- test("[REQ-TEST-CALLBACK-EXCLUSION] bench callback is never excluded even when included in additionalTestHelperNames", () => {
462
- const node = {
463
- type: "ArrowFunctionExpression",
464
- parent: {
465
- type: "CallExpression",
466
- callee: { type: "Identifier", name: "bench" },
467
- },
468
- };
469
- const result = (0, require_story_helpers_1.shouldProcessNode)(node, require_story_helpers_1.DEFAULT_SCOPE, "all", {
470
- additionalTestHelperNames: ["bench"],
471
- });
472
- expect(result).toBeTruthy();
473
- });
474
- });
@@ -1,7 +0,0 @@
1
- /**
2
- * Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
3
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
4
- * @req REQ-IO-BEHAVIOR-EDGE-CASES - Edge-case behavior tests for IO helpers in require-story-io.ts
5
- * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-IO-BEHAVIOR-EDGE-CASES
6
- */
7
- export {};
@@ -1,46 +0,0 @@
1
- "use strict";
2
- /**
3
- * Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
4
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
5
- * @req REQ-IO-BEHAVIOR-EDGE-CASES - Edge-case behavior tests for IO helpers in require-story-io.ts
6
- * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-IO-BEHAVIOR-EDGE-CASES
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const require_story_io_1 = require("../../src/rules/helpers/require-story-io");
10
- const ioTestHelpers_1 = require("../utils/ioTestHelpers");
11
- describe("Require Story IO helpers - additional behavior (Story 003.0)", () => {
12
- test("parentChainHasStory returns false when sourceCode.getCommentsBefore is not a function", () => {
13
- const fakeSource = {}; // no getCommentsBefore function
14
- const node = { parent: { parent: null } };
15
- expect((0, require_story_io_1.parentChainHasStory)(fakeSource, node)).toBe(false);
16
- });
17
- test("parentChainHasStory returns false when getCommentsBefore returns comments but none contain @story", () => {
18
- const fakeSource = {
19
- getCommentsBefore: () => [{ value: 123 }, { value: "no story here" }],
20
- };
21
- const node = { parent: { leadingComments: [], parent: null } };
22
- expect((0, require_story_io_1.parentChainHasStory)(fakeSource, node)).toBe(false);
23
- });
24
- test("parentChainHasStory returns true when ancestor leadingComments contain @story", () => {
25
- const fakeSource = { getCommentsBefore: () => [] };
26
- const node = {
27
- parent: {
28
- leadingComments: [
29
- {
30
- value: "@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md",
31
- },
32
- ],
33
- parent: null,
34
- },
35
- };
36
- expect((0, require_story_io_1.parentChainHasStory)(fakeSource, node)).toBe(true);
37
- });
38
- test("fallbackTextBeforeHasStory returns false when node.range[0] is not a number", () => {
39
- const fakeSource = { getText: () => "some text without story" };
40
- const node = { range: ["a", 10] };
41
- expect((0, require_story_io_1.fallbackTextBeforeHasStory)(fakeSource, node)).toBe(false);
42
- });
43
- test("fallbackTextBeforeHasStory detects @story in text before node.range", () => {
44
- (0, ioTestHelpers_1.runFallbackTextBeforeHasStoryDetectsStoryTest)("@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md", require_story_io_1.fallbackTextBeforeHasStory);
45
- });
46
- });
@@ -1,7 +0,0 @@
1
- /**
2
- * Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
3
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
4
- * @req REQ-ANNOTATION-REQUIRED - Edge case tests for IO helpers (linesBeforeHasStory/fallbackTextBeforeHasStory/parentChainHasStory)
5
- * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED
6
- */
7
- export {};
@@ -1,46 +0,0 @@
1
- "use strict";
2
- /**
3
- * Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
4
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
5
- * @req REQ-ANNOTATION-REQUIRED - Edge case tests for IO helpers (linesBeforeHasStory/fallbackTextBeforeHasStory/parentChainHasStory)
6
- * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const require_story_io_1 = require("../../src/rules/helpers/require-story-io");
10
- const ioTestHelpers_1 = require("../utils/ioTestHelpers");
11
- describe("Require Story IO helpers - edge cases (Story 003.0)", () => {
12
- test("linesBeforeHasStory returns false when source.lines missing or node.loc missing", () => {
13
- const fakeSource = {};
14
- const node = { loc: null };
15
- expect((0, require_story_io_1.linesBeforeHasStory)(fakeSource, node)).toBe(false);
16
- const fakeSource2 = { lines: ["line1", "line2"] };
17
- const node2 = { loc: { start: { line: 100 } } };
18
- expect((0, require_story_io_1.linesBeforeHasStory)(fakeSource2, node2)).toBe(false);
19
- });
20
- test("fallbackTextBeforeHasStory returns false when getText missing or node.range missing", () => {
21
- const fakeSource = {};
22
- const node = { range: null };
23
- expect((0, require_story_io_1.fallbackTextBeforeHasStory)(fakeSource, node)).toBe(false);
24
- const fakeSource2 = { getText: () => "no story here" };
25
- const node2 = { range: [] };
26
- expect((0, require_story_io_1.fallbackTextBeforeHasStory)(fakeSource2, node2)).toBe(false);
27
- });
28
- test("fallbackTextBeforeHasStory detects @story in text before node.range", () => {
29
- (0, ioTestHelpers_1.runFallbackTextBeforeHasStoryDetectsStoryTest)(require_story_io_1.fallbackTextBeforeHasStory);
30
- });
31
- test("parentChainHasStory returns true when ancestor comments contain @story", () => {
32
- const fakeSource = {
33
- getCommentsBefore: () => [
34
- {
35
- type: "Block",
36
- value: "@story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md",
37
- },
38
- ],
39
- };
40
- const node = { parent: { parent: { type: "SomeParent" } } };
41
- expect((0, require_story_io_1.parentChainHasStory)(fakeSource, node)).toBe(true);
42
- const fakeSource2 = { getCommentsBefore: () => [] };
43
- const node2 = { parent: null };
44
- expect((0, require_story_io_1.parentChainHasStory)(fakeSource2, node2)).toBe(false);
45
- });
46
- });
@@ -1,7 +0,0 @@
1
- /**
2
- * Tests for: docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
3
- * @story docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md
4
- * @req REQ-ANNOTATION-REQUIRED - Verify getNodeName resolves names for diverse AST node shapes
5
- * @supports docs/stories/003.0-DEV-FUNCTION-ANNOTATIONS.story.md REQ-ANNOTATION-REQUIRED
6
- */
7
- export {};