Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

extractExpectedAssertionsErrors.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _jestMatcherUtils = require('jest-matcher-utils');
  7. var _jestMatchersObject = require('./jestMatchersObject');
  8. /**
  9. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  10. *
  11. * This source code is licensed under the MIT license found in the
  12. * LICENSE file in the root directory of this source tree.
  13. *
  14. */
  15. const resetAssertionsLocalState = () => {
  16. (0, _jestMatchersObject.setState)({
  17. assertionCalls: 0,
  18. expectedAssertionsNumber: null,
  19. isExpectingAssertions: false
  20. });
  21. }; // Create and format all errors related to the mismatched number of `expect`
  22. // calls and reset the matcher's state.
  23. const extractExpectedAssertionsErrors = () => {
  24. const result = [];
  25. const {
  26. assertionCalls,
  27. expectedAssertionsNumber,
  28. expectedAssertionsNumberError,
  29. isExpectingAssertions,
  30. isExpectingAssertionsError
  31. } = (0, _jestMatchersObject.getState)();
  32. resetAssertionsLocalState();
  33. if (
  34. typeof expectedAssertionsNumber === 'number' &&
  35. assertionCalls !== expectedAssertionsNumber
  36. ) {
  37. const numOfAssertionsExpected = (0, _jestMatcherUtils.EXPECTED_COLOR)(
  38. (0, _jestMatcherUtils.pluralize)('assertion', expectedAssertionsNumber)
  39. );
  40. expectedAssertionsNumberError.message =
  41. (0, _jestMatcherUtils.matcherHint)(
  42. '.assertions',
  43. '',
  44. String(expectedAssertionsNumber),
  45. {
  46. isDirectExpectCall: true
  47. }
  48. ) +
  49. '\n\n' +
  50. `Expected ${numOfAssertionsExpected} to be called but received ` +
  51. (0, _jestMatcherUtils.RECEIVED_COLOR)(
  52. (0, _jestMatcherUtils.pluralize)('assertion call', assertionCalls || 0)
  53. ) +
  54. '.';
  55. result.push({
  56. actual: assertionCalls.toString(),
  57. error: expectedAssertionsNumberError,
  58. expected: expectedAssertionsNumber.toString()
  59. });
  60. }
  61. if (isExpectingAssertions && assertionCalls === 0) {
  62. const expected = (0, _jestMatcherUtils.EXPECTED_COLOR)(
  63. 'at least one assertion'
  64. );
  65. const received = (0, _jestMatcherUtils.RECEIVED_COLOR)('received none');
  66. isExpectingAssertionsError.message =
  67. (0, _jestMatcherUtils.matcherHint)('.hasAssertions', '', '', {
  68. isDirectExpectCall: true
  69. }) +
  70. '\n\n' +
  71. `Expected ${expected} to be called but ${received}.`;
  72. result.push({
  73. actual: 'none',
  74. error: isExpectingAssertionsError,
  75. expected: 'at least one'
  76. });
  77. }
  78. return result;
  79. };
  80. var _default = extractExpectedAssertionsErrors;
  81. exports.default = _default;