UNPKG

console-fail-test

Version:

Gently fails test runs if the console was used during them. 📢

1 lines • 1.42 kB
{"version":3,"sources":["../../src/complaining/formatMethodComplaint.ts"],"sourcesContent":["import { SpyCallArgs } from \"../spies/spyTypes.js\";\nimport { formatComplaintCall } from \"./formatComplaintCall.js\";\n\nconst lineThreshold = 3;\n\nexport const formatMethodComplaint = ([methodName, calls]: [\n\tkeyof Console,\n\tSpyCallArgs[],\n]) => {\n\tconst summary = ` * ${methodName} (${calls.length} call${\n\t\tcalls.length === 1 ? \"\" : \"s\"\n\t})`;\n\n\tconst lines = calls\n\t\t.slice(0, Math.min(calls.length, lineThreshold))\n\t\t.map(formatComplaintLineWithIndex);\n\n\tif (calls.length > lineThreshold) {\n\t\tlines.push(`...${calls.length - lineThreshold} more`);\n\t}\n\n\treturn `${summary}\\n${lines.map((line) => ` > Call ${line}`).join(\"\\n\")}`;\n};\n\nconst formatComplaintLineWithIndex = (call: SpyCallArgs, i: number) =>\n\t`${i}: ${formatComplaintCall(call)}`;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iCAAoC;AAEpC,MAAM,gBAAgB;AAEf,MAAM,wBAAwB,CAAC,CAAC,YAAY,KAAK,MAGlD;AACL,QAAM,UAAU,OAAO,UAAU,KAAK,MAAM,MAAM,QACjD,MAAM,WAAW,IAAI,KAAK,GAC3B;AAEA,QAAM,QAAQ,MACZ,MAAM,GAAG,KAAK,IAAI,MAAM,QAAQ,aAAa,CAAC,EAC9C,IAAI,4BAA4B;AAElC,MAAI,MAAM,SAAS,eAAe;AACjC,UAAM,KAAK,MAAM,MAAM,SAAS,aAAa,OAAO;AAAA,EACrD;AAEA,SAAO,GAAG,OAAO;AAAA,EAAK,MAAM,IAAI,CAAC,SAAS,cAAc,IAAI,EAAE,EAAE,KAAK,IAAI,CAAC;AAC3E;AAEA,MAAM,+BAA+B,CAAC,MAAmB,MACxD,GAAG,CAAC,SAAK,gDAAoB,IAAI,CAAC;","names":[]}