MCPcopy Create free account
hub / github.com/adobe/react-spectrum / extractTestInstructions

Function extractTestInstructions

scripts/getCommitsForTesting.mjs:246–284  ·  view source on GitHub ↗
(contents)

Source from the content-addressed store, hash-verified

244}
245
246function extractTestInstructions(contents) {
247 if (!contents) {
248 return '';
249 }
250
251 let tree = unified().use(remarkParse).parse(contents);
252
253 let collecting = false;
254 let headingDepth = null;
255 let collected = [];
256
257 for (let node of tree.children) {
258 if (node.type === 'heading') {
259 let text = getHeadingText(node).toLowerCase();
260
261 if (/test(?:ing)? instructions?/.test(text)) {
262 collecting = true;
263 headingDepth = node.depth;
264 continue;
265 }
266
267 // Stop when we reach another heading of same or higher level
268 if (collecting && node.depth <= headingDepth) {
269 break;
270 }
271 }
272
273 if (collecting) {
274 collected.push(node);
275 }
276 }
277
278 return collected
279 .map(node => toString(node))
280 .join(' ')
281 .replace(/\r\n/g, '\n')
282 .replace(/\s+/g, ' ')
283 .trim();
284}
285
286function escapeCSV(value) {
287 if (!value) {

Callers 1

generateDataFunction · 0.85

Calls 4

getHeadingTextFunction · 0.85
toStringFunction · 0.85
pushMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected