assertionHandler.mjs 939 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * assertionHandler.mjs
  3. *
  4. * Pair native node assertions with a description for
  5. * the benefit of the TestRegister.
  6. *
  7. * @author d98762625 [d98762625@gmail.com]
  8. * @copyright Crown Copyright 2018
  9. * @license Apache-2.0
  10. */
  11. import assert from "assert";
  12. /**
  13. * it - wrapper for assertions to provide a helpful description
  14. * to the TestRegister
  15. * @param {String} description - The description of the test
  16. * @param {Function} assertion - The test
  17. *
  18. * @example
  19. * // One assertion
  20. * it("should run one assertion", () => assert.equal(1,1))
  21. *
  22. * @example
  23. * // multiple assertions
  24. * it("should handle multiple assertions", () => {
  25. * assert.equal(1,1)
  26. * assert.notEqual(3,4)
  27. * })
  28. *
  29. * @example
  30. * // async assertions
  31. * it("should handle async", async () => {
  32. * let r = await asyncFunc()
  33. * assert(r)
  34. * })
  35. */
  36. export function it(name, run) {
  37. return {
  38. name,
  39. run
  40. };
  41. }
  42. export default it;