get_mock_name.js 880 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. var _path;
  6. function _load_path() {
  7. return (_path = _interopRequireDefault(require('path')));
  8. }
  9. function _interopRequireDefault(obj) {
  10. return obj && obj.__esModule ? obj : {default: obj};
  11. }
  12. const MOCKS_PATTERN =
  13. (_path || _load_path()).default.sep +
  14. '__mocks__' +
  15. (_path || _load_path()).default.sep;
  16. /**
  17. * Copyright (c) 2014-present, Facebook, Inc. 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. *
  23. */
  24. const getMockName = filePath => {
  25. const mockPath = filePath.split(MOCKS_PATTERN)[1];
  26. return mockPath
  27. .substring(
  28. 0,
  29. mockPath.lastIndexOf((_path || _load_path()).default.extname(mockPath))
  30. )
  31. .replace(/\\/g, '/');
  32. };
  33. exports.default = getMockName;