MCPcopy Index your code
hub / github.com/adobe/react-spectrum / extractTestInstructions

Function extractTestInstructions

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

Source from the content-addressed store, hash-verified

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