getMockName.js 906 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _path() {
  7. const data = _interopRequireDefault(require('path'));
  8. _path = function _path() {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _interopRequireDefault(obj) {
  14. return obj && obj.__esModule ? obj : {default: obj};
  15. }
  16. /**
  17. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  18. *
  19. * This source code is licensed under the MIT license found in the
  20. * LICENSE file in the root directory of this source tree.
  21. */
  22. const MOCKS_PATTERN = _path().default.sep + '__mocks__' + _path().default.sep;
  23. const getMockName = filePath => {
  24. const mockPath = filePath.split(MOCKS_PATTERN)[1];
  25. return mockPath
  26. .substring(0, mockPath.lastIndexOf(_path().default.extname(mockPath)))
  27. .replace(/\\/g, '/');
  28. };
  29. var _default = getMockName;
  30. exports.default = _default;