testit/dist/testit.min.js.map

8 lines
2.6 KiB
Plaintext
Raw Normal View History

2021-01-02 08:42:41 +00:00
{
"version": 3,
"sources": ["../src/testit.js"],
"sourcesContent": ["/*! Test.it v1.0.0 | MIT | https://github.com/n2geoff/testit */\r\nconst test = {\r\n \"log\": console.log, // eslint-disable-line\r\n \"version\": \"v1.0.0\",\r\n \"_tests\": {},\r\n \"run\": function run(errors, next) {\r\n // TODO: rewrite to allow a show errors flag (optional)\r\n if(typeof errors !== \"boolean\") {\r\n next = errors;\r\n errors = true;\r\n }\r\n\r\n let tests = this._tests || [];\r\n // capture results\r\n let failed = [];\r\n let passed = [];\r\n\r\n // loop through tests\r\n Object.keys(tests).forEach((name) => {\r\n let test = tests[name];\r\n\r\n // execute\r\n try {\r\n test();\r\n passed.push(`\\n+OK ${name}`);\r\n } catch (err) {\r\n if (errors) {\r\n failed.push(`\\n-ERR ${name} \\n --- \\n ${err.stack} \\n ---`);\r\n } else {\r\n failed.push(`\\n-ERR ${name}`);\r\n }\r\n }\r\n });\r\n\r\n // summary\r\n if(typeof next === \"function\") {\r\n return next({\r\n pass: passed,\r\n fail: failed\r\n });\r\n } else {\r\n test.log(...passed, ...failed);\r\n test.log(`\\n# tests ${failed.length + passed.length} pass ${passed.length} fail ${failed.length}`);\r\n\r\n return failed.length ? false : true;\r\n }\r\n },\r\n \"it\": function it(tests) {\r\n this._tests = tests;\r\n return this;\r\n },\r\n \"assert\": (expression, msg) => {\r\n try {\r\n if(!expression) {\r\n throw new Error(msg || \"Assertion Failed\");\r\n }\r\n } catch (e) {\r\n throw new Error(msg);\r\n }\r\n }\r\n};\r\n\r\nexport default test;\r\n"],
"mappings": "AAAA,+DACA,MAAM,EAAO,CACT,IAAO,QAAQ,IACf,QAAW,SACX,OAAU,GACV,IAAO,cAEH,AAAG,MAAO,IAAW,WACjB,GAAO,EACP,EAAS,IAGb,MAAY,KAAK,QAAU,KAEd,KACA,GAoBb,MAjBA,QAAO,KAAK,GAAO,QAAQ,IACvB,MAAW,EAAM,GAGjB,IACI,IACA,EAAO,KAAK;AAAA,MAAS,cAErB,AAAI,EACA,EAAO,KAAK;AAAA,OAAU;AAAA;AAAA,GAAkB,EAAI;AAAA,OAE5C,EAAO,KAAK;AAAA,OAAU,QAM/B,MAAO,IAAS,WACR,EAAK,CACR,KAAM,EACN,KAAM,IAGV,GAAK,IAAI,GAAG,EAAQ,GAAG,GACvB,EAAK,IAAI;AAAA,UAAa,EAAO,OAAS,EAAO,eAAe,EAAO,eAAe,EAAO,UAElF,GAAO,SAGtB,GAAM,YACF,YAAK,OAAS,EACP,MAEX,OAAU,QACN,IACI,GAAG,CAAC,EACA,KAAM,IAAI,OAAM,GAAO,6BAG3B,KAAM,IAAI,OAAM,MAK5B,MAAe",
"names": []
}