utils.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. "use strict";
  2. var __spreadArray = (this && this.__spreadArray) || function (to, from) {
  3. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
  4. to[j] = from[i];
  5. return to;
  6. };
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.ABSENCE_MATCHERS = exports.PRESENCE_MATCHERS = exports.LIBRARY_MODULES = exports.TESTING_FRAMEWORK_SETUP_HOOKS = exports.SYNC_EVENTS = exports.ASYNC_UTILS = exports.ALL_QUERIES_COMBINATIONS = exports.ASYNC_QUERIES_COMBINATIONS = exports.SYNC_QUERIES_COMBINATIONS = exports.ALL_QUERIES_METHODS = exports.ALL_QUERIES_VARIANTS = exports.ASYNC_QUERIES_VARIANTS = exports.SYNC_QUERIES_VARIANTS = exports.getDocsUrl = void 0;
  9. var combineQueries = function (variants, methods) {
  10. var combinedQueries = [];
  11. variants.forEach(function (variant) {
  12. var variantPrefix = variant.replace('By', '');
  13. methods.forEach(function (method) {
  14. combinedQueries.push("" + variantPrefix + method);
  15. });
  16. });
  17. return combinedQueries;
  18. };
  19. var getDocsUrl = function (ruleName) {
  20. return "https://github.com/testing-library/eslint-plugin-testing-library/tree/main/docs/rules/" + ruleName + ".md";
  21. };
  22. exports.getDocsUrl = getDocsUrl;
  23. var LIBRARY_MODULES = [
  24. '@testing-library/dom',
  25. '@testing-library/angular',
  26. '@testing-library/react',
  27. '@testing-library/preact',
  28. '@testing-library/vue',
  29. '@testing-library/svelte',
  30. ];
  31. exports.LIBRARY_MODULES = LIBRARY_MODULES;
  32. var SYNC_QUERIES_VARIANTS = ['getBy', 'getAllBy', 'queryBy', 'queryAllBy'];
  33. exports.SYNC_QUERIES_VARIANTS = SYNC_QUERIES_VARIANTS;
  34. var ASYNC_QUERIES_VARIANTS = ['findBy', 'findAllBy'];
  35. exports.ASYNC_QUERIES_VARIANTS = ASYNC_QUERIES_VARIANTS;
  36. var ALL_QUERIES_VARIANTS = __spreadArray(__spreadArray([], SYNC_QUERIES_VARIANTS), ASYNC_QUERIES_VARIANTS);
  37. exports.ALL_QUERIES_VARIANTS = ALL_QUERIES_VARIANTS;
  38. var ALL_QUERIES_METHODS = [
  39. 'ByLabelText',
  40. 'ByPlaceholderText',
  41. 'ByText',
  42. 'ByAltText',
  43. 'ByTitle',
  44. 'ByDisplayValue',
  45. 'ByRole',
  46. 'ByTestId',
  47. ];
  48. exports.ALL_QUERIES_METHODS = ALL_QUERIES_METHODS;
  49. var SYNC_QUERIES_COMBINATIONS = combineQueries(SYNC_QUERIES_VARIANTS, ALL_QUERIES_METHODS);
  50. exports.SYNC_QUERIES_COMBINATIONS = SYNC_QUERIES_COMBINATIONS;
  51. var ASYNC_QUERIES_COMBINATIONS = combineQueries(ASYNC_QUERIES_VARIANTS, ALL_QUERIES_METHODS);
  52. exports.ASYNC_QUERIES_COMBINATIONS = ASYNC_QUERIES_COMBINATIONS;
  53. var ALL_QUERIES_COMBINATIONS = __spreadArray(__spreadArray([], SYNC_QUERIES_COMBINATIONS), ASYNC_QUERIES_COMBINATIONS);
  54. exports.ALL_QUERIES_COMBINATIONS = ALL_QUERIES_COMBINATIONS;
  55. var ASYNC_UTILS = [
  56. 'waitFor',
  57. 'waitForElementToBeRemoved',
  58. 'wait',
  59. 'waitForElement',
  60. 'waitForDomChange',
  61. ];
  62. exports.ASYNC_UTILS = ASYNC_UTILS;
  63. var SYNC_EVENTS = [
  64. 'fireEvent',
  65. 'userEvent',
  66. ];
  67. exports.SYNC_EVENTS = SYNC_EVENTS;
  68. var TESTING_FRAMEWORK_SETUP_HOOKS = ['beforeEach', 'beforeAll'];
  69. exports.TESTING_FRAMEWORK_SETUP_HOOKS = TESTING_FRAMEWORK_SETUP_HOOKS;
  70. var PRESENCE_MATCHERS = ['toBeInTheDocument', 'toBeTruthy', 'toBeDefined'];
  71. exports.PRESENCE_MATCHERS = PRESENCE_MATCHERS;
  72. var ABSENCE_MATCHERS = ['toBeNull', 'toBeFalsy'];
  73. exports.ABSENCE_MATCHERS = ABSENCE_MATCHERS;