get_mock_name.js 1.6 KB

1234567891011121314151617181920212223242526272829
  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) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. const MOCKS_PATTERN = (_path || _load_path()).default.sep + '__mocks__' + (_path || _load_path()).default.sep; /**
  11. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  12. *
  13. * This source code is licensed under the MIT license found in the
  14. * LICENSE file in the root directory of this source tree.
  15. *
  16. *
  17. */
  18. const getMockName = filePath => {
  19. const mockPath = filePath.split(MOCKS_PATTERN)[1];
  20. return mockPath.substring(0, mockPath.lastIndexOf((_path || _load_path()).default.extname(mockPath))).replace(/\\/g, '/');
  21. };
  22. exports.default = getMockName;